instruction
stringlengths
14
27.6k
completion
stringlengths
3
38.3k
__original_row_idx
int64
0
50k
conversations
listlengths
2
2
Given a function which produces a random integer in the range 1 to 5, write a function which produces a random integer in the range 1 to 7.
To generate a random integer in the range from 1 to 7 using a function that generates a random integer in the range from 1 to 5, we can employ a technique that involves using the outputs of the 1-to-5 function in a combination. Here's how you can do it: 1. Use the random function to generate numbers in the range of 1 ...
10,999
[ { "from": "human", "value": "Given a function which produces a random integer in the range 1 to 5, write a function which produces a random integer in the range 1 to 7.\n" }, { "from": "gpt", "value": "To generate a random integer in the range from 1 to 7 using a function that generates a random...
My boss loves VB (we work in a Java shop) because he thinks it's easy to learn and maintain. We want to replace some of the VB with java equivalents using the Eclipse SWT editor, because we think it is almost as easy to maintain. To sell this, we'd like to use an aerith style L&F. Can anyone provide an example of an SW...
To create an SWT application with an Aerith look and feel (L&F) in Eclipse, you can use the `SWT` library along with the `SWT_Aerith` theme. Unfortunately, the Aerith look and feel is not natively available in SWT like in Swing. However, you can achieve a similar appearance by customizing your SWT application. Here's ...
9,965
[ { "from": "human", "value": "My boss loves VB (we work in a Java shop) because he thinks it's easy to learn and maintain. We want to replace some of the VB with java equivalents using the Eclipse SWT editor, because we think it is almost as easy to maintain. To sell this, we'd like to use an aerith style L&...
I want to recreate the stickiness and snapping of windows, like it is implemented in Winamp. The basic premise is, when you drag a window and it comes close to another one, it will snap to it and will stick. When you move it the two will move together. I need it for a MDI application.
To implement window snapping and stickiness similar to Winamp in a Multiple Document Interface (MDI) application, you can follow these general steps. The core idea is to detect when windows are close to each other and then "snap" them together when a certain threshold is met. Below is a conceptual guide along with samp...
8,643
[ { "from": "human", "value": "I want to recreate the stickiness and snapping of windows, like it is implemented in Winamp.\nThe basic premise is, when you drag a window and it comes close to another one, it will snap to it and will stick. When you move it the two will move together.\nI need it for a MDI appl...
In a C++ project I'm working on, I have a flag kind of value which can have four values. Those four flags can be combined. Flags describe the records in database and can be: new record deleted record modified record existing record Now, for each record I wish to keep this attribute, so I could use an enum: enum { xNe...
In this case, it is best to leverage C++'s strong type safety features while also providing a mechanism for bitwise operations. You can accomplish this using a combination of a `class` or `struct` with bitwise operator overloads. This provides both type safety and flexibility for combining flags. Here’s an approach th...
9,811
[ { "from": "human", "value": "In a C++ project I'm working on, I have a flag kind of value which can have four values. Those four flags can be combined. Flags describe the records in database and can be:\n\nnew record\ndeleted record\nmodified record\nexisting record\n\nNow, for each record I wish to keep th...
I'm translating a library written in C++ to C#, and the keyword 'union' exists once. In a struct. What's the correct way of translating it into C#? And what does it do? It looks something like this; struct Foo { float bar; union { int killroy; float fubar; } as; }
In C++, a `union` allows you to define a data structure that can store different types in the same memory location. Essentially, a `union` can hold one of its non-static data members at any given time, and the size of the `union` is determined by the size of its largest member. This is useful in scenarios where you wan...
11,281
[ { "from": "human", "value": "I'm translating a library written in C++ to C#, and the keyword 'union' exists once. In a struct.\nWhat's the correct way of translating it into C#? And what does it do? It looks something like this;\nstruct Foo {\n float bar;\n\n union {\n int killroy;\n flo...
Here's the situation: I'm trying my hand at some MySpace page customisations. If you've ever tried [stackoverflow], I'm sure you understand how frustrating it can be. Basically it can be all customised via CSS, within a certain set of rules (e.g. the '#' character is not allowed...how useful!). Have a look at this blog...
It sounds like you're dealing with a common issue where long URLs can break the layout of your page. Since you're limited to CSS for your MySpace customizations and cannot use JavaScript, you can try a few CSS techniques to handle long URLs within your comments section. 1. **Word Wrapping**: Use the `word-wrap` proper...
11,485
[ { "from": "human", "value": "Here's the situation: I'm trying my hand at some MySpace page customisations. If you've ever tried [stackoverflow], I'm sure you understand how frustrating it can be.\nBasically it can be all customised via CSS, within a certain set of rules (e.g. the '#' character is not allowe...
Using Rails v2.1, lets say you have an action for a controller that is accessible from more than one location. For example, within the Rails app, you have a link to edit a user from two different views, one on the users index view, and another from another view (lets say from the nav bar on every page). I'm wondering ...
Your approach of using the referrer header in combination with a `before_filter` to save the previous page is a reasonable and efficient way to handle redirects after form submissions in a Rails application, especially with Rails 2.1. Here’s a step-by-step breakdown of how you can implement this solution: ### Step 1: ...
10,305
[ { "from": "human", "value": "Using Rails v2.1, lets say you have an action for a controller that is accessible from more than one location. For example, within the Rails app, you have a link to edit a user from two different views, one on the users index view, and another from another view (lets say from t...
I have a C extension module and it would be nice to distribute built binaries. Setuptools makes it easy to build extensions modules on OS X and GNU/Linux, since those OSs come with GCC, but I don't know how to do it in Windows. Would I need to buy a copy of Visual Studio, or does Visual Studio Express work? Can I just ...
When distributing a C extension module for Python, especially on Windows, you have several options for building binaries. Here’s a breakdown of your options: ### 1. **Using Visual Studio:** - **Visual Studio Community Edition:** This is a free version of Visual Studio that is fully featured and allows you to build ...
10,634
[ { "from": "human", "value": "I have a C extension module and it would be nice to distribute built binaries. Setuptools makes it easy to build extensions modules on OS X and GNU/Linux, since those OSs come with GCC, but I don't know how to do it in Windows.\nWould I need to buy a copy of Visual Studio, or do...
I'm having a hard time understanding and therefore managing arrays and indexes manually in C. These are my two classic approaches but they doesn't seem to work as they keep looping when the condition is reached: #include<stdio.h> #define MAX 255 int main(){ int arr[MAX]={0}; int idx=0; /* Approach #1 */...
I'm glad to hear that you're making progress! However, I see some potential issues in both of your approaches that could cause problems when managing the array and its indices. Let's review them and suggest corrections. ### Key Issues 1. **Indexing Before Initialization**: In your while and do-while loops, you check `...
10,584
[ { "from": "human", "value": "I'm having a hard time understanding and therefore managing arrays and indexes manually in C. These are my two classic approaches but they doesn't seem to work as they keep looping when the condition is reached: \n#include<stdio.h>\n#define MAX 255\n\nint main(){\n\n int arr[...
In an HTML form post what are valid characters for creating a multipart boundary?
In an HTML form submission that uses the `multipart/form-data` encoding type, a boundary is used to separate multiple parts of the form data. According to the specifications outlined in [RFC 2046](https://datatracker.ietf.org/doc/html/rfc2046) and related documents, the characters that are valid for creating a multipar...
13,373
[ { "from": "human", "value": "In an HTML form post what are valid characters for creating a multipart boundary?\n" }, { "from": "gpt", "value": "In an HTML form submission that uses the `multipart/form-data` encoding type, a boundary is used to separate multiple parts of the form data. According ...
I always believe they did, but seeing some answers here make me doubt... Can I access private fields/properties/methods from outside a class through reflection?
Yes, you can access private fields, properties, and methods of a class from outside that class using reflection in languages such as C# and Java. Reflection allows you to inspect and interact with types at runtime, including accessing members that are normally inaccessible due to their visibility modifiers. ### Exampl...
9,247
[ { "from": "human", "value": "I always believe they did, but seeing some answers here make me doubt...\nCan I access private fields/properties/methods from outside a class through reflection?\n" }, { "from": "gpt", "value": "Yes, you can access private fields, properties, and methods of a class f...
I've got a client that sees the "Page can not be displayed" (nothing else) whenever they perform a certain action in their website. I don't get the error, ever. I've tried IE, FF, Chrome, and I do not see the error. The client sees the error on IE. The error occurs when they press a form submit button that has only ...
The "Page cannot be displayed" error can arise from a variety of issues, especially if it appears only for one client and not for others. Here are several troubleshooting steps and considerations that could help identify and resolve the issue: 1. **Browser-Specific Issues:** - Since the client is using Internet Exp...
10,167
[ { "from": "human", "value": "I've got a client that sees the \"Page can not be displayed\" (nothing else) whenever they perform a certain action in their website. I don't get the error, ever. I've tried IE, FF, Chrome, and I do not see the error. The client sees the error on IE.\nThe error occurs when th...
Fedora Core 9 seems to have FCGID instead of FastCGI as a pre-built, YUM-managed module. [I'd rather not have to maintain a module outside of YUM; so no manual builds for me or my sysadmins.] I'm trying to launch Django through the runfastcgi interface (per the FastCGI deployment docs). What I'm seeing is the result...
It sounds like you're facing a common challenge when trying to integrate Django with FastCGI on Fedora Core 9 using FCGID. Let's address your questions step by step. ### 1. FastCGI Availability in Fedora Core 9 Fedora Core 9 does support FastCGI through mod_fcgid, which is what you're currently trying to use. However,...
8,212
[ { "from": "human", "value": "Fedora Core 9 seems to have FCGID instead of FastCGI as a pre-built, YUM-managed module. [I'd rather not have to maintain a module outside of YUM; so no manual builds for me or my sysadmins.]\nI'm trying to launch Django through the runfastcgi interface (per the FastCGI deploym...
On my VPS server (Fedora 9), mingetty keeps respawning itself because of a "permission denied" error on tty[1-6], even though: root# ls -la /dev/tty1 crw------- 1 root root 4, 1 Sep 19 14:22 /dev/tty1 Even weirder, this doesn't work: root# cat </dev/tty1 bash: /dev/tty1: Permission denied I am guessing this has som...
The issue you are encountering with `mingetty` and the "Permission denied" error on your `/dev/tty1` could stem from a few possibilities, particularly related to the virtualization environment of your VPS. Here are several things to consider and check: 1. **Character Device Access**: You mentioned that the permissions...
8,697
[ { "from": "human", "value": "On my VPS server (Fedora 9), mingetty keeps respawning itself because of a \"permission denied\" error on tty[1-6], even though:\n\nroot# ls -la /dev/tty1\ncrw------- 1 root root 4, 1 Sep 19 14:22 /dev/tty1\n\nEven weirder, this doesn't work:\n\nroot# cat </dev/tty1\nbash: /dev/...
From within my Java program I want to determine which .NET Framework is installed on the system. What is the best (and easiest) way to do this? Answer Thanks scubabbl! It worked to check the directory System.getenv( "WINDIR" ) + "\\Microsoft.NET\\Framework" for its directories starting with the letter "v".
To determine which .NET Framework versions are installed on a system from a Java program, checking the directories under `C:\Windows\Microsoft.NET\Framework` (or the equivalent path depending on the operating system) is indeed a straightforward approach. Here’s how you can do it: 1. **Get the Windows Directory**: Use ...
11,842
[ { "from": "human", "value": "From within my Java program I want to determine which .NET Framework is installed on the system. What is the best (and easiest) way to do this?\nAnswer Thanks scubabbl! It worked to check the directory System.getenv( \"WINDIR\" ) + \"\\\\Microsoft.NET\\\\Framework\" for its dire...
I build websites for a small-ish media company. Unfortunately, around 45-50% of our client base uses IE6, while the other half are pretty much equally split between Firefox and Webkit-based browsers, with a sprinkling of Opera users. I start every one of my sites with a reset stylesheet similar to Eric Meyer's, with a ...
It's definitely challenging to work with older browsers like IE6, especially when modern development practices and frameworks are often tailored to more contemporary standards. Since you're already familiar with a reset stylesheet and Blueprint CSS, here are a few suggestions for stylesheets and frameworks that can hel...
11,965
[ { "from": "human", "value": "I build websites for a small-ish media company. Unfortunately, around 45-50% of our client base uses IE6, while the other half are pretty much equally split between Firefox and Webkit-based browsers, with a sprinkling of Opera users.\nI start every one of my sites with a reset s...
I'm running Django 1.0 and I'm close to deploying my app. As such, I'll be changing the DEBUG setting to False. With that being said, I'd still like to include the stacktrace on my 500.html page when errors occur. By doing so, users can copy-and-paste the errors and easily email them to the developers. Any thoughts o...
In Django 1.0, it's important to understand that running with `DEBUG = False` disables detailed error reporting by default for security reasons. However, if you want to include the stack trace in your 500 error page for debugging purposes, you'll need to customize your error handling. Here's a general approach to achi...
10,428
[ { "from": "human", "value": "I'm running Django 1.0 and I'm close to deploying my app. As such, I'll be changing the DEBUG setting to False.\nWith that being said, I'd still like to include the stacktrace on my 500.html page when errors occur. By doing so, users can copy-and-paste the errors and easily em...
I need to implement auto-capitalization inside of a Telerik RadEditor control on an ASPX page as a user types. This can be an IE specific solution (IE6+). I currently capture every keystroke (down/up) as the user types to support a separate feature called "macros" that are essentially short keywords that expand into fo...
Implementing auto-capitalization in a Telerik RadEditor control while managing the existing macro functionality requires careful handling of keystrokes and text manipulation. Since you have access to keystrokes and are already using `TextRange` for your macros, you can leverage both approaches: monitoring for punctuati...
7,587
[ { "from": "human", "value": "I need to implement auto-capitalization inside of a Telerik RadEditor control on an ASPX page as a user types.\nThis can be an IE specific solution (IE6+).\nI currently capture every keystroke (down/up) as the user types to support a separate feature called \"macros\" that are e...
I would like to replicate this in python: gvimdiff <(hg cat file.txt) file.txt (hg cat file.txt outputs the most recently committed version of file.txt) I know how to pipe the file to gvimdiff, but it won't accept another file: $ hg cat file.txt | gvimdiff file.txt - Too many edit arguments: "-" Getting to the python...
In Python, the way to achieve the functionality of process substitution (`<(...)`) that you're used to in Bash is a bit different. Since Python doesn’t have built-in support for process substitution, you'll need to use temporary files or `Named Pipes` to achieve a similar effect. Here's a possible solution using a tem...
4,347
[ { "from": "human", "value": "I would like to replicate this in python:\ngvimdiff <(hg cat file.txt) file.txt\n\n(hg cat file.txt outputs the most recently committed version of file.txt)\nI know how to pipe the file to gvimdiff, but it won't accept another file:\n$ hg cat file.txt | gvimdiff file.txt -\nToo ...
What is the best way to version control my database objects? I'm using Visual studio 2005/2008 and SQL server 2005. I would prefer a solution which can be used with SVN.
Version controlling database objects, especially when using Visual Studio 2005/2008 and SQL Server 2005, requires careful planning and the right tools. Below are some strategies and tools that can help you effectively manage your database schema and version control using SVN: ### Strategies for Version Controlling Dat...
12,113
[ { "from": "human", "value": "What is the best way to version control my database objects? I'm using Visual studio 2005/2008 and SQL server 2005. I would prefer a solution which can be used with SVN.\n" }, { "from": "gpt", "value": "Version controlling database objects, especially when using Visu...
In general, what kinds of design decisions help an application scale well? (Note: Having just learned about Big O Notation, I'm looking to gather more principles of programming here. I've attempted to explain Big O Notation by answering my own question below, but I want the community to improve both this question and t...
Your question and the responses you’ve gathered so far touch on several important principles of software design that can help applications scale effectively. Here are some additional insights and refinements to enhance your understanding of scalability in software design: ### 1. Define Scaling - **Horizontal vs. Verti...
6,605
[ { "from": "human", "value": "In general, what kinds of design decisions help an application scale well?\n(Note: Having just learned about Big O Notation, I'm looking to gather more principles of programming here. I've attempted to explain Big O Notation by answering my own question below, but I want the com...
Simple example: I want to have some items on a page (like divs or table rows), and I want to let the user click on them to select them. That seems easy enough in jQuery. To save which items a user clicks on with no server-side post backs, I was thinking a cookie would be a simple way to get this done. Is this assumpti...
Your assumption that a cookie is a viable method for saving user selections without server-side postbacks is correct. Cookies are a common way to store user preferences and small amounts of data on the client side. However, there are some considerations to keep in mind: 1. **Size Limit**: Cookies have a size limit of ...
9,012
[ { "from": "human", "value": "Simple example: I want to have some items on a page (like divs or table rows), and I want to let the user click on them to select them. That seems easy enough in jQuery. To save which items a user clicks on with no server-side post backs, I was thinking a cookie would be a simpl...
I have two machines in two different domains. On both I have VS 2005 installed. I want remote debug between them. Without authentication it is possible but I want to debug managed code. I don't want to debug directly since it is really crappy machine. When I try to attach with debugger I get message "The trust relation...
The issue you are facing arises from the fact that the two machines are in different domains, and the trust relationship between them is failing when trying to perform remote debugging. Here are some steps and considerations to help you troubleshoot and resolve the issue: ### Steps to Resolve the Trust Relationship Is...
7,999
[ { "from": "human", "value": "I have two machines in two different domains. On both I have VS 2005 installed. I want remote debug between them. Without authentication it is possible but I want to debug managed code. I don't want to debug directly since it is really crappy machine.\nWhen I try to attach with ...
Should libraries that the application relies on be stored in source control? One part of me says it should and another part say's no. It feels wrong to add a 20mb library that dwarfs the entire app just because you rely on a couple of functions from it (albeit rather heavily). Should you just store the jar/dll or maybe...
Deciding whether to store libraries in source control can depend on a variety of factors, including the type of project, team practices, and the nature of the libraries in question. Here are some considerations and common practices to help you make a decision: ### Reasons to Store Libraries in Source Control 1. **Ver...
8,677
[ { "from": "human", "value": "Should libraries that the application relies on be stored in source control? One part of me says it should and another part say's no. It feels wrong to add a 20mb library that dwarfs the entire app just because you rely on a couple of functions from it (albeit rather heavily). S...
I need to join two binary files with a *.bat script on Windows. How can I achieve that?
To join two binary files using a `.bat` script in Windows, you can use the `copy` command. Here's how to do it: 1. Open Notepad (or any text editor) and create a new file. 2. Type the following script into the file: ```batch @echo off setlocal rem Set the names of the binary files you want to join set file1=file1.bi...
10,280
[ { "from": "human", "value": "I need to join two binary files with a *.bat script on Windows.\nHow can I achieve that?\n" }, { "from": "gpt", "value": "To join two binary files using a `.bat` script in Windows, you can use the `copy` command. Here's how to do it:\n\n1. Open Notepad (or any text e...
I have a base class object array into which I have typecasted many different child class objects and am passing it to a sub vi. Is there any way by which I can find out the original type of the object of each individual elements in the array? Thanks ...
In LabVIEW, if you have an array of objects that are all derived from a common base class, you can determine the specific type of each object at runtime using the `Class ID` or `Type Name` features. Here’s how you can achieve that: 1. **Using the `Class ID`:** - When you pass an array of the base class objects to y...
12,100
[ { "from": "human", "value": "I have a base class object array into which I have typecasted many different child class objects and am passing it to a sub vi. Is there any way by which I can find out the original type of the object of each individual elements in the array?\nThanks ...\n" }, { "from": ...
This morning, I was reading Steve Yegge's: When Polymorphism Fails, when I came across a question that a co-worker of his used to ask potential employees when they came for their interview at Amazon. As an example of polymorphism in action, let's look at the classic "eval" interview question, which (as far as I ...
Sure! Let's tackle the problem of parsing an arithmetic expression from a string (e.g., "2 + (2)") into an expression tree using three different approaches: cascaded ifs, a table of function pointers, and polymorphism. ### 1. Cascaded Ifs This approach uses a series of `if` or `switch` statements to determine the typ...
1,759
[ { "from": "human", "value": "This morning, I was reading Steve Yegge's: When Polymorphism Fails, when I came across a question that a co-worker of his used to ask potential employees when they came for their interview at Amazon.\n\nAs an example of polymorphism in\n action, let's look at the classic\n \"e...
I'm trying to start an external application through system() - for example, system("ls"). I would like to capture its output as it happens so I can send it to another function for further processing. What's the best way to do that in C/C++?
To capture the output of an external application in C or C++, you typically use pipes. You can create a pipe that connects the standard output of the command to your program. Here's a simple example demonstrating how to do this using the `popen()` function, which is part of the standard library. Here's a complete exam...
10,662
[ { "from": "human", "value": "I'm trying to start an external application through system() - for example, system(\"ls\"). I would like to capture its output as it happens so I can send it to another function for further processing. What's the best way to do that in C/C++?\n" }, { "from": "gpt", "...
Compiler, TASM 5 Architecture x86. For a random number generator algorithm, take tha clock as the seed. I found that solution: AcquireSeed PROC PUSH AX PUSH CX PUSH DX MOV Ah, 00h ; Int INT 1AH ; return the clock in CX:DX MOV seed, DL ; save the less significant byte of the clock at seed...
Your implementation of a function to acquire a seed from the system clock is almost correct, but there are a few points that need correction, especially in the stack management and variable handling. Let's clarify and correct your code snippet. 1. **Data Segment Declaration**: Make sure to define the seed variable in ...
12,279
[ { "from": "human", "value": "Compiler, TASM 5\nArchitecture x86.\nFor a random number generator algorithm, take tha clock as the seed.\n\nI found that solution:\nAcquireSeed PROC\n\n PUSH AX\n PUSH CX\n PUSH DX\n\n MOV Ah, 00h ; Int\n INT 1AH ; return the clock in CX:DX\n\n MOV seed, D...
When a PHP application makes a database connection it of course generally needs to pass a login and password. If I'm using a single, minimum-permission login for my application, then the PHP needs to know that login and password somewhere. What is the best way to secure that password? It seems like just writing it in t...
You're correct that hardcoding database credentials directly into your PHP code is not a secure practice, as it increases the risk of exposing sensitive information. Here are several best practices to securely manage and store database credentials in a PHP application: ### 1. **Use Environment Variables** - Store y...
11,106
[ { "from": "human", "value": "When a PHP application makes a database connection it of course generally needs to pass a login and password. If I'm using a single, minimum-permission login for my application, then the PHP needs to know that login and password somewhere. What is the best way to secure that pas...
SQL is not my forte, but I'm working on it - thank you for the replies. I am working on a report that will return the completion percent of services for indiviudals in our contracts. There is a master table "Contracts," each individual Contract can have multiple services from the "services" table, each service has mul...
It looks like you're trying to create a report that shows the percent completion for services across all contracts. To do that, you'll need to modify your SQL query to remove the filter on `Contract_ServiceId`, and instead group by the relevant contract and service columns to calculate the completion percentage for all...
11,052
[ { "from": "human", "value": "SQL is not my forte, but I'm working on it - thank you for the replies.\nI am working on a report that will return the completion percent of services for indiviudals in our contracts. There is a master table \"Contracts,\" each individual Contract can have multiple services fro...
There doesn't seem to be a way to change the padding (or row height) for all rows in a .NET ListView. Does anybody have an elegant hack-around?
In a .NET WinForms `ListView`, directly changing the row height or padding for all rows is not supported out-of-the-box. However, you can achieve a custom row height effect by overriding the painting of the `ListView` and drawing the items manually. Here’s an elegant workaround that involves handling the `DrawItem`, `D...
9,360
[ { "from": "human", "value": "There doesn't seem to be a way to change the padding (or row height) for all rows in a .NET ListView. Does anybody have an elegant hack-around?\n" }, { "from": "gpt", "value": "In a .NET WinForms `ListView`, directly changing the row height or padding for all rows is...
I need to display a bunch of images on a web page using AJAX. All of them have different dimensions, so I want to adjust their size before displaying them. Is there any way to do this in JavaScript? Using PHP's getimagesize() for each image causes an unnecessary performance hit since there will be many images.
Yes, you can dynamically adjust the size of images in JavaScript before displaying them on your webpage, without the need to use `getimagesize()` in PHP. Here’s a common approach using JavaScript and CSS to resize images on the client side after loading them via AJAX. ### Steps to Resize Images Dynamically with JavaSc...
7,100
[ { "from": "human", "value": "I need to display a bunch of images on a web page using AJAX. All of them have different dimensions, so I want to adjust their size before displaying them. Is there any way to do this in JavaScript?\nUsing PHP's getimagesize() for each image causes an unnecessary performance hit...
Last Friday where I work, an oracle client was upgarded and our IIS server from version 9 to version 10. Now that its on version 10, we are seeing a lot of connections being open up to the database. It is opening up so many connections that we cannot log onto the database using tools like PlSQL developer or Toad. We ne...
It sounds like you're experiencing a connection issue after upgrading your Oracle client from version 9 to version 10. This kind of issue can arise due to various reasons, including changes in the way connections are managed or connection pooling between the Oracle client and the database. Here are a few things to cons...
11,086
[ { "from": "human", "value": "Last Friday where I work, an oracle client was upgarded and our IIS server from version 9 to version 10. Now that its on version 10, we are seeing a lot of connections being open up to the database. It is opening up so many connections that we cannot log onto the database using ...
Excluding the check digit, what is the minimum length number the luhn algorithm will work on? My thoughts are that it would work on any number greater than 2 digits (again, excluding the check digit). The reason I ask is this: if i iterates over all digits in the number from right to left. This causes i%2 == 0 (used ...
The Luhn algorithm requires at least two digits in the number (excluding the check digit) for it to be effective. This is because the algorithm is designed to create a checksum that is used to validate a series of digits based on their position and value. Here's a brief breakdown of how the algorithm works: 1. Starti...
12,877
[ { "from": "human", "value": "Excluding the check digit, what is the minimum length number the luhn algorithm will work on? \nMy thoughts are that it would work on any number greater than 2 digits (again, excluding the check digit).\nThe reason I ask is this:\nif i iterates over all digits in the number fro...
is there an easy way to transform HTML into markdown with JAVA? I am currently using the Java MarkdownJ library to transform markdown to html. import com.petebevin.markdown.MarkdownProcessor; ... public static String getHTML(String markdown) { MarkdownProcessor markdown_processor = new MarkdownProcessor(); retu...
Yes, there are a few libraries in Java that can help you convert HTML to Markdown. One popular choice is the **jsoup** library for parsing HTML, combined with a custom conversion logic or a Markdown library that supports HTML to Markdown conversion. However, there's also a library called **flexmark-java** that can han...
8,596
[ { "from": "human", "value": "is there an easy way to transform HTML into markdown with JAVA?\nI am currently using the Java MarkdownJ library to transform markdown to html.\nimport com.petebevin.markdown.MarkdownProcessor;\n...\npublic static String getHTML(String markdown) {\n MarkdownProcessor markdown...
Has anyone experienced issues with Java's default garbage collector while running apps on VmWare instances? I am experiencing issues where full garbage collections are not running as often as I would expect and am curious if the VmWare variable has anything to do with it.
Yes, issues with Java's garbage collector (GC) can sometimes be observed in virtualized environments like VMware, and several factors could contribute to this behavior. Here are some considerations and potential causes for your observed issue: ### 1. **Resource Allocation:** - **CPU and Memory Resources:** Ensure t...
9,836
[ { "from": "human", "value": "Has anyone experienced issues with Java's default garbage collector while running apps on VmWare instances?\nI am experiencing issues where full garbage collections are not running as often as I would expect and am curious if the VmWare variable has anything to do with it.\n" ...
I have a VARCHAR column in a SQL Server 2000 database that can contain either letters or numbers. It depends on how the application is configured on the front-end for the customer. When it does contain numbers, I want it to be sorted numerically, e.g. as "1", "2", "10" instead of "1", "10", "2". Fields containing just...
To achieve the desired sort order in SQL Server 2000, where numeric values are sorted numerically and mixed or alphabetic values are sorted alphabetically, you can use a combination of SQL functions to separate the numeric values from the alphabetic ones during the sorting process. One approach is to use a `CASE` stat...
12,447
[ { "from": "human", "value": "I have a VARCHAR column in a SQL Server 2000 database that can contain either letters or numbers. It depends on how the application is configured on the front-end for the customer. \nWhen it does contain numbers, I want it to be sorted numerically, e.g. as \"1\", \"2\", \"10\" i...
This question talks about different payment processors and what they cost, but I'm looking for the answer to what do I need to do if I want to accept credit card payments? Assume I need to store credit card numbers for customers, so that the obvious solution of relying on the credit card processor to do the heavy lifti...
Accepting credit card payments and securely storing credit card information requires strict adherence to PCI (Payment Card Industry) Data Security Standards. Here’s a comprehensive overview of steps you should take, including technical and physical security measures. ### 1. **Merchant Account and Payment Processor** -...
7,695
[ { "from": "human", "value": "This question talks about different payment processors and what they cost, but I'm looking for the answer to what do I need to do if I want to accept credit card payments?\nAssume I need to store credit card numbers for customers, so that the obvious solution of relying on the c...
Rails comes with a handy session hash into which we can cram stuff to our heart's content. I would, however, like something like ASP's application context, which instead of sharing data only within a single session, will share it with all sessions in the same application. I'm writing a simple dashboard app, and would l...
In Rails, if you need to share data across sessions (i.e., application-wide state) without using a database, there are a couple of approaches you can consider: ### 1. Use a Global Variable You can utilize a global variable to store application-wide data. This approach is straightforward but has some caveats regarding...
10,174
[ { "from": "human", "value": "Rails comes with a handy session hash into which we can cram stuff to our heart's content. I would, however, like something like ASP's application context, which instead of sharing data only within a single session, will share it with all sessions in the same application. I'm wr...
What is the best way to vertically center the content of a div when the height of the content is variable. In my particular case, the height of the container div is fixed, but it would be great if there were a solution that would work in cases where the container has a variable height as well. Also, I would love a sol...
There are several ways to vertically center content within a div, both for fixed-height and variable-height containers. Below are a few common methods that require minimal CSS hacks and non-semantic markup. ### 1. Flexbox Method Using Flexbox is one of the simplest and most effective ways to vertically center content....
7,766
[ { "from": "human", "value": "What is the best way to vertically center the content of a div when the height of the content is variable. In my particular case, the height of the container div is fixed, but it would be great if there were a solution that would work in cases where the container has a variable...
Our application takes significantly more time to launch after a reboot (cold start) than if it was already opened once (warm start). Most (if not all) the difference seems to come from loading DLLs, when the DLLs' are in cached memory pages they load much faster. We tried using ClearMem to simulate rebooting (since it...
Yes, it's common to experience significant differences in launch times between cold starts and warm starts in applications, especially when dealing with native libraries (DLLs) and other resources that the operating system caches in memory. ### 1. Differences in Launch Time: Cold starts generally take longer because: ...
9,985
[ { "from": "human", "value": "Our application takes significantly more time to launch after a reboot (cold start) than if it was already opened once (warm start). \nMost (if not all) the difference seems to come from loading DLLs, when the DLLs' are in cached memory pages they load much faster. We tried usin...
Working on a project at the moment and we have to implement soft deletion for the majority of users (user roles). We decided to add an is_deleted='0' field on each table in the database and set it to '1' if particular user roles hit a delete button on a specific record. For future maintenance now, each SELECT query wil...
Implementing soft deletion is a common practice in database design, especially when you need to retain historical data or allow for potential restoration of records. Here are some considerations and potential improvements over the approach you've described: ### Alternatives to Basic Soft Deletion 1. **Use of Views**:...
8,444
[ { "from": "human", "value": "Working on a project at the moment and we have to implement soft deletion for the majority of users (user roles). We decided to add an is_deleted='0' field on each table in the database and set it to '1' if particular user roles hit a delete button on a specific record.\nFor fut...
I am working on a WinForms application programmed in C# .NET 2.0 and VS2008. I am just about to start translating the app into several languages. Before I start, is it a good idea to use the VS2008 itself for all the localization? Or is it better to use some external tool right away? This is my first .NET app, so I rat...
Hi Petr, It's great to hear that you're moving forward with localizing your WinForms application! Since you already have your strings stored in resources, you're off to a good start. ### Using Visual Studio 2008 for Localization Visual Studio 2008 provides built-in support for localization through resource files (.r...
10,296
[ { "from": "human", "value": "I am working on a WinForms application programmed in C# .NET 2.0 and VS2008. I am just about to start translating the app into several languages. Before I start, is it a good idea to use the VS2008 itself for all the localization? Or is it better to use some external tool right ...
As Jeff Atwood asked: "What’s your logging philosophy? Should all code be littered with .logthis() and .logthat() calls? Or do you inject logging after the fact somehow?"
The logging philosophy in software development is an important consideration, as it significantly impacts both the maintainability of the code and the effectiveness of troubleshooting. Here are some key points to consider in response to Jeff Atwood's question: ### 1. Purpose of Logging - **Debugging and Monitoring*...
12,025
[ { "from": "human", "value": "As Jeff Atwood asked: \"What’s your logging philosophy? Should all code be littered with .logthis() and .logthat() calls? Or do you inject logging after the fact somehow?\"\n" }, { "from": "gpt", "value": "The logging philosophy in software development is an importan...
So, I am kinda new to ASP.net development still, and I already don't like the stock ASP.net controls for displaying my database query results in table format. (I.e. I would much rather handle the HTML myself and so would the designer!) So my question is: What is the best and most secure practice for doing this without ...
Welcome to ASP.NET development! It's completely understandable that you'd want more control over your HTML output than what is provided by the built-in ASP.NET controls. Your approach using a `DataTable` and iterating over it in your `.aspx` page is a valid one. However, there are several best practices you should foll...
9,511
[ { "from": "human", "value": "So, I am kinda new to ASP.net development still, and I already don't like the stock ASP.net controls for displaying my database query results in table format. (I.e. I would much rather handle the HTML myself and so would the designer!)\nSo my question is: What is the best and mo...
I'm looking for people who have had experiences scaling WebMethods ESB to large traffic volumes (both size and number of messages). How has that gone? Were there any issues and how did you solve them?
Scaling WebMethods ESB (Enterprise Service Bus) for large traffic volumes can be a challenging but rewarding endeavor. Here are some common experiences, issues, and solutions that organizations have faced while scaling WebMethods ESB: ### Common Experiences 1. **Increased Throughput**: Many organizations have succ...
10,874
[ { "from": "human", "value": "I'm looking for people who have had experiences scaling WebMethods ESB to large traffic volumes (both size and number of messages). How has that gone? Were there any issues and how did you solve them?\n" }, { "from": "gpt", "value": "Scaling WebMethods ESB (Enterpris...
Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like: class MyStruct(): def __init__(self, field1, field2, field3): self.field1 = field1 self.field2 = field2 self.field3 = field3
Yes, Python provides several convenient ways to define structures similar to C-like structures. Here are a few approaches you can use to achieve this: ### 1. Using `dataclasses` (Python 3.7+) The `dataclasses` module allows you to easily create classes that are primarily used to store data. You can define fields with...
9,431
[ { "from": "human", "value": "Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like:\nclass MyStruct():\n def __init__(self, field1, field2, field3):\n self.field1 = field1\n self.field2 = field2\n self.field3 = field3\n\n" }, { "f...
kt@rails-ubuntu:~/rails/ledger/releases/20080820144914/.git/hooks$ ls -al ls: cannot access post-commit: No such file or directory ls: cannot access update: No such file or directory ls: cannot access post-update: No such file or directory ls: cannot access commit-msg: No such file or directory ls: cannot access pre-r...
The output of the `ls -al` command you provided shows that there are several Git hook files (like `commit-msg`, `post-commit`, etc.) in the `.git/hooks` directory, but they are not accessible, as indicated by the `-?????????` output. This typically means that the files may have been corrupted or that there are filesys...
8,058
[ { "from": "human", "value": "\nkt@rails-ubuntu:~/rails/ledger/releases/20080820144914/.git/hooks$ ls -al\nls: cannot access post-commit: No such file or directory\nls: cannot access update: No such file or directory\nls: cannot access post-update: No such file or directory\nls: cannot access commit-msg: No ...
I want to generate a thumbnail preview of videos in Java. I'm mostly JMF and video manipulation alienated. Is there an easy way to do it? What about codecs? Will I have to deal with it? Any video type is suported? (including Quicktime)
Generating thumbnail previews of videos in Java can be accomplished through various libraries. Since you mentioned JMF (Java Media Framework), it's important to note that JMF is quite outdated and has limited support for modern video formats and codecs. Therefore, I recommend using more current libraries like **Xuggle ...
4,895
[ { "from": "human", "value": "I want to generate a thumbnail preview of videos in Java. I'm mostly JMF and video manipulation alienated. \n\nIs there an easy way to do it?\nWhat about codecs? Will I have to deal with it?\nAny video type is suported? (including Quicktime)\n\n" }, { "from": "gpt", ...
I have a pdf file of a logo, about 1"x2" in dimension. Can anybody provide the code snippet to import that PDF logo into another PDF file using the Zend_PDF API's? Ideally, I'd like to be able to place it like the PNG, TIFF or JPG objects with the Zend_Pdf_Image object. In other words, I want to be able to place th...
To import a PDF logo into another PDF file using the Zend_PDF API, you'll need to convert the PDF into an image format that the API can handle (like PNG or JPG) because Zend_PDF does not directly support embedding other PDF files as images. Here’s a basic approach to achieve this: 1. Convert your PDF logo to an image...
10,314
[ { "from": "human", "value": "I have a pdf file of a logo, about 1\"x2\" in dimension. Can anybody provide the code snippet to import that PDF logo into another PDF file using the Zend_PDF API's? \nIdeally, I'd like to be able to place it like the PNG, TIFF or JPG objects with the Zend_Pdf_Image object. \n...
I'm interested in the Presentation-Abstraction-Control? (aka Hierarchical-Model-View-Controller (HMVC)) Architectural Pattern for constructing complex user interfaces (GUI or web) and was wondering if anyone was aware of any examples in the wild where I could read the code? I'm aware of the JavaWorld article and associ...
The Presentation-Abstraction-Control (PAC) architectural pattern, often referred to as Hierarchical Model-View-Controller (HMVC), is a great choice for developing complex user interfaces as it promotes modularity and separation of concerns. Here are some examples and frameworks in the wild that use PAC or HMVC, along w...
11,516
[ { "from": "human", "value": "I'm interested in the Presentation-Abstraction-Control? (aka Hierarchical-Model-View-Controller (HMVC)) Architectural Pattern for constructing complex user interfaces (GUI or web) and was wondering if anyone was aware of any examples in the wild where I could read the code?\nI'm...
Our software manages a lot of data feeds from various sources: real time replicated databases, files FTPed automatically, scheduled running of database stored procedures to cache snapshots of data from linked servers and numerous other methods of acquiring data. We need to verify and validate this data: has an impor...
Your approach to validating and verifying data imports resembles a testing framework, which is a well-established pattern in software development. Here are some considerations, suggestions, and potential alternative patterns you might want to explore: ### Your Current Approach 1. **Unit Testing Analogy**: - Treati...
10,890
[ { "from": "human", "value": "Our software manages a lot of data feeds from various sources: real time replicated databases, files FTPed automatically, scheduled running of database stored procedures to cache snapshots of data from linked servers and numerous other methods of acquiring data. \nWe need to ver...
I have a pretty good knowledge of programming languages like C/C++, Java, Python. But they were all mostly learnt in a college / high school class room setting where the best user interface was a numbered menu. You know, the standard data structures, implementation of various algorithms, file handling and the like. Wh...
Given your background and requirements for getting started with GUI programming in a cross-platform manner, here are several frameworks and tools that might meet your needs: ### 1. **Qt (C++)** - **Overview**: Qt is a powerful C++ framework for cross-platform GUI development. It supports the WIMP paradigm and inclu...
7,404
[ { "from": "human", "value": "I have a pretty good knowledge of programming languages like C/C++, Java, Python. But they were all mostly learnt in a college / high school class room setting where the best user interface was a numbered menu. You know, the standard data structures, implementation of various al...
Is there a way to know and output the stack size needed by a function at compile time in C ? Here is what I would like to know : Let's take some function : void foo(int a) { char c[5]; char * s; //do something return; } When compiling this function, I would like to know how much stack space it will con...
In C, determining the stack size required by a function at compile time is not straightforward and generally not supported directly as a language feature. However, there are a few approaches that you could consider depending on your compiler and build environment: ### 1. Compiler Warnings and Flags Some compilers pro...
10,801
[ { "from": "human", "value": "Is there a way to know and output the stack size needed by a function at compile time in C ?\nHere is what I would like to know :\nLet's take some function :\nvoid foo(int a) {\n char c[5];\n char * s;\n //do something\n return;\n}\n\nWhen compiling this function, I ...
I'm writing an application to start and monitor other applications in C#. I'm using the System.Diagnostics.Process class to start applications and then monitor the applications using the Process.Responding property to poll the state of the application every 100 milisecs. I use Process.CloseMainWindow to stop the applic...
You're on the right track in understanding that the `Process.Responding` property can sometimes give you inaccurate results if you check it immediately after starting a process. The issue you're encountering is related to the timing of when Windows sends messages to the main thread of the process. When you check `Proce...
10,741
[ { "from": "human", "value": "I'm writing an application to start and monitor other applications in C#. I'm using the System.Diagnostics.Process class to start applications and then monitor the applications using the Process.Responding property to poll the state of the application every 100 milisecs. I use P...
I thought I heard that py2exe was able to do this, but I never figured it out. Has anyone successfully done this? Can I see your setup.py file, and what command line options you used? Basically I'm thinking of it giving me a single executable file that does something like unzips itself to maybe /temp and runs.
Creating a single executable file with `py2exe` that unzips itself and runs is a bit unconventional, but it's achievable with a few steps. Below, I will provide you with a sample `setup.py` and how to structure your project for py2exe. First, ensure you have `py2exe` installed. You can install it using pip: ```bash p...
11,339
[ { "from": "human", "value": "I thought I heard that py2exe was able to do this, but I never figured it out. Has anyone successfully done this? Can I see your setup.py file, and what command line options you used?\nBasically I'm thinking of it giving me a single executable file that does something like unz...
I've run setHeight(600) on a Window, that's it's initial size. I've also went ahead and done setAutoScroll(true). When the content of the window resizes, the window itself resizes. What I want is for the window to stay fixed in size, and when the content grows larger, add scrollbars. I can get this if I resize the wind...
To achieve the desired behavior where the window size remains fixed and scrollbars are added when the content grows larger, you'll need to ensure that the window's resizing logic does not automatically resize the window based on its content. Here's how you can do it: 1. **Set Fixed Size**: Make sure you have explicitl...
11,373
[ { "from": "human", "value": "I've run setHeight(600) on a Window, that's it's initial size. I've also went ahead and done setAutoScroll(true).\nWhen the content of the window resizes, the window itself resizes. What I want is for the window to stay fixed in size, and when the content grows larger, add scrol...
Apart from commercial tools like Dundas, are there any open source or cheaper (and decent) 3rd party charting tools/controls for reporting services out there?
Yes, there are several open-source and cost-effective charting tools and libraries that you can use for reporting and data visualization besides commercial options like Dundas. Here are some of the popular ones: ### Open Source Charting Libraries: 1. **Chart.js** - A simple yet flexible JavaScript charting library...
10,464
[ { "from": "human", "value": "Apart from commercial tools like Dundas, are there any open source or cheaper (and decent) 3rd party charting tools/controls for reporting services out there? \n" }, { "from": "gpt", "value": "Yes, there are several open-source and cost-effective charting tools and l...
We have MS Sharepoint -- which isn't all bad for managing a task list. The data's publicly available, people are notified of changes and assignments. I think that Bugzilla might be a little easier for management and reporting purposes. While there are some nice Open Source Scrum management tools, I've used up a lot...
Using Bugzilla as a general project management tool can work, but it may not be the most effective solution for managing tasks and projects outside of its intended use case (bug tracking). Here are some points to consider: ### Pros of Using Bugzilla: 1. **Familiarity**: If your team is already familiar with Bugzilla, ...
11,427
[ { "from": "human", "value": "We have MS Sharepoint -- which isn't all bad for managing a task list. The data's publicly available, people are notified of changes and assignments. \nI think that Bugzilla might be a little easier for management and reporting purposes. While there are some nice Open Source ...
I'm currently using Wordpress to run my website. However, with each new release I become more concerned with software bloat and the convoluted table structures used to store my data. Maybe this is a fruitless pursuit. Features are always added to blogging software until it claims to be a CMS--and at that point your ...
It's understandable to be concerned about software bloat and complex database structures, especially as WordPress evolves from a blogging platform into a more comprehensive content management system (CMS). Here are a few considerations and alternatives you might explore: ### 1. **Evaluate Your Needs** - **Assess Fe...
8,811
[ { "from": "human", "value": "I'm currently using Wordpress to run my website. However, with each new release I become more concerned with software bloat and the convoluted table structures used to store my data. Maybe this is a fruitless pursuit. Features are always added to blogging software until it cl...
When refactoring away some #defines I came across declarations similar to the following in a C++ header file: static const unsigned int VAL = 42; const unsigned int ANOTHER_VAL = 37; The question is, what difference, if any, will the static make? Note that multiple inclusion of the headers isn't possible due to the c...
In C++, the `static` storage class specifier has a specific effect on the linkage of the variable it qualifies. Here's a breakdown of the two declarations you provided: 1. **`static const unsigned int VAL = 42;`** 2. **`const unsigned int ANOTHER_VAL = 37;`** ### Difference in Linkage - **`static const unsigned int ...
8,833
[ { "from": "human", "value": "When refactoring away some #defines I came across declarations similar to the following in a C++ header file:\nstatic const unsigned int VAL = 42;\nconst unsigned int ANOTHER_VAL = 37;\n\nThe question is, what difference, if any, will the static make? Note that multiple inclusi...
I know next to nothing when it comes to the how and why of https connections. Obviously, when I'm transmitting secure data like passwords or especially credit card information, https is a critical tool. What do I need to know about it, though? What are the most common mistakes you see developers making when they imp...
HTTPS (Hypertext Transfer Protocol Secure) is a protocol that secures the communication between a user's web browser and a web server. It achieves this by using SSL (Secure Sockets Layer) or TLS (Transport Layer Security) to encrypt data in transit, ensuring that sensitive information, like passwords or credit card num...
9,202
[ { "from": "human", "value": "I know next to nothing when it comes to the how and why of https connections. Obviously, when I'm transmitting secure data like passwords or especially credit card information, https is a critical tool. What do I need to know about it, though? What are the most common mistake...
The VS Database Project does not seem to have the "Show All Files" option in the Solution Explorer. Does anyone know of a way to turn the option on in VS? The "Show All Files" option on the solution explorer actually does two things. With the option selected, VS shows "hidden/nested" files within the project AND it s...
In Visual Studio, the "Show All Files" option is not available for Database Projects (SQL Server Database Project) in the same way that it is for other project types. However, you can use a workaround to view files in the project directory that are not part of the project. Here are a couple of methods to achieve this:...
13,342
[ { "from": "human", "value": "The VS Database Project does not seem to have the \"Show All Files\" option in the Solution Explorer. Does anyone know of a way to turn the option on in VS?\nThe \"Show All Files\" option on the solution explorer actually does two things. With the option selected, VS shows \"h...
I want to know the memory usage of my Python application and specifically want to know what code blocks/portions or objects are consuming most memory. Google search shows a commercial one is Python Memory Validator (Windows only). And open source ones are PySizer and Heapy. I haven't tried anyone, so I wanted to know w...
When it comes to analyzing memory usage in Python applications, there are several tools you can use, each with its strengths and trade-offs. Based on your criteria—detailed insights with minimal code changes—here’s a comparison of some of the tools you mentioned and a couple of others: ### 1. **Heapy (part of Guppy3)*...
8,335
[ { "from": "human", "value": "I want to know the memory usage of my Python application and specifically want to know what code blocks/portions or objects are consuming most memory.\nGoogle search shows a commercial one is Python Memory Validator (Windows only).\nAnd open source ones are PySizer and Heapy.\nI...
My Visual Studio 2005 is storing the info about which projects and solutions go with which source control repositories in the .sln and .csproj files. Is it possible to make it store that binding information in some external file instead? The reason I wish the info were stored outside the solution/project files is to fa...
Unfortunately, Visual Studio 2005 does not provide a built-in way to externalize the source control binding information from the solution (`.sln`) and project (`.csproj`) files. The binding information is embedded directly within these files, which poses challenges when attempting to use multiple source control systems...
13,531
[ { "from": "human", "value": "My Visual Studio 2005 is storing the info about which projects and solutions go with which source control repositories in the .sln and .csproj files. Is it possible to make it store that binding information in some external file instead?\nThe reason I wish the info were stored o...
Let me explain: this is path to this folder: > www.my_site.com/images And images are created by user_id, and for example, images of user_id = 27 are, 27_1.jpg, 27_2.jpg, 27_3.jpg! How to list and print images which start with 27_%.jpg? I hope You have understood me! PS. I am totally beginmer in ASP.NET (VB) and please ...
Yes, I understand your requirement! You want to list all images for a specific user based on their `user_id`, and you want to create XML nodes for those images. You will be working in ASP.NET with VB.NET. Here’s how you can do it step by step: ### Step 1: Read the `user_id` You're already doing this with your loop, ...
9,504
[ { "from": "human", "value": "Let me explain:\nthis is path to this folder: > www.my_site.com/images\nAnd images are created by user_id, and for example, images of user_id = 27 are,\n27_1.jpg, 27_2.jpg, 27_3.jpg!\nHow to list and print images which start with 27_%.jpg?\nI hope You have understood me!\nPS. I ...
In Ruby on Rails Development (or MVC in general), what quick rule should I follow as to where to put logic. Please answer in the affirmative - With Do put this here, rather than Don't put that there.
Sure! Here are some quick rules to guide you on where to put logic in Ruby on Rails development: - **Do put business logic in models.** This keeps your data handling and rules in one place, making it easier to manage and test. - **Do put presentation logic in views.** Use views to manage how data is displayed to the ...
13,901
[ { "from": "human", "value": "In Ruby on Rails Development (or MVC in general), what quick rule should I follow as to where to put logic.\nPlease answer in the affirmative - With Do put this here, rather than Don't put that there.\n" }, { "from": "gpt", "value": "Sure! Here are some quick rules t...
I would like to know what would be the best way to do unit testing of a servlet. Testing internal methods is not a problem as long as they don't refer to the servlet context, but what about testing the doGet/doPost methods as well as the internal method that refer to the context or make use of session parameters? Is t...
Unit testing servlets can be a bit challenging due to their dependence on the servlet context and HTTP request/response objects. However, there are several ways to effectively unit test servlets without needing to embed a full Tomcat server. Below are some approaches and tools you can use, especially focusing on JUnit ...
9,678
[ { "from": "human", "value": "I would like to know what would be the best way to do unit testing of a servlet. \nTesting internal methods is not a problem as long as they don't refer to the servlet context, but what about testing the doGet/doPost methods as well as the internal method that refer to the conte...
Assume the following class: public class MyEnum: IEnumerator { private List<SomeObject> _myList = new List<SomeObject>(); ... } It is necessary to implement the IEnumerator methods in MyEnum. But is it possible to 'delegate' or redirect the implementation for IEnumerator directly to _myList without needing to imp...
Yes, it's possible to delegate or redirect the implementation of the `IEnumerator` methods directly to the underlying collection (`_myList` in your case). This approach involves encapsulating the enumerator of `_myList` and implementing the `IEnumerator` methods to call the corresponding methods on the enumerator of `_...
10,867
[ { "from": "human", "value": "Assume the following class:\npublic class MyEnum: IEnumerator\n{\n private List<SomeObject> _myList = new List<SomeObject>();\n...\n}\n\nIt is necessary to implement the IEnumerator methods in MyEnum. \nBut is it possible to 'delegate' or redirect the implementation for IEnum...
Is there a freely available library to create a MPEG (or any other simple video format) out of an image sequence ? It must run on Linux too, and ideally have Python bindings.
Yes, there are several libraries that you can use to create a video from an image sequence on Linux, and many of them have Python bindings. Here are a few options: 1. **OpenCV**: - OpenCV is a popular computer vision library that can handle video creation from image sequences. - It has Python bindings and is cro...
9,566
[ { "from": "human", "value": "Is there a freely available library to create a MPEG (or any other simple video format) out of an image sequence ?\nIt must run on Linux too, and ideally have Python bindings.\n" }, { "from": "gpt", "value": "Yes, there are several libraries that you can use to creat...
I have a MOJO I would like executed once, and once only after the test phase of the last project in the reactor to run. Using: if (!getProject().isExecutionRoot()) { return ; } at the start of the execute() method means my mojo gets executed once, however at the very beginning of the build - before all other c...
To execute your Mojo at the end of the test phase for the last project in a reactor build, you'll want to use the `@Execute` annotation with a specific phase and also implement a check to ensure it runs only for the last module in the reactor. Here's how you can achieve this: 1. **Use the `@Execute` Annotation:** To ...
11,880
[ { "from": "human", "value": "I have a MOJO I would like executed once, and once only after the test phase of the last project in the reactor to run.\nUsing:\nif (!getProject().isExecutionRoot()) {\n return ;\n}\n\nat the start of the execute() method means my mojo gets executed once, however at the v...
I unpacked a zip-file delivery into a clearcase view. Now I want to add the complete file tree to the repository. The GUI only provides an "Add to source control ..." for individual files/directories. Do you know how to recursively add the whole tree? (I'm on a Windows system, but have Cygwin installed.)
To add an entire file tree to a ClearCase repository recursively, you can use the command line rather than the GUI. Here’s how you can do it using Cygwin or a Command Prompt on Windows. ### Using ClearCase Command Line 1. **Open Cygwin or Command Prompt**: Make sure you have the appropriate ClearCase commands availab...
11,717
[ { "from": "human", "value": "I unpacked a zip-file delivery into a clearcase view. Now I want to add the complete file tree to the repository. The GUI only provides an \"Add to source control ...\" for individual files/directories. Do you know how to recursively add the whole tree?\n(I'm on a Windows system...
Shell ("explorer.exe www.google.com") is how I'm currently opening my products ad page after successful install. However I think it would look much nicer if I could do it more like Avira does, or even a popup where there are no address bar links etc. Doing this via an inbrowser link is easy enough <a href="http://pag...
To create a popup window similar to what you described in your VB application after a successful install, you can use the WebBrowser control along with some JavaScript to achieve this. This will allow you to present a webpage without the typical browser chrome (like the address bar and toolbar). Here’s how you can do ...
9,290
[ { "from": "human", "value": "Shell (\"explorer.exe www.google.com\")\n\nis how I'm currently opening my products ad page after successful install. However I think it would look much nicer if I could do it more like Avira does, or even a popup where there are no address bar links etc. Doing this via an inbr...
In my database (SQL 2005) I have a field which holds a comment but in the comment I have an id and I would like to strip out just the id, and IF possible convert it to an int: activation successful of id 1010101 The line above is the exact structure of the data in the db field. And no I don't want to do this in the cod...
You can achieve this in SQL Server 2005 by using a combination of string functions to extract the ID from the comment. Since the structure of your comment is consistent (i.e., it always contains the phrase "activation successful of id " followed by the ID), you can use `CHARINDEX`, `SUBSTRING`, and `CAST` (or `CONVERT`...
11,024
[ { "from": "human", "value": "In my database (SQL 2005) I have a field which holds a comment but in the comment I have an id and I would like to strip out just the id, and IF possible convert it to an int:\nactivation successful of id 1010101\nThe line above is the exact structure of the data in the db field...
How do I change the style (color) of a div such as the following? "<div id=foo class="ed" style="display: <%= ((foo.isTrue) ? string.Empty : "none") %>"> <%= ((foo.isTrue) ? foo.Name: "false foo") %>"`
To change the style (color) of a `div` element in your example, you can modify the `style` attribute directly within the `div` tag. In your case, you want to add a `color` property (or any other style property) to the inline styles. Here's how you could do it: ```html <div id="foo" class="ed" style="display: <%= ((fo...
10,538
[ { "from": "human", "value": "How do I change the style (color) of a div such as the following? \n\"<div id=foo class=\"ed\" style=\"display: <%= ((foo.isTrue) ? string.Empty : \"none\") %>\">\n <%= ((foo.isTrue) ? foo.Name: \"false foo\") %>\"`\n\n" }, { "from": "gpt", "va...
XAML allows you to specify an attribute value using a string that contains curly braces. Here is an example that creates a Binding instance and assigns it to the Text property of the TextBox element. <TextBox Text="{Binding ElementName=Foo, Path=Bar}"/> I want to extend XAML so that the developer could enter this as v...
Yes, it is indeed possible to extend XAML to support custom syntax similar to what you described with your `MyCustomObject`. To do this, you can create a custom markup extension in WPF (Windows Presentation Foundation). Below is a step-by-step guide to achieving this. ### Step 1: Create the Custom Markup Extension Fi...
9,121
[ { "from": "human", "value": "XAML allows you to specify an attribute value using a string that contains curly braces. Here is an example that creates a Binding instance and assigns it to the Text property of the TextBox element.\n<TextBox Text=\"{Binding ElementName=Foo, Path=Bar}\"/>\n\nI want to extend XA...
I would like to write a small program in C# which goes through my jpeg photos and, for example, sorts them into dated folders (using MY dating conventions, dammit...). Does anyone know a relatively easy way to get at the EXIF data such as Date And Time or Exposure programatically? Thanks!
You can use the `System.Drawing` namespace in C# to access EXIF data from JPEG files. The EXIF metadata is embedded within the image file itself, and you can retrieve it using the `PropertyItems` collection. Here’s a simple example that demonstrates how to read the date and time from the EXIF data and then organize JPE...
6,355
[ { "from": "human", "value": "I would like to write a small program in C# which goes through my jpeg photos and, for example, sorts them into dated folders (using MY dating conventions, dammit...). \nDoes anyone know a relatively easy way to get at the EXIF data such as Date And Time or Exposure programatica...
I've trouble setting up Vim (7.1.xxx) for editing Python files (*.py). Indenting seems to be broken (optimal 4 spaces). I've followed some tutorials I found via Google. Still no effect :/ Please help.
Setting up Vim to properly edit Python files with correct indentation can be achieved by adjusting a few settings in your Vim configuration file. Here's how you can do it: 1. **Open your Vim configuration file**. This file is usually located at `~/.vimrc`. You can create it if it doesn't exist: ```bash vim ~/.v...
12,079
[ { "from": "human", "value": "I've trouble setting up Vim (7.1.xxx) for editing Python files (*.py).\nIndenting seems to be broken (optimal 4 spaces).\nI've followed some tutorials I found via Google. Still no effect :/ \nPlease help.\n" }, { "from": "gpt", "value": "Setting up Vim to properly ed...
I'd like to find a good object oriented C++ (as opposed to C) wrapper for sqlite. What do people recommend? If you have several suggestions please put them in separate replies for voting purposes. Also, please indicate whether you have any experience of the wrapper you are suggesting and how you found it to use.
One popular object-oriented C++ wrapper for SQLite is **SQLiteCpp**. ### SQLiteCpp **Description:** SQLiteCpp is a smart and easy-to-use C++ wrapper around SQLite. It provides a simple interface for database operations and helps manage the SQLite connection and queries more conveniently than using the C API directly...
12,925
[ { "from": "human", "value": "I'd like to find a good object oriented C++ (as opposed to C) wrapper for sqlite. What do people recommend? If you have several suggestions please put them in separate replies for voting purposes. Also, please indicate whether you have any experience of the wrapper you are sugge...
Does anyone know how to get the HTML out of an IFRAME I have tried several different ways: document.getElementById('iframe01').contentDocument.body.innerHTML document.frames['iframe01'].document.body.innerHTML document.getElementById('iframe01').contentWindow.document.body.innerHTML etc
To access the contents of an `<iframe>`, the methods you've tried are correct, but there are a couple of important considerations to keep in mind. Here's a breakdown of how to properly retrieve the HTML from an `<iframe>` along with the factors that might cause issues. ### Basic Access to an IFRAME's Content 1. **Sam...
11,599
[ { "from": "human", "value": "Does anyone know how to get the HTML out of an IFRAME I have tried several different ways:\ndocument.getElementById('iframe01').contentDocument.body.innerHTML\ndocument.frames['iframe01'].document.body.innerHTML\ndocument.getElementById('iframe01').contentWindow.document.body.in...
I have a HTML report, which needs to be printed landscape because of the many columns. It there a way to do this, without the user having to change the document settings? And what are the options amongst browsers.
Printing a web page in landscape mode without requiring the user to manually change settings can be a bit tricky because print styles and configurations are largely dependent on the browser's print dialog and user settings. However, there are some strategies you can implement to encourage the browser to print in landsc...
11,841
[ { "from": "human", "value": "I have a HTML report, which needs to be printed landscape because of the many columns. It there a way to do this, without the user having to change the document settings?\nAnd what are the options amongst browsers.\n" }, { "from": "gpt", "value": "Printing a web page...
I'd like to use JavaScript to calculate the width of a string. Is this possible without having to use a monospace typeface? If it's not built-in, my only idea is to create a table of widths for each character, but this is pretty unreasonable especially supporting Unicode and different type sizes (and all browsers for t...
Yes, you can calculate the width of a string in JavaScript without using a monospace typeface by leveraging the HTML canvas element. This approach allows you to measure text width dynamically, supporting various fonts and sizes, including Unicode characters. Here's how you can do it: 1. Create an offscreen `<canvas>`...
10,937
[ { "from": "human", "value": "I'd like to use JavaScript to calculate the width of a string. Is this possible without having to use a monospace typeface?\nIf it's not built-in, my only idea is to create a table of widths for each character, but this is pretty unreasonable especially supporting Unicode and di...
What could be the cause of JVM thread dumps that show threads waiting to lock on a monitor, but the monitors do not have corresponding locking threads? Java 1.5_14 on Windows 2003
When you observe JVM thread dumps showing threads waiting to acquire a lock on a monitor but with no threads holding those monitors, it can indicate several potential issues. Here are some common causes: 1. **Deadlocks**: It's possible that a deadlock has occurred, where two or more threads are waiting for each other ...
11,919
[ { "from": "human", "value": "What could be the cause of JVM thread dumps that show threads waiting to lock on a monitor, but the monitors do not have corresponding locking threads? \nJava 1.5_14 on Windows 2003\n" }, { "from": "gpt", "value": "When you observe JVM thread dumps showing threads w...
I've been learning Squeak Smalltalk & have noticed that it's got a really faithful community and is used in some large academic and open-source projects, but I haven't found any examples of it being used commercially in any significant way. I'm curious about how this environment is doing in the world commercially. Mayb...
Squeak Smalltalk is indeed a strong and vibrant community, and while its commercial use might not be as widespread as some other languages, it has found its niche in certain areas. Here are some aspects to consider regarding its commercial application: 1. **Education and Research**: Squeak is often used in academic se...
13,741
[ { "from": "human", "value": "I've been learning Squeak Smalltalk & have noticed that it's got a really faithful community and is used in some large academic and open-source projects, but I haven't found any examples of it being used commercially in any significant way. I'm curious about how this environment...
Does anyone know of a good example of how to expose a WCF service programatically without the use of a configuration file? I know the service object model is much richer now with WCF, so I know it's possible. I just have not seen an example of how to do so. Conversely, I would like to see how consuming without a config...
Certainly! You can expose and consume a WCF service programmatically without relying on a configuration file by setting up the service host and client directly in code. Below is a simplified example demonstrating how to achieve this. ### Exposing a WCF Service Programmatically 1. **Define the Service Contract**: ...
11,551
[ { "from": "human", "value": "Does anyone know of a good example of how to expose a WCF service programatically without the use of a configuration file? I know the service object model is much richer now with WCF, so I know it's possible. I just have not seen an example of how to do so. Conversely, I would l...
I've got an Apache server that has one access log file that is topping 600MB. This makes it really hard to search the file or parse it. What software or modules for Apache are available that will make a daily copy of my access file to make it more manageable?
To manage large Apache access log files, you can utilize log rotation, which allows you to create daily copies of your access logs, thereby keeping them at a more manageable size. Here are several methods and tools you can use to achieve this: ### 1. **Logrotate** Logrotate is a system utility that manages the automat...
10,602
[ { "from": "human", "value": "I've got an Apache server that has one access log file that is topping 600MB. This makes it really hard to search the file or parse it.\nWhat software or modules for Apache are available that will make a daily copy of my access file to make it more manageable?\n" }, { "...
I'm toying with the idea of volumetric particles. By 'volumetric' I don't mean actually 3D model per particle - usually it's more expensive and harder to blend with other particles. What I mean is 2D particles that will look as close as possible to be volumetric. Right now what I/we have tried is particles with addi...
Creating a volumetric appearance using 2D particles is an intriguing challenge, especially for effects like smoke, dust, and clouds. Here are some ideas and considerations for achieving this look, particularly focusing on your lighting and blending approach: ### 1. **Lighting Model for Particles** You might consider a...
3,653
[ { "from": "human", "value": "I'm toying with the idea of volumetric particles. By 'volumetric' I don't mean actually 3D model per particle - usually it's more expensive and harder to blend with other particles. What I mean is 2D particles that will look as close as possible to be volumetric.\nRight now w...
Coming from J2ME programming are there any similarities that would make it easy to adapt to Android API. Or is Android API completely different from the J2ME way of programming mobile apps.
Transitioning from J2ME (Java 2 Micro Edition) to Android development can be both challenging and straightforward, depending on your experience and the specific aspects of J2ME you have worked with. Here are some similarities and differences that may affect your adaptation: ### Similarities: 1. **Java Language**: ...
10,268
[ { "from": "human", "value": "Coming from J2ME programming are there any similarities that would make it easy to adapt to Android API. Or is Android API completely different from the J2ME way of programming mobile apps. \n" }, { "from": "gpt", "value": "Transitioning from J2ME (Java 2 Micro Editi...
I have an Asset object that has a property AssignedSoftware, which is a collection. I want to make sure that the same piece of Software is not assigned to an Asset more than once. In Add method I check to see if the Software already exist, and if it does, I want to throw an exception. Is there a standard .NET excep...
In .NET, the choice of exception to throw when a specific condition is not met often depends on the context of your application and the nature of the error. For the scenario you described—preventing duplicate assignments of software to an asset—you have a couple of common options: ### Standard .NET Exceptions 1. **In...
12,347
[ { "from": "human", "value": "I have an Asset object that has a property AssignedSoftware, which is a collection. \nI want to make sure that the same piece of Software is not assigned to an Asset more than once. In Add method I check to see if the Software already exist, and if it does, I want to throw an ...
I want my Ruby program to do different things on a Mac than on Windows. How can I find out on which system my program is running?
In Ruby, you can determine the operating system by using the built-in `RbConfig` module or the `RUBY_PLATFORM` constant. Here's how you can do this: ### Using `RbConfig` You can use the `RbConfig` module to check the OS like this: ```ruby require 'rbconfig' case RbConfig::CONFIG['host_os'] when /darwin/ puts "Run...
14,568
[ { "from": "human", "value": "I want my Ruby program to do different things on a Mac than on Windows. How can I find out on which system my program is running?\n" }, { "from": "gpt", "value": "In Ruby, you can determine the operating system by using the built-in `RbConfig` module or the `RUBY_PLA...
I want to use Vim's quickfix features with the output from Visual Studio's devenv build process or msbuild. I've created a batch file called build.bat which executes the devenv build like this: devenv MySln.sln /Build Debug In vim I've pointed the :make command to that batch file: :set makeprg=build.bat When I now ru...
It looks like you've successfully navigated through the configuration to use Vim's quickfix feature with the output from Visual Studio's `devenv` or `msbuild`. To summarize your solution for anyone else who might be facing a similar situation: 1. **Using `msbuild`:** You've discovered that `msbuild` can be more effi...
12,989
[ { "from": "human", "value": "I want to use Vim's quickfix features with the output from Visual Studio's devenv build process or msbuild.\nI've created a batch file called build.bat which executes the devenv build like this:\ndevenv MySln.sln /Build Debug\n\nIn vim I've pointed the :make command to that batc...
Has anyone got any suggestions for unit testing a Managed Application Add-In for Office? I'm using NUnit but I had the same issues with MSTest. The problem is that there is a .NET assembly loaded inside the Office application (in my case, Word) and I need a reference to that instance of the .NET assembly. I can't jus...
Unit testing a Managed Application Add-In for Office, especially when it heavily relies on the host application's context (like Microsoft Word), can be quite tricky. Given the nature of Office Add-Ins, there are a few strategies you could consider to make unit testing more manageable: ### 1. Use Dependency Injection ...
11,122
[ { "from": "human", "value": "Has anyone got any suggestions for unit testing a Managed Application Add-In for Office? I'm using NUnit but I had the same issues with MSTest.\nThe problem is that there is a .NET assembly loaded inside the Office application (in my case, Word) and I need a reference to that i...
Can I rename a folder in Perforce from //depot/FooBar/ to //depot/Foobar/? I've tried this by renaming from //depot/FooBar/ to //depot/Temp/ to //Depot/Foobar/ but the end result ends up the same as //depot/FooBar/.
In Perforce, folder names are case-sensitive on some operating systems, but it may not allow you to rename a folder just by changing its case due to potential issues with the underlying file system or because it interprets it as the same path. To rename a folder from `//depot/FooBar/` to `//depot/Foobar/` and ensure t...
13,507
[ { "from": "human", "value": "Can I rename a folder in Perforce from //depot/FooBar/ to //depot/Foobar/?\nI've tried this by renaming from //depot/FooBar/ to //depot/Temp/ to //Depot/Foobar/ but the end result ends up the same as //depot/FooBar/.\n" }, { "from": "gpt", "value": "In Perforce, fold...
I need to be able to get a list of the groups a user is in, but I need to have one/some/all of the following properties visible: distinguishedname name cn samaccountname What I have right now returns some sort of name, but not any of the ones above (the names seem close, but don't all match correctly. This is what I...
To retrieve a list of groups a user is in, along with specific properties like `distinguishedName`, `name`, `cn`, and `samAccountName`, you need to leverage the Active Directory (AD) through the `DirectoryServices` namespace in .NET. The issue with your current implementation is that it only retrieves the group names ...
6,566
[ { "from": "human", "value": "I need to be able to get a list of the groups a user is in, but I need to have one/some/all of the following properties visible:\n\ndistinguishedname\nname\ncn\nsamaccountname\n\nWhat I have right now returns some sort of name, but not any of the ones above (the names seem close...
I'm writing an inner loop that needs to place structs in contiguous storage. I don't know how many of these structs there will be ahead of time. My problem is that STL's vector initializes its values to 0, so no matter what I do, I incur the cost of the initialization plus the cost of setting the struct's members to ...
In C++, when you use `std::vector::resize()`, it initializes new elements to their default constructor, which in the case of primitive types initializes them to zero, thus incurring unnecessary costs. If you want to add elements to a vector without default initializing them, you have a few options. ### Option 1: Use ...
9,721
[ { "from": "human", "value": "I'm writing an inner loop that needs to place structs in contiguous storage. I don't know how many of these structs there will be ahead of time. My problem is that STL's vector initializes its values to 0, so no matter what I do, I incur the cost of the initialization plus the...
How to make database connection pool in PowerBuilder (v9+) with... ...ODBC? ...SQL Server? ...Oracle?
Creating a database connection pool in PowerBuilder using ODBC, SQL Server, or Oracle requires a structured approach. Below is a general guide for each of these database types. ### 1. Using ODBC PowerBuilder can use ODBC to connect to various databases. Here's how you can set up a connection pool: #### Steps: 1. **...
10,020
[ { "from": "human", "value": "How to make database connection pool in PowerBuilder (v9+) with...\n\n...ODBC?\n...SQL Server?\n...Oracle?\n\n" }, { "from": "gpt", "value": "Creating a database connection pool in PowerBuilder using ODBC, SQL Server, or Oracle requires a structured approach. Below i...
I need to manipulate 100,000 - 200,000 records. I am thinking of using LINQ (to SQL) to do this. I know from experience that filtering dataviews is very slow. So how quick is LINQ? Can you please tell me your experiences and if it is worth using, or would I be better off using SQL stored procedures (heavy going and le...
When working with large datasets, the choice between using LINQ to SQL and SQL stored procedures depends on several factors, including performance, maintainability, and the specific operations you need to perform on the data. ### Performance Considerations 1. **LINQ to SQL:** - **Ease of Use:** LINQ provides a mor...
9,349
[ { "from": "human", "value": "I need to manipulate 100,000 - 200,000 records.\nI am thinking of using LINQ (to SQL) to do this.\nI know from experience that filtering dataviews is very slow.\nSo how quick is LINQ?\n\nCan you please tell me your experiences and if it is worth using, or would I be better off u...
I'm looking for a common pattern that will store and access global addresses in database. Components or other technologies can be used. The following criteria must be adheard to... Every line of the address is saved for every country Postal codes are tested with a regular expression before being saved Country of ori...
To meet your requirements for storing and accessing global addresses in a database while ensuring data integrity and usability, we can design a solution that encompasses a structured database schema, regular expression validation, dynamic form generation, and localized formatting. Here’s a proposed architecture and wor...
7,208
[ { "from": "human", "value": "I'm looking for a common pattern that will store and access global addresses in database. Components or other technologies can be used. The following criteria must be adheard to...\n\nEvery line of the address is saved for every country \nPostal codes are tested with a regular e...
I want to run text through a filter to ensure it is all UTF-8 encoded. What is the recommended way to do this with PHP?
To ensure that a string is valid UTF-8 encoded in PHP, you can use the `mb_check_encoding` function. This function checks if the provided string is encoded in a specified character encoding, which in this case is UTF-8. Here's a simple example of how you can use this function to check and filter your text: ```php fun...
9,981
[ { "from": "human", "value": "I want to run text through a filter to ensure it is all UTF-8 encoded. What is the recommended way to do this with PHP?\n" }, { "from": "gpt", "value": "To ensure that a string is valid UTF-8 encoded in PHP, you can use the `mb_check_encoding` function. This functio...