instruction stringlengths 14 27.6k | completion stringlengths 3 38.3k | __original_row_idx int64 0 50k | conversations listlengths 2 2 |
|---|---|---|---|
How should I show users which fields are compulsory in a windows forms application.
I have considered changing the label color or maybe the background color of the text box.
I use an error provider to show a red exclamation mark next to the field, however this is only visible after they have clicked the save button.
| In a Windows Forms application, it's important to clearly indicate which fields are compulsory to improve the user experience and guide users through the form completion. Here are several methods to effectively show which fields are required:
### 1. Change Label Color
Changing the label color is a widely used method. ... | 30,071 | [
{
"from": "human",
"value": "How should I show users which fields are compulsory in a windows forms application.\nI have considered changing the label color or maybe the background color of the text box.\nI use an error provider to show a red exclamation mark next to the field, however this is only visible ... |
Most of the documentation available for building Python extension modules
uses distutils, but I would like to achieve this by using the appropriate
python autoconf & automake macros instead.
I'd like to know if there is an open source project out there that does
exactly this. Most of the ones I've found end up relying ... | If you're looking for an open source project that builds Python extension modules using autoconf and automake without relying on `setup.py`, there are indeed a few examples available. Here’s how you can get started and what you might find helpful:
### Example Projects
1. **PyGTK**: The PyGTK project uses autoconf and... | 28,199 | [
{
"from": "human",
"value": "Most of the documentation available for building Python extension modules\nuses distutils, but I would like to achieve this by using the appropriate\npython autoconf & automake macros instead.\nI'd like to know if there is an open source project out there that does\nexactly this... |
As title.
ruby test/functionals/whatevertest.rb doesn't work, that requires me to replace all require 'test_helper' to require File.dirname(__FILE__) + '/../test_helper'. For some reason most of those test templates have such issue, so I rather to see if there is a hack I could get around it.
| When working with Ruby on Rails and its testing framework, the `require 'test_helper'` is typically used to load the necessary test setup. If you are facing issues where `require 'test_helper'` does not work correctly in your tests, it usually indicates a problem with your project's structure or the way the test files ... | 30,995 | [
{
"from": "human",
"value": "As title. \nruby test/functionals/whatevertest.rb doesn't work, that requires me to replace all require 'test_helper' to require File.dirname(__FILE__) + '/../test_helper'. For some reason most of those test templates have such issue, so I rather to see if there is a hack I coul... |
Preface
I'm using the newly released Microsoft Virtual Earth SDK v6.2 which has built-in support for pushpin clustering. I realize there are custom ways of doing clustering where my question is easy to answer, but I'd like to leverage the built-in support as much as possible, so this question is specifically related t... | In the Microsoft Virtual Earth SDK v6.2, while the built-in clustering functionality provides convenient clustering of pushpins, it does have limitations when it comes to customizing the cluster infoboxes directly or accessing the original pushpins after clustering. However, you can achieve your goals with some workaro... | 27,127 | [
{
"from": "human",
"value": "Preface\nI'm using the newly released Microsoft Virtual Earth SDK v6.2 which has built-in support for pushpin clustering. I realize there are custom ways of doing clustering where my question is easy to answer, but I'd like to leverage the built-in support as much as possible, ... |
I have a table in lua with some data.
sometable = {
{name = "bob", something = "foo"},
{name = "greg", something = "bar"}
}
I then want to loop through the table and assign a number to each name as a variable. New to lua and tried it like this.
for i,t in ipairs(sometable) do
t.name = i
end
I was then as... | In Lua, when you assign a value to a key in a table, that key-value pair is stored within that table. When you do `t.name = i`, you are setting the `name` field of the current table entry to the value of `i`. This means that `name` now holds the number (1, 2, etc.) instead of the original string ("bob", "greg").
If yo... | 32,399 | [
{
"from": "human",
"value": "I have a table in lua with some data.\nsometable = { \n {name = \"bob\", something = \"foo\"},\n {name = \"greg\", something = \"bar\"}\n}\n\nI then want to loop through the table and assign a number to each name as a variable. New to lua and tried it like this.\nfor i,t i... |
I am wondering what is the best way to construct a common utilities library that can be used in different projects. I am using .Net and C#.
Should I create a separate project for each utility such as Logging, Authentication, Excel etc. and release them separately along with dependencies or should i include all utilitie... | When constructing a common utilities library in .NET and C#, you need to consider several factors including maintainability, usability, project organization, and dependency management. Here are the pros and cons of each approach you mentioned, along with a recommended strategy:
### Approach 1: Separate Projects for Ea... | 20,898 | [
{
"from": "human",
"value": "I am wondering what is the best way to construct a common utilities library that can be used in different projects. I am using .Net and C#.\nShould I create a separate project for each utility such as Logging, Authentication, Excel etc. and release them separately along with dep... |
We get this error in Visual Studio 2005 and TFS very often.
Can anyone help us pinpoint the cause for this message?
The full message is:
There appears to be a discrepancy between the solution's source
control information about some project(s) and the information in the
project file(s).
To resolve this discrepancy ... | The error you're encountering in Visual Studio 2005 and TFS regarding discrepancies between the solution's source control information and the project files can be frustrating, especially when it appears to be a lingering issue after your migration from Visual SourceSafe (VSS). Here are several steps and considerations ... | 32,250 | [
{
"from": "human",
"value": "We get this error in Visual Studio 2005 and TFS very often.\nCan anyone help us pinpoint the cause for this message?\nThe full message is:\n\nThere appears to be a discrepancy between the solution's source\n control information about some project(s) and the information in the\n... |
if(!eregi("^([0-9a-z_\[\]\*\- ])+$", $subuser))
$form->setError($field, "* Username not alphanumeric");
Can anybody tell me why it is not allowing characters such as - and *?
if(!eregi("^([0-9a-z])+$", $subuser))
$form->setError($field, "* Username not alphanumeric");
That is the original piece of code. A fri... | The issue with the regex in your friend's modification lies in how the `eregi()` function processes the character set defined in the brackets. Let's break it down.
### Original Regex:
```php
if(!eregi("^([0-9a-z])+$", $subuser))
```
- This regex matches only lowercase letters (`a-z`) and digits (`0-9`).
### Modified ... | 30,587 | [
{
"from": "human",
"value": "if(!eregi(\"^([0-9a-z_\\[\\]\\*\\- ])+$\", $subuser))\n $form->setError($field, \"* Username not alphanumeric\");\n\nCan anybody tell me why it is not allowing characters such as - and *?\nif(!eregi(\"^([0-9a-z])+$\", $subuser))\n $form->setError($field, \"* Username not a... |
I have the HTML given below:
<ul id="thumbsPhotos">
<li src="/images/1alvaston-hall-relaxing-lg.jpg" onclick="updatePhoto (this.title)"><img src="/images/1alvaston-hall-relaxing-sl.jpg" width="56" height="56"></li>
<li onclick="updatePhoto(this.title)" src=""><img src="" width="56" height="56"></li>
<... | To replace all `src` attributes in `<li>` tags (that are not in `<img>` tags) with a `title` attribute using `innerHTML`, you can use JavaScript to manipulate the HTML. Below is an example of how you can achieve this.
### JavaScript Code:
```javascript
// Get the <ul> element by its ID
var ulElement = document.getEle... | 32,703 | [
{
"from": "human",
"value": "I have the HTML given below:\n<ul id=\"thumbsPhotos\">\n <li src=\"/images/1alvaston-hall-relaxing-lg.jpg\" onclick=\"updatePhoto (this.title)\"><img src=\"/images/1alvaston-hall-relaxing-sl.jpg\" width=\"56\" height=\"56\"></li>\n <li onclick=\"updatePhoto(this.title)... |
I am migrating web apps to new hosting servers, but when I try to access them to test on the new server, I get all these assemblies not found errors like:
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error d... | The error message you are encountering indicates that your web application is trying to load specific versions of certain assemblies, which are not available on the new hosting server. Here are steps to troubleshoot and resolve the issue:
1. **Check the .NET Framework Version**:
Ensure that the new hosting environm... | 30,130 | [
{
"from": "human",
"value": "I am migrating web apps to new hosting servers, but when I try to access them to test on the new server, I get all these assemblies not found errors like:\nConfiguration Error\nDescription: An error occurred during the processing of a configuration file required to service this ... |
I have an asp.net server control (with the asp: in its definition). The button has been set to do post back.
On the server side, I have the on click event handler
e.g btnSave_click()
On the client side, I have a javascript function to be invoked on the click event
e.g btnSave.Attributes.Add("onclick","javascript: retur... | In ASP.NET, when you attach a JavaScript function to an event like `onclick` of a button, the JavaScript will execute first before the server-side event handler is invoked. This means that if you return `false` from the JavaScript function, the postback will be canceled, and the server-side event handler will not be ex... | 30,968 | [
{
"from": "human",
"value": "I have an asp.net server control (with the asp: in its definition). The button has been set to do post back.\nOn the server side, I have the on click event handler\ne.g btnSave_click()\nOn the client side, I have a javascript function to be invoked on the click event\ne.g btnSav... |
I spend hours every week coding my own personal projects.
I have a nice C++ backend. For my next idea, it is small and lite enough to be done in flash. But i want to do it in a scripting language so i can call the code in my C++ projects. What script can i use in flash along with c++?
| For integrating scripting into your C++ projects, particularly with a Flash backend, you may consider using **ActionScript**, which is the primary scripting language for Flash. However, ActionScript is tightly coupled with the Flash environment, which may not be ideal if you want to call it from your C++ code.
If you'... | 29,654 | [
{
"from": "human",
"value": "I spend hours every week coding my own personal projects.\nI have a nice C++ backend. For my next idea, it is small and lite enough to be done in flash. But i want to do it in a scripting language so i can call the code in my C++ projects. What script can i use in flash along wi... |
In the situation of having a project initiated by a marketing or sales team, how can we capture the not so obvious requirements that the project be marketable, or even better, self marketing?
In many cases the marketing/sales team can hardly enumerate the functional specs of what the project should do, let alone descr... | Capturing not-so-obvious requirements in projects, particularly in web applications initiated by marketing or sales teams, is essential for ensuring that the final product is not only functional but also marketable and self-promoting. Here are several strategies you can implement to enhance your project scoping process... | 30,496 | [
{
"from": "human",
"value": "In the situation of having a project initiated by a marketing or sales team, how can we capture the not so obvious requirements that the project be marketable, or even better, self marketing? \nIn many cases the marketing/sales team can hardly enumerate the functional specs of w... |
I have an aspx page which will upload images to server harddisk from client pc
But now i need to change my program in such a way that it would allow me to resize the image while uploading.
Does anyone has any idea on this ? I couldnt not find such properties/methods with Input file server control
Any one there to guide... | To resize an image while uploading it through an ASP.NET web application (ASPX page), you'll typically need to handle the image processing on the server-side after the image has been uploaded. Below are the steps you can follow to achieve this using C# and the System.Drawing namespace.
### Steps to Resize an Image on ... | 30,349 | [
{
"from": "human",
"value": "I have an aspx page which will upload images to server harddisk from client pc\nBut now i need to change my program in such a way that it would allow me to resize the image while uploading.\nDoes anyone has any idea on this ? I couldnt not find such properties/methods with Input... |
Into some view data i have put the result of an anonymous type:
var projectData = from p in db.Projects
orderby p.title
select new
{
Title = p.title,
DevURL = p.devURL ??... | To iterate through the `ViewData["ProjectSummary"]` containing the anonymous type in your MVC view and display the results in a table format, you can cast `ViewData["ProjectSummary"]` to `IEnumerable<dynamic>`. Here's how you can do that step-by-step:
1. **In the View**: First, make sure you have the appropriate using... | 32,374 | [
{
"from": "human",
"value": "Into some view data i have put the result of an anonymous type:\n var projectData = from p in db.Projects\n orderby p.title\n select new\n {\n Title = p.title,\n ... |
Problem solved: Thanks guys, see my answer below.
I have a website running in Tomcat 5.5 hooked up to a MySQL5 database using Hibernate3.
One record simply refuses to keep any changes performed on it. If I change the record programmatically, the values revert back to what they were previously.
If I manually modify the... | It sounds like you're experiencing a caching issue, which is common when using Hibernate. The fact that the values revert back after being changed could be due to a couple of reasons. Here are some steps and considerations that might help you resolve this issue:
### 1. **Check Hibernate Caching Configuration:**
Hib... | 31,245 | [
{
"from": "human",
"value": "Problem solved: Thanks guys, see my answer below.\nI have a website running in Tomcat 5.5 hooked up to a MySQL5 database using Hibernate3.\nOne record simply refuses to keep any changes performed on it. If I change the record programmatically, the values revert back to what they... |
Using DBIx::Class and I have a resultset which needs to be filtered by data which cannot be generated by SQL. What I need to do is something effectively equivalent to this hypothetical example:
my $resultset = $schema->resultset('Service')->search(\%search);
my $new_resultset = $resultset->filter( sub {
my $we... | In DBIx::Class, while you can perform a wide range of filtering directly in SQL via the `search` method, there are times when you may want to filter the result set using Perl code instead. Since SQL can only be used to filter on the database level, when you need to apply custom filtering that can't be done in SQL, you ... | 33,142 | [
{
"from": "human",
"value": "Using DBIx::Class and I have a resultset which needs to be filtered by data which cannot be generated by SQL. What I need to do is something effectively equivalent to this hypothetical example:\nmy $resultset = $schema->resultset('Service')->search(\\%search);\nmy $new_resu... |
Being really new to wx, I'm wondering if there is an IDE (especially for Linux) which would help me lay out a frame or dialog or whatever just to help me see what I'm doing. That means also creating the code for those changes.
I remember way back when using resource compilers for OS/2 and Windows that produced binarie... | When working with wxWidgets (wx) for creating graphical user interfaces (GUIs), having an integrated development environment (IDE) that can help you lay out your GUI components visually can be very beneficial. For Linux users, there are a few options you might consider:
1. **wxFormBuilder**:
- wxFormBuilder is a po... | 30,632 | [
{
"from": "human",
"value": "Being really new to wx, I'm wondering if there is an IDE (especially for Linux) which would help me lay out a frame or dialog or whatever just to help me see what I'm doing. That means also creating the code for those changes.\nI remember way back when using resource compilers ... |
I am not as familiar with Oracle as I would like to be. I have some 250k records, and I want to display them 100 per page. Currently I have one stored procedure which retrieves all quarter of a million records to a dataset using a data adapter, and dataset, and the dataadapter.Fill(dataset) method on the results from... | To efficiently retrieve a specific "page" of records from a large dataset in Oracle, you can use the `ROWNUM` or the more modern `OFFSET FETCH` approach available in Oracle 12c and later. Given your requirement, let's assume you have the following parameters to pass:
- `PageNumber`: This indicates which page of record... | 30,490 | [
{
"from": "human",
"value": "I am not as familiar with Oracle as I would like to be. I have some 250k records, and I want to display them 100 per page. Currently I have one stored procedure which retrieves all quarter of a million records to a dataset using a data adapter, and dataset, and the dataadapter... |
As the title suggests, is it correct or valid to import/export static data from within a C++ class?
I found out my problem - the author of the class I was looking at was trying to export writable static data which isn't supported on this platform.
Many thanks for the responses however.
| In C++, static data members of a class can indeed be exported and imported, but there are some considerations regarding how and when you do this, especially in the context of shared libraries or DLLs.
### Basic Concepts
1. **Static Data Members**: A static data member belongs to the class itself rather than to any pa... | 31,959 | [
{
"from": "human",
"value": "As the title suggests, is it correct or valid to import/export static data from within a C++ class?\nI found out my problem - the author of the class I was looking at was trying to export writable static data which isn't supported on this platform.\nMany thanks for the responses... |
I want this page to return 200 whilst still sending the redirect...
<script>
sub page_load
'Get the parameters
dim content As String
content = request.querystring("text")
response.redirect ("http://100.200.100.10/test1/Default.aspx?CommandParm=" + content)
end sub
</script>
<h... | If you want to perform a redirect while still returning an HTTP status code of 200, you can't use the typical `Response.Redirect` method because it automatically returns a 302 status code for a temporary redirect. Instead, you can set the status code manually and use JavaScript to perform the redirect on the client sid... | 33,409 | [
{
"from": "human",
"value": "I want this page to return 200 whilst still sending the redirect...\n<script>\n sub page_load\n 'Get the parameters\n dim content As String\n content = request.querystring(\"text\")\n response.redirect (\"http://100.200.100.10/test1/Default.aspx... |
I have this loop, which I am using to get the values of all cells within all rows of a gridview and then write it to a csv file. My loop looks like this:
string filename = @"C:\Users\gurdip.sira\Documents\Visual Studio 2008\WebSites\Supressions\APP_DATA\surpressionstest.csv";
StreamWriter sWriter = new StreamWriter(fil... | It looks like you're trying to iterate over the rows and columns of a GridView, but the issue is with how you're accessing the columns. In ASP.NET's GridView, you typically access columns via the `Cells` collection of a `GridViewRow`, but you seem to be trying to access it via the `Columns` property, which is not valid... | 32,177 | [
{
"from": "human",
"value": "I have this loop, which I am using to get the values of all cells within all rows of a gridview and then write it to a csv file. My loop looks like this:\nstring filename = @\"C:\\Users\\gurdip.sira\\Documents\\Visual Studio 2008\\WebSites\\Supressions\\APP_DATA\\surpressionstes... |
I installed SQL server 2000 personal edition in my pc. I am now accessing it using windows authentication account. I can use the enterprise manager but when I try to access the sql query analyzer, there aint no window appearing for the query analyzer. Can someone help me on this? Thank you.
| It sounds like you’re experiencing issues launching the SQL Query Analyzer in SQL Server 2000 Personal Edition. Here are some troubleshooting steps you can try to resolve the issue:
1. **Check Taskbar or Other Desktops**: Sometimes, the Query Analyzer window might be opening off-screen or minimized. Check the taskbar ... | 30,659 | [
{
"from": "human",
"value": "I installed SQL server 2000 personal edition in my pc. I am now accessing it using windows authentication account. I can use the enterprise manager but when I try to access the sql query analyzer, there aint no window appearing for the query analyzer. Can someone help me on this... |
I've created a jQuery wee plugin for myself which takes care of showing, hiding and submitting a form to give in-place editing. Currently I have several of these on a page which function independently and I am happy. However, I'm thinking that an 'Edit All' might be useful. I'd therefore want to be able to access all i... | Yes, you can definitely implement an "Edit All" feature for your jQuery plugin that allows you to interact with all instances of the plugin on the page. Here are the steps to achieve this:
### 1. Store Instances
First, you need to ensure that each instance of your plugin is stored in a way that you can easily access ... | 32,196 | [
{
"from": "human",
"value": "I've created a jQuery wee plugin for myself which takes care of showing, hiding and submitting a form to give in-place editing. Currently I have several of these on a page which function independently and I am happy. However, I'm thinking that an 'Edit All' might be useful. I'd ... |
ffdshow has this awesome little API for controlling playback of video files. It allows you to change subtitles, fast forward, get the name of the file playing, etc...
Its implemented as a windows message loop that accepts user messages and posts data back using WM_COPYDATA.
I would like a c#/vb class that will allow me... | If you're looking for a C# or VB.NET class that interfaces with ffdshow's API to control playback, there are indeed some existing solutions and libraries that can serve as a starting point. However, since your requirement is quite specific, here’s a guide to help you implement your own messaging class.
### Implementin... | 26,338 | [
{
"from": "human",
"value": "ffdshow has this awesome little API for controlling playback of video files. It allows you to change subtitles, fast forward, get the name of the file playing, etc...\nIts implemented as a windows message loop that accepts user messages and posts data back using WM_COPYDATA.\nI ... |
I'm coming from Eclipse, working in Visual Studio 2008 Express and just want to highlight code, right-click and comment it out.
nothing in right-click
looking in Tools | Options, Toolbars, Commands, can't find a button for it...
How do I activate this the comment/uncomment feature, I know Visual Studio 2003 had it.
H... | In Visual Studio 2008, commenting and uncommenting code can indeed vary slightly depending on the specific version you're using. Here's a summary of how to comment and uncomment code in the different editions:
### Visual Studio 2008 Full Version:
- **Comment Selected Code**: `Ctrl + K`, then `Ctrl + C`
- **Uncomment S... | 35,619 | [
{
"from": "human",
"value": "I'm coming from Eclipse, working in Visual Studio 2008 Express and just want to highlight code, right-click and comment it out.\n\nnothing in right-click\nlooking in Tools | Options, Toolbars, Commands, can't find a button for it...\n\nHow do I activate this the comment/uncommen... |
I've a performance related question regarding use of StringBuilder.
In a very long loop I'm manipulating a StringBuilder and passing it to another method like this:
for (loop condition) {
StringBuilder sb = new StringBuilder();
sb.append("some string");
. . .
sb.append(anotherString);
. . .
pass... | In terms of performance and efficiency, your second approach—reusing a single `StringBuilder` instance across loop iterations—generally yields better results than creating a new instance in each iteration. Let’s look at both approaches:
### Approach 1: Creating a new `StringBuilder` in each iteration
```java
for (loop... | 33,621 | [
{
"from": "human",
"value": "I've a performance related question regarding use of StringBuilder.\nIn a very long loop I'm manipulating a StringBuilder and passing it to another method like this:\nfor (loop condition) {\n StringBuilder sb = new StringBuilder();\n sb.append(\"some string\");\n . . .\... |
I have an iframe and couple of tables on my aspx page. Now when the page loads these tables are hidden. The iframe is used to upload file to database. Depending on the result of the event I have to show a particular table on my main page (these tables basically have "Retry","next" buttons...depending on whether or not ... | This issue arises because the iframe reloads after the file upload, triggering the `onload` event again, which causes you to hide the tables every time the iframe loads. To solve this, you can use a combination of JavaScript and the iframe's load event to control the visibility of the tables more effectively.
Here’s a... | 20,530 | [
{
"from": "human",
"value": "I have an iframe and couple of tables on my aspx page. Now when the page loads these tables are hidden. The iframe is used to upload file to database. Depending on the result of the event I have to show a particular table on my main page (these tables basically have \"Retry\",\"... |
I am trying to migrate a part of an SVN repository using svnadmin dump.
The provided svndumpfilter tool doesn't manage copy/move/rename dependencies from directories not included in the export.
Is there a tool which can manage these dependencies?
| Migrating a portion of an SVN repository while preserving the history and maintaining the integrity of move/copy/rename operations can indeed be challenging, especially if `svndumpfilter` does not handle the dependencies correctly.
One commonly recommended tool for this task is `svnrdump`, which allows you to create a... | 32,341 | [
{
"from": "human",
"value": "I am trying to migrate a part of an SVN repository using svnadmin dump.\nThe provided svndumpfilter tool doesn't manage copy/move/rename dependencies from directories not included in the export.\nIs there a tool which can manage these dependencies?\n"
},
{
"from": "gpt",... |
I have an old ASP.NET 1.1 site that I am maintaining. We are working with Google to place analytics code on all pages. Since I can't take advantage of master pages in 1.1, I have my pages include headers/footers/sidebars with User Controls.
What came to mind first is to place the JavaScript in my footer ascx control ... | In ASP.NET 1.1, there are indeed limitations compared to later versions, especially with features like master pages. However, you can still include JavaScript in your user controls (`.ascx`) and have it rendered on all pages that use those controls.
Here are a few approaches you can take to include your Google Analyti... | 26,679 | [
{
"from": "human",
"value": "I have an old ASP.NET 1.1 site that I am maintaining. We are working with Google to place analytics code on all pages. Since I can't take advantage of master pages in 1.1, I have my pages include headers/footers/sidebars with User Controls.\nWhat came to mind first is to place... |
How can I use Hyperlink button in gridview. I mean when I run my program,all data is displayed in gridview,but I want hyperlink in gridview, so that when I will click in hyperlink it will show the select path which is in gridview : if there is pdf file path and I just click on this hyper link then I can see the pdf fil... | To achieve this functionality where you have a hyperlink in a GridView that allows you to open a PDF file when clicked, you'll need to follow these steps:
1. **Set up your GridView in ASP.NET**: You will need to have a GridView that is bound to a data source that contains the file paths of your PDF files.
2. **Add a ... | 26,945 | [
{
"from": "human",
"value": "How can I use Hyperlink button in gridview. I mean when I run my program,all data is displayed in gridview,but I want hyperlink in gridview, so that when I will click in hyperlink it will show the select path which is in gridview : if there is pdf file path and I just click on t... |
I would like to create an application that runs on XBox 360 (downloaded using XBox Live) that will play the DVD movie in the tray. I know the XBox already has this ability, but I want my custom DVD player to allow users to save bookmarks for parts of the movie they really like and then browse their bookmarks later whe... | Creating a custom DVD player application for the Xbox 360 that allows users to save bookmarks for parts of a movie is a creative idea, but there are several significant challenges and limitations you should consider.
### 1. Is this possible?
**Short answer:** No, it is not possible.
The Xbox 360 does not allow third... | 32,706 | [
{
"from": "human",
"value": "I would like to create an application that runs on XBox 360 (downloaded using XBox Live) that will play the DVD movie in the tray. I know the XBox already has this ability, but I want my custom DVD player to allow users to save bookmarks for parts of the movie they really like ... |
I'm operating a neighbourhood WIFI network in a rural environment.
Now I'm looking fo a monitoring tool to run on a server (Windows or Linux) which would track bandwidth, uptime (clients as well as internet connection), etc...
Most of this information is exposed via SNMP by my routers and access points, so SNMP suppor... | Based on your requirements for a monitoring tool that supports SNMP, offers graphical data representation, has a free license, and runs on either Windows or Linux, here are some insights into the tools you mentioned:
1. **Cacti**:
- **Strengths**: Cacti is specifically designed for monitoring network bandwidth and... | 30,816 | [
{
"from": "human",
"value": "I'm operating a neighbourhood WIFI network in a rural environment.\nNow I'm looking fo a monitoring tool to run on a server (Windows or Linux) which would track bandwidth, uptime (clients as well as internet connection), etc... \nMost of this information is exposed via SNMP by m... |
I'm working with a client that needs to generate millions of the alphanumeric codes used in magazine scratch-off cards, bottlecap prizes, and so on. They have to be short enough to print on a cap, they want to make sure that ambiguous characters like 1 and I, 0 and O, etc. are not included, and they have to be explicit... | Generating alphanumeric codes for scratch-off cards and similar applications requires careful planning to ensure both uniqueness and usability. Here’s a structured approach to creating a code generation system that meets the specifications you provided:
### 1. Define the Character Set
First, determine the characters y... | 30,593 | [
{
"from": "human",
"value": "I'm working with a client that needs to generate millions of the alphanumeric codes used in magazine scratch-off cards, bottlecap prizes, and so on. They have to be short enough to print on a cap, they want to make sure that ambiguous characters like 1 and I, 0 and O, etc. are n... |
What is the best method for utilizing a single code base for multiple websites?
We have validation and session management libraries that we use on multiple websites. Is there a best practice for keeping a single copy rather than having to maintain updates of local copies for each website?
| Utilizing a single code base for multiple websites can be efficiently managed through various best practices. Here are several methods to achieve this, particularly for shared libraries like validation and session management:
### 1. **Microservices Architecture**
- **Separate Services**: Break your application into... | 32,384 | [
{
"from": "human",
"value": "What is the best method for utilizing a single code base for multiple websites? \nWe have validation and session management libraries that we use on multiple websites. Is there a best practice for keeping a single copy rather than having to maintain updates of local copies for e... |
I'm just getting started with C# and often find myself going back to other projects and reusing some snippet of code in a new project.
Is there a good tool out there with which on can store all the little pieces of code they reuse again and again AND integrates with Visual Studio Express??
| Yes, there are several tools and methods you can use to store and manage reusable code snippets in a way that integrates well with Visual Studio, including Visual Studio Express. Here are some options:
1. **Visual Studio Snippet Manager**: Visual Studio includes a built-in Snippet Manager that allows you to create and... | 33,602 | [
{
"from": "human",
"value": "I'm just getting started with C# and often find myself going back to other projects and reusing some snippet of code in a new project. \nIs there a good tool out there with which on can store all the little pieces of code they reuse again and again AND integrates with Visual Stu... |
I'm preparing a class on Visual Basic 2005 targeting Visual Basic 6 programmers migrating to the .NET platform.
I would like a word of advice about whether to recommend them to always enable Option Strict or not.
I've worked exclusively with C-style programming languages, mostly Java and C#, so for me explicit casting ... | Encouraging Visual Basic 6 (VB6) programmers who are migrating to the .NET platform to adopt `Option Strict On` is indeed a good practice, and here are some reasons why you should consider recommending it:
### 1. **Type Safety and Predictability**
Enabling `Option Strict` forces developers to explicitly declare and co... | 33,030 | [
{
"from": "human",
"value": "I'm preparing a class on Visual Basic 2005 targeting Visual Basic 6 programmers migrating to the .NET platform.\nI would like a word of advice about whether to recommend them to always enable Option Strict or not.\nI've worked exclusively with C-style programming languages, most... |
When I use DateTime.Now I get the date and time from the server point of view. Is there any way to get the client date and time in ASP.NET?
| In ASP.NET, when you use `DateTime.Now`, it retrieves the server's date and time. If you need to get the client's date and time, there are several approaches you can take, but it's important to remember that server-side code (like ASP.NET) does not have direct access to the client's system time. Here are some common me... | 32,914 | [
{
"from": "human",
"value": "When I use DateTime.Now I get the date and time from the server point of view. Is there any way to get the client date and time in ASP.NET?\n"
},
{
"from": "gpt",
"value": "In ASP.NET, when you use `DateTime.Now`, it retrieves the server's date and time. If you need ... |
Is there a control out in the world that allows a user to log in to a website with MS Passport (Windows Live ID, whatever), Facebook, OpenID, etc. all in one control?
Thanks, everyone!
| Yes, there are solutions that allow users to log in to a website using multiple authentication providers, such as Microsoft Passport (now known as Microsoft Account), Facebook, OpenID, and others. These solutions are commonly referred to as "social login" or "single sign-on" (SSO) systems.
Here are a few popular optio... | 34,280 | [
{
"from": "human",
"value": "Is there a control out in the world that allows a user to log in to a website with MS Passport (Windows Live ID, whatever), Facebook, OpenID, etc. all in one control?\nThanks, everyone!\n"
},
{
"from": "gpt",
"value": "Yes, there are solutions that allow users to log... |
I have a repository containing paths with non-ASCII characters (latin1)
I am having problems with authorization file containing those paths.
Do you know which encoding should be the AuthzSVNAccessFile?
Thank you.
| The `AuthzSVNAccessFile` in Apache Subversion (SVN) typically expects the authorization file to be encoded in UTF-8. This encoding is widely supported and can handle a variety of characters, including those from various languages and scripts.
If your repository paths contain non-ASCII characters (like those in Latin1)... | 34,086 | [
{
"from": "human",
"value": "I have a repository containing paths with non-ASCII characters (latin1)\nI am having problems with authorization file containing those paths. \nDo you know which encoding should be the AuthzSVNAccessFile?\nThank you.\n"
},
{
"from": "gpt",
"value": "The `AuthzSVNAcce... |
For a Silverlight 2 webapp. I added a combobox. I have an IEnumerable as Itemsource to populate the combobox. Works fine.
But I would like to add an extra item ("please select a....") to the combobox, anyone an idea how this can be done using the Silverlight 2 combobox.
Any more info about using a template for the Comb... | To add an extra item (like "please select a...") to a ComboBox in a Silverlight 2 application, you can do this by modifying your `IEnumerable` collection before setting it as the `ItemsSource` for the ComboBox. Here's how you can approach this:
1. **Modify Your IEnumerable**: You can create a new collection that inclu... | 32,224 | [
{
"from": "human",
"value": "For a Silverlight 2 webapp. I added a combobox. I have an IEnumerable as Itemsource to populate the combobox. Works fine.\nBut I would like to add an extra item (\"please select a....\") to the combobox, anyone an idea how this can be done using the Silverlight 2 combobox.\nAny ... |
I was trying to compile a program using an external compiled object coreset.o. I wrote the public01.c test file and my functions are in computation.c, both of which compiles. However its failing on linking it together. What might be the problem?
gcc -o public01.x public01.o computation.o coreset.o
ld: fatal: file co... | The error you're encountering indicates a mismatch in the architecture of the object files you're trying to link. The message `wrong ELF class: ELFCLASS64` suggests that `coreset.o` is a 64-bit object file, while the other object files (`public01.o` and `computation.o`) are likely 32-bit object files, or vice versa.
T... | 32,959 | [
{
"from": "human",
"value": "I was trying to compile a program using an external compiled object coreset.o. I wrote the public01.c test file and my functions are in computation.c, both of which compiles. However its failing on linking it together. What might be the problem?\ngcc -o public01.x public01.o ... |
I have a Perl module that I would like to use from Java. Is there a way to call this code using either ActiveState Perl on Windows or the generic Perl that comes with Linux? I have found references to JPL but it doesn’t appear to be maintained anymore.
| Yes, you can call Perl code from Java, even if JPL (Java Perl Language) is no longer actively maintained. There are a few different approaches you can take to achieve this. Here are some of the most common methods:
### 1. **Use the ProcessBuilder to Call Perl Scripts**
One straightforward approach is to use Java's `P... | 32,938 | [
{
"from": "human",
"value": "I have a Perl module that I would like to use from Java. Is there a way to call this code using either ActiveState Perl on Windows or the generic Perl that comes with Linux? I have found references to JPL but it doesn’t appear to be maintained anymore.\n"
},
{
"from": "g... |
What's the difference between the two?
| Could you please provide more context or specify what two things you're referring to? This will help me give you a more accurate and relevant comparison. | 36,679 | [
{
"from": "human",
"value": "What's the difference between the two?\n"
},
{
"from": "gpt",
"value": "Could you please provide more context or specify what two things you're referring to? This will help me give you a more accurate and relevant comparison."
}
] |
I want to autowire a bean partially - that is, I want some args to be autowired but other to be explicitly set. For example:
public MyClient(Service svc, boolean b)
In the case of this constructor, I would like to specify in my xml the value for b, but have svc autowired. Is that possible?
Thanks,
Lowell
| Yes, it's possible to partially autowire a bean in Spring. You can achieve this using a combination of constructor injection for the autowired dependency and property injection (or constructor argument) for the explicitly set value.
In your case, if you want `Service svc` to be autowired and `boolean b` to be specifie... | 33,471 | [
{
"from": "human",
"value": "I want to autowire a bean partially - that is, I want some args to be autowired but other to be explicitly set. For example:\npublic MyClient(Service svc, boolean b)\nIn the case of this constructor, I would like to specify in my xml the value for b, but have svc autowired. Is t... |
This question has been asked before (link) but I have slightly different requirements. First, I'm in Canada so that rules out Google Checkout and probably a few others. I just need a basic service that provides "Buy Now" functionality, no shopping carts or anything like that. The site isn't super high volume, so I'd li... | For your requirements in Canada, you have several options for a "Buy Now" payment service with discount code functionality and payment notification services. Here are a few recommendations:
1. **Stripe**: Stripe allows you to create one-time payment buttons and offers a robust API for integrating "Buy Now" functionali... | 33,900 | [
{
"from": "human",
"value": "This question has been asked before (link) but I have slightly different requirements. First, I'm in Canada so that rules out Google Checkout and probably a few others. I just need a basic service that provides \"Buy Now\" functionality, no shopping carts or anything like that. ... |
Is the index value of the first record in a dbf file 0 or 1? Is the index zero-based?
| In a DBF file (dBase file format), the index values for records are typically 1-based, meaning that the first record is accessed with an index of 1, not 0. This convention is common in many database systems that follow the original dBase design.
However, in programming languages or environments that manipulate DBF fil... | 35,965 | [
{
"from": "human",
"value": "Is the index value of the first record in a dbf file 0 or 1? Is the index zero-based?\n"
},
{
"from": "gpt",
"value": "In a DBF file (dBase file format), the index values for records are typically 1-based, meaning that the first record is accessed with an index of 1... |
Is there a repository for JQuery UI themes?
| Yes, there is a repository for jQuery UI themes called the **jQuery UI ThemeRoller**. The ThemeRoller allows you to create, customize, and download jQuery UI themes. You can find it on the official jQuery UI website:
- **ThemeRoller**: [jQuery UI ThemeRoller](https://jqueryui.com/themeroller/)
Additionally, there are... | 35,586 | [
{
"from": "human",
"value": "Is there a repository for JQuery UI themes?\n"
},
{
"from": "gpt",
"value": "Yes, there is a repository for jQuery UI themes called the **jQuery UI ThemeRoller**. The ThemeRoller allows you to create, customize, and download jQuery UI themes. You can find it on the o... |
Is there a way to dynamically invoke a method in the same class for PHP? I don't have the syntax right, but I'm looking to do something similar to this:
$this->{$methodName}($arg1, $arg2, $arg3);
| Yes, in PHP, you can dynamically invoke a method of the same class using variable variables or braces. The syntax you provided is indeed the correct way to do it.
Here's an example to illustrate how you can dynamically call a method within the same class using a variable that holds the method name:
```php
class MyCl... | 32,757 | [
{
"from": "human",
"value": "Is there a way to dynamically invoke a method in the same class for PHP? I don't have the syntax right, but I'm looking to do something similar to this:\n$this->{$methodName}($arg1, $arg2, $arg3);\n\n"
},
{
"from": "gpt",
"value": "Yes, in PHP, you can dynamically in... |
I have an application which get copied and run on client machines. The program is in the form of an Adobe Projector file. I want to write a process that checks when the program starts running whether or not the license is still active, and if not, delete the entire program.
The program itself knows the real date that ... | Implementing a licensing check for a software application is a common requirement, but it's important to keep in mind that software licensing can be quite complex, especially if you're trying to prevent users from circumventing the license checks. Below are some suggestions to implement the licensing check as well as s... | 28,800 | [
{
"from": "human",
"value": "I have an application which get copied and run on client machines. The program is in the form of an Adobe Projector file. I want to write a process that checks when the program starts running whether or not the license is still active, and if not, delete the entire program. \nTh... |
My lack of C++ experience, or rather my early learning in garbage collected languages is really stinging me at the moment and I have a problem working with strings in C++.
To make it very clear, using std::string or equlivents is not an option - this is char* 's all the way.
So: what I need to do is very simple and bas... | In C++, when you work with raw pointers (like `char*`), memory management becomes crucial. Since you're constrained to using `char*` and not `std::string`, you need to manage the memory yourself to avoid memory leaks.
From your description, it sounds like you want to dynamically create a concatenated filename that nee... | 30,284 | [
{
"from": "human",
"value": "My lack of C++ experience, or rather my early learning in garbage collected languages is really stinging me at the moment and I have a problem working with strings in C++.\nTo make it very clear, using std::string or equlivents is not an option - this is char* 's all the way.\nS... |
What is the equivalent of /dev/null on Windows?
| On Windows, the equivalent of `/dev/null` is `NUL`. It is used to discard output streams or to serve as a source of empty input. For example, if you want to redirect output to nowhere in a command prompt, you can use:
```cmd
command > NUL
```
This will effectively ignore any output from the command you run. | 35,958 | [
{
"from": "human",
"value": "What is the equivalent of /dev/null on Windows?\n"
},
{
"from": "gpt",
"value": "On Windows, the equivalent of `/dev/null` is `NUL`. It is used to discard output streams or to serve as a source of empty input. For example, if you want to redirect output to nowhere in... |
I have a gridview like below:
<asp:GridView DataKeyNames="TransactionID"
AllowSorting="True" AllowPaging="True"ID="grvBrokerage"
runat="server" AutoGenerateColumns="False"
CssClass="datatable" Width="100%"
<Columns>
<asp:BoundField DataFie... | The issue you're facing where `grvBrokerage.DataSource` is `null` during the sorting event is due to the way the data is being bound to the GridView. When you bind the GridView to an `ObjectDataSource`, it does not store the data in `grvBrokerage.DataSource` directly. Instead, it pulls the data from the `ObjectDataSour... | 31,003 | [
{
"from": "human",
"value": "I have a gridview like below:\n <asp:GridView DataKeyNames=\"TransactionID\" \n AllowSorting=\"True\" AllowPaging=\"True\"ID=\"grvBrokerage\" \n runat=\"server\" AutoGenerateColumns=\"False\" \n CssClass=\"datatable\" Width=\"100%\"\n ... |
If I were writing my own HTML and placing the values in the table I would use css and style the borders using something like:
td{
border-left : solid gray 1px;
}
| That’s correct! Using CSS to style table borders allows you to customize the appearance of your HTML tables easily. Here's how you can apply styles to the `<table>` and its cells using CSS, including your example for `td`:
### Example HTML and CSS
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF... | 33,428 | [
{
"from": "human",
"value": "If I were writing my own HTML and placing the values in the table I would use css and style the borders using something like:\ntd{\n border-left : solid gray 1px;\n}\n\n"
},
{
"from": "gpt",
"value": "That’s correct! Using CSS to style table borders allows you to... |
We have a couple of applications running on Java 5 and would like now to bring in an application based on Java 6. Can both java versions live together under Windows?
Is there any control panel to set the appropriate Java version for different applications, or any other way to set up, what version of Java will be used ... | Yes, you can have both Java 5 and Java 6 installed on the same Windows machine, and they can coexist without any issues. However, managing which version of Java is used to run specific applications requires some manual configuration since there is no built-in control panel to switch Java versions for individual applica... | 33,209 | [
{
"from": "human",
"value": "We have a couple of applications running on Java 5 and would like now to bring in an application based on Java 6. Can both java versions live together under Windows? \nIs there any control panel to set the appropriate Java version for different applications, or any other way to ... |
I am looking for an elegant solution for removing content from an ASP.Net page if no data has been set. Let me explain this a little more.
I have some blocks of data on a page that contain some sub-sections with individual values in them. If no data has been set for one of the values I need to hide it (so it does not t... | To implement the functionality you're describing, you can create a recursive method that checks for visibility based on the content of each Panel (or DIV) and its child Panels. You can use a custom attribute to signify which Panels should be evaluated for visibility. This way, you avoid deeply nested if-else statements... | 28,931 | [
{
"from": "human",
"value": "I am looking for an elegant solution for removing content from an ASP.Net page if no data has been set. Let me explain this a little more.\nI have some blocks of data on a page that contain some sub-sections with individual values in them. If no data has been set for one of the ... |
I am admin on a forum.
Earlier we had phpbb 2.0 and i made a bot that could write to the forum.
Now, we have upgraded the forum to phpbb 3.0, but i can't get my bot to write to the forum anymore.
I have looked for a solution, but now i am out of ideas.
So it would have been great if anyone have a suggestion.
i have bt... | Upgrading from phpBB 2.x to 3.x involves changes to both the database schema and the way the forum handles sessions and posts, which can affect how your bot interacts with the forum. Here's a general guide on how to adapt your bot to work with phpBB 3.x:
### Step 1: Understand Authentication
In phpBB 3.x, the authenti... | 29,569 | [
{
"from": "human",
"value": "I am admin on a forum.\nEarlier we had phpbb 2.0 and i made a bot that could write to the forum.\nNow, we have upgraded the forum to phpbb 3.0, but i can't get my bot to write to the forum anymore.\nI have looked for a solution, but now i am out of ideas. \nSo it would have been... |
HI All,
I have a piece of javaScript that removes commas from a provided string (in my case currency values)
It is:
function replaceCommaInCurrency(myField, val)
{
var re = /,/g;
document.net1003Form.myField.value=val.replace(re, '');
}
'MyField' was my attempt to dynamically have this wor... | The issue you are encountering is related to the way you are attempting to access the form field within the `replaceCommaInCurrency` function. The variable `myField` is a string that represents the name of the field, but in your code, you're trying to access it as a property of `document.net1003Form`, which is not vali... | 35,594 | [
{
"from": "human",
"value": "HI All,\nI have a piece of javaScript that removes commas from a provided string (in my case currency values)\nIt is:\n function replaceCommaInCurrency(myField, val)\n {\n var re = /,/g;\n\n document.net1003Form.myField.value=val.replace(re, '');\n }\n\n'M... |
I know that it's possible to get SVN to send emails after a commit using hooks, but I was just wondering if there's any way to create a personal "watch list" like MediaWiki (Wikipedia) has, whereby you only get notified if there have been changes to certain files?
| Yes, you can create a personal "watch list" for specific files in an SVN repository using hooks and custom scripts, although it requires some manual setup since SVN does not provide this feature out of the box like MediaWiki does. Here's a general approach you can take to achieve this:
### Step 1: Set Up a Post-Commit... | 31,224 | [
{
"from": "human",
"value": "I know that it's possible to get SVN to send emails after a commit using hooks, but I was just wondering if there's any way to create a personal \"watch list\" like MediaWiki (Wikipedia) has, whereby you only get notified if there have been changes to certain files?\n"
},
{
... |
Our web application sends e-mails. We have lots of users, and we get lots of bounces. For example, user changes company and his company e-mail is no longer valid.
To find bounces, I parse SMTP log file with log parser. The logs come from Microsoft SMTP server.
Some bounces are great, like 550+#5.1.0+Address+rejected+us... | While there are indeed larger solutions like Zabbix and Splunk that can handle log analysis for various applications, you're correct that they may be overkill for your specific need. Fortunately, there are some simpler tools and approaches that you can consider for parsing SMTP logs and identifying bounces. Here are a ... | 33,506 | [
{
"from": "human",
"value": "Our web application sends e-mails. We have lots of users, and we get lots of bounces. For example, user changes company and his company e-mail is no longer valid.\nTo find bounces, I parse SMTP log file with log parser. The logs come from Microsoft SMTP server.\nSome bounces are... |
This error message appears on a colleague's machine when he tries to launch a Windows application he's working on:
An unhandled non-continuable exception was thrown during process load
What does this mean, and how does one go about investigating what is causing it?
I have Googled it, but haven't found a clear answer.... | The error message "An unhandled non-continuable exception was thrown during process load" indicates that a critical error occurred when the application was attempting to load, and this error was not caught or handled appropriately within the application. This kind of exception usually prevents the application from star... | 32,309 | [
{
"from": "human",
"value": "This error message appears on a colleague's machine when he tries to launch a Windows application he's working on:\n\nAn unhandled non-continuable exception was thrown during process load\n\nWhat does this mean, and how does one go about investigating what is causing it?\nI have... |
I want to write a WCF service that can't run more than X times per hour. I want the service to suspended messages to a queue if the service was called more than x time in the last 60 minutes.
Any ideas how can one limit the service?
I am willing to write custom components in the WCF stack.
| To implement rate limiting in a WCF service, where the service can’t be invoked more than a specified number of times (X) within an hour, you can follow these general steps:
1. **Use a Concurrent Dictionary or a Cache**: Maintain a counter and a timestamp for tracking the number of calls made in the last hour. A concu... | 24,287 | [
{
"from": "human",
"value": "I want to write a WCF service that can't run more than X times per hour. I want the service to suspended messages to a queue if the service was called more than x time in the last 60 minutes.\nAny ideas how can one limit the service?\nI am willing to write custom components in ... |
How do I get the KeyDown event to work in a Delphi (2007) MDI Applications Parent window, even if a Child window has focus?
I would like to implement a shortcut key (F1) that brings up a help screen in a MDI application, I have added the KeyDown procedure to the MDI Parent window and enabled KeyPreview in both the Par... | To ensure that the MDI parent window in Delphi (2007) receives key events, even when a child window is focused, you can use the `OnMessage` event to intercept the key messages before they reach the child windows. This way, you can handle the key events in the parent window without needing to duplicate the code across m... | 33,947 | [
{
"from": "human",
"value": "How do I get the KeyDown event to work in a Delphi (2007) MDI Applications Parent window, even if a Child window has focus?\nI would like to implement a shortcut key (F1) that brings up a help screen in a MDI application, I have added the KeyDown procedure to the MDI Parent win... |
I am using an XmlDocument to parse and manipulate an XHTML string, converting some nodes to non-HTML nodes.
What is the best way to get a list of all nodes with a given class name? Can it be done with XPath?
| Yes, you can use XPath to select nodes with a specific class name in an `XmlDocument`. If you're working with XHTML, which is essentially a stricter version of HTML that conforms to XML standards, you can easily query nodes based on their attributes, including the class attribute.
Here's an example of how you might ac... | 33,423 | [
{
"from": "human",
"value": "I am using an XmlDocument to parse and manipulate an XHTML string, converting some nodes to non-HTML nodes.\nWhat is the best way to get a list of all nodes with a given class name? Can it be done with XPath?\n"
},
{
"from": "gpt",
"value": "Yes, you can use XPath to... |
I want to write a small program that should print something like
testing CPU... done
testing RAM... done
and so on.
I wrote the following program in C:
printf( "testing RAM...\t\t" );
sleep( sleep_time );
printf( "done\n\n" );
printf( "testing HDD...\t\t" );
sleep( sleep_time );
printf( "done\n\n" );
where ... | The behavior you're observing is due to output buffering in C. When you use `printf`, the output may not appear immediately on the screen because it's buffered. By default, the standard output (stdout) is line-buffered when connected to a terminal, which means that it waits until a newline is printed before flushing th... | 33,464 | [
{
"from": "human",
"value": "I want to write a small program that should print something like\n\ntesting CPU... done\n testing RAM... done\n\nand so on.\nI wrote the following program in C:\nprintf( \"testing RAM...\\t\\t\" );\nsleep( sleep_time );\nprintf( \"done\\n\\n\" );\n\nprintf( \"testing HDD.... |
My application links against libsamplerate.a. I am doing this to make distributing the final binary easier.
I am worried that perhaps the code inside the .a file depends on some other libraries I also will need to distribute.
But if it doesn't I am worried I am bloating up my application too much by including multiple ... | The `.a` file you're referring to, `libsamplerate.a`, is a static library. When you link your application against a static library like this, the compiler includes only the necessary object code from the library into your final executable. Here are some key points to understand regarding static libraries and your conce... | 30,796 | [
{
"from": "human",
"value": "My application links against libsamplerate.a. I am doing this to make distributing the final binary easier.\nI am worried that perhaps the code inside the .a file depends on some other libraries I also will need to distribute.\nBut if it doesn't I am worried I am bloating up my ... |
The situation is this. I have an asp.net webservice application...say a page called api.asmx
In the code behind I have several methods, for example:
[WebMethod(Description="Method1")]
public int GetSomething(int num1, int num2){
try{
return SomeObject.DatabaseCall.DoSomething(num1, num2);
}
catch(Exception e... | Your question is not at all stupid, and you're on the right track in looking for a more elegant solution to logging errors in your ASP.NET web service methods.
### Using Reflection for Logging
One approach to streamline your error logging is to use reflection to obtain the method name and parameters dynamically. Thi... | 31,343 | [
{
"from": "human",
"value": "The situation is this. I have an asp.net webservice application...say a page called api.asmx\nIn the code behind I have several methods, for example:\n[WebMethod(Description=\"Method1\")]\npublic int GetSomething(int num1, int num2){\n try{\n return SomeObject.DatabaseCall.... |
Alright. I have a query that looks like this:
SELECT
SUM(`order_items`.`quantity`) as `count`,
`menu_items`.`name`
FROM
`orders`,
`menu_items`,
`order_items`
WHERE
`orders`.`id` = `order_items`.`order_id` AND
`menu_items`.`id` = `order_items`.`menu_item_id` AND
`orders`.`date` >= '2... | To achieve your goal of showing a count of 0 for menu items that have no sales in a given date range, you can use a LEFT JOIN instead of the implicit join you are currently using. This way, you will retain all `menu_items`, even if there are no corresponding records in `order_items` or `orders`.
Here's how you can re... | 34,617 | [
{
"from": "human",
"value": "Alright. I have a query that looks like this:\nSELECT\n SUM(`order_items`.`quantity`) as `count`,\n `menu_items`.`name`\nFROM \n `orders`,\n `menu_items`,\n `order_items` \nWHERE \n `orders`.`id` = `order_items`.`order_id` AND \n `menu_items`.`id` = `order_i... |
I have a function that automatically exports a table into a CSV file, then I try to attach that same file into a function that will email it. I have sent attachments using html mime mail before, but I was wondering if that created CSV file needs to be stored on the server first before attaching it to the email?
| Yes, in most cases, if you want to attach a CSV file (or any file) to an email, that file needs to exist on the server where your script is running. Here’s a general outline of how this process works:
1. **Export the Table to CSV**: You generate the CSV file and save it on the server's file system.
2. **Prepare to Se... | 30,374 | [
{
"from": "human",
"value": "I have a function that automatically exports a table into a CSV file, then I try to attach that same file into a function that will email it. I have sent attachments using html mime mail before, but I was wondering if that created CSV file needs to be stored on the server first ... |
After logging in using the Login control the browser loses the session. This only occurs in Internet Explorer 7. Has anyone else run into this problem? If so, do you know a work around?
| Yes, losing session information after logging in can be a common issue in Internet Explorer 7 due to its handling of cookies and sessions. Here are some potential causes and workarounds to consider:
### Potential Causes
1. **Cookie Settings**: IE7 has stricter cookie policies compared to modern browsers. If cookies ar... | 32,740 | [
{
"from": "human",
"value": "After logging in using the Login control the browser loses the session. This only occurs in Internet Explorer 7. Has anyone else run into this problem? If so, do you know a work around?\n"
},
{
"from": "gpt",
"value": "Yes, losing session information after logging... |
How do I check for an open connection in jdbc for oracle database?
Note: conn.isClosed() cannot be used for this.
| In JDBC, while the `conn.isClosed()` method is commonly used to check if a connection is closed, there are situations where you might want to check if a connection is "open" or "valid" without using this method.
If you can't use `conn.isClosed()`, a typical approach is to utilize the `Connection.isValid(int timeout)` ... | 32,892 | [
{
"from": "human",
"value": "How do I check for an open connection in jdbc for oracle database?\nNote: conn.isClosed() cannot be used for this.\n"
},
{
"from": "gpt",
"value": "In JDBC, while the `conn.isClosed()` method is commonly used to check if a connection is closed, there are situations w... |
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?
What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
| A **Null Pointer Exception (NPE)** in Java, represented by `java.lang.NullPointerException`, is a runtime exception that occurs when the Java Virtual Machine (JVM) attempts to dereference a null reference. This means that the program is trying to access an object or call a method on a reference that hasn't been initial... | 24,710 | [
{
"from": "human",
"value": "What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?\nWhat methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?\n"
},
{
"from": "gpt",
"value": "A **Null ... |
I have tested all my systems developed in Delphi (in Windows XP) on Wine (OpenSuse Linux) and they work perfectly. My question is: should I start distributing my systems (on a local basis that I can support) as Wine ready or are there other issues I should take into account?
| Distributing your Delphi applications as Wine-ready software on a local basis can be a viable option, especially since you've tested them and they work well. However, there are several factors you should consider before proceeding:
1. **User Base Familiarity**: Ensure that your target audience is comfortable with usin... | 31,405 | [
{
"from": "human",
"value": "I have tested all my systems developed in Delphi (in Windows XP) on Wine (OpenSuse Linux) and they work perfectly. My question is: should I start distributing my systems (on a local basis that I can support) as Wine ready or are there other issues I should take into account?\n"
... |
I have a windows setup project that installs a service. All works well except for one thing: The default directory offered to the user during install is of the form "C:\Program Files\Microsoft\ProgramName". I am trying to modify this so that instead of "Microsoft" we would have our company's name.
I found the applicati... | To set the Manufacturer property in a Visual Studio setup project (Windows Installer project), you can follow these steps:
1. **Select the Setup Project**:
- In Solution Explorer, locate your setup project. Right-click on it and select "Properties."
2. **Modify the Properties**:
- In the Properties window, look... | 32,311 | [
{
"from": "human",
"value": "I have a windows setup project that installs a service. All works well except for one thing: The default directory offered to the user during install is of the form \"C:\\Program Files\\Microsoft\\ProgramName\". I am trying to modify this so that instead of \"Microsoft\" we woul... |
I'm trying filter the child collection of an aggregate root when loading it with Nhibernate. Load a Customer with all their Orders that have been shipped. Is this possible?
| Yes, it is possible to filter a child collection while loading an aggregate root with NHibernate. When you want to load a `Customer` with only the `Orders` that have been shipped, you can use a combination of HQL (Hibernate Query Language), Criteria API, or LINQ queries (if using NHibernate's LINQ provider) to achieve ... | 30,824 | [
{
"from": "human",
"value": "I'm trying filter the child collection of an aggregate root when loading it with Nhibernate. Load a Customer with all their Orders that have been shipped. Is this possible?\n"
},
{
"from": "gpt",
"value": "Yes, it is possible to filter a child collection while load... |
How can I create unicode console application with Delphi 2009?
If I do like this:
{$APPTYPE CONSOLE}
uses
SysUtils;
begin
writeln('öüğşç سيمانتت');
end.
I get the following:
ougsc ???????
| Creating a Unicode console application in Delphi 2009 requires you to ensure that the console output properly supports Unicode characters. The default console in Windows might not support Unicode properly unless configured. Here's how you can set it up:
1. **Set Console Code Page**: The console should be set to a code... | 33,660 | [
{
"from": "human",
"value": "How can I create unicode console application with Delphi 2009?\nIf I do like this:\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\nbegin\n writeln('öüğşç سيمانتت');\nend.\n\nI get the following:\nougsc ???????\n\n"
},
{
"from": "gpt",
"value": "Creating a Unicode console ap... |
I have signed numbers (2s complement) stored in 32-bit integers, and I want to extract 16-bit fields from them. Is it true that if I extract the low 16 bits from a 32-bit signed number, the result will be correct as long as the original (32-bit) number fits into 16 bits ?
For positive numbers it is trivially true, and ... | Yes, your assertion is correct. When you extract the low 16 bits from a 32-bit signed integer in 2's complement representation, the result will indeed be correct as long as the original 32-bit number fits into 16 bits. Let's analyze why this is the case.
### Understanding 2's Complement Representation
In 2's compleme... | 30,636 | [
{
"from": "human",
"value": "I have signed numbers (2s complement) stored in 32-bit integers, and I want to extract 16-bit fields from them. Is it true that if I extract the low 16 bits from a 32-bit signed number, the result will be correct as long as the original (32-bit) number fits into 16 bits ?\nFor p... |
I am implementing a tree tag for one of my practice projects, where I would display the contents of a directory in the form of a tree (recursively). I had implemented a similar requirement as a Custom Tag in Java during the pre-JSP2.0 days.
Handling a directory needs recursion (to handle the subdirectories)! Is it poss... | Yes, you can implement a tree tag for displaying the contents of a directory in the form of a tree using JSP tag files. Since JSP 2.0, tag files allow you to create reusable components that can encapsulate Java code and JSP elements. However, handling recursion within tag files can be a bit tricky since tag files are n... | 32,632 | [
{
"from": "human",
"value": "I am implementing a tree tag for one of my practice projects, where I would display the contents of a directory in the form of a tree (recursively). I had implemented a similar requirement as a Custom Tag in Java during the pre-JSP2.0 days.\nHandling a directory needs recursion ... |
I noticed in my custom application log that I had 600 requests to Global.asax within a few minutes, while no other users were using the application. They all came from an IP address of a known application user, so I don't think it's an attack of any kind. I generate log entires in a custom SQL Server database at the en... | It's interesting that you're observing a high volume of requests to `Global.asax` from a known user without corresponding entries in your IIS logs. Here are some potential reasons and considerations for the behavior you're seeing:
1. **Client-Side Script**: The user may have been using a script (such as JavaScript) th... | 29,734 | [
{
"from": "human",
"value": "I noticed in my custom application log that I had 600 requests to Global.asax within a few minutes, while no other users were using the application. They all came from an IP address of a known application user, so I don't think it's an attack of any kind. I generate log entires ... |
With SQL Server 2005 using SSMS, when I run this:
SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\TestIDs.xls', 'SELECT * FROM [Sheet1$]')
And get this:
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered.
Is it referring to the server or my local machine?
| The error message you are encountering, "The OLE DB provider 'Microsoft.Jet.OLEDB.4.0' has not been registered," typically indicates an issue with the OLE DB provider not being available on the machine where SQL Server is running.
In the context of your SQL statement, it is the SQL Server instance that is having troub... | 30,123 | [
{
"from": "human",
"value": "With SQL Server 2005 using SSMS, when I run this:\nSELECT * \nFROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\\TestIDs.xls', 'SELECT * FROM [Sheet1$]')\nAnd get this:\nThe OLE DB provider \"Microsoft.Jet.OLEDB.4.0\" has not been registered.\nIs it referring to t... |
I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially "inline", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in produc... | To use your SQLite database in a production-like manner, you'll want to set up a mechanism that checks for the database's existence before attempting to connect to it or create any tables. The typical pattern is to try to connect to the database and catch any exceptions related to its non-existence or related operation... | 31,691 | [
{
"from": "human",
"value": "I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially \"inline\", i.e. they walk through using SQLite in a linear fashion r... |
This may be a doozy, but does anyone have an idea how to:
Pass the users windows token (authenticated from domain) to the wcf service that is called - the service would then perform an action based on the users windows credentials that made the call.
ie: Client -> WCF -> SOME 3rd PARTY REPOSITORY THAT INTEGRATES WITH A... | You're on the right track in trying to set up a WCF service to authenticate using Windows credentials and pass the user's token to a third-party repository. It looks like you've set up the binding and endpoint address correctly. However, the error you are encountering—"The identity check failed for outgoing message"—is... | 28,749 | [
{
"from": "human",
"value": "This may be a doozy, but does anyone have an idea how to:\nPass the users windows token (authenticated from domain) to the wcf service that is called - the service would then perform an action based on the users windows credentials that made the call.\nie: Client -> WCF -> SOME ... |
Much related to this question, we have a scenario on my team where we need to copy the contents of a folder for a suite of libraries and configuration files for said libraries to our folder where our test code is running from, as part of the test's deployment step.
Due to the installation size, and other factors, check... | You can accomplish your goal of making the deployment of the shared library suite seamless for all team members without checking the suite into source control. Here are several strategies that you can use, tailored to fit within your specified constraints:
### 1. Use a Post-Build Event in Your Project
You can set up a... | 30,237 | [
{
"from": "human",
"value": "Much related to this question, we have a scenario on my team where we need to copy the contents of a folder for a suite of libraries and configuration files for said libraries to our folder where our test code is running from, as part of the test's deployment step.\nDue to the i... |
How do I apply 'use base' in Perl to inherit subs from some base module?
I'm used to C++ inheritance mechanics, and all the sites I googled for this caused more confusion then help. I want to do something like the following:
#! /usr/bin/perl
#The base class to inherit from
use strict;
use warnings;
package 'TestBase';... | In Perl, to inherit methods from a base class using the `use base` pragma, you need to follow a specific structure. The error you're encountering is likely due to how you're calling the method `tbSub` from the subclass without properly referencing the inheritance.
Here’s a correct example of how to set up the base cla... | 30,942 | [
{
"from": "human",
"value": "How do I apply 'use base' in Perl to inherit subs from some base module?\nI'm used to C++ inheritance mechanics, and all the sites I googled for this caused more confusion then help. I want to do something like the following:\n#! /usr/bin/perl\n#The base class to inherit from\nu... |
I know that there has been a couple questions about tutorials on rhino-mocks. But I am wondering if there are any sample apps out there that use rhino-mocks in the context of an n-tier business application using ado.net.
I find the tutes good, but they don't seem to bring everything all together into the big picture. ... | Hi Anthony,
Finding comprehensive examples that integrate Rhino Mocks within an n-tier architecture, especially when focusing on the data access layer (DAL) and ADO.NET, can indeed be challenging. However, I can guide you on how to structure your application and provide some direction on where to look for example proj... | 29,884 | [
{
"from": "human",
"value": "I know that there has been a couple questions about tutorials on rhino-mocks. But I am wondering if there are any sample apps out there that use rhino-mocks in the context of an n-tier business application using ado.net. \nI find the tutes good, but they don't seem to bring ever... |
I have a product idea that requires integration into the Microsoft Office suite.
Are there any licensing/limitation issues to be aware of for me to proceed?
| Integrating a product with the Microsoft Office suite involves several considerations regarding licensing and potential limitations. Here are some key points to keep in mind:
1. **Microsoft Office APIs and SDKs**: Microsoft provides various APIs and Software Development Kits (SDKs) for Office integration, such as the ... | 26,446 | [
{
"from": "human",
"value": "I have a product idea that requires integration into the Microsoft Office suite.\nAre there any licensing/limitation issues to be aware of for me to proceed?\n"
},
{
"from": "gpt",
"value": "Integrating a product with the Microsoft Office suite involves several consi... |
I'm building a mobile application in VB.NET (compact framework), and I'm wondering what the best way to approach the potential offline interactions on the device. Basically, the devices have cellular and 802.11, but may still be offline (where there's poor reception, etc). A driver will scan boxes as they leave his tru... | Designing mobile applications that need to operate reliably under varying connectivity conditions is a common challenge. Here are some approaches and strategies that have been effectively utilized by developers facing similar situations.
### Strategies for Handling Offline Functionality
1. **Local Data Caching:**
... | 29,990 | [
{
"from": "human",
"value": "I'm building a mobile application in VB.NET (compact framework), and I'm wondering what the best way to approach the potential offline interactions on the device. Basically, the devices have cellular and 802.11, but may still be offline (where there's poor reception, etc). A dri... |
I'm painfully new to PHP, and was trying to set up phpBB on my local site. I have a stock debian install of apache2 and php5. The phpBB installer ran fine, connected to the database and created all its tables with no problem. But when I tried to open the login page, I got a 0-byte response.
A little digging showed t... | It sounds like you resolved your issue with the PHP `mysql_pconnect()` function and successfully connected to your MySQL database. This is great news! Let's summarize the important steps you took, along with some best practices that will help you in the future:
### Steps Taken to Resolve the Issue:
1. **Error Suppres... | 30,269 | [
{
"from": "human",
"value": "I'm painfully new to PHP, and was trying to set up phpBB on my local site. I have a stock debian install of apache2 and php5. The phpBB installer ran fine, connected to the database and created all its tables with no problem. But when I tried to open the login page, I got a 0... |
Is it possible to scale a UIView down to 0 (width and height is 0) using CGAffineTransformMakeScale?
view.transform = CGAffineTransformMakeScale(0.0f, 0.0f);
Why would this throw an error of "<Error>: CGAffineTransformInvert: singular matrix." ?
Update:
There is another way of scaling down a UIView to 0
[UIView begin... | Scaling a `UIView` down to a size of (0, 0) using `CGAffineTransformMakeScale(0.0f, 0.0f)` is technically possible, but it can lead to issues when you try to perform certain operations afterward, particularly any transformations that require an inverse matrix.
The error `<Error>: CGAffineTransformInvert: singular mat... | 33,105 | [
{
"from": "human",
"value": "Is it possible to scale a UIView down to 0 (width and height is 0) using CGAffineTransformMakeScale?\nview.transform = CGAffineTransformMakeScale(0.0f, 0.0f);\nWhy would this throw an error of \"<Error>: CGAffineTransformInvert: singular matrix.\" ?\n\n\nUpdate:\nThere is anothe... |
What is the right way to perform some static finallization?
There is no static destructor. The AppDomain.DomainUnload event is not raised in the default domain. The AppDomain.ProcessExit event shares the total time of the three seconds (default settings) between all event handlers, so it's not really usable.
| Static finalization in .NET can be a bit tricky because there isn't a straightforward way to clean up static resources when an application exits, as you noted. However, there are a few strategies you can employ to ensure that your static resources are properly released or finalized:
### 1. Use `AppDomain.ProcessExit` ... | 32,448 | [
{
"from": "human",
"value": "What is the right way to perform some static finallization? \nThere is no static destructor. The AppDomain.DomainUnload event is not raised in the default domain. The AppDomain.ProcessExit event shares the total time of the three seconds (default settings) between all event hand... |
I have designed my site with a 900 x 600 fixed background image. On the computer it looks fine. How will it look on a PDA device? Will I have to design it separately for PDA?
How should check whether my site can be browsed effectively from mobile phone?
What should I do?
| When designing a website with a fixed background image sized at 900 x 600 pixels, it's important to consider how it will render on smaller devices like PDAs or smartphones. Here's how your site might perform on those devices and what you can do to ensure it's accessible:
### How It Might Look on PDA Devices
1. **Resol... | 32,130 | [
{
"from": "human",
"value": "I have designed my site with a 900 x 600 fixed background image. On the computer it looks fine. How will it look on a PDA device? Will I have to design it separately for PDA?\nHow should check whether my site can be browsed effectively from mobile phone?\nWhat should I do?\n"
... |
Ok, I am reading in dat files into a byte array. For some reason, the people who generate these files put about a half meg's worth of useless null bytes at the end of the file. Anybody know a quick way to trim these off the end?
First thought was to start at the end of the array and iterate backwards until I found so... | To efficiently trim the trailing null bytes from a byte array, you can indeed use a backward iteration approach, but you can also implement it more succinctly by using built-in functions in modern programming languages. Below are different approaches depending on the programming language you're using. I'll provide a ge... | 27,546 | [
{
"from": "human",
"value": "Ok, I am reading in dat files into a byte array. For some reason, the people who generate these files put about a half meg's worth of useless null bytes at the end of the file. Anybody know a quick way to trim these off the end?\nFirst thought was to start at the end of the ar... |
Is there a substitute in emacs for the vi gf command?
I mean to open the file which is under the cursor right now, if a real file name is in fact there.
| Yes, in Emacs, you can achieve similar functionality to the `gf` command in `vi`, which opens the file under the cursor, by using the following methods:
1. **Using `find-file-at-point` command:**
- Place your cursor over the file name (or path) you want to open.
- Then, execute the command by typing `M-x find-fi... | 35,406 | [
{
"from": "human",
"value": "Is there a substitute in emacs for the vi gf command?\nI mean to open the file which is under the cursor right now, if a real file name is in fact there.\n"
},
{
"from": "gpt",
"value": "Yes, in Emacs, you can achieve similar functionality to the `gf` command in `vi`... |
I have an app that is built using .Net remoting. When authenticating, If there is an error, I threw an exception on the server. The exception is serializable. But when the exception is thrown on the server, Sometimes I see an error on the client side that says "An established connection was aborted by the software in y... | The error "An established connection was aborted by the software in your host machine" suggests that the connection between your client and server is being interrupted due to an issue on the server side, often related to how exceptions are handled in .NET Remoting.
Here are some potential reasons and solutions for the... | 25,079 | [
{
"from": "human",
"value": "I have an app that is built using .Net remoting. When authenticating, If there is an error, I threw an exception on the server. The exception is serializable. But when the exception is thrown on the server, Sometimes I see an error on the client side that says \"An established c... |
Got a Cocoa video capture app that works fine in 10.4. It uses NSThread to start the video capture driver. When app just started, video capture is very slow ( 1-2 fps). But after resize the UI window (or bring the window from background to foreground), video capture speed is back to normal. This only happens in 10.5.
| The behavior you're observing where video capture starts off slowly and then resumes normal speed after some UI interaction (like resizing the window or bringing it to the foreground) is a common issue that can arise due to a few different factors in macOS 10.5 (Leopard) compared to 10.4 (Tiger).
Here are some suggest... | 31,030 | [
{
"from": "human",
"value": "Got a Cocoa video capture app that works fine in 10.4. It uses NSThread to start the video capture driver. When app just started, video capture is very slow ( 1-2 fps). But after resize the UI window (or bring the window from background to foreground), video capture speed is bac... |
Given a class instance, is it possible to determine if it implements a particular interface? As far as I know, there isn't a built-in function to do this directly. What options do I have (if any)?
| Yes, you can determine if a class instance implements a particular interface in Python using several methods, despite there being no single built-in function specifically designed for this purpose. Below are some common approaches:
1. **Using `isinstance()`**:
If the interface you are checking against is defined as... | 31,011 | [
{
"from": "human",
"value": "Given a class instance, is it possible to determine if it implements a particular interface? As far as I know, there isn't a built-in function to do this directly. What options do I have (if any)?\n"
},
{
"from": "gpt",
"value": "Yes, you can determine if a class ins... |
I would like to print only the contents of a textarea element from a website page. In particular, I would like to ensure that nothing gets clipped by the boundary of the textarea as the contents will be quite large.
What is the best strategy for tackling this?
| To print the contents of a textarea element without clipping and to ensure that all content is visible, you can follow these steps:
### Step-by-Step Strategy
1. **Extract the Textarea Content**: Use JavaScript to grab the content of the textarea.
2. **Create a New Printable Element**: Create a new HTML element (like... | 31,295 | [
{
"from": "human",
"value": "I would like to print only the contents of a textarea element from a website page. In particular, I would like to ensure that nothing gets clipped by the boundary of the textarea as the contents will be quite large.\nWhat is the best strategy for tackling this?\n"
},
{
... |
I'm trying to get my head around mutable vs immutable objects. Using mutable objects gets a lot of bad press (e.g. returning an array of strings from a method) but I'm having trouble understanding what the negative impacts are of this. What are the best practices around using mutable objects? Should you avoid them when... | Understanding the distinction between mutable and immutable objects is crucial in programming, as it impacts both code behavior and maintainability. Let's break down these concepts and discuss best practices.
### Mutable vs. Immutable Objects
- **Mutable Objects**: These are objects whose state or contents can be cha... | 32,140 | [
{
"from": "human",
"value": "I'm trying to get my head around mutable vs immutable objects. Using mutable objects gets a lot of bad press (e.g. returning an array of strings from a method) but I'm having trouble understanding what the negative impacts are of this. What are the best practices around using mu... |
I have a rails template (.rhtml file) generating a Javascript object. It looks something like the following:
var volumes = {
<% for volume in @volumes %>
<%= volume.id %> : <%= volume.data %>
<%= ',' unless volume === @volumes.last %>
<% end %>
};
Note the unless statement modifier to suppress printing th... | Using `<%= value unless condition %>` in your Rails template can work, but it can also make your code less clear and less maintainable. While it is certainly valid Ruby syntax, using modifiers in this way may lead to confusion for someone who reads the code later, as it combines rendering logic with conditionals in a s... | 35,510 | [
{
"from": "human",
"value": "I have a rails template (.rhtml file) generating a Javascript object. It looks something like the following:\nvar volumes = {\n <% for volume in @volumes %>\n <%= volume.id %> : <%= volume.data %> \n <%= ',' unless volume === @volumes.last %>\n <% end %>\n};\n\nNote the ... |
So I've got a Ruby method like this:
def something(variable, &block)
....
end
And I want to call it like this:
something 'hello' { do_it }
Except that isn't working for me, I'm getting a syntax error. If I do this instead, it works:
something 'hello' do
do_it
end
Except there I'm kind of missing the nice look of... | You're correct that the syntax you're trying to use causes ambiguity in Ruby because the curly braces `{}` can be interpreted as a hash rather than a block. However, there is a way to call your method with a block in one line without syntax errors.
To achieve the desired effect while keeping it on one line, you can us... | 27,045 | [
{
"from": "human",
"value": "So I've got a Ruby method like this:\ndef something(variable, &block)\n ....\nend\n\nAnd I want to call it like this:\nsomething 'hello' { do_it }\n\nExcept that isn't working for me, I'm getting a syntax error. If I do this instead, it works:\nsomething 'hello' do\n do_it\nen... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.