instruction stringlengths 14 27.6k | completion stringlengths 3 38.3k | __original_row_idx int64 0 50k | conversations listlengths 2 2 |
|---|---|---|---|
I'm quite confident that globally declared variables get allocated (and initialized, if applicable) at program start time.
int globalgarbage;
unsigned int anumber = 42;
But what about static ones defined within a function?
void doSomething()
{
static bool globalish = true;
// ...
}
When is the space for globalish... | You are correct in your understanding of global variables and static variables defined within functions. Let's clarify the behavior of static local variables in your example:
1. **Allocation Timing**: The space for a `static` local variable, like `globalish` in your `doSomething` function, is allocated when the progra... | 9,503 | [
{
"from": "human",
"value": "I'm quite confident that globally declared variables get allocated (and initialized, if applicable) at program start time.\nint globalgarbage;\nunsigned int anumber = 42;\n\nBut what about static ones defined within a function?\nvoid doSomething()\n{\n static bool globalish = t... |
Are .css files always needed? Or may I have a .css "basic" file and define other style items inside the HTML page?
Does padding, borders and so on always have to be defined in a .css file that is stored separately, or may I embed then into an HTML page?
| You do not always need a separate `.css` file for styling your HTML pages. You have the flexibility to define styles directly within the HTML file using inline styles or `<style>` tags.
### Options for CSS:
1. **External CSS File**:
- You can create a separate `.css` file (e.g., `styles.css`) and link it to your H... | 9,819 | [
{
"from": "human",
"value": "Are .css files always needed? Or may I have a .css \"basic\" file and define other style items inside the HTML page?\nDoes padding, borders and so on always have to be defined in a .css file that is stored separately, or may I embed then into an HTML page?\n"
},
{
"from"... |
In which parts of a project writing unit tests is nearly or really impossible? Data access? ftp?
If there is an answer to this question then %100 coverage is a myth, isn't it?
| Writing unit tests can indeed be challenging or nearly impossible in certain parts of a project, particularly when dealing with specific types of dependencies or integration points. Here are some examples of areas where unit testing can become difficult:
1. **Data Access Layers**: Testing components that interact dire... | 7,710 | [
{
"from": "human",
"value": "In which parts of a project writing unit tests is nearly or really impossible? Data access? ftp?\nIf there is an answer to this question then %100 coverage is a myth, isn't it?\n"
},
{
"from": "gpt",
"value": "Writing unit tests can indeed be challenging or nearly im... |
Is there a runtime performance penalty when using interfaces (abstract base classes) in C++?
| In C++, using interfaces (typically implemented via abstract base classes with pure virtual functions) can introduce some runtime performance penalties compared to using concrete classes with direct method calls. Here are a few key points to consider:
1. **Virtual Function Overhead**: When you call a member function t... | 8,106 | [
{
"from": "human",
"value": "Is there a runtime performance penalty when using interfaces (abstract base classes) in C++?\n"
},
{
"from": "gpt",
"value": "In C++, using interfaces (typically implemented via abstract base classes with pure virtual functions) can introduce some runtime performance... |
With ViEmu you really need to unbind a lot of resharpers keybindings to make it work well.
Does anyone have what they think is a good set of keybindings that work well for resharper when using ViEmu?
What I'm doing at the moment using the Visual Studio bindings from Resharper. Toasting all the conflicting ones with ViE... | Using ViEmu along with ReSharper and Visual Assist can indeed lead to keybinding conflicts, as you've noticed. Here are some suggestions and strategies that might help you achieve a smoother workflow when using these tools together:
### Keybinding Strategy
1. **Unbind Conflicting Keybindings**: The first step is to id... | 7,931 | [
{
"from": "human",
"value": "With ViEmu you really need to unbind a lot of resharpers keybindings to make it work well.\nDoes anyone have what they think is a good set of keybindings that work well for resharper when using ViEmu?\nWhat I'm doing at the moment using the Visual Studio bindings from Resharper.... |
I've found how to sort query results by a given field in a Lucene.Net index instead of by score; all it takes is a field that is indexed but not tokenized. However, what I haven't been able to figure out is how to sort that field while ignoring stop words such as "a" and "the", so that the following book titles, for ex... | Sorting in Lucene.Net while ignoring stop words is not directly supported out of the box, particularly in the manner you're hoping for. However, you can achieve similar functionality by manipulating how you index your documents or how you store and retrieve your field data.
Here's one possible approach to sort book ti... | 5,843 | [
{
"from": "human",
"value": "I've found how to sort query results by a given field in a Lucene.Net index instead of by score; all it takes is a field that is indexed but not tokenized. However, what I haven't been able to figure out is how to sort that field while ignoring stop words such as \"a\" and \"the... |
I have an image (mx) and i want to get the uint of the pixel that was clicked.
Any ideas?
| To get the value of a pixel (its uint representation) when a user clicks on an image, you can follow a general approach that involves the following steps. This can be implemented in various programming environments (such as web development with JavaScript, or desktop applications with Python, etc.). Here’s how you can ... | 4,964 | [
{
"from": "human",
"value": "I have an image (mx) and i want to get the uint of the pixel that was clicked.\nAny ideas?\n"
},
{
"from": "gpt",
"value": "To get the value of a pixel (its uint representation) when a user clicks on an image, you can follow a general approach that involves the follo... |
when they say the action controller in the struts framework is multi threaded, does it mean that there are multiple instances of the servlet taking the request and forwarding it to the model. OR does it mean that there is one single instance taking all the requests? Any visuals will be appreciated
| In the Struts framework, when we say that the Action Controller is multi-threaded, it typically means that there is a single instance of the Action class that handles multiple requests concurrently. Here’s a breakdown to clarify this concept:
### Understanding Action Controller in Struts
1. **Single Instance of Actio... | 8,508 | [
{
"from": "human",
"value": "when they say the action controller in the struts framework is multi threaded, does it mean that there are multiple instances of the servlet taking the request and forwarding it to the model. OR does it mean that there is one single instance taking all the requests? Any visuals ... |
I need to write a function that receives a string and a regex. I need to check if there is a match and return the start and end location of a match. (The regex was already compiled by qr//.)
The function might also receive a "global" flag and then I need to return the (start,end) pairs of all the matches.
I cannot chan... | You can achieve this functionality in Perl using the built-in regex functions along with the provided regex. Below is an example of how to write the required function.
Here is the function `find_matches` that takes a string, a compiled regex, and an optional global flag:
```perl
use strict;
use warnings;
sub find_ma... | 7,930 | [
{
"from": "human",
"value": "I need to write a function that receives a string and a regex. I need to check if there is a match and return the start and end location of a match. (The regex was already compiled by qr//.)\nThe function might also receive a \"global\" flag and then I need to return the (start,... |
I've always taken the approach of first deploying the database with a minimal set of indexes and then adding/changing indexes as performance dictates.
This approach works reasonably well. However, it still doesn't tell me where I could improve performance. It only tells me where performance is so bad that users complai... | Your approach of starting with a minimal set of indexes and then adjusting them based on performance is a practical one. However, you're correct that it doesn't provide proactive insight into potential performance improvements. Here are some strategies, tools, and techniques that can help you monitor and improve databa... | 8,067 | [
{
"from": "human",
"value": "I've always taken the approach of first deploying the database with a minimal set of indexes and then adding/changing indexes as performance dictates.\nThis approach works reasonably well. However, it still doesn't tell me where I could improve performance. It only tells me wher... |
Does anybody have experience of a decent J2SE (preferably at least Java JDK 1.5-level) Java Virtual Machine for Windows Mobile 6? If you know of any CLDC VMs, I'm also interested because even that would be better than what we currently have for the platform.
| Finding a Java Virtual Machine (JVM) for Windows Mobile 6 can be challenging, especially if you're looking for something that supports J2SE features or even CLDC. However, here are some options and resources that may help you:
1. **IBM WebSphere Everyplace Micro Environment**: This was a popular JVM for mobile devices... | 8,487 | [
{
"from": "human",
"value": "Does anybody have experience of a decent J2SE (preferably at least Java JDK 1.5-level) Java Virtual Machine for Windows Mobile 6? If you know of any CLDC VMs, I'm also interested because even that would be better than what we currently have for the platform. \n"
},
{
"fr... |
My web application generates pdf files and either e-mails or faxes them to our customers. Somehow IIS6 is keeping hold of the file and blocking any other requests for it claiming the old '..the process cannot access the file 'xxx.pdf' because it is being used by another process.'
When I recycle the application pool all... | The issue you are experiencing with IIS6 blocking access to PDF files that are generated by your web application may be due to the way file handles are being managed in your code or by the IIS server itself. Here are a few strategies you can employ to troubleshoot and resolve this problem:
### 1. **File Locking Issues... | 5,800 | [
{
"from": "human",
"value": "My web application generates pdf files and either e-mails or faxes them to our customers. Somehow IIS6 is keeping hold of the file and blocking any other requests for it claiming the old '..the process cannot access the file 'xxx.pdf' because it is being used by another process.... |
I'm looking for a little shell script that will take anything piped into it, and dump it to a file.. for email debugging purposes. Any ideas?
| Certainly! You can create a simple shell script that takes input from standard input (stdin) and appends it to a file. Here's a basic script to do just that:
1. Create a new shell script file, for example, `dump_to_file.sh`:
```bash
#!/bin/bash
# Define the output file where the content will be stored
OUTPUT_FILE="d... | 10,837 | [
{
"from": "human",
"value": "I'm looking for a little shell script that will take anything piped into it, and dump it to a file.. for email debugging purposes. Any ideas?\n"
},
{
"from": "gpt",
"value": "Certainly! You can create a simple shell script that takes input from standard input (stdin)... |
I was out running.. listening to a podcast about Toyota.. anyway.
This principle I think does not come to use in the software projects. (maybe project management). The art is still to young. We don't know what we are doing, at the moment. But eventually, we will.
Or, do some one see how to use this core principle?
Ok, ... | It sounds like you're referring to principles that might be drawn from Toyota's production system, such as Lean manufacturing or the concept of continuous improvement (Kaizen). These principles emphasize efficiency, waste reduction, and iterative improvement, which can certainly be applied to software development and p... | 8,472 | [
{
"from": "human",
"value": "I was out running.. listening to a podcast about Toyota.. anyway.\nThis principle I think does not come to use in the software projects. (maybe project management). The art is still to young. We don't know what we are doing, at the moment. But eventually, we will.\nOr, do some o... |
I've got a multiline textBox that I would like to have a label on the form displaying the current line and column position of, as Visual Studio does.
I know I can get the line # with GetLineFromCharIndex, but how can I get the column # on that line?
(I really want the Cursor Position on that line, not 'column', per se)... | To display the current line and column position in a multiline TextBox in a Windows Forms application, you can indeed use the `GetLineFromCharIndex` method to get the current line number. To get the column (or cursor position) on that line, you can use the `SelectionStart` property to get the current character index an... | 6,454 | [
{
"from": "human",
"value": "I've got a multiline textBox that I would like to have a label on the form displaying the current line and column position of, as Visual Studio does.\nI know I can get the line # with GetLineFromCharIndex, but how can I get the column # on that line?\n(I really want the Cursor P... |
So I'm looking at writing an iPhone application that shows things on a map. What frameworks/methodologies are out there for doing this?
Searching around on Google, I could only find this one:
http://code.google.com/p/iphone-google-maps-component/
Which according to the issues list is slow, and stops working after a whi... | When developing an iPhone application that displays content on a map, you have several frameworks and methodologies at your disposal. Here are some popular options to consider:
1. **MapKit**:
- **Overview**: MapKit is Apple's native framework for displaying maps. It provides a range of features, including annotatio... | 7,550 | [
{
"from": "human",
"value": "So I'm looking at writing an iPhone application that shows things on a map. What frameworks/methodologies are out there for doing this?\nSearching around on Google, I could only find this one:\nhttp://code.google.com/p/iphone-google-maps-component/\nWhich according to the issues... |
I took a data structures class in C++ last year, and consequently implemented all the major data structures in templated code. I saved it all on a flash drive because I have a feeling that at some point in my life, I'll use it again. I imagine something I end up programming will need a B-Tree, or is that just delusio... | It's great that you implemented major data structures in templated code; that knowledge and experience are invaluable! Storing code on a flash drive is a good initial step, but there are more sustainable ways to keep your code accessible and organized.
As for the relevance of specific data structures like B-Trees, it'... | 7,750 | [
{
"from": "human",
"value": "I took a data structures class in C++ last year, and consequently implemented all the major data structures in templated code. I saved it all on a flash drive because I have a feeling that at some point in my life, I'll use it again. I imagine something I end up programming wi... |
Inversion of Control (IoC) can be quite confusing when it is first encountered.
What is it?
Which problem does it solve?
When is it appropriate to use and when not?
| Inversion of Control (IoC) is a design principle in software engineering that refers to the reversal of the flow of control in a system. Traditionally, in a procedural programming context, the flow of control is directed by the main program or application. In an IoC approach, the control is inverted: instead of the pro... | 2,601 | [
{
"from": "human",
"value": "Inversion of Control (IoC) can be quite confusing when it is first encountered.\n\nWhat is it?\nWhich problem does it solve?\nWhen is it appropriate to use and when not?\n\n"
},
{
"from": "gpt",
"value": "Inversion of Control (IoC) is a design principle in software e... |
I currently use the following function to do a simple HTTP GET.
public static String download(String url) throws java.io.IOException {
java.io.InputStream s = null;
java.io.InputStreamReader r = null;
//java.io.BufferedReader b = null;
StringBuilder content = new StringBuilder();
try {
s = (... | You're correct that in your specific implementation, you are not gaining much benefit from using a `BufferedReader`. You are reading data directly from the `InputStreamReader` into a character buffer, which is already a buffered approach. Using a `BufferedReader` would introduce an additional layer of buffering, which ... | 4,418 | [
{
"from": "human",
"value": "I currently use the following function to do a simple HTTP GET.\npublic static String download(String url) throws java.io.IOException {\n java.io.InputStream s = null;\n java.io.InputStreamReader r = null;\n //java.io.BufferedReader b = null;\n StringBuilder content ... |
I have an asp.net url path which is being generated in a web form, and is coming out something like "/foo/bar/../bar/path.aspx", and is coming out in the generated html like this too. It should be shortened to "/foo/bar/path.aspx".
Path.Combine didn't fix it. Is there a function to clean this path up?
| In ASP.NET, you can use `Path.GetFullPath` to normalize the URL and clean it up. However, since the URL you provided looks like a relative URL, you might want to use a custom method to eliminate the `..` segments in the path.
The `Path.GetFullPath` method is typically used for file system paths, so we will create a fu... | 8,914 | [
{
"from": "human",
"value": "I have an asp.net url path which is being generated in a web form, and is coming out something like \"/foo/bar/../bar/path.aspx\", and is coming out in the generated html like this too. It should be shortened to \"/foo/bar/path.aspx\". \nPath.Combine didn't fix it. Is there a fu... |
I am reading a .NET book, and in one of the code examples there is a class definition with this field:
private DateTime? startdate
What does DateTime? mean?
| In C#, the syntax `DateTime?` is a shorthand for a nullable type. Specifically, `DateTime?` means that the variable can either hold a valid `DateTime` value or it can be `null`.
Here's a breakdown of what that means:
- `DateTime` is a value type in C#. Value types (like `int`, `float`, `DateTime`, etc.) cannot be nul... | 8,074 | [
{
"from": "human",
"value": "I am reading a .NET book, and in one of the code examples there is a class definition with this field:\nprivate DateTime? startdate\n\nWhat does DateTime? mean?\n"
},
{
"from": "gpt",
"value": "In C#, the syntax `DateTime?` is a shorthand for a nullable type. Specifi... |
Ok - a bit of a mouthful. So the problem I have is this - I need to store a Date for expiry where only the date part is required and I don't want any timezone conversion. So for example if I have an expiry set to "08 March 2008" I want that value to be returned to any client - no matter what their timezone is.
The pro... | Hi Ian,
This is a common challenge when dealing with date representations across different time zones. Since you want to avoid timezone conversions and focus solely on the date part, here are a few approaches you can consider:
### 1. Use a Date-only Type
If your data storage system or programming environment supports... | 9,229 | [
{
"from": "human",
"value": "Ok - a bit of a mouthful. So the problem I have is this - I need to store a Date for expiry where only the date part is required and I don't want any timezone conversion. So for example if I have an expiry set to \"08 March 2008\" I want that value to be returned to any client -... |
I am trying to apply styles to HTML tags dynamically by reading in the value of certain HTML attributes and applying a class name based on their values. For instance, if I have:
<p height="30">
I want to apply a class="h30" to that paragraph so that I can style it in my style sheet. I can't find any information on get... | You can achieve this using JavaScript to read the value of the custom attribute (in this case, `height`) and then dynamically apply a class based on that value. Here's a step-by-step approach on how to do this:
1. **Select the elements** that you want to manipulate. In this case, it would be the `<p>` tags.
2. **Retri... | 6,784 | [
{
"from": "human",
"value": "I am trying to apply styles to HTML tags dynamically by reading in the value of certain HTML attributes and applying a class name based on their values. For instance, if I have:\n<p height=\"30\">\n\nI want to apply a class=\"h30\" to that paragraph so that I can style it in my ... |
I'm looking for an open source, cross platform (Windows & Linux at least) command line tool to take some code (C++, but multiple languages would be sweet), and spit out valid a XHTML representation of that code, with syntax highlighting included.
Ideally the XHTML should just wrap the code with <span> and <div> tags wi... | You might want to consider using **Pygments**, a popular open-source syntax highlighting tool that supports multiple programming languages, including C++. Pygments can output highlighted code in various formats, including HTML and XHTML, and is cross-platform, working on both Windows and Linux.
### Installation
1. **... | 8,534 | [
{
"from": "human",
"value": "I'm looking for an open source, cross platform (Windows & Linux at least) command line tool to take some code (C++, but multiple languages would be sweet), and spit out valid a XHTML representation of that code, with syntax highlighting included.\nIdeally the XHTML should just w... |
Suppose I have the following code:
class some_class{};
some_class some_function()
{
return some_class();
}
This seems to work pretty well and saves me the trouble of having to declare a variable just to make a return value. But I don't think I've ever seen this in any kind of tutorial or reference. Is this a co... | The code you've provided is valid C++ and is not compiler-specific; it adheres to standard C++ rules. What you're doing is using the feature of automatic (or implicit) object creation and return value optimization (RVO).
Here’s a breakdown of the code:
```cpp
class some_class {}; // Declaration of a class named some_... | 9,702 | [
{
"from": "human",
"value": "Suppose I have the following code:\nclass some_class{};\n\nsome_class some_function()\n{\n return some_class();\n}\n\nThis seems to work pretty well and saves me the trouble of having to declare a variable just to make a return value. But I don't think I've ever seen this in... |
one of the most frequent requests I get is to create XY report for YZ App. These apps are normally built on PHP, so far I have manually created most of this reports, and while I enjoy the freedom of building it as I want, it usually becomes pretty tedious to calculate subtotals, averages, exporting to different formats... | If you’re looking for tools that can help you automate the generation of reports from SQL data without diving into a full-fledged business intelligence solution, there are several open-source and free options you can consider. Here’s a list of some tools that might fit your needs:
### 1. **Metabase**
- **Description**... | 5,509 | [
{
"from": "human",
"value": "one of the most frequent requests I get is to create XY report for YZ App. These apps are normally built on PHP, so far I have manually created most of this reports, and while I enjoy the freedom of building it as I want, it usually becomes pretty tedious to calculate subtotals,... |
I have an ASP.Net/AJAX control kit project that i am working on. 80% of the time there is no problem. The page runs as it should. If you refresh the page it will sometimes show a javascript error "Sys is undefined".
It doesn't happen all the time, but it is reproducible. When it happens, the user has to shut down t... | The "Sys is undefined" error you are encountering in your ASP.NET/AJAX application usually indicates that the ASP.NET AJAX framework did not load properly. This can happen for several reasons, particularly if there are issues with the loading of the `ScriptResource.axd` handler. Here are a few potential causes and solu... | 6,739 | [
{
"from": "human",
"value": "I have an ASP.Net/AJAX control kit project that i am working on. 80% of the time there is no problem. The page runs as it should. If you refresh the page it will sometimes show a javascript error \"Sys is undefined\".\nIt doesn't happen all the time, but it is reproducible. ... |
Is accessing a bool field atomic in C#? In particular, do I need to put a lock around:
class Foo
{
private bool _bar;
//... in some function on any thread (or many threads)
_bar = true;
//... same for a read
if (_bar) { ... }
}
| In C#, access to a `bool` field is not guaranteed to be atomic in a multithreaded environment. While reading from and writing to a `bool` is typically done in a single instruction on most hardware architectures, this is not enough to ensure thread safety, especially when multiple threads are involved.
When one thread ... | 8,133 | [
{
"from": "human",
"value": "Is accessing a bool field atomic in C#? In particular, do I need to put a lock around:\nclass Foo\n{\n private bool _bar;\n\n //... in some function on any thread (or many threads)\n _bar = true;\n\n //... same for a read\n if (_bar) { ... }\n}\n\n"
},
{
"from"... |
While editing an aspx file I found both these opening tags used for seemingly the same thing. Is there a difference and if yes, what is it?
| In ASP.NET Web Forms, the opening tags `<asp:...>` and `<%@...%>` serve different purposes and are used in different contexts.
1. **`<asp:...>` Tags**:
- These are server-side controls, which are used to create UI elements on the web page.
- The `<asp:...>` tags represent controls like buttons, text boxes, grids... | 9,942 | [
{
"from": "human",
"value": "While editing an aspx file I found both these opening tags used for seemingly the same thing. Is there a difference and if yes, what is it?\n"
},
{
"from": "gpt",
"value": "In ASP.NET Web Forms, the opening tags `<asp:...>` and `<%@...%>` serve different purposes and... |
I'd like to use the field type RichHTML in a custom content type that I'm making. However, I think that the RichHTML type comes with MOSS Publishing so I'm unsure how to add it to my content type. Right now I've tried with this:
<Field ID="{7F55A8F0-4555-46BC-B24C-222240B862AF}" Type="RichHTML" Name="NewsBodyField" Dis... | To use the `RichHTML` field type in a custom content type in SharePoint, you'll need to ensure that you are using the right syntax and field definitions as `RichHTML` is indeed a field that is available in the SharePoint Publishing feature, typically found in the MOSS (Microsoft Office SharePoint Server) Publishing sit... | 6,274 | [
{
"from": "human",
"value": "I'd like to use the field type RichHTML in a custom content type that I'm making. However, I think that the RichHTML type comes with MOSS Publishing so I'm unsure how to add it to my content type. Right now I've tried with this:\n<Field ID=\"{7F55A8F0-4555-46BC-B24C-222240B862AF... |
Simple question, but one that I've been curious about...is there a functional difference between the following two commands?
String::class
String.class
They both do what I expect -- that is to say they return Class -- but what is the difference between using the :: and the .?
I notice that on those classes that have c... | In Ruby, there is a subtle but important difference between using `::` and `.` for accessing classes and their methods or constants.
### `::` Operator
- The `::` operator is used for namespace resolution and is specifically designed for accessing constants, classes, and modules.
- When you use `String::class`, you're... | 8,815 | [
{
"from": "human",
"value": "Simple question, but one that I've been curious about...is there a functional difference between the following two commands?\nString::class\nString.class\n\nThey both do what I expect -- that is to say they return Class -- but what is the difference between using the :: and the ... |
I want to write a little "DBQuery" function in perl so I can have one-liners which send an SQL statement and receive back and an array of hashes, i.e. a recordset. However, I'm running into an issue with Perl syntax (and probably some odd pointer/reference issue) which is preventing me from packing out the information ... | The issue you are encountering arises from how Perl handles copying of references versus values. In your code, the elements of the `@records` array are hash references, not hashes. When you do `%row = $records[$index];`, Perl is trying to treat `$records[$index]` as a hash, but it is actually a reference to a hash. Thu... | 9,185 | [
{
"from": "human",
"value": "I want to write a little \"DBQuery\" function in perl so I can have one-liners which send an SQL statement and receive back and an array of hashes, i.e. a recordset. However, I'm running into an issue with Perl syntax (and probably some odd pointer/reference issue) which is prev... |
I am taking on a maintenance team and would like to introduce tools like FxCop and StyleCop to help improve the code and introduce the developers to better programming techniques and standards. Since we are maintaining code and not making significant enhancements, we will probably only deal with a couple of methods/rou... | Hi Matt,
Introducing tools like FxCop and StyleCop is a great way to enhance code quality and ensure that developers adhere to programming standards. Here’s how you can target specific areas of code to avoid being overwhelmed by issues.
### Targeting Specific Areas with FxCop
**1. Use Code Annotations:**
You can use... | 8,240 | [
{
"from": "human",
"value": "I am taking on a maintenance team and would like to introduce tools like FxCop and StyleCop to help improve the code and introduce the developers to better programming techniques and standards. Since we are maintaining code and not making significant enhancements, we will probab... |
We are currently testing a Java Swing application for it's performance. I wonder if there is a good tool to automate this?
| Yes, there are several tools that can help you automate the performance testing of a Java Swing application. Here are some popular options:
1. **JMeter**: While primarily known for load testing web applications, Apache JMeter can also be used for testing the performance of Java applications, including desktop applicat... | 9,152 | [
{
"from": "human",
"value": "We are currently testing a Java Swing application for it's performance. I wonder if there is a good tool to automate this?\n"
},
{
"from": "gpt",
"value": "Yes, there are several tools that can help you automate the performance testing of a Java Swing application. He... |
I'm using MySQL in particular, but I'm hoping for a cross-vendor solution. I'm using the NOW() function to add a timestamp as a column for each record.
INSERT INTO messages
(typeId, messageTime, stationId, message)
VALUES
(?, NOW(), ?, ?)
| Using `NOW()` to add a timestamp in a SQL `INSERT` statement is common, but if you are looking for a cross-vendor solution, it's important to consider how different database systems handle timestamps and date functions.
The `NOW()` function is specific to MySQL, and while other databases have equivalent functions, th... | 8,149 | [
{
"from": "human",
"value": "I'm using MySQL in particular, but I'm hoping for a cross-vendor solution. I'm using the NOW() function to add a timestamp as a column for each record.\nINSERT INTO messages \n(typeId, messageTime, stationId, message) \nVALUES \n(?, NOW(), ?, ?)\n\n"
},
{
"from": "gpt",... |
If I create a class A as follows:
class A:
def __init__(self):
self.name = 'A'
Inspecting the __dict__ member looks like {'name': 'A'}
If however I create a class B:
class B:
name = 'B'
__dict__ is empty.
What is the difference between the two, and why doesn't name show up in B's __dict__?
| The difference between classes `A` and `B` lies in where the attribute `name` is defined and how it is stored in the class objects.
### Class `A`
```python
class A:
def __init__(self):
self.name = 'A'
```
In this class, `name` is defined as an instance variable within the `__init__` method. When you crea... | 7,991 | [
{
"from": "human",
"value": "If I create a class A as follows:\nclass A:\n def __init__(self):\n self.name = 'A'\n\nInspecting the __dict__ member looks like {'name': 'A'}\nIf however I create a class B:\nclass B:\n name = 'B'\n\n__dict__ is empty.\nWhat is the difference between the two, and w... |
I have ms sql databases that grow very large. Upon examination I find that there is a bunch of unused space in certain tables. I don't do many physical deletes, so I don't think that its just deleted records. DBCC SHRINK doesn't make the file smaller. But, if I dump the table to a new, empty database, the size goes dow... | It sounds like you're dealing with table fragmentation and potentially inefficient space usage within your SQL Server database. The behavior you're seeing—where a table's size is significantly reduced when moved to a new database—can occur due to various factors such as fragmentation, unallocated pages, and space alloc... | 5,395 | [
{
"from": "human",
"value": "I have ms sql databases that grow very large. Upon examination I find that there is a bunch of unused space in certain tables. I don't do many physical deletes, so I don't think that its just deleted records. DBCC SHRINK doesn't make the file smaller. But, if I dump the table to... |
I couldn't find any useful information on Microsoft's site, so here is the question: has the compiler in Visual C++ 2008 been improved significantly since the 2005 version? I'm especially looking for better optimization.
| Yes, the compiler in Visual C++ 2008 introduced several improvements and optimizations compared to the 2005 version. Some of the significant enhancements include:
1. **Code Optimization Improvements**: Visual C++ 2008 includes better optimization techniques, leading to improved performance for generated code. This inc... | 10,926 | [
{
"from": "human",
"value": "I couldn't find any useful information on Microsoft's site, so here is the question: has the compiler in Visual C++ 2008 been improved significantly since the 2005 version? I'm especially looking for better optimization.\n"
},
{
"from": "gpt",
"value": "Yes, the comp... |
Is there a security limit to the number of Ajax XMLHttpRequest objects you can create on a single page? If so, does this vary from one browser to another?
| Yes, there are security and performance limits to the number of `XMLHttpRequest` objects (XHR) that you can create on a single page, and these limits can indeed vary from one browser to another.
1. **Concurrency Limits**: Most modern browsers impose a limit on the number of simultaneous HTTP requests that can be made ... | 8,714 | [
{
"from": "human",
"value": "Is there a security limit to the number of Ajax XMLHttpRequest objects you can create on a single page? If so, does this vary from one browser to another?\n"
},
{
"from": "gpt",
"value": "Yes, there are security and performance limits to the number of `XMLHttpRequest... |
What is the reason browsers do not correctly recognize:
<script src="foobar.js" /> <!-- self-closing script element -->
Only this is recognized:
<script src="foobar.js"></script>
Does this break the concept of XHTML support?
Note: This statement is correct at least for all IE (6-8 beta 2).
| The issue you're encountering with the self-closing `<script>` tag is tied to how HTML and XHTML are structured and interpreted by browsers.
1. **HTML vs. XHTML**:
- HTML (especially older versions like HTML4) does not support self-closing tags for elements like `<script>`. In HTML, the `<script>` tag is a containe... | 8,591 | [
{
"from": "human",
"value": "What is the reason browsers do not correctly recognize:\n<script src=\"foobar.js\" /> <!-- self-closing script element -->\n\nOnly this is recognized:\n<script src=\"foobar.js\"></script>\n\nDoes this break the concept of XHTML support?\nNote: This statement is correct at least ... |
I am creating a windows service and want to know best practices for this. In all my windows Program I have a form that asks the user if he wants to report the error and if he answers yes I created a case in FogBugz. What should I do in a windows service.
| Creating a Windows Service comes with its own set of challenges and best practices, especially regarding error handling and user interaction. Since Windows Services run in the background and do not have a user interface, you cannot interact with users directly. Instead, here are some best practices for handling errors ... | 7,203 | [
{
"from": "human",
"value": "I am creating a windows service and want to know best practices for this. In all my windows Program I have a form that asks the user if he wants to report the error and if he answers yes I created a case in FogBugz. What should I do in a windows service. \n"
},
{
"from":... |
What is the best way to create a lock on a file in Perl?
Is it best to flock on the file or to create a lock file to place a lock on and check for a lock on the lock file?
| In Perl, the best way to create a lock on a file largely depends on your specific use case, but generally, using the `flock` function is the preferred method for file locking. Let's discuss both methods and their implications.
### Method 1: Using `flock`
The `flock` function in Perl allows you to apply a lock directl... | 2,303 | [
{
"from": "human",
"value": "What is the best way to create a lock on a file in Perl?\nIs it best to flock on the file or to create a lock file to place a lock on and check for a lock on the lock file?\n"
},
{
"from": "gpt",
"value": "In Perl, the best way to create a lock on a file largely depe... |
I have a core dump file from a process that has probably a file descriptor leak (it opens files and sockets but apparently sometimes forgets to close some of them). Is there a way to find out which files and sockets the process had opened before crashing? I can't easily reproduce the crash, so analyzing the core file s... | Yes, you can analyze the core dump file to investigate file descriptor leaks. The steps below outline how to do this, primarily using Linux tools and commands.
### Steps to Analyze a Core Dump for Open File Descriptors
1. **Load the Core Dump in GDB**:
First, you need to load the core dump file into the GNU Debugg... | 5,938 | [
{
"from": "human",
"value": "I have a core dump file from a process that has probably a file descriptor leak (it opens files and sockets but apparently sometimes forgets to close some of them). Is there a way to find out which files and sockets the process had opened before crashing? I can't easily reproduc... |
I have a Windows Form that takes quite a bit of time to load initially. However, each subsequent request to load the Form doesn't take as long. Is there a way to optimize a Form's load time?
| Yes, there are several strategies you can use to optimize the load time of a Windows Form. Here are some effective techniques:
### 1. **Lazy Loading**
- **Load Controls on Demand:** Instead of loading all controls when the form initializes, consider loading them only when they are needed. For example, if you have a... | 8,330 | [
{
"from": "human",
"value": "I have a Windows Form that takes quite a bit of time to load initially. However, each subsequent request to load the Form doesn't take as long. Is there a way to optimize a Form's load time?\n"
},
{
"from": "gpt",
"value": "Yes, there are several strategies you can... |
I have a servlet that is used for many different actions, used in the Front Controller pattern. Does anyone know if it is possible to tell if the data posted back to it is enctype="multipart/form-data"? I can't read the request parameters until I decide this, so I can't dispatch the request to the proper controller.
... | Yes, it is possible to determine if the incoming request is of the `enctype="multipart/form-data"` type within a servlet. You can check the content type of the request by examining the `Content-Type` header. If the content type indicates that the request is a multipart request, you can then handle it accordingly.
Here... | 6,296 | [
{
"from": "human",
"value": "I have a servlet that is used for many different actions, used in the Front Controller pattern. Does anyone know if it is possible to tell if the data posted back to it is enctype=\"multipart/form-data\"? I can't read the request parameters until I decide this, so I can't disp... |
C++ just sucks too much of my time by making me micro-manage my own memory, making me type far too much (hello std::vector<Thingy>::const_iterator it = lotsOfThingys.begin()), and boring me with long compile times. What's the single best alternative for serious real-time graphics programming? Garbage collection is a ... | For serious real-time graphics programming, one of the most popular alternatives to C++ is **Rust**. Here's why Rust could be a compelling choice for your criteria:
1. **Memory Management**: Rust provides fine-grained control over memory management similar to C++ but with a strong emphasis on safety. It eliminates the... | 8,057 | [
{
"from": "human",
"value": "C++ just sucks too much of my time by making me micro-manage my own memory, making me type far too much (hello std::vector<Thingy>::const_iterator it = lotsOfThingys.begin()), and boring me with long compile times. What's the single best alternative for serious real-time graphi... |
I would like to use the Logger tool that ships with the Microsoft Debugging Tools for Windows. However, on Vista it crashes even with built-in Vista applications:
> logger calc
or
> logger notepad
The issue occurs if I run the tool from a command prompt with or without administrator rights. I'm using version 3.01 ... | The issue you're experiencing with the Logger tool from the Microsoft Debugging Tools for Windows crashing on Windows Vista appears to be linked to compatibility problems or issues with access violations in the underlying code, especially when attempting to handle settings for logging categories.
Here are a few potent... | 8,862 | [
{
"from": "human",
"value": "I would like to use the Logger tool that ships with the Microsoft Debugging Tools for Windows. However, on Vista it crashes even with built-in Vista applications:\n> logger calc\n\nor\n> logger notepad\n\nThe issue occurs if I run the tool from a command prompt with or without... |
I've recently embarked upon the grand voyage of Wordpress theming and I've been reading through the Wordpress documentation for how to write a theme. One thing I came across here was that the style.css file must contain a specific header in order to be used by the Wordpress engine. They give a brief example but I hav... | Yes, the `style.css` file in a WordPress theme must contain a specific header comment that provides important information about the theme. This header comment is how WordPress identifies the theme and displays it in the dashboard.
Here’s a breakdown of the required fields in the header comment of the `style.css` file:... | 5,230 | [
{
"from": "human",
"value": "I've recently embarked upon the grand voyage of Wordpress theming and I've been reading through the Wordpress documentation for how to write a theme. One thing I came across here was that the style.css file must contain a specific header in order to be used by the Wordpress eng... |
I have a machine with VmWare installed which added two extra network interfaces. The OS is Vista. I have two Java applications, one which broadcasts datagrams, and one which receives those datagrams. The problem I'm having is that unless I disable both VmWare network interfaces, the receiver can't receive the datagr... | The issue you're encountering with your Java applications in a VMware environment is likely due to how network interfaces are configured and how Java handles network sockets. When there are multiple network interfaces, your applications may not be binding or listening on the intended interface for broadcasting and rece... | 6,945 | [
{
"from": "human",
"value": "I have a machine with VmWare installed which added two extra network interfaces. The OS is Vista. I have two Java applications, one which broadcasts datagrams, and one which receives those datagrams. The problem I'm having is that unless I disable both VmWare network interfac... |
I have a content query web part that queries by content type against a site collection. I have grouped it by content type so I have:
-- Agenda (Content Type)
----Agenda #1
----Agenda #2
-- Report (Content Type)
----Report #1
----Report #2
I would like to show a second grouping for site, so:
-- Agenda (Content Type)
--... | To achieve the second level of grouping by site within a Content Query Web Part (CQWP) in SharePoint, you can follow these steps:
### Step 1: Modify the Content Query Web Part
1. **Edit the Page**: Go to the page where your Content Query Web Part is located, and enter edit mode.
2. **Edit the CQWP**: Click on the CQ... | 7,077 | [
{
"from": "human",
"value": "I have a content query web part that queries by content type against a site collection. I have grouped it by content type so I have:\n-- Agenda (Content Type)\n----Agenda #1\n----Agenda #2\n-- Report (Content Type)\n----Report #1\n----Report #2\n\nI would like to show a second g... |
My current setup.py script works okay, but it installs tvnamer.py (the tool) as tvnamer.py into site-packages or somewhere similar..
Can I make setup.py install tvnamer.py as tvnamer, and/or is there a better way of installing command-line applications?
| Yes, you can modify your `setup.py` to install the command-line application in a way that it can be executed directly from the command line. Typically, command-line tools are set up as entry points in the `setup.py` file.
Here's how you can modify your `setup.py` to install `tvnamer.py` as the command `tvnamer`:
```... | 7,505 | [
{
"from": "human",
"value": "My current setup.py script works okay, but it installs tvnamer.py (the tool) as tvnamer.py into site-packages or somewhere similar..\nCan I make setup.py install tvnamer.py as tvnamer, and/or is there a better way of installing command-line applications?\n"
},
{
"from": ... |
I installed Visual Studio 2005 ( with SP1 ) and made the default settings as what is required for C++ .
Now i open a solution and run the exe .
Under " Tools " menu item i go and Select " Attach the process " and i attach it to the exe i just ran . I put breakpoints several places in the code ( this breakpoints looks... | When your breakpoints in Visual Studio 2005 are not being hit, even though you have verified that the PDB files are in the correct location, there may be a few common issues or settings to check:
1. **Debug Build Configuration**: Make sure that your project is built in the "Debug" configuration, not "Release". Release... | 7,649 | [
{
"from": "human",
"value": "I installed Visual Studio 2005 ( with SP1 ) and made the default settings as what is required for C++ . \nNow i open a solution and run the exe .\nUnder \" Tools \" menu item i go and Select \" Attach the process \" and i attach it to the exe i just ran . I put breakpoints seve... |
There are some HTML based games (ie bootleggers.us) that have a simple login form and after that your entire game experience revolves around submitting various forms and reading information from the website itself.
My Question is, what is the best way to go about writing a bot / automate the html-based game using C#? ... | Automating interactions with HTML-based games can be efficiently done using several libraries in C#. Here are some recommended approaches that abstract away some of the complexities of using `HttpRequest` and `WebRequest` for web automation:
### 1. **HtmlAgilityPack**
This is a popular library for parsing HTML. It all... | 7,807 | [
{
"from": "human",
"value": "There are some HTML based games (ie bootleggers.us) that have a simple login form and after that your entire game experience revolves around submitting various forms and reading information from the website itself.\nMy Question is, what is the best way to go about writing a bot ... |
In an ASP.NET 2.0 website, I have a string representing some well-formed XML. I am currently creating an XmlDocument object with it and running an XSL transformation for display in a Web form. Everything was operating fine until the XML input started to contain namespaces.
How can I read in this string and allow name... | The error you're encountering indicates that the XML being processed includes elements with namespaces that are not properly declared in your `XmlDocument`. When you're trying to create an `XmlDocument` from a string that includes XML with namespaces, you need to ensure that these namespaces are declared in the root of... | 9,854 | [
{
"from": "human",
"value": "In an ASP.NET 2.0 website, I have a string representing some well-formed XML. I am currently creating an XmlDocument object with it and running an XSL transformation for display in a Web form. Everything was operating fine until the XML input started to contain namespaces.\nHo... |
When creating the id attributes for HTML elements, what rules are there for the value?
| When creating `id` attributes for HTML elements, there are several rules and best practices to follow to ensure that the `id` values are valid and functional:
### Rules for `id` Attributes:
1. **Uniqueness**: Each `id` value must be unique within the HTML document. No two elements should have the same `id`.
2. **Val... | 9,988 | [
{
"from": "human",
"value": "When creating the id attributes for HTML elements, what rules are there for the value?\n"
},
{
"from": "gpt",
"value": "When creating `id` attributes for HTML elements, there are several rules and best practices to follow to ensure that the `id` values are valid and ... |
Here is a scenario: Let's say I have site with two controllers responsible for displaying different type of content - Pages and Articles. I need to embed Partial View into my masterpage that will list pages and articles filtered with some criteria, and be displayed on each page. I cannot set Model on my masterpage (am ... | You're correct that in ASP.NET MVC, you typically cannot set a model directly on a master page (or _Layout) in the same way you would for a regular view. Instead, you can pass data to your partial views from your controllers or through the use of ViewBag or ViewData. Here's how you can solve your problem of embedding p... | 7,378 | [
{
"from": "human",
"value": "Here is a scenario: Let's say I have site with two controllers responsible for displaying different type of content - Pages and Articles. I need to embed Partial View into my masterpage that will list pages and articles filtered with some criteria, and be displayed on each page.... |
How do I create a resource that I can reference and use in various parts of my program easily?
My specific problem is that I have a NotifyIcon that I want to change the icon of depending on the state of the program. A common problem, but one I've been struggling with for a long time.
| To create a resource that you can reference and use across various parts of your program, you can define a centralized location or class that manages your resources, such as icons, and handles state changes. Below are steps to achieve this, particularly focusing on using a `NotifyIcon` in a Windows Forms application:
... | 8,924 | [
{
"from": "human",
"value": "How do I create a resource that I can reference and use in various parts of my program easily?\nMy specific problem is that I have a NotifyIcon that I want to change the icon of depending on the state of the program. A common problem, but one I've been struggling with for a long... |
Is there a way to send a file using POST from a Python script?
| Yes, you can send a file using an HTTP POST request in Python by using the `requests` library. This library simplifies the process of making HTTP requests. Below is a step-by-step guide on how to do this.
### Step 1: Install the `requests` library
If you haven't already installed the `requests` library, you can do so... | 8,985 | [
{
"from": "human",
"value": "Is there a way to send a file using POST from a Python script?\n"
},
{
"from": "gpt",
"value": "Yes, you can send a file using an HTTP POST request in Python by using the `requests` library. This library simplifies the process of making HTTP requests. Below is a step... |
In order to know how many times a pattern exists in current buffer, I do:
:%s/pattern-here/pattern-here/g
It gives the number of occurrences of the pattern, but is obviously cumbersome and also has the side-effect of setting the 'changed' status.
Is there a more elegant way to count?
| Yes, there is a more elegant way to count occurrences of a pattern in the current buffer without modifying the buffer or changing its status. You can use the `:vimgrep` command in combination with the `:cget` command to accomplish this. However, a simpler method is to use the `:g` command with the `#` option.
Here's ... | 8,822 | [
{
"from": "human",
"value": "In order to know how many times a pattern exists in current buffer, I do:\n:%s/pattern-here/pattern-here/g\n\nIt gives the number of occurrences of the pattern, but is obviously cumbersome and also has the side-effect of setting the 'changed' status.\nIs there a more elegant way... |
I installed Web Client Software Factory February 2008 release on Visual Studio Team System 2008 Development Edition (without SP1). When I first installed that, I tried out the software factory as I've never used one before and it worked fine. That was two months ago.
Recently I needed to learn how to use the software f... | It sounds like you're encountering a frustrating issue with the Web Client Software Factory (WCSF) in Visual Studio Team System 2008. Here are some troubleshooting steps you can take to try to resolve the problem:
### 1. **Ensure All Updates Are Installed**
- Make sure that you have installed Visual Studio Team Sys... | 6,588 | [
{
"from": "human",
"value": "I installed Web Client Software Factory February 2008 release on Visual Studio Team System 2008 Development Edition (without SP1). When I first installed that, I tried out the software factory as I've never used one before and it worked fine. That was two months ago.\nRecently I... |
My Access 2000 DB causes me problems - sometimes (haven't pinpointed the cause) the "book" form won't close. Clicking its close button does nothing, File -> Close does nothing, even closing Access results in no action. I don't have an OnClose handler for this form. The only workaround I can find involves opening the... | It sounds like you're experiencing a frustrating issue with your Access 2000 database form. Here are a few suggestions to help diagnose and potentially resolve the problem:
1. **Corruption Check**: Your database file might be corrupt. Use the built-in compact and repair tool in Access to fix any potential corruption i... | 4,057 | [
{
"from": "human",
"value": "My Access 2000 DB causes me problems - sometimes (haven't pinpointed the cause) the \"book\" form won't close. Clicking its close button does nothing, File -> Close does nothing, even closing Access results in no action. I don't have an OnClose handler for this form. The only... |
I want to find any text in a file that matches a regexp of the form t[A-Z]u (i.e., a match t followed by a capital letter and another match u, and transform the matched text so that the capital letter is lowercase. For example, for the regexp x[A-Z]y
xAy
becomes
xay
and
xZy
becomes
xzy
Emacs' query-replace function... | Yes, you've got the right idea! In Emacs, you can indeed use back-references and Elisp expressions in your replacement patterns to perform transformations on matched text.
To achieve your specific transformation for the pattern `t[A-Z]u`, you can use the following steps:
1. Use `M-x replace-regexp` to start the regul... | 8,695 | [
{
"from": "human",
"value": "I want to find any text in a file that matches a regexp of the form t[A-Z]u (i.e., a match t followed by a capital letter and another match u, and transform the matched text so that the capital letter is lowercase. For example, for the regexp x[A-Z]y\nxAy\n\nbecomes\nxay\n\nand\... |
I am testing a function called extractions that operates over any list.
extractions :: [a] -> [(a,[a])]
extractions [] = []
extractions l = extract l []
where extract [] _ = []
extract (x:xs) prev = (x, prev++xs) : extract xs (x : prev)
I want to test it, for example, with
import Test.QuickCheck.Batch ... | In QuickCheck, when you want to test a property that involves polymorphic types (like `[a]`), you need to provide a concrete type for `a`, because QuickCheck needs to know how to generate values of type `[a]`. However, you can write your property in a more flexible way using type classes to allow for testing over multi... | 6,317 | [
{
"from": "human",
"value": "I am testing a function called extractions that operates over any list.\nextractions :: [a] -> [(a,[a])]\nextractions [] = []\nextractions l = extract l []\n where extract [] _ = []\n extract (x:xs) prev = (x, prev++xs) : extract xs (x : prev)\n\nI want to test it, f... |
How do I add an empty directory (that contains no files) to a Git repository?
| In Git, an empty directory cannot be tracked directly because Git only tracks files, not directories. However, there is a common workaround to include an empty directory in a Git repository. You can do this by adding a placeholder file in the directory. The most common practice is to add a file named `.gitkeep`, but yo... | 9,618 | [
{
"from": "human",
"value": "How do I add an empty directory (that contains no files) to a Git repository?\n"
},
{
"from": "gpt",
"value": "In Git, an empty directory cannot be tracked directly because Git only tracks files, not directories. However, there is a common workaround to include an em... |
I think title should be good enough.
| It seems like you're referring to a title for a project, paper, or some form of creative work. Could you provide more context or details? This way, I can help you refine it or suggest alternatives! | 12,062 | [
{
"from": "human",
"value": "I think title should be good enough.\n"
},
{
"from": "gpt",
"value": "It seems like you're referring to a title for a project, paper, or some form of creative work. Could you provide more context or details? This way, I can help you refine it or suggest alternatives!... |
I've found many sources that talk about the automated Eclipse PDE process. I feel these sources don't do a good job explaining what's going on.
I can create the deployable package, in a semi-manual process via the Feature Export.
The automated process requires knowledge of how the org.eclipse.pde.build scripts work.... | Deploying an Eclipse Rich Client Platform (RCP) application via JNLP (Java Network Launch Protocol) can indeed be challenging, particularly when trying to automate the build process. Here are some insights and responses to your questions:
### Deploying RCP Applications via JNLP
1. **Has anyone ever deployed RCP throu... | 4,005 | [
{
"from": "human",
"value": "I've found many sources that talk about the automated Eclipse PDE process. I feel these sources don't do a good job explaining what's going on.\nI can create the deployable package, in a semi-manual process via the Feature Export. \nThe automated process requires knowledge of ... |
I need to enumerate all the user defined types created in a SQL Server database with CREATE TYPE, and/or find out whether they have already been defined.
With tables or stored procedures I'd do something like this:
if exists (select * from dbo.sysobjects where name='foobar' and xtype='U')
drop table foobar
However... | In SQL Server, user-defined types (UDTs) are not stored in `sysobjects`. Instead, they can be found in the `sys.types` system catalog view. This view contains all types defined in the database, including system types and user-defined types.
You can use the following query to enumerate all user-defined types in a SQL ... | 10,830 | [
{
"from": "human",
"value": "I need to enumerate all the user defined types created in a SQL Server database with CREATE TYPE, and/or find out whether they have already been defined.\nWith tables or stored procedures I'd do something like this:\nif exists (select * from dbo.sysobjects where name='foobar' an... |
What are good ways of dealing with the issues surrounding plugin code that interacts with outside system?
To give a concrete and representative example, suppose I would like to use Subversion and Eclipse to develop plugins for WordPress. The main code body of WordPress is installed on the webserver, and the plugin code... | When developing plugins for systems like WordPress, which require your code to be deployed in a specific directory on a web server, it’s important to maintain a smooth workflow between your development environment and the actual server. Here are some effective strategies for managing the development of such plugins:
#... | 5,874 | [
{
"from": "human",
"value": "What are good ways of dealing with the issues surrounding plugin code that interacts with outside system?\nTo give a concrete and representative example, suppose I would like to use Subversion and Eclipse to develop plugins for WordPress. The main code body of WordPress is insta... |
I was asked a question in C last night and I did not know the answer since I have not used C much since college so I thought maybe I could find the answer here instead of just forgetting about it.
If a person has a define such as:
#define count 1
Can that person find the variable name count using the 1 that is inside ... | In C, when you use the `#define` preprocessor directive to create a macro like:
```c
#define count 1
```
you are essentially telling the preprocessor to replace every instance of `count` in your code with `1` before the actual compilation occurs. This means that `count` itself does not exist as a variable or symbol d... | 10,396 | [
{
"from": "human",
"value": "I was asked a question in C last night and I did not know the answer since I have not used C much since college so I thought maybe I could find the answer here instead of just forgetting about it.\nIf a person has a define such as:\n#define count 1\n\nCan that person find the va... |
I'm working on an application that needs to quickly render simple 3D scenes on the server, and then return them as a JPEG via HTTP. Basically, I want to be able to simply include a dynamic 3D scene in an HTML page, by doing something like:
<img src="http://www.myserver.com/renderimage?scene=1&x=123&y=123&z=123">
My qu... | When it comes to rendering 3D scenes on a server and delivering them as images via HTTP, there are several technologies and approaches you can consider. Your concerns about DirectX and OpenGL in a server environment are valid, as these APIs are typically designed for graphics-intensive applications on local machines, a... | 6,391 | [
{
"from": "human",
"value": "I'm working on an application that needs to quickly render simple 3D scenes on the server, and then return them as a JPEG via HTTP. Basically, I want to be able to simply include a dynamic 3D scene in an HTML page, by doing something like:\n<img src=\"http://www.myserver.com/ren... |
Want a WYSIWYG jQuery Editor as an example to illustrate how to use jQuery to built OOP javascript component.
P.S.
It is so good stackoverflow can use markdown... Would be a heaven if users would love such thing too
| Certainly! To illustrate how to build a WYSIWYG (What You See Is What You Get) editor using jQuery and Object-Oriented Programming (OOP) principles, I'll provide you with a simple example. This example will cover creating a basic editor that allows users to format text in a content-editable div.
### Step 1: HTML Struc... | 4,682 | [
{
"from": "human",
"value": "Want a WYSIWYG jQuery Editor as an example to illustrate how to use jQuery to built OOP javascript component. \nP.S.\nIt is so good stackoverflow can use markdown... Would be a heaven if users would love such thing too\n"
},
{
"from": "gpt",
"value": "Certainly! To i... |
I'm downloading a web page (tag soup HTML) with XMLHttpRequest and I want to take the output and turn it into a DOM object that I can then run XPATH queries on. How do I convert from a string into DOM object?
It appears that the general solution is to create a hidden iframe and throw the contents of the string into tha... | You can indeed convert a string representation of HTML into a DOM object without needing to use an iframe. In modern browsers, you can use the `DOMParser` with the `text/html` MIME type. However, since you've mentioned issues with Firefox versions before 3.5, the following solution leverages both `DOMParser` and ensure... | 3,798 | [
{
"from": "human",
"value": "I'm downloading a web page (tag soup HTML) with XMLHttpRequest and I want to take the output and turn it into a DOM object that I can then run XPATH queries on. How do I convert from a string into DOM object?\nIt appears that the general solution is to create a hidden iframe and... |
I need to make an ArrayList of ArrayLists thread safe. I also cannot have the client making changes to the collection. Will the unmodifiable wrapper make it thread safe or do I need two wrappers on the collection?
| To make an `ArrayList` of `ArrayLists` thread-safe while also preventing clients from making modifications, you need to take the right approach to handle both concurrency and immutability.
1. **Thread Safety**: To make your `ArrayList` thread-safe, you can use `Collections.synchronizedList()` to wrap your outer list. ... | 6,772 | [
{
"from": "human",
"value": "I need to make an ArrayList of ArrayLists thread safe. I also cannot have the client making changes to the collection. Will the unmodifiable wrapper make it thread safe or do I need two wrappers on the collection?\n"
},
{
"from": "gpt",
"value": "To make an `ArrayLis... |
Service Oriented Architecture seems to be more and more of a hot quote these days, but after asking around the office I have found that I seem to get many different definitions for it. How would you guys define SOA? What would you consider the official definition?
| Service-Oriented Architecture (SOA) is an architectural style that enables the design of software systems as a collection of loosely coupled, reusable services. Each service is a self-contained unit that performs a specific business function and can communicate with other services over a network, typically using standa... | 8,571 | [
{
"from": "human",
"value": "Service Oriented Architecture seems to be more and more of a hot quote these days, but after asking around the office I have found that I seem to get many different definitions for it. How would you guys define SOA? What would you consider the official definition?\n"
},
{
... |
I have a 3d object that I wish to be able to rotate around in 3d. The easiest way is to directly translate X and Y mouse motion to rotation about the Y and X axes, but if there is some rotation along both axes, the way the model rotates becomes highly counterintuitive (i.e. if you flip the object 180 degrees about one... | You're right to be concerned about the potential pitfalls of using a simple Euler angle approach for 3D rotations, especially when you want intuitive controls. The issue of gimbal lock and the counterintuitive nature of rotations can arise when using Euler angles.
A better approach is to use **quaternions**, which are... | 7,541 | [
{
"from": "human",
"value": "I have a 3d object that I wish to be able to rotate around in 3d. The easiest way is to directly translate X and Y mouse motion to rotation about the Y and X axes, but if there is some rotation along both axes, the way the model rotates becomes highly counterintuitive (i.e. if ... |
I want my website to join some webcam recordings in FLV files (like this one). This needs to be done on Linux without user input. How do I do this? For simplicity's sake, I'll use the same flv as both inputs in hope of getting a flv that plays the same thing twice in a row.
That should be easy enough, right? There's ev... | Joining FLV files in a Linux environment can be a bit tricky due to the intricacies of the FLV format and the limitations of various tools like FFmpeg and MEncoder. Let's go through your questions and see if we can clarify things and provide better solutions.
### a) Why doesn't the example script work as advertised?
T... | 6,199 | [
{
"from": "human",
"value": "I want my website to join some webcam recordings in FLV files (like this one). This needs to be done on Linux without user input. How do I do this? For simplicity's sake, I'll use the same flv as both inputs in hope of getting a flv that plays the same thing twice in a row.\nTha... |
We have a java program that requires a large amount of heap space - we start it with (among other command line arguments) the argument -Xmx1500m, which specifies a maximum heap space of 1500 MB. When starting this program on a Windows XP box that has been freshly rebooted, it will start and run without issues. But if t... | Your suspicion about memory fragmentation causing the Java Virtual Machine (JVM) initialization error is reasonable, especially on a system like Windows XP where long-term uptime can lead to fragmentation issues.
### Confirming Memory Fragmentation
1. **Check Memory Allocation**: Use tools like **Process Explorer** o... | 8,375 | [
{
"from": "human",
"value": "We have a java program that requires a large amount of heap space - we start it with (among other command line arguments) the argument -Xmx1500m, which specifies a maximum heap space of 1500 MB. When starting this program on a Windows XP box that has been freshly rebooted, it wi... |
Any suggestions? Using visual studio in C#.
Are there any specific tools to use or methods to approach this?
Update:
Sorry, I should have been a little more specific. I am using ASP.Net 2.0 and was looking more for a tool like jUnit for Java. I took a look at NUnit and NUnitAsp and that looks very promising. And I did... | It's great to hear that you're diving into ASP.NET and C#. Here are some tools and methods that you can use for testing in your ASP.NET 2.0 environment:
### Testing Frameworks:
1. **NUnit**:
- As you mentioned, NUnit is a popular unit testing framework for .NET that is similar to JUnit for Java. It allows you to ... | 5,696 | [
{
"from": "human",
"value": "Any suggestions? Using visual studio in C#.\nAre there any specific tools to use or methods to approach this?\nUpdate:\nSorry, I should have been a little more specific. I am using ASP.Net 2.0 and was looking more for a tool like jUnit for Java. I took a look at NUnit and NUnit... |
I am developing an ASP.NET mobile website using .NET 3.5 and mobile controls that come with the framework. I have a login form where the system will authenticate the user so he/she can access certain restricted pages.
In a standard ASP.NET website, I can use a session to store some flag after a user had logined, but I... | Yes, you can use session variables and cookies in an ASP.NET mobile website just like you would in a standard ASP.NET web application. The ASP.NET mobile controls support the same session and cookie management features as the standard ASP.NET framework, so you can manage user authentication effectively.
### Using Sess... | 6,760 | [
{
"from": "human",
"value": "I am developing an ASP.NET mobile website using .NET 3.5 and mobile controls that come with the framework. I have a login form where the system will authenticate the user so he/she can access certain restricted pages. \nIn a standard ASP.NET website, I can use a session to store... |
This is a bit hypothetical and grossly simplified but...
Assume a program that will be calling functions written by third parties. These parties can be assumed to be non-hostile but can't be assumed to be "competent". Each function will take some arguments, have side effects and return a value. They have no state while... | Your question addresses a challenging problem in managing memory when using third-party functions that could potentially cause memory leaks. Given the constraints you've outlined, let's consider some possible approaches to ensure that any memory allocated within a function is cleaned up after the function exits.
### P... | 5,476 | [
{
"from": "human",
"value": "This is a bit hypothetical and grossly simplified but...\nAssume a program that will be calling functions written by third parties. These parties can be assumed to be non-hostile but can't be assumed to be \"competent\". Each function will take some arguments, have side effects ... |
I'm just getting started with learning about Unit testing (and TDD in general). My question is does the latest version of NUnit support working in VS2008 with .NET 3.5? I've looked at the documentation pages at NUnit and they don't mention it.
If anyone has worked with it in 3.5 are there any limitations or features... | NUnit has been around for a long time, and it has gone through many iterations. As of your reference to Visual Studio 2008 and .NET 3.5, you'll be looking primarily at earlier versions of NUnit.
The latest versions of NUnit (like NUnit 3.x) do not support .NET Framework 3.5 directly; they are more suited for .NET 4.0 ... | 8,742 | [
{
"from": "human",
"value": "I'm just getting started with learning about Unit testing (and TDD in general). My question is does the latest version of NUnit support working in VS2008 with .NET 3.5? I've looked at the documentation pages at NUnit and they don't mention it. \nIf anyone has worked with it in... |
Suppose you're developing a software product that has periodic releases. What are the best practices with regard to branching and merging? Slicing off periodic release branches to the public (or whomever your customer is) and then continuing development on the trunk, or considering the trunk the stable version, tagging... | When it comes to managing branches and merges in a software development environment with periodic releases, adopting a well-defined branching strategy is critical for ensuring stability, facilitating collaboration, and streamlining the release process. Here are some best practices to consider:
### Best Practices for B... | 6,155 | [
{
"from": "human",
"value": "Suppose you're developing a software product that has periodic releases. What are the best practices with regard to branching and merging? Slicing off periodic release branches to the public (or whomever your customer is) and then continuing development on the trunk, or consider... |
I am connecting to a Windows XP machine via Microsoft's Remote Desktop Connection Client, version 2.0.0 Beta 3, running on a Mac. On the Windows machine there is a Java console running, where I want to send a Ctrl-Break so I can see the Java threads running.
According to the RDC help, Alt/Option-F3 is break, but Ctrl-O... | To send a Ctrl-Break command to a Windows XP machine through Microsoft Remote Desktop Connection Client on a Mac, you can use a combination of keyboard shortcuts. The traditional `Ctrl-Break` key combination might not be directly supported or might not work as expected when using a remote connection from Mac to Windows... | 9,002 | [
{
"from": "human",
"value": "I am connecting to a Windows XP machine via Microsoft's Remote Desktop Connection Client, version 2.0.0 Beta 3, running on a Mac. On the Windows machine there is a Java console running, where I want to send a Ctrl-Break so I can see the Java threads running.\nAccording to the RD... |
I have a VB6 program that someone recently helped me convert to VB.NET
In the program, when saving files, I stamp them with the date which I was getting by calling the Today() function.
When I try to run the new VB.NET code in Vista it throws a permission exception for the Today() . If I run Visual Studio Express (thi... | The issue you're experiencing with the `Today()` function in VB.NET on Vista is unusual, as accessing the current date should not typically cause a permission exception. The `Today()` function, which returns the current date, does not require special permissions to access.
Here are some steps and suggestions to troub... | 7,243 | [
{
"from": "human",
"value": "I have a VB6 program that someone recently helped me convert to VB.NET\nIn the program, when saving files, I stamp them with the date which I was getting by calling the Today() function. \nWhen I try to run the new VB.NET code in Vista it throws a permission exception for the To... |
Is there a TortoiseSVN equivalent for OS X? I'm looking for an SVN client that will integrate with OS X's Finder and be added as Context menu items.
Update: Just found SmartSVN. Anyone with feedback on it?
| Yes, SmartSVN is a popular SVN client for macOS and offers a variety of features that can help with version control tasks. It's a powerful client that supports a user-friendly interface, making it easier to manage your SVN repositories. It integrates well with the macOS environment, although it may not integrate direct... | 10,081 | [
{
"from": "human",
"value": "Is there a TortoiseSVN equivalent for OS X? I'm looking for an SVN client that will integrate with OS X's Finder and be added as Context menu items.\nUpdate: Just found SmartSVN. Anyone with feedback on it?\n"
},
{
"from": "gpt",
"value": "Yes, SmartSVN is a popular ... |
In a few weeks, we'll be teaching a crash course on C++ for Java programmers straight out of college. They have little or no experience yet with C or C++.
Previous editions of this course were just 1 or 2 half-day sessions and covered topics including:
new language features, e.g.
header vs. implementation
pointers an... | Teaching a crash course on C++ for Java programmers can be a rewarding experience, especially since many concepts will be familiar to the attendees, even if the syntax and certain paradigms differ. Here are some suggestions based on your outline:
### Most Crucial Topics
1. **Basic Syntax and Structure**:
- Differen... | 6,607 | [
{
"from": "human",
"value": "In a few weeks, we'll be teaching a crash course on C++ for Java programmers straight out of college. They have little or no experience yet with C or C++.\nPrevious editions of this course were just 1 or 2 half-day sessions and covered topics including:\n\nnew language features,... |
I need to be able to find the last occurrence of a character within an element.
For example:
<mediaurl>http://www.blah.com/path/to/file/media.jpg</mediaurl>
If I try to locate it through using substring-before(mediaurl, '.') and substring-after(mediaurl, '.') then it will, of course, match on the first dot.
How woul... | To extract the file name and file extension from a URL using XSLT, you need to focus on getting the last occurrence of the character `.` in the string. This will allow you to differentiate between the base file name and its extension.
Here’s how you can achieve this using XSLT 1.0. Since XSLT 1.0 does not have built-i... | 4,291 | [
{
"from": "human",
"value": "I need to be able to find the last occurrence of a character within an element.\nFor example:\n<mediaurl>http://www.blah.com/path/to/file/media.jpg</mediaurl>\n\nIf I try to locate it through using substring-before(mediaurl, '.') and substring-after(mediaurl, '.') then it will, ... |
1.exe doesn't give enough time for me to launch the IDE and attach 1.exe to the debugger to break into.
| When you're dealing with a program like `1.exe` that terminates too quickly for you to attach a debugger, there are a few strategies you can use to get around this issue:
### 1. Add a Delay to the Program
If you have access to the source code of `1.exe`, consider adding a delay (e.g., a `sleep` function) before the pr... | 7,333 | [
{
"from": "human",
"value": "1.exe doesn't give enough time for me to launch the IDE and attach 1.exe to the debugger to break into.\n"
},
{
"from": "gpt",
"value": "When you're dealing with a program like `1.exe` that terminates too quickly for you to attach a debugger, there are a few strategi... |
I have some code which is supposed to display a short message. Here's the pertinent code:
DATA SEGMENT 'DATA'
MSG DB 0AH, 0DH, 'Hello, Adam', '$'
CHAR DB 00H
DATA ENDS
CODE SEGMENT 'CODE'
PRINT_MSG:
MOV AH, 09H ;Command to print string of characters
MOV DX, OFFSET MSG ;Mov address of message into ... | The issue you're experiencing with the unexpected characters appearing before your message "Hello, Adam" is likely due to the presence of the carriage return (`0DH`) and line feed (`0AH`) characters at the beginning of your message string.
In your code:
```assembly
MSG DB 0AH, 0DH, 'Hello, Adam', '$'
```
Here, `0AH... | 9,047 | [
{
"from": "human",
"value": "I have some code which is supposed to display a short message. Here's the pertinent code:\nDATA SEGMENT 'DATA'\nMSG DB 0AH, 0DH, 'Hello, Adam', '$'\nCHAR DB 00H\nDATA ENDS\n\nCODE SEGMENT 'CODE'\nPRINT_MSG:\n MOV AH, 09H ;Command to print string of characters\n ... |
I need to know if it is possible to dynamically bind a textbox residing within a datarepeater to a 'dynamically' created BindingSource. I am using VB.net. The database I am using is a MySQL database.
I have to use the connection dynamically due to the fact that the database my not permanently reside on the same ser... | Binding controls like TextBoxes within a DataRepeater to a dynamically created `BindingSource` in VB.NET is definitely possible. Below, I'll outline how you can achieve this by following these general steps:
1. **Dynamically Create a DataTable**: Fetch data from your MySQL database and load it into a DataTable.
2. **C... | 5,920 | [
{
"from": "human",
"value": "I need to know if it is possible to dynamically bind a textbox residing within a datarepeater to a 'dynamically' created BindingSource. I am using VB.net. The database I am using is a MySQL database. \nI have to use the connection dynamically due to the fact that the database... |
Is there a performance hit if we use a loop instead of recursion or vice versa in algorithms where both can serve the same purpose? Eg: Check if the given string is a palindrome.
I have seen many programmers using recursion as a means to show off when a simple iteration algorithm can fit the bill.
Does the compiler pla... | Yes, there can be performance differences between using recursion and iteration for algorithms that can be implemented in both ways, such as checking if a string is a palindrome. Here are some key points to consider:
### Performance Differences
1. **Overhead**: Recursive function calls have overhead due to maintainin... | 6,256 | [
{
"from": "human",
"value": "Is there a performance hit if we use a loop instead of recursion or vice versa in algorithms where both can serve the same purpose? Eg: Check if the given string is a palindrome.\nI have seen many programmers using recursion as a means to show off when a simple iteration algorit... |
Do C#/.NET floating point operations differ in precision between debug mode and release mode?
| In C# and .NET, floating-point operations themselves do not inherently differ in precision between debug and release modes. However, there are several factors to consider that might lead to differences in behavior or performance between the two modes, which could indirectly affect how floating-point calculations appear... | 9,116 | [
{
"from": "human",
"value": "Do C#/.NET floating point operations differ in precision between debug mode and release mode?\n"
},
{
"from": "gpt",
"value": "In C# and .NET, floating-point operations themselves do not inherently differ in precision between debug and release modes. However, there a... |
I'm doing something bad in my ASP.NET app. It could be the any number of CTP libraries I'm using or I'm just not disposing something properly. But when I redeploy my ASP.NET to my Vista IIS7 install or my server's IIS6 install I crash an IIS worker process.
I've narrowed the problem down to my HTTP crawler, which is a ... | When an IIS worker process crashes, a crash dump can be very useful for diagnosing the problem. The crash dump will typically be located in a specific location, depending on how your IIS is configured and which version you are using. Here’s how you can find the crash dump for analysis:
### For IIS 7 (Windows Vista/Win... | 6,639 | [
{
"from": "human",
"value": "I'm doing something bad in my ASP.NET app. It could be the any number of CTP libraries I'm using or I'm just not disposing something properly. But when I redeploy my ASP.NET to my Vista IIS7 install or my server's IIS6 install I crash an IIS worker process.\nI've narrowed the pr... |
I'm looking for something that can copy (preferably only changed) files from a development machine to a staging machine and finally to a set of production machines.
A "what if" mode would be nice as would the capability to "rollback" the last deployment. Database migrations aren't a necessary feature.
UPDATE: A fre... | For your requirements of deploying files from a development machine to staging and production environments, while only copying changed files and providing a "what if" mode and rollback capabilities, here are some tools you can consider:
### 1. **RoboCopy**
- **Overview**: RoboCopy is a command-line tool included with ... | 5,529 | [
{
"from": "human",
"value": "I'm looking for something that can copy (preferably only changed) files from a development machine to a staging machine and finally to a set of production machines.\nA \"what if\" mode would be nice as would the capability to \"rollback\" the last deployment. Database migrat... |
Normally I use imagecreatefromjpeg() and then getimagesize(), but with Firefox 3 I need to go round this different. So now im using imagecreatefromstring(), but how do I retreive the image dimensions now?
| When you use `imagecreatefromstring()` to create an image from a string of binary data, you don't get the image dimensions directly from that function. Instead, you can use the `getimagesizefromstring()` function to retrieve the dimensions of the image. Here's how you can do it:
1. First, read the image data into a st... | 10,666 | [
{
"from": "human",
"value": "Normally I use imagecreatefromjpeg() and then getimagesize(), but with Firefox 3 I need to go round this different. So now im using imagecreatefromstring(), but how do I retreive the image dimensions now?\n"
},
{
"from": "gpt",
"value": "When you use `imagecreatefrom... |
I need a function like this:
// return true if 'n' is a power of 2, e.g.
// is_power_of_2(16) => true
// is_power_of_2(3) => false
bool is_power_of_2(int n);
Can anyone suggest how I could write this?
| Certainly! You can implement the `is_power_of_2` function in C++ by checking whether `n` is greater than zero and whether it has only one bit set in its binary representation. A number `n` is a power of 2 if and only if the expression `n & (n - 1)` equals 0, and `n` is greater than 0.
Here’s how you could write this f... | 8,877 | [
{
"from": "human",
"value": "I need a function like this:\n// return true if 'n' is a power of 2, e.g.\n// is_power_of_2(16) => true \n// is_power_of_2(3) => false\nbool is_power_of_2(int n);\n\nCan anyone suggest how I could write this?\n"
},
{
"from": "gpt",
"value": "Certainly! You can imple... |
I've got a (mostly) working plugin developed, but since its function is directly related to the project it processes, how do you develop unit and integration tests for the plugin. The best idea I've had is to create an integration test project for the plugin that uses the plugin during its lifecycle and has tests that... | Creating unit and integration tests for a plugin can be a bit challenging, especially if the functionality is tightly coupled with the project it processes. However, your idea of creating an integration test project that utilizes the plugin during its lifecycle is a solid approach. Here are some strategies to enhance y... | 7,543 | [
{
"from": "human",
"value": "I've got a (mostly) working plugin developed, but since its function is directly related to the project it processes, how do you develop unit and integration tests for the plugin. The best idea I've had is to create an integration test project for the plugin that uses the plugi... |
Can you specialize a template method within a template class without specializing the class template parameter?
Please note that the specialization is on the value of the template parameter, not its type.
This seems to compile under Visual Studio 2008 SP1 complier, but not GCC 4.2.4.
#include <iostream>
using namespace... | The issue you're encountering is due to the fact that the C++ standard (specifically C++03 and C++11) does not allow explicit template specialization inside a class definition. Your code compiles successfully with Visual Studio because it has some non-standard extensions, but it fails with GCC and other compliant compi... | 7,443 | [
{
"from": "human",
"value": "Can you specialize a template method within a template class without specializing the class template parameter?\nPlease note that the specialization is on the value of the template parameter, not its type.\nThis seems to compile under Visual Studio 2008 SP1 complier, but not GCC... |
Is there a trivial, or at least moderately straight-forward way to generate territory maps (e.g. Risk)?
I have looked in the past and the best I could find were vague references to Voronoi diagrams. An example of a Voronoi diagram is this:
.
These hold promise, but I guess i haven't seen any straight-forward ways of r... | Generating territory maps for games like Risk can be approached through several methods, including Voronoi diagrams and flood fill algorithms. Here's a breakdown of both methods and some additional options you might consider.
### Method 1: Voronoi Diagrams
Voronoi diagrams partition a plane into regions based on the ... | 4,980 | [
{
"from": "human",
"value": "Is there a trivial, or at least moderately straight-forward way to generate territory maps (e.g. Risk)?\nI have looked in the past and the best I could find were vague references to Voronoi diagrams. An example of a Voronoi diagram is this:\n.\nThese hold promise, but I guess i... |
I want to shift the contents of an array of bytes by 12-bit to the left.
For example, starting with this array of type uint8_t shift[10]:
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xBC}
I'd like to shift it to the left by 12-bits resulting in:
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAB, 0xC0, 0x00}
| To shift an array of bytes left by 12 bits, you need to consider how this operation affects each byte in the array. In this case, you're working with a `uint8_t` array (which means each element is 8 bits), and you want to perform a left shift of 12 bits.
A left shift of 12 bits means you effectively want to remove the... | 5,761 | [
{
"from": "human",
"value": "I want to shift the contents of an array of bytes by 12-bit to the left.\nFor example, starting with this array of type uint8_t shift[10]:\n{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xBC}\n\nI'd like to shift it to the left by 12-bits resulting in:\n{0x00, 0x00, 0x0... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.