instruction
stringlengths
14
27.6k
completion
stringlengths
3
38.3k
__original_row_idx
int64
0
50k
conversations
listlengths
2
2
I'm setting up a simple SQLite database to hold sensor readings. The tables will look something like this: sensors - id (pk) - name - description - units sensor_readings - id (pk) - sensor_id (fk to sensors) - value (actual sensor value stored here) - time (date/time the sensor sample was taken) ...
Your database design is a solid start for storing sensor readings. To ensure that your queries remain efficient as the `sensor_readings` table grows, there are several strategies you can employ without resorting to creating separate tables for each sensor. Here are the key points to consider: ### 1. Indexing Creating ...
19,486
[ { "from": "human", "value": "I'm setting up a simple SQLite database to hold sensor readings. The tables will look something like this:\nsensors \n - id (pk) \n - name \n - description\n - units \n\nsensor_readings \n - id (pk) \n - sensor_id (fk to sensors) \n - value (actual sensor value stored her...
I have a friend who is need of a web page. He does interior construction, and would like to have a gallery of his work. I'll probably go for a php host, and was thinking about the best way to implement the image gallery for him. I came up with: Use flickr to host the images. They can be tagged, added to sets, and ...
Using Flickr to host images for an interior construction portfolio can be a good idea due to its features, but there are several aspects to consider. Let's address each of your points: ### Using Flickr for Hosting Images Flickr offers features like tagging and organizing images into sets, which could be useful for cat...
16,090
[ { "from": "human", "value": "I have a friend who is need of a web page. He does interior construction, and would like to have a gallery of his work. I'll probably go for a php host, and was thinking about the best way to implement the image gallery for him. I came up with:\n\nUse flickr to host the image...
Hiya I am working on an FTP client, can someone tell me the difference in speed and efficiency for using WebRequest and sockets (direct network streams) to download and upload files on the FTP server. (Our files will be video streams.) I am using C#3.5.
When developing an FTP client in C# 3.5, you have two main options for handling file transfers: using the `WebRequest` class or working directly with sockets (network streams). Each approach has its pros and cons regarding speed, efficiency, ease of implementation, and flexibility. Here's a breakdown: ### WebRequest A...
20,338
[ { "from": "human", "value": "Hiya I am working on an FTP client, can someone tell me the difference in speed and efficiency for using WebRequest and sockets (direct network streams) to download and upload files on the FTP server. (Our files will be video streams.) \nI am using C#3.5.\n" }, { "from":...
I have the source of a program (taken from cvs/svn/git/...) and I'd like to build a Debian/Ubuntu package for it. The package is present in the repositories, but: It is an older version (lacking features I need) I need slightly different compile options than the default. What is the easiest way of doing it? I am conc...
Building a custom Debian/Ubuntu package from source can be straightforward if you follow a few steps. Here's how to address your concerns while creating your custom package: ### Steps to Create a Custom Debian/Ubuntu Package 1. **Set Up Your Build Environment**: Make sure you have the necessary tools for building ...
15,426
[ { "from": "human", "value": "I have the source of a program (taken from cvs/svn/git/...) and I'd like to build a Debian/Ubuntu package for it. The package is present in the repositories, but:\n\nIt is an older version (lacking features I need)\nI need slightly different compile options than the default.\n\n...
I have a colleague who is looking into opcode caching/Zend Acceleration (I've always assumed these are the same thing) for our PHP based application. His Benchmarks appear to indicate that we're NOT seeing a performance benefit if we include our (large) class libraries with require_once, but we DO see the performance ...
It's great that you're investigating performance optimization for your PHP application, especially with regards to opcode caching and inclusion patterns. While opcode caching (such as with Opcache or Zend Acceleration) generally aims to improve performance by caching the compiled bytecode of PHP scripts, the behavior y...
21,778
[ { "from": "human", "value": "I have a colleague who is looking into opcode caching/Zend Acceleration (I've always assumed these are the same thing) for our PHP based application. His Benchmarks appear to indicate that we're NOT seeing a performance benefit if we include our (large) class libraries with req...
Can I run the python interpreter without generating the compiled .pyc files?
Yes, you can run the Python interpreter without generating the compiled `.pyc` files. This can be achieved by using the `-B` option when you start the Python interpreter. The `-B` option tells Python not to write `.pyc` files, which are the bytecode compiled versions of your Python scripts. Here's how you can do it: ...
21,596
[ { "from": "human", "value": "Can I run the python interpreter without generating the compiled .pyc files?\n" }, { "from": "gpt", "value": "Yes, you can run the Python interpreter without generating the compiled `.pyc` files. This can be achieved by using the `-B` option when you start the Python...
If I have a string (010) and i want to add 1 to it (011) what value type should i use to convert this string into a number for adding and at the same time preserve the whole number and not 10 + 1 = 11.
To achieve your goal of adding 1 to the binary string `010` while preserving its representation as a three-bit binary number (resulting in `011`), you can use integer arithmetic and then convert it back to a binary string. Here's how you can do this in Python: 1. Convert the binary string to an integer. 2. Add 1 to th...
21,250
[ { "from": "human", "value": "If I have a string (010) and i want to add 1 to it (011) what value type should i use to convert this string into a number for adding and at the same time preserve the whole number and not 10 + 1 = 11. \n" }, { "from": "gpt", "value": "To achieve your goal of adding ...
I would really like to annotate a method with a reference to a single property in a property file for injection. @Resource("${my.service.url}") private String myServiceUrl; Of course, this syntax does not work ;) Thats why I'm asking here. I am aware that I can inject the full properties file, but that just seems exce...
In Spring, injecting property values directly into fields using annotations does not allow for the same syntax as in XML configurations. However, you can achieve the desired outcome by using the `@Value` annotation. Here’s how you can do it: 1. Ensure that you have the property file loaded in your Spring context. You...
22,782
[ { "from": "human", "value": "I would really like to annotate a method with a reference to a single property in a property file for injection.\n@Resource(\"${my.service.url}\")\nprivate String myServiceUrl;\n\nOf course, this syntax does not work ;) Thats why I'm asking here.\nI am aware that I can inject th...
I've implemented a .NET Web control that uses the callback structure implemented in ASP.Net 2.0. It's an autodropdown control, and it works correctly in IE 6.0/7.0 and Google Chrome. Here's the relevant callback function: function ReceiveServerData(args, context) { document.getElementById(context).style.zIndex = 300;...
It sounds like you're encountering an issue specific to Firefox regarding the handling of AJAX callbacks in your custom dropdown control. Since the `ReceiveServerData` function is being called with old data after the first keystroke, there are a few potential issues to investigate: ### 1. Caching Issue Firefox might b...
21,211
[ { "from": "human", "value": "I've implemented a .NET Web control that uses the callback structure implemented in ASP.Net 2.0. It's an autodropdown control, and it works correctly in IE 6.0/7.0 and Google Chrome. Here's the relevant callback function:\nfunction ReceiveServerData(args, context)\n{\ndocument...
Internet Explorer (from versions 4 to 7, at least) limits the number of files uploaded using a single 'input type="file"' form field to one. What is the best approach to take if I want to upload more than one file in a single HTTP POST request?
To allow users to upload multiple files in a single HTTP POST request, you can employ a few strategies. Here are some of the best approaches: 1. **Multiple File Input Fields**: You can create multiple `<input type="file">` fields in your HTML form. This allows the user to select more than one file across different inp...
15,796
[ { "from": "human", "value": "Internet Explorer (from versions 4 to 7, at least) limits the number of files uploaded using a single 'input type=\"file\"' form field to one. What is the best approach to take if I want to upload more than one file in a single HTTP POST request?\n" }, { "from": "gpt", ...
Suppose I've got the following program: namespace ReflectionTest { public class Example { private string field; public void MethodOne() { } public void MethodTwo() { } public string Property { get { return field; } set { this.field = value; } ...
In your situation, since you are working with .NET 2.0, using LINQ is indeed not an option. Instead, as you discovered, filtering out property accessors by checking the `IsSpecialName` property of `MethodInfo` is the correct approach. Unfortunately, there is no specific `BindingFlags` that excludes property accessors ...
23,563
[ { "from": "human", "value": "Suppose I've got the following program:\nnamespace ReflectionTest\n{\n public class Example\n {\n private string field;\n\n public void MethodOne() { }\n\n public void MethodTwo() { }\n\n public string Property\n {\n get { retu...
Does anyone know if there is a debug visualiser for this yet along the same lines and the linq to SQL debug visualiser?
If you're looking for a debug visualizer similar to the LINQ to SQL debug visualizer, you might want to check out various options depending on the specific framework or technology you're working with. Here are a few general suggestions: 1. **Entity Framework Visualizers**: If you're using Entity Framework, there are t...
23,419
[ { "from": "human", "value": "Does anyone know if there is a debug visualiser for this yet along the same lines and the linq to SQL debug visualiser?\n" }, { "from": "gpt", "value": "If you're looking for a debug visualizer similar to the LINQ to SQL debug visualizer, you might want to check out ...
I need to serialize an object to JSON. I'm using jQuery. Is there a "standard" way to do this? My specific situation: I have an array defined as shown below: var countries = new Array(); countries[0] = 'ga'; countries[1] = 'cd'; ... and I need to turn this into a string to pass to $.ajax() like this: $.ajax({ type...
To serialize your array to JSON in a way that can be passed to `$.ajax()`, you can use the built-in `JSON.stringify()` method. In your specific case, instead of manually creating the string for the `data` property, you can construct an object and then serialize it to JSON. Here's how you can do it: 1. Create an objec...
23,659
[ { "from": "human", "value": "I need to serialize an object to JSON. I'm using jQuery. Is there a \"standard\" way to do this?\nMy specific situation: I have an array defined as shown below:\nvar countries = new Array();\ncountries[0] = 'ga';\ncountries[1] = 'cd';\n...\n\nand I need to turn this into a strin...
I am developing a Compact Framework 3.5 application for Windows CE 6.0. Help.ShowHelp() throws a NotSupportedException. At windowsembedded.com I found this statement: "Help is not included in the Core run-time because it requires a browser." Is this the reason for the exception? If so, is there any recommended way t...
Yes, the `NotSupportedException` you are encountering when calling `Help.ShowHelp()` in a Compact Framework 3.5 application on Windows CE 6.0 is due to the fact that the Help functionality relies on a browser for rendering the help content. As stated in your source, the Compact Framework does not include support for He...
20,460
[ { "from": "human", "value": "I am developing a Compact Framework 3.5 application for Windows CE 6.0. Help.ShowHelp() throws a NotSupportedException. At windowsembedded.com I found this statement:\n\"Help is not included in the Core run-time because it requires a browser.\"\nIs this the reason for the exce...
I would like display something more meaningful that animated gif while users upload file to my web application. What possibilities do I have? Edit: I am using .Net but I don't mind if somebody shows me platform agnostic version.
When users upload files to a web application, providing them with a meaningful and engaging experience during the upload process is essential. Here are several alternatives to using an animated GIF that you can implement in your .NET application, but these suggestions are generally platform-agnostic: ### 1. **Progress...
13,821
[ { "from": "human", "value": "I would like display something more meaningful that animated gif while users upload file to my web application. What possibilities do I have? \nEdit: I am using .Net but I don't mind if somebody shows me platform agnostic version.\n" }, { "from": "gpt", "value": "Whe...
I have a image upload form that should take image types (PNG, JPEG, GIF), resize it and then save it to a path. For some reason I can't get the PNG file types to work, it works fine with JPEG/GIF and the file is copied so it looks like it's something to do with how I'm creating the PNG. Does PNG creation in PHP requi...
When dealing with PNG images in PHP, there are a few key considerations and differences compared to JPEG and GIF formats. Here’s how you can ensure that your PNG handling works correctly in your code: 1. **File Transparency**: PNG supports transparency, which can lead to issues if not handled correctly when creating a...
19,674
[ { "from": "human", "value": "I have a image upload form that should take image types (PNG, JPEG, GIF), resize it and then save it to a path. \nFor some reason I can't get the PNG file types to work, it works fine with JPEG/GIF and the file is copied so it looks like it's something to do with how I'm creatin...
Anybody know what my DLLImport statement should look like here: extern "C" __declspec(dllexport) long SomeFunction(VARIANT *argNames, VARIANT *argValues, VARIANT *pVal) { ... }
When using `DllImport` in C# to call a C++ function that's defined like the one you provided (`extern "C" __declspec(dllexport) long SomeFunction(VARIANT *argNames, VARIANT *argValues, VARIANT *pVal)`), you need to ensure that you're properly marshaling the VARIANT types. Here's how you can define your `DllImport` st...
11,252
[ { "from": "human", "value": "Anybody know what my DLLImport statement should look like here:\nextern \"C\" __declspec(dllexport) long SomeFunction(VARIANT *argNames, VARIANT *argValues, VARIANT *pVal)\n{\n...\n}\n\n" }, { "from": "gpt", "value": "When using `DllImport` in C# to call a C++ functi...
what is the best way of displaying/using the revision number in a java webapp? we just use ant to build our .war archive, no buildserver or such. i'd hope there was some kind if $ref that i could write in a resource file, but this is only updated when the file in question is committed. i need it globally. what would yo...
Displaying or using the revision number in a Java web application can be accomplished in several ways, especially since you're using Ant to build your `.war` archive. Here are a few approaches to consider, including both non-hacky and more custom solutions. ### 1. **Use SVN Keywords** Subversion supports the use of ke...
19,233
[ { "from": "human", "value": "what is the best way of displaying/using the revision number in a java webapp?\nwe just use ant to build our .war archive, no buildserver or such. i'd hope there was some kind if $ref that i could write in a resource file, but this is only updated when the file in question is co...
I have a web service running, and it uses Spring.NET for it's IoCness. One of the classes needs to do some stuff when it loads (I'm using AfterPropertiesSet) and "some stuff" involves a call to ContextRegistry.GetContext(). The problem is this code in the ContextRegistry class: if (rootContextCurrentlyInCreation) { ...
In Spring.NET, when you encounter a situation where you need to wait for the context to be fully created before performing certain actions (like fetching the context using `ContextRegistry.GetContext()`), you can implement a workaround by using a combination of lifecycle callbacks and bean post-processing. Here’s a ge...
18,590
[ { "from": "human", "value": "I have a web service running, and it uses Spring.NET for it's IoCness. One of the classes needs to do some stuff when it loads (I'm using AfterPropertiesSet) and \"some stuff\" involves a call to ContextRegistry.GetContext(). The problem is this code in the ContextRegistry cla...
I see Oracle procedures sometimes written with "AS", and sometimes with "IS" keyword. CREATE OR REPLACE Procedure TESTUSER.KILLINSTANCE (INSTANCEID integer) **AS** ... vs. CREATE OR REPLACE Procedure TESTUSER.KILLINSTANCE (INSTANCEID integer) **IS** ... Is there any difference between the two? Edit: Apparently, the...
You're correct that there is no functional difference between using `AS` and `IS` in the context of defining PL/SQL procedures or functions. Both keywords serve the same purpose, which is to introduce the declaration section of the procedure or function. The choice between using `AS` and `IS` often comes down to perso...
24,089
[ { "from": "human", "value": "I see Oracle procedures sometimes written with \"AS\", and sometimes with \"IS\" keyword. \nCREATE OR REPLACE Procedure TESTUSER.KILLINSTANCE (INSTANCEID integer) **AS**\n...\n\nvs.\nCREATE OR REPLACE Procedure TESTUSER.KILLINSTANCE (INSTANCEID integer) **IS**\n...\n\nIs there a...
I am looking for a relatively good and well supported, and preferably open source blog application that runs on ASP.NET and SQL Server. It doesn’t need to be packed full of features, it just needs the basics, such as tagging, comments, etc. Extra features are a bonus. I would also like it to be either open source or ha...
Here are several well-supported, open-source blog applications that run on ASP.NET and SQL Server, which you may find suitable for your needs: ### 1. BlogEngine.NET - **Link:** [BlogEngine.NET GitHub](https://github.com/rjkjr/BlogEngine.NET) - **Highlights:** - Easy to install and set up. - Supports multiple theme...
19,846
[ { "from": "human", "value": "I am looking for a relatively good and well supported, and preferably open source blog application that runs on ASP.NET and SQL Server. It doesn’t need to be packed full of features, it just needs the basics, such as tagging, comments, etc. Extra features are a bonus.\nI would a...
I want to automate a Windows 2000+ server reboot process using Task Scheduler or similar tool to remotely reboot a server and wait for it to come back up. I can issue shutdown or psshutdown to remotely reboot, but I want something better than sleep to wait for it to come back. I need to verify it is back online withi...
Automating a server reboot process along with a reliable mechanism to check if the server is back online is a good idea for server maintenance. Here’s a way you can achieve this using a combination of a batch script and PowerShell. ### Step 1: Prepare the Batch Script 1. Create a batch script (e.g., `RebootServer.bat...
18,846
[ { "from": "human", "value": "I want to automate a Windows 2000+ server reboot process using Task Scheduler or similar tool to remotely reboot a server and wait for it to come back up. I can issue shutdown or psshutdown to remotely reboot, but I want something better than sleep to wait for it to come back. ...
I installed Tomcat 6.0.18 on a windows server 2003 box and it will not start as a service. I'm running it with jdk 1.6.0_07. It runs when I start it with tomcat6.exe. I got a vague error in the System Event Log on Windows. The Apache Tomcat 6 service terminated with service-specific error 0 (0x0).
When Apache Tomcat fails to start as a service on Windows but runs fine when started manually, it can be frustrating. Here are some steps to troubleshoot and resolve the issue: ### 1. Check the Service Configuration - Make sure that the service is configured correctly. You can do this by accessing the service properti...
18,559
[ { "from": "human", "value": "I installed Tomcat 6.0.18 on a windows server 2003 box and it will not start as a service.\nI'm running it with jdk 1.6.0_07.\nIt runs when I start it with tomcat6.exe.\nI got a vague error in the System Event Log on Windows.\nThe Apache Tomcat 6 service terminated with service-...
We have a web application that was implemented using GWT. What it presents is fetched from a Jboss/Seam server using the remoting mechanism, and this works fine. However, the application is now extended to support sessions and users. The Seam GWT service doesn't seem to provide a way to let me log in such that Seam can...
Integrating GWT with a Seam backend for user sessions can be a bit challenging, but it's definitely feasible. Let's clarify the core concepts and outline how you can approach this problem. ### Seam and GWT Integration Seam is designed to simplify the development of web applications and facilitates session management,...
18,150
[ { "from": "human", "value": "We have a web application that was implemented using GWT. What it presents is fetched from a Jboss/Seam server using the remoting mechanism, and this works fine. However, the application is now extended to support sessions and users. The Seam GWT service doesn't seem to provide ...
Is there a freely available Base64 decoding code snippet in C++?
Yes, you can easily implement a Base64 decoding function in C++. Below is a simple code snippet that demonstrates how to decode a Base64-encoded string. This implementation does not rely on any external libraries and is freely available for use. ```cpp #include <iostream> #include <string> #include <vector> #include <...
18,304
[ { "from": "human", "value": "Is there a freely available Base64 decoding code snippet in C++?\n" }, { "from": "gpt", "value": "Yes, you can easily implement a Base64 decoding function in C++. Below is a simple code snippet that demonstrates how to decode a Base64-encoded string. This implementat...
What is the maximum length for the text string contained in a CEdit control in MFC? I get a beep when trying to add a character after the character 30001 is this documented anywhere? Can I display longer texts in a CEdit? Should I use another control? As "Windows programmer" says down below, the text length limit is no...
In MFC (Microsoft Foundation Class), the `CEdit` control does indeed impose some limits on the length of text that can be entered or set programmatically. ### Maximum Length of Text in `CEdit` 1. **User Input Limit**: By default, the `CEdit` control limits user input to 32,767 characters. This limit is generally tie...
17,965
[ { "from": "human", "value": "What is the maximum length for the text string contained in a CEdit control in MFC? I get a beep when trying to add a character after the character 30001 is this documented anywhere? Can I display longer texts in a CEdit? Should I use another control?\nAs \"Windows programmer\" ...
Believe it or not I need a way of displaying animated gifs in Flex 3. This guy has a component for sale but it's Flex 2 only: http://dougmccune.com/blog/2007/01/19/how-to-load-animated-gifs-using-adobe-flex-20/. And I’ve implemented this example: http://www.bytearray.org/?p=95, but for larger gifs it’s very CPU intensi...
Displaying animated GIFs in Flex 3 can be challenging, especially since the existing solutions might not perform well with larger files. Here are a few alternatives and suggestions that could help: 1. **Use a Third-Party Library**: Consider using a library that might be more efficient in handling GIFs. Libraries like ...
20,993
[ { "from": "human", "value": "Believe it or not I need a way of displaying animated gifs in Flex 3. This guy has a component for sale but it's Flex 2 only: http://dougmccune.com/blog/2007/01/19/how-to-load-animated-gifs-using-adobe-flex-20/.\nAnd I’ve implemented this example: http://www.bytearray.org/?p=95,...
I am trying to call a WCF webservice (which I developed) from a Silverlight application. For some reason the Silverlight app does not make the http soap call to the service. I know this because I am sniffing all http traffic with Fiddler (and it is not a localhost call). This my configuration in the server relevant to ...
It looks like you're trying to call a WCF service from a Silverlight application, but the service call is not being made. Here are a few things to check and suggestions to help troubleshoot and resolve the issue: ### 1. **Cross-Domain Policy**: Silverlight applications run in a sandboxed environment, and they must com...
13,143
[ { "from": "human", "value": "I am trying to call a WCF webservice (which I developed) from a Silverlight application. For some reason the Silverlight app does not make the http soap call to the service. I know this because I am sniffing all http traffic with Fiddler (and it is not a localhost call).\nThis m...
Given this: Public Sub timReminder_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) If DateTime.Now() > g_RemindTime Then Reminders.ShowDialog() timReminder.Enabled = False End If End Sub I want to be able to say this (as I would in Delphi): timReminder.Tick = timReminder_Tick ...
In VB.NET, you can assign a method to the `Tick` event of a Timer control at runtime. This is done using the `AddHandler` statement. Here’s how you can do it: 1. First, ensure your Timer control is properly declared and instantiated. 2. Then, use `AddHandler` to associate your custom event handler with the Timer's `T...
22,644
[ { "from": "human", "value": "Given this:\nPublic Sub timReminder_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)\n If DateTime.Now() > g_RemindTime Then\n Reminders.ShowDialog()\n timReminder.Enabled = False\n End If\nEnd Sub\n\nI want to be able to say this (as I would ...
Before you start firing at me, I'm NOT looking to do this, but someone in another post said it was possible. How is it possible? I've never heard of inheriting from anything using reflection. But I've seen some strange things...
It sounds like you’re curious about the possibilities of reflection in programming, specifically how it can be used to work with inheritance and object-oriented concepts. Reflection is a feature in many programming languages (like Java, C#, and Python) that allows you to inspect and interact with program elements at ru...
18,976
[ { "from": "human", "value": "Before you start firing at me, I'm NOT looking to do this, but someone in another post said it was possible. How is it possible? I've never heard of inheriting from anything using reflection. But I've seen some strange things...\n" }, { "from": "gpt", "value": "It so...
I was looking at the Ruby logging library Logging.logger method and have a question from the source at github relating to this piece of code: logger = ::Logging::Logger.new(name) logger.add_appenders appender logger.additive = false class << logger def close @appenders.each {|a| a.close} h = ::...
The line `class << self; undef :close; end` is a Ruby idiom used to undefine a method from the singleton class of the object `logger`. Here’s a breakdown of what’s happening in your code snippet: 1. **Eigenclass/Singeon Class Context**: The `class << logger` syntax opens up the singleton class (also known as the eigen...
22,300
[ { "from": "human", "value": "I was looking at the Ruby logging library Logging.logger method and have a question from the source at github relating to this piece of code:\n logger = ::Logging::Logger.new(name)\n logger.add_appenders appender\n logger.additive = false\n\n class << logger\n def close\n...
What is the best way to persist/save printer settings in .Net? There used to be a bug in .Net 1.1 in the serialization of the PrinterSetting object and there were some workarounds but I'm wondering if there isn't a better or easier way of doing this in the more recent versions of the framework. The main use case is to ...
Persisting printer settings in .NET can indeed be a bit tricky, especially considering some of the historical issues with the `PrinterSettings` class in .NET Framework. However, recent versions of .NET have improved capabilities for handling printer settings more reliably. Here are some strategies you can use to persi...
17,623
[ { "from": "human", "value": "What is the best way to persist/save printer settings in .Net?\nThere used to be a bug in .Net 1.1 in the serialization of the PrinterSetting object and there were some workarounds but I'm wondering if there isn't a better or easier way of doing this in the more recent versions ...
I'm developing and application that runs as a Windows service. There are other components which include a few WCF services, a client GUI and so on - but it is the Windows service that access the database. So, the application is a long-running server, and I'd like to improve its performance and scalability, I was lookin...
Managing a long-running Windows service that interacts with a database through NHibernate can indeed introduce complexities, especially when it comes to session management and performance optimization. Here are some suggestions to improve your current design: ### Session Management 1. **Use a Single Session per Long-...
15,073
[ { "from": "human", "value": "I'm developing and application that runs as a Windows service. There are other components which include a few WCF services, a client GUI and so on - but it is the Windows service that access the database.\nSo, the application is a long-running server, and I'd like to improve its...
I'm writing a program and am having trouble using the scanf and fopen working together. From what I can tell my erroneous lines seems to be: FiLE * DataFile DataFile = fopen("StcWx.txt","r"); scanf(DataFile, "%i %i %i %.2f %i %i", &Year, &Month, &Day, &Precip, &High, &Low); The file it opens from has a list of weather...
The issue you're encountering is related to how you're using `scanf` and `fopen`. The `scanf` function is used to read input from the standard input (usually the keyboard), while `fopen` is used to open files. To read data from a file, you should use the `fscanf` function instead of `scanf`. Here’s how you can modify ...
20,754
[ { "from": "human", "value": "I'm writing a program and am having trouble using the scanf and fopen working together.\nFrom what I can tell my erroneous lines seems to be:\nFiLE * DataFile\nDataFile = fopen(\"StcWx.txt\",\"r\");\nscanf(DataFile, \"%i %i %i %.2f %i %i\", &Year, &Month, &Day, &Precip, &High, &...
Let's say that you have overridden an object's equals() and hashCode() methods, so that they use the object's fields. How you do you check if two references are to the same object, ala the stock equals() method?
In Java, the default `equals()` method from the `Object` class checks if two references point to the same object in memory. If you have overridden the `equals()` method in your class to compare the object's fields, you can still check if two references are to the same object by using the `==` operator. This operator co...
22,216
[ { "from": "human", "value": "Let's say that you have overridden an object's equals() and hashCode() methods, so that they use the object's fields.\nHow you do you check if two references are to the same object, ala the stock equals() method?\n" }, { "from": "gpt", "value": "In Java, the default ...
I have the following piece of code pattern: void M1(string s, string v) { try { // Do some work } catch(Exception ex) { // Encapsulate and rethrow exception } } The only difference is that the return type and the number and types of parameters to the methods can vary. I want to create a generic / t...
You can achieve this by using a generic method with a delegate (or a lambda) to encapsulate the "Do some work" part. This way, you can handle the try-catch logic in a single location and delegate the actual work to a method that you pass in. Here's an example in C# demonstrating this pattern: ```csharp using System; ...
20,290
[ { "from": "human", "value": "I have the following piece of code pattern:\nvoid M1(string s, string v)\n{\n try\n {\n // Do some work\n }\n catch(Exception ex)\n {\n // Encapsulate and rethrow exception\n }\n}\n\nThe only difference is that the return type and the number and types of parameters t...
I collect a few corner cases and brain teasers and would always like to hear more. The page only really covers C# language bits and bobs, but I also find core .NET things interesting too. For example, here's one which isn't on the page, but which I find incredible: string x = new string(new char[0]); string y = new str...
Certainly! Here are some interesting corner cases and quirks in C# and .NET that you may find intriguing: 1. **Null Coalescing with Nullable Types**: ```csharp int? a = null; int b = a ?? 0; // b will be 0 Console.WriteLine(b); ``` The `??` operator provides a default value when the left-hand side is...
18,316
[ { "from": "human", "value": "I collect a few corner cases and brain teasers and would always like to hear more. The page only really covers C# language bits and bobs, but I also find core .NET things interesting too. For example, here's one which isn't on the page, but which I find incredible:\nstring x = n...
I know you can access the Contact Store from the SDk, but is it possible to create and read appointment data?
Yes, it is possible to work with appointment data in some SDKs, particularly those related to mobile platforms like iOS and Android. For example: 1. **iOS**: You can use the EventKit framework to create, read, update, and delete calendar events and reminders. EventKit provides APIs that allow you to interact with the ...
25,237
[ { "from": "human", "value": "I know you can access the Contact Store from the SDk, but is it possible to create and read appointment data?\n" }, { "from": "gpt", "value": "Yes, it is possible to work with appointment data in some SDKs, particularly those related to mobile platforms like iOS and ...
I came from Java, and now I am working more with Ruby. One language feature I am not familiar with is the module. I am wondering what exactly is a module and when do you use one, and why use a module over a class?
In Ruby, a module is a way to group related methods, classes, and constants together. While both modules and classes can contain methods, there are key differences between the two, as well as specific use cases for each. ### Characteristics of Modules: 1. **No Instantiation**: Unlike classes, you cannot create an ins...
18,501
[ { "from": "human", "value": "I came from Java, and now I am working more with Ruby. \nOne language feature I am not familiar with is the module. I am wondering what exactly is a module and when do you use one, and why use a module over a class?\n" }, { "from": "gpt", "value": "In Ruby, a module ...
I want to take the value stored in a 32 bit unsigned int, put it into four chars and then store the integer value of each of these chars in a string. I think the first part goes like this: char a = orig << 8; char b = orig << 8; char c = orig << 8; char d = orig << 8;
It looks like you're trying to split a 32-bit unsigned integer into four separate bytes (chars), but the code snippet you've provided contains a mistake in the way you're shifting the value. Instead of shifting all to the left by 8 bits, you should be shifting it by different amounts to get each byte. Here's how to do...
21,198
[ { "from": "human", "value": "I want to take the value stored in a 32 bit unsigned int, put it into four chars and then store the integer value of each of these chars in a string.\nI think the first part goes like this:\nchar a = orig << 8;\nchar b = orig << 8;\nchar c = orig << 8;\nchar d = orig << 8;\n\n" ...
I have a Flex app that does a a fair amount of network traffic, it uses ExternalInterface to make some javascript calls (for SCORM), it loads XML files, images, video, audio and it has a series of modules that it could be loading at some point... So the problem is - we now have a requirement where the user needs to run...
Running a Flex application locally without the proper security settings can indeed be challenging due to the inherent security model of Flash Player. Here are a few strategies you might consider to allow your application to run without requiring the user to change security settings on their machine: ### 1. **Modify Se...
21,117
[ { "from": "human", "value": "I have a Flex app that does a a fair amount of network traffic, it uses ExternalInterface to make some javascript calls (for SCORM), it loads XML files, images, video, audio and it has a series of modules that it could be loading at some point...\nSo the problem is - we now have...
Due to the lack of clientaccesspolicy.xml, there appears to be problems with using Amazon S3 via Flex. Are there any work arounds? Edit: Both of the below answers are great and work, I've upvoted both (I'm not going to assign an answer to the question as they both work): Can you use Amazon S3 via Flex? Can you use Amaz...
Using Amazon S3 via Flex can indeed be challenging if you're encountering issues related to the lack of a `clientaccesspolicy.xml` file. This file is essential for allowing cross-domain access to resources in S3 when using Flash applications like Flex. Here are some workarounds you might consider: 1. **Use CORS (Cross...
19,317
[ { "from": "human", "value": "Due to the lack of clientaccesspolicy.xml, there appears to be problems with using Amazon S3 via Flex. Are there any work arounds?\nEdit: Both of the below answers are great and work, I've upvoted both (I'm not going to assign an answer to the question as they both work):\nCan y...
I need to add a tooltip/alt to a "td" element inside of my tables with jquery. Can someone help me out? I tried: var tTip ="Hello world"; $(this).attr("onmouseover", tip(tTip)); where I have verified that I am using the "td" as "this". **Edit:**I am able to capture the "td" element through using the "alert" command an...
It looks like you're trying to set up a tooltip for `<td>` elements using jQuery. There are a few things you might want to consider: 1. **Function Invocation**: In your current approach, you're invoking the `tip` function immediately with `tip(tTip)` instead of passing the function as a reference. This means that the ...
21,467
[ { "from": "human", "value": "I need to add a tooltip/alt to a \"td\" element inside of my tables with jquery.\nCan someone help me out?\nI tried:\nvar tTip =\"Hello world\";\n$(this).attr(\"onmouseover\", tip(tTip));\n\nwhere I have verified that I am using the \"td\" as \"this\".\n**Edit:**I am able to cap...
What tools do you use to find unused/dead code in large java projects? Our product has been in development for some years, and it is getting very hard to manually detect code that is no longer in use. We do however try to delete as much unused code as possible. Suggestions for general strategies/techniques (other than ...
Detecting unused or dead code in large Java projects can be challenging, especially when code has been developed over many years. Here are some strategies, techniques, and tools you can use to help identify and remove dead code: ### General Strategies and Techniques: 1. **Dependency Analysis**: Use tools that can per...
14,638
[ { "from": "human", "value": "What tools do you use to find unused/dead code in large java projects? Our product has been in development for some years, and it is getting very hard to manually detect code that is no longer in use. We do however try to delete as much unused code as possible.\nSuggestions for ...
What I'm trying to do is encode a gif file, to include in an XML document. This is what I have now, but it doesn't seem to work. Function gifToBase64(strGifFilename) On Error Resume Next Dim strBase64 Set inputStream = WScript.CreateObject("ADODB.Stream") inputStream.LoadFromFile strGifFilename strBase64 = inputSt...
The issue you're facing arises from the way you're trying to read the GIF file and convert it to a Base64 string. The method you're currently using (`inputStream.Text`) is not suitable for binary files such as GIF images. Instead, you need to read the GIF file as a binary stream and then convert that binary data to a B...
17,237
[ { "from": "human", "value": "What I'm trying to do is encode a gif file, to include in an XML document.\nThis is what I have now, but it doesn't seem to work.\nFunction gifToBase64(strGifFilename)\n On Error Resume Next\n Dim strBase64\n Set inputStream = WScript.CreateObject(\"ADODB.Stream\")\n inputStream...
I have a CakePHP 1.2 application. I'm running into the case where I need to do some logic to render things correctly in the view. Example: I have a table called Types. There are flags for various types, so each row has one or more BOOL fields set. For one type of type, I store the contents of an RTF in another field. ...
In CakePHP, it’s important to separate concerns and maintain a clean architecture by following the MVC (Model-View-Controller) pattern. The logic you are describing for determining whether to create a link or not belongs in the View layer, as it deals with presentation logic. Here’s a step-by-step approach to implemen...
20,981
[ { "from": "human", "value": "I have a CakePHP 1.2 application.\nI'm running into the case where I need to do some logic to render things correctly in the view. \nExample:\nI have a table called Types. There are flags for various types, so each row has one or more BOOL fields set. For one type of type, I sto...
I have a requirement in my application that I think can be met by using thread local storage, but I'm wondering if it's one of those things that's best to avoid. I have read a few articles on the subject: http://www.dotnetcoders.com/web/Articles/ShowArticle.aspx?article=58 http://msdn.microsoft.com/en-us/library/system...
Thread Local Storage (TLS) can be a useful tool in certain scenarios, but it’s important to carefully consider the implications of using it. Your use case—storing the last SQL command for logging purposes in the context of a web application—raises some good points for discussion. ### Pros of Using Thread Local Storage...
21,159
[ { "from": "human", "value": "I have a requirement in my application that I think can be met by using thread local storage, but I'm wondering if it's one of those things that's best to avoid.\nI have read a few articles on the subject:\nhttp://www.dotnetcoders.com/web/Articles/ShowArticle.aspx?article=58\nht...
Can someone please explain how to remove the background/borders off an embedded CrystalReportViewer control in Visual Studio 2008. I'm trying to remove the light gray (below the "Crystal Report" heading) and then the darker gray underneath that. I want to be left with only the white box and the report inside this. This...
To remove the background and borders of the `CrystalReportViewer` in Visual Studio 2008, you can adjust several properties both in the control itself and in the surrounding HTML/CSS. Below are the steps you can take to achieve the desired look of just having the report within a clean white box. ### 1. Update CSS for t...
16,492
[ { "from": "human", "value": "Can someone please explain how to remove the background/borders off an embedded CrystalReportViewer control in Visual Studio 2008.\nI'm trying to remove the light gray (below the \"Crystal Report\" heading) and then the darker gray underneath that. I want to be left with only th...
Is it possible to access the Abstract Syntax Tree(AST) inside the javac.exe programmatically? Could you provide an example?
Yes, it is possible to access the Abstract Syntax Tree (AST) programmatically when compiling Java code using the `javac` compiler, but it requires the use of the Java Compiler API that was introduced in JDK 6. This API allows you to create a custom annotation processor or a compilation task where you can visit the AST ...
19,223
[ { "from": "human", "value": "Is it possible to access the Abstract Syntax Tree(AST) inside the javac.exe programmatically? Could you provide an example?\n" }, { "from": "gpt", "value": "Yes, it is possible to access the Abstract Syntax Tree (AST) programmatically when compiling Java code using t...
I know it's a long shot, but is there some package or means to insert emoticons into a LaTeX document?
Yes, it is indeed possible to include emoticons and emojis in LaTeX documents. There are a few packages that can help you achieve this. Here are some methods you can use: ### 1. Using the `emoji` package You can use the `emoji` package, which allows you to insert emojis using their shortcode. First, ensure you have t...
17,291
[ { "from": "human", "value": "I know it's a long shot, but is there some package or means to insert emoticons into a LaTeX document?\n" }, { "from": "gpt", "value": "Yes, it is indeed possible to include emoticons and emojis in LaTeX documents. There are a few packages that can help you achieve t...
At the team with which I work, we have an old codebase using PHP's ibase_* functions all over the code to communicate with database. We created a wrapper to it that would do something else beside just calling the original function and I did a mass search-replace in the entire code to make sure that wrapper is used inst...
To prevent the usage of `ibase_*` functions in your PHP codebase while still keeping them available, you can use the following approach: 1. **Create a Wrapper**: First, ensure that your wrapper function is comprehensive and can handle all cases where `ibase_*` functions might be called. For instance, if your wrapper f...
18,043
[ { "from": "human", "value": "At the team with which I work, we have an old codebase using PHP's ibase_* functions all over the code to communicate with database. We created a wrapper to it that would do something else beside just calling the original function and I did a mass search-replace in the entire co...
This is what I have, which works in IE7, but not in Firefox: @media screen { @import 'screen.css'; } It works outside of the @media block in Firefox: @import 'screen.css'; UPDATE: This works: @media screen { .yui-d3f { border: 1px solid #999; height: 250px; } } What am I missing?
The issue you're encountering with the `@import` rule inside a `@media` block is due to how different browsers implement CSS specifications. While Internet Explorer 7 might handle this correctly, Firefox and other modern browsers do not support importing stylesheets within media queries in the same way. In CSS, the `@...
24,142
[ { "from": "human", "value": "This is what I have, which works in IE7, but not in Firefox:\n@media screen { @import 'screen.css'; }\n\nIt works outside of the @media block in Firefox:\n@import 'screen.css';\n\nUPDATE: \nThis works:\n@media screen { \n\n .yui-d3f\n {\n border: 1px solid #999;\n ...
I have a piece of software which is linked against several libraries. They all exists in a dynamic (.so) and a static (.a) version. By default, when using g++ it chooses the dynamic version of the libraries and that's fine with me. However, one of them absolutely needs to be linked statically. I thought about using -s...
You can achieve linking a specific library statically while keeping the others linked dynamically by specifying the library's static version directly in your g++ command and ensuring the order of linking is correct. Here’s how you can do it: 1. **Link the Static Library Directly**: Instead of using the `-l` option for...
22,703
[ { "from": "human", "value": "I have a piece of software which is linked against several libraries. They all exists in a dynamic (.so) and a static (.a) version. By default, when using g++ it chooses the dynamic version of the libraries and that's fine with me. \nHowever, one of them absolutely needs to be l...
As a developer I often release different versions of applications that I want tested by users to identify bugs and to confirm requirements are being met. I give the users a rough idea of what I have changed or new features that need testing, but this seems a bit slap-dash and not very well strucutured. I'd like to know...
User Acceptance Testing (UAT) is a crucial part of the software development lifecycle, especially in iterative development where frequent releases and feedback loops are common. Here are some structured approaches and procedures that you can consider to improve your UAT process: ### 1. **Develop a Clear UAT Plan** ...
16,840
[ { "from": "human", "value": "As a developer I often release different versions of applications that I want tested by users to identify bugs and to confirm requirements are being met.\nI give the users a rough idea of what I have changed or new features that need testing, but this seems a bit slap-dash and n...
Upon page load I want to move the cursor to a particular field. No problem. But I also need to select and highlight the default value that is placed in that text field.
To achieve the functionality where the cursor is moved to a particular text field upon page load, and the default value in that field is selected and highlighted, you can use JavaScript. Here’s a simple example using plain HTML and JavaScript: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> ...
23,196
[ { "from": "human", "value": "Upon page load I want to move the cursor to a particular field. No problem. But I also need to select and highlight the default value that is placed in that text field.\n" }, { "from": "gpt", "value": "To achieve the functionality where the cursor is moved to a par...
I've tested my iPhone app on the iPhone. Now I want to test it on the iPod touch. Assuming I have an iPod touch what else do I need? I just want to make sure all the certificates and stuff that I used for the iPhone will work for the iPod touch too.
To test your iPhone app on an iPod touch, you'll need to ensure that your development environment is set up correctly. Here are the steps and considerations to make sure everything works seamlessly: 1. **Development Certificates and Provisioning Profiles**: The same provisioning profiles and development certificates y...
21,784
[ { "from": "human", "value": "I've tested my iPhone app on the iPhone. Now I want to test it on the iPod touch. Assuming I have an iPod touch what else do I need?\nI just want to make sure all the certificates and stuff that I used for the iPhone will work for the iPod touch too.\n" }, { "from": "g...
I'll regularly get an extract from a DB/2 database with dates and timestaps formatted like this: 2002-01-15-00.00.00.000000 2008-01-05-12.36.05.190000 9999-12-31-24.00.00.000000 Is there an easier way to convert this into the Excel date format than decomposing with substrings? DB2date = DateValue(Left(a, 4) + "/" + Mi...
Yes, there is a more efficient way to convert the date and timestamp strings from your DB2 database format to a standard Excel date format without decomposing them with substrings. You can utilize the `DateSerial` and `TimeSerial` functions in Excel to handle the conversion. Here’s how you can do it using a single form...
19,178
[ { "from": "human", "value": "I'll regularly get an extract from a DB/2 database with dates and timestaps formatted like this:\n2002-01-15-00.00.00.000000\n2008-01-05-12.36.05.190000\n9999-12-31-24.00.00.000000\n\nIs there an easier way to convert this into the Excel date format than decomposing with substri...
I'm experimenting with OpenSSL on my network application and I want to test if the data sent is encrypted and can't be seen by eavesdropper. What tools can you use to check? Could this be done programmatically so it could be placed in a unit test?
To test whether your data is encrypted when using OpenSSL in your network application, you can use a variety of tools and approaches to verify that the data sent over the network is not easily readable by eavesdroppers. Below are some tools and programmatic methods you can consider: ### Tools to Check Encryption 1. *...
15,591
[ { "from": "human", "value": "I'm experimenting with OpenSSL on my network application and I want to test if the data sent is encrypted and can't be seen by eavesdropper.\nWhat tools can you use to check? Could this be done programmatically so it could be placed in a unit test?\n" }, { "from": "gpt",...
I have a function pointer defined by: typedef void (*EventFunction)(int nEvent); Is there a way to handle that function with a specific instance of a C++ object? class A { private: EventFunction handler; public: void SetEvent(EventFunction func) { handler = func; } void EventOne() { handler(1); } }; cla...
To achieve the functionality you're looking for—specifically, to allow a class method to be set as a callback using a function pointer—you'll need to wrap the member function pointer in a way that allows it to be called as a regular function pointer. Since C++ function pointers cannot directly point to member functions...
18,146
[ { "from": "human", "value": "I have a function pointer defined by:\ntypedef void (*EventFunction)(int nEvent);\n\nIs there a way to handle that function with a specific instance of a C++ object?\nclass A\n{\nprivate:\n EventFunction handler;\n\npublic:\n void SetEvent(EventFunction func) { handler = f...
I work with a lot of offsite developers and contractors. I ask them daily to send me a quick 5 minute status of their work for the day. I have to sometimes consolidate the status of individuals into teams and sometimes consolidate the status of a week, for end-of-period reporting to my clients. I want to learn: Items ...
To create a status report format that meets your needs, I recommend using a structured template that is simple and consistent for all developers. A table format, whether in a spreadsheet or a text document, can be effective. Here’s a proposed template that captures all the necessary information while being quick to fil...
18,424
[ { "from": "human", "value": "I work with a lot of offsite developers and contractors. I ask them daily to send me a quick 5 minute status of their work for the day. I have to sometimes consolidate the status of individuals into teams and sometimes consolidate the status of a week, for end-of-period reportin...
I personally use var_dump, but lots of people like print_r. What does everyone use? Pros and Cons? Does someone have a special home brew function of their own?
When it comes to debugging in PHP, both `var_dump()` and `print_r()` are commonly used functions. Each has its pros and cons, and developers may choose one over the other based on their specific needs. Here's a breakdown of both, along with some alternatives: ### `var_dump()` **Pros:** - **Detailed Information:** `va...
19,428
[ { "from": "human", "value": "I personally use var_dump, but lots of people like print_r. \nWhat does everyone use? Pros and Cons?\nDoes someone have a special home brew function of their own?\n" }, { "from": "gpt", "value": "When it comes to debugging in PHP, both `var_dump()` and `print_r()` ar...
What is the best way to determine available bandwidth in .NET? We have users that access business applications from various remote access points, wired and wireless and at times the bandwidth can be very low based on where the user is. When the applications appear to be running slow, the issue could be due to low band...
Determining available bandwidth in .NET can be accomplished using various approaches. Below are some strategies and tools you might consider to monitor and warn users about bandwidth issues in your application. ### 1. **Ping and Latency Tests** You can measure round-trip time (RTT) to a known server using ICMP packet...
17,184
[ { "from": "human", "value": "What is the best way to determine available bandwidth in .NET?\nWe have users that access business applications from various remote access points, wired and wireless and at times the bandwidth can be very low based on where the user is. When the applications appear to be runnin...
i have a flow panel that i'm adding extra items to it at runtime based on whether they have chosen to show all the items. that's all works fine; the expansion is controlled by a toolbar button. the trouble is we'd like the user to be able to move his mouse over the "+" sign to expand the section. initially i looked a...
It sounds like you are looking to create a more visually appealing and user-friendly way for users to expand/collapse a section of your application using a "+" sign. Since you've explored a few options and are leaning towards creating a custom component for reusability across your application, here's an approach you ca...
17,075
[ { "from": "human", "value": "i have a flow panel that i'm adding extra items to it at runtime based on whether they have chosen to show all the items. that's all works fine; the expansion is controlled by a toolbar button.\nthe trouble is we'd like the user to be able to move his mouse over the \"+\" sign ...
I'm seeking a library, technique or advice on how to read an EAN-13 barcode from an image (including ISBN,and ISSN encodings). The image would come from a mobile phone or webcam, so resolution may be quite poor and not well aligned. I'm specifically interested in something that could be used from ruby on rails, but ans...
Reading EAN-13 barcodes (which also cover ISBN and ISSN) from images, especially those captured by mobile phones or webcams, can be a challenging task due to potential issues with resolution, alignment, and lighting. Here are several open-source libraries and techniques that you can consider for your Ruby on Rails appl...
18,253
[ { "from": "human", "value": "I'm seeking a library, technique or advice on how to read an EAN-13 barcode from an image (including ISBN,and ISSN encodings).\nThe image would come from a mobile phone or webcam, so resolution may be quite poor and not well aligned.\nI'm specifically interested in something tha...
How can I make a Facebook RSS application that autoupdates from the provided RSS feeds. Of course doing this is trivial for canvas applications, but I need this for showing on the Facebook Page. All the RSS apps I've taken a look at either dont update or dont work on Facebook Pages. Especially now that infinite sessi...
Creating a Facebook RSS application that updates automatically on a Facebook Page can be a bit challenging, especially considering the restrictions and changes in Facebook's platform. However, you can achieve this using a combination of the Facebook API and a server-side solution to fetch and display the RSS feed. Her...
16,591
[ { "from": "human", "value": "How can I make a Facebook RSS application that autoupdates from the provided RSS feeds. \nOf course doing this is trivial for canvas applications, but I need this for showing on the Facebook Page. All the RSS apps I've taken a look at either dont update or dont work on Facebook ...
I noticed a good while back that Wikipedia links to a Javascript implementation of different hash functions. Also found Clipperz Crypto. Even Mozilla implements a crypto object in Firefox. So, Is Javascript a proper platform for cryptography? Or, can it be? Or, I suppose.. Are there any purposes or benefits for hashing...
JavaScript can certainly be used for cryptographic purposes, including hashing, but there are several considerations to keep in mind regarding its implementation, security, and use cases. ### Can JavaScript be a proper platform for cryptography? 1. **Environment**: JavaScript can run in various environments, includin...
19,657
[ { "from": "human", "value": "I noticed a good while back that Wikipedia links to a Javascript implementation of different hash functions. Also found Clipperz Crypto. Even Mozilla implements a crypto object in Firefox.\nSo, Is Javascript a proper platform for cryptography? Or, can it be?\nOr, I suppose.. Are...
What techniques or tools are recommended for finding broken links on a website? I have access to the logfiles, so could conceivably parse these looking for 404 errors, but would like something automated which will follow (or attempt to follow) all links on a site.
Finding broken links on a website can be done effectively using a variety of techniques and tools. Since you're looking for an automated solution that can crawl the site and identify broken links, here are some recommended approaches: ### Tools for Finding Broken Links 1. **Online Broken Link Checkers:** - **Dead ...
15,642
[ { "from": "human", "value": "What techniques or tools are recommended for finding broken links on a website?\nI have access to the logfiles, so could conceivably parse these looking for 404 errors, but would like something automated which will follow (or attempt to follow) all links on a site.\n" }, { ...
I am sure there is a simple answer to this one. I have a docx file that I get an error when trying to download(document cannot be found).... .doc is fine .txt is also fine. I am sure this is just an iis setting, the permissions on the server are all the same for all files.
If you are encountering an issue where downloading `.docx` files results in a "document cannot be found" error while `.doc` and `.txt` files work fine, it could be related to how IIS (Internet Information Services) is configured to handle certain MIME types. Here are a few steps to troubleshoot and potentially resolve...
19,683
[ { "from": "human", "value": "I am sure there is a simple answer to this one.\nI have a docx file that I get an error when trying to download(document cannot be found).... .doc is fine .txt is also fine. I am sure this is just an iis setting, the permissions on the server are all the same for all files. \n" ...
I'm trying to make a select that calculates affiliate payouts. my approach is pretty simple. SELECT month(payments.timestmap) ,sum(if(payments.amount>=29.95,4,0)) As Tier4 ,sum(if(payments.amount>=24.95<=29.94,3,0)) As Tier3 ,sum(if(payments.amount>=19.95<=24.94,2,0)) As Tier2 FROM payments GROUP BY month(payments.tim...
Yes, you can use range comparisons in MySQL, but the syntax needs to be correct. Specifically, when you want to check if a value is within a certain range, you can use the `BETWEEN` operator or combine two conditions with `AND`. The issue with your original condition `if(payments.amount>=24.95<=29.94,3,0)` is that it...
22,796
[ { "from": "human", "value": "I'm trying to make a select that calculates affiliate payouts.\nmy approach is pretty simple.\nSELECT\n month(payments.timestmap)\n,sum(if(payments.amount>=29.95,4,0)) As Tier4\n,sum(if(payments.amount>=24.95<=29.94,3,0)) As Tier3\n,sum(if(payments.amount>=19.95<=24.94,2,0)) As ...
I want to download and parse webpage using python, but to access it I need a couple of cookies set. Therefore I need to login over https to the webpage first. The login moment involves sending two POST params (username, password) to /login.php. During the login request I want to retrieve the cookies from the response h...
To achieve the task of logging into a website and retrieving cookies to access another page using only built-in Python modules (especially for Python 2.6), you can use the `httplib` module for HTTP requests and `Cookie` to handle cookies. Here's a step-by-step breakdown of how to do it: 1. **Send a POST request with l...
16,798
[ { "from": "human", "value": "I want to download and parse webpage using python, but to access it I need a couple of cookies set. Therefore I need to login over https to the webpage first. The login moment involves sending two POST params (username, password) to /login.php. During the login request I want to...
Often times when mixing jQuery with asp.net I need to use asp .net angle bracket percent, <% %>, syntax within a jQuery selector. If I would like to separate the JavaScript from markup into different files is there still a way to evaluate my JavaScript file so the angle bracket percents are interpolated before reachin...
When working with ASP.NET and jQuery, you may encounter the need to use server-side ASP.NET code (with angle bracket percent syntax, `<% %>`) within your JavaScript files. However, since JavaScript files are served as static files, ASP.NET code will not be executed in external `.js` files. Here are some strategies to h...
19,889
[ { "from": "human", "value": "Often times when mixing jQuery with asp.net I need to use asp .net angle bracket percent, <% %>, syntax within a jQuery selector.\nIf I would like to separate the JavaScript from markup into different files is there still a way to evaluate my JavaScript file so the angle bracke...
I've been developing GPL'd software for years, but now I need a more restrictive license. This is for a commercial application, and I want to share my source code with the whole world, regardless of whether they've purchased the application from me or not. I also want to allow people to produce derivative works, but I ...
Based on your requirements, it seems you are looking for a license that allows for the source code to be shared and modified while restricting the distribution of compiled binaries and requiring payment for access to compiled versions of the software. Unfortunately, there is no widely accepted open source or free softw...
21,798
[ { "from": "human", "value": "I've been developing GPL'd software for years, but now I need a more restrictive license.\nThis is for a commercial application, and I want to share my source code with the whole world, regardless of whether they've purchased the application from me or not. I also want to allow ...
Is it possible for a web server to know which type of device request has been received from? For example, can a create a website which shows different contents if request came from a computer (Firefox) and something different if it came from iPhone?
Yes, it is indeed possible for a web server to determine the type of device from which a request has been received. This is often done through the use of the **User-Agent** string that browsers send as part of the HTTP request headers. The User-Agent string provides information about the client's device, operating syst...
19,800
[ { "from": "human", "value": "Is it possible for a web server to know which type of device request has been received from?\nFor example, can a create a website which shows different contents if request came from a computer (Firefox) and something different if it came from iPhone?\n" }, { "from": "gpt...
I need to a script that will pull up the Task Manager in Vista but with processes from all users (like when you click "Show processes from all users"). I don't mind the UAC interruption but I'd like to save some time and go straight to the "all users" version. I don't care what language per se, just something that'll ...
In Windows Vista, you can use a simple command line to open the Task Manager with processes from all users. Since you are fine with the UAC prompt, you can use a script that utilizes the `runas` command to achieve this. Here's a simple batch script that you can create: 1. Open Notepad (or any text editor). 2. Copy an...
22,260
[ { "from": "human", "value": "I need to a script that will pull up the Task Manager in Vista but with processes from all users (like when you click \"Show processes from all users\"). I don't mind the UAC interruption but I'd like to save some time and go straight to the \"all users\" version.\nI don't care...
I have a symlink to an important directory. I want to get rid of that symlink, while keeping the directory behind it. I tried rm and get back rm: cannot remove 'foo'. I tried rmdir and got back rmdir: failed to remove 'foo': Directory not empty I then progressed through rm -f, rm -rf and sudo rm -rf Then I went to find...
Yes, you can safely remove a symlink without affecting the directory it points to. The commands you're using (`rm`, `rmdir`, etc.) are likely being interpreted as attempts to remove the actual directory instead of just the symlink. Here’s how to properly remove a symlink: 1. **Check if it is a symlink:** First, ensu...
22,569
[ { "from": "human", "value": "I have a symlink to an important directory. I want to get rid of that symlink, while keeping the directory behind it.\nI tried rm and get back rm: cannot remove 'foo'.\nI tried rmdir and got back rmdir: failed to remove 'foo': Directory not empty\nI then progressed through rm -f...
I need to know when the user finishes editing a cell in an NSTableView. The table contains all of the user's calendars (obtained from the CalCalendarStore), so in order for the user's changes to be saved I need to inform the CalCalendarStore of the changes. However, I can't find anything that gets called after the user...
In `NSTableView`, you can handle the completion of cell editing by implementing the `tableView(_:didEndEditingRow:column:)` delegate method. This method is called when editing ends for a specific row and column. Here is a quick overview of how you can implement it: 1. Make sure your class conforms to the `NSTableVie...
18,106
[ { "from": "human", "value": "I need to know when the user finishes editing a cell in an NSTableView. The table contains all of the user's calendars (obtained from the CalCalendarStore), so in order for the user's changes to be saved I need to inform the CalCalendarStore of the changes. However, I can't find...
I am using tinyMCE as my text editor on my site and i want to reformat the text before saving it to my database (changing the &rsquo; tags into ' then in to &#39;). I cannot find a simple way of doing this using tinyMCe and using htmlentities() changes everything including <>. Any ideas?
To achieve your goal of converting specific HTML entities in TinyMCE before saving the text to your database, you can use a JavaScript function to manipulate the content of the editor. This allows you to specifically target the `&rsquo;` entity and replace it with the desired format (`'` then encoded as `&#39;`). Here...
20,883
[ { "from": "human", "value": "I am using tinyMCE as my text editor on my site and i want to reformat the text before saving it to my database (changing the &rsquo; tags into ' then in to &#39;). I cannot find a simple way of doing this using tinyMCe and using htmlentities() changes everything including <>. A...
Could someone please explain to me how the current python webframworks fit together? The three I've heard of are CherryPy, TurboGears and Pylons. However I'm confused because TurboGears seems to use CherryPy as the 'Controller' (although isn't CherryPy a framework in in it's own right?), and TurbGears 2 is going to be ...
Certainly! The world of Python web frameworks can be a bit confusing due to the various interdependencies and the evolution of these frameworks over time. Let's break down the three frameworks you've mentioned: CherryPy, TurboGears, and Pylons, and see how they fit together. ### 1. CherryPy - **Overview**: CherryPy is...
17,991
[ { "from": "human", "value": "Could someone please explain to me how the current python webframworks fit together?\nThe three I've heard of are CherryPy, TurboGears and Pylons. However I'm confused because TurboGears seems to use CherryPy as the 'Controller' (although isn't CherryPy a framework in in it's ow...
I need help please. No clue in xml & WebtextEdit, I am editing an xslt stylesheet that creates asp controls. Below is the WebTextEdit control, I want to add an mousemove event: <xsl:element name="igtxt:WebTextEdit"> <xsl:attribute name='id'><xsl:value-of select='$Name' /></xsl:attribute> <xsl:attri...
To add a `mousemove` event to the `WebTextEdit` control in your XSLT stylesheet, it looks like you're already on the right track. The attribute that you want to define for the `MouseMove` event should be added properly, but the JavaScript syntax you use must be correctly formatted. Here's an updated version of your X...
18,573
[ { "from": "human", "value": "I need help please. \nNo clue in xml & WebtextEdit, I am editing an xslt stylesheet that creates asp controls. \nBelow is the WebTextEdit control, I want to add an mousemove event:\n <xsl:element name=\"igtxt:WebTextEdit\">\n <xsl:attribute name='id'><xsl:value-of selec...
What is the best way to automatically install an MSI file or installer .exe? We want to do some automated testing from our build system on the installed copy of the product. Our installer has the usual license acceptance screen, install location, etc. As FryHard pointed out there are two options in particular that see...
To automatically install an MSI file or a setup executable (.exe) without user interaction, you have a couple of effective methods. Below are the common approaches for both MSI files and EXE installers: ### Installing MSI Files For MSI files, you can use the `msiexec` command with various switches to perform an unatt...
19,061
[ { "from": "human", "value": "What is the best way to automatically install an MSI file or installer .exe? We want to do some automated testing from our build system on the installed copy of the product. Our installer has the usual license acceptance screen, install location, etc.\n\nAs FryHard pointed out t...
I have an iPhone app that compiles and runs fine in the Simulator on my laptop. Now, I try to build and run the same code in the Simulator on an iMac, and it starts up and lets me click a button, but then I get an assertion failure. Here is what is in the console: *** Assertion failure in -[UILabel setFont:], /SourceC...
The issue you're encountering stems from the way certain fonts are managed and accessed in iOS. Here are some key points to consider that might help you troubleshoot and resolve the issue: 1. **Font Availability**: Just because a font is installed on your iMac doesn't mean it's available to the iOS Simulator. The Simu...
20,031
[ { "from": "human", "value": "I have an iPhone app that compiles and runs fine in the Simulator on my laptop. Now, I try to build and run the same code in the Simulator on an iMac, and it starts up and lets me click a button, but then I get an assertion failure.\nHere is what is in the console:\n*** Asserti...
There are many techniques to enforce strong passwords on website: Requesting that passwords pass a regex of varying complexity Setting the password autonomously, so that casual users have a strong password Letting passwords expire etc. On the other hands there are drawbacks, because all of them make life less easy fo...
When it comes to enforcing strong passwords on websites that require user registration, it’s essential to strike a balance between security and user experience. Here are several techniques that can help achieve this balance, along with their pros and cons: ### Techniques for Strong Password Enforcement 1. **Password ...
17,057
[ { "from": "human", "value": "There are many techniques to enforce strong passwords on website:\n\nRequesting that passwords pass a regex of varying complexity\nSetting the password autonomously, so that casual users have a strong password\nLetting passwords expire\netc.\n\nOn the other hands there are drawb...
I'm seeing an ambiguous error in Firebug. I don't think it's particularly related to the script I'm writing, however I don't have enough details to be able to determine that from this one error alone. Has anyone seen something similar and have a suggestion? error: [Exception... "Component is not available" nsresult: "...
The error message you’re encountering is related to Firefox’s session store, which is responsible for saving the state of open tabs and windows. The specific error (`NS_ERROR_NOT_AVAILABLE`) indicates that a component required by the session store is not available at the time it attempts to save the session state. Her...
21,587
[ { "from": "human", "value": "I'm seeing an ambiguous error in Firebug. I don't think it's particularly related to the script I'm writing, however I don't have enough details to be able to determine that from this one error alone. Has anyone seen something similar and have a suggestion?\nerror:\n\n[Exception...
I would like to know where to get started, or how possible it is to hook into, or patch the windows kernel(XP and up). I am specifically interested in software like McAfee Entercept, or certain antivirus scanners that patch the kernel. I would like to know how feasable it is for a startup to create software that added ...
Creating software that hooks into or modifies the Windows kernel is a complex and highly technical endeavor that requires a deep understanding of operating system internals, as well as careful consideration of security and stability implications. Here’s a breakdown of how you might get started, the feasibility of such ...
16,825
[ { "from": "human", "value": "I would like to know where to get started, or how possible it is to hook into, or patch the windows kernel(XP and up). I am specifically interested in software like McAfee Entercept, or certain antivirus scanners that patch the kernel. I would like to know how feasable it is for...
Here is the directory layout that was installed with Leopard. What is the "A" directory and why the "Current" directory in addition to the "CurrentJDK"? It seems like you can easily switch the current JDK by move the CurrentJDK link, but then the contents under Current and A will be out of sync. lrwxr-xr-x 1 root w...
In macOS (particularly in older versions like Leopard), the directory structure for the Java Virtual Machine (JVM) is organized in a specific way to manage different Java versions. Let's break down the directories you see in your output: ### "A" Directory The "A" directory typically represents the default Java version...
18,145
[ { "from": "human", "value": "Here is the directory layout that was installed with Leopard. What is the \"A\" directory and why the \"Current\" directory in addition to the \"CurrentJDK\"?\nIt seems like you can easily switch the current JDK by move the CurrentJDK link, but then the contents under Current a...
I'm trying to use the giveio.sys driver which requires a "file" to be opened before you can access protected memory. I'm looking at a C example from WinAVR/AVRdude that uses the syntax: #define DRIVERNAME "\\\\.\\giveio" HANDLE h = CreateFile(DRIVERNAME, GENERIC_READ, 0, NULL...
The issue you’re facing is related to how file paths and device interfaces are handled in Python compared to C. The `os.open()` function does not support the same syntax as the `CreateFile()` function in the Windows API. Instead, you can use the `pywin32` library, which provides access to many Windows API functionaliti...
20,711
[ { "from": "human", "value": "I'm trying to use the giveio.sys driver which requires a \"file\" to be opened before you can access protected memory. I'm looking at a C example from WinAVR/AVRdude that uses the syntax:\n #define DRIVERNAME \"\\\\\\\\.\\\\giveio\"\n HANDLE h = CreateFile(DRIVERNAME,\n ...
I am working on a very large scale computing library that is using STL heavily. The library is being built using MSVC2003 and it is using its STL implementation. I am looking for an alternative STL implementation that would help the library lower its memory requirements and increase its performance. It is not possible ...
When considering alternative STL implementations for MSVC 2003, several options have been used in real-world applications that might help with your goals of reducing memory usage and improving performance. Here are a few you might want to consider, along with insights from their usage in the community: 1. **STLPort**:...
12,244
[ { "from": "human", "value": "I am working on a very large scale computing library that is using STL heavily. The library is being built using MSVC2003 and it is using its STL implementation.\nI am looking for an alternative STL implementation that would help the library lower its memory requirements and inc...
How do I check from within my NSIS installer if my installer has the blocked option in preferences on it. Even if you know of a way to check this without NSIS, please let me know so I can script it myself. See this question to find out more info about this blocked option.
In NSIS (Nullsoft Scriptable Install System), if you want to check whether your installer has been blocked by Windows due to the "blocked option" (which can occur when an installer is downloaded from the internet and not digitally signed), there are a few approaches you can take. ### 1. **Check for the Blocked Flag** ...
14,111
[ { "from": "human", "value": "How do I check from within my NSIS installer if my installer has the blocked option in preferences on it. \nEven if you know of a way to check this without NSIS, please let me know so I can script it myself. \nSee this question to find out more info about this blocked option.\n"...
My zune just updated to 3.0 (didn't even realize they were releasing something new!) and the update came with two games, but the Zune marketplace does not have games. Where do I go to get started, and what are the capabilities of the Zune in terms of games/apps?
The Zune is primarily known as a media player, but it also includes some gaming capabilities, especially after the 3.0 update. The introduction of games in this update was part of Microsoft's effort to enhance the Zune's functionality and make it more appealing to users. To get started with games on your Zune after th...
22,561
[ { "from": "human", "value": "My zune just updated to 3.0 (didn't even realize they were releasing something new!) and the update came with two games, but the Zune marketplace does not have games. \nWhere do I go to get started, and what are the capabilities of the Zune in terms of games/apps?\n" }, { ...
I have a c# .NET 2.0 application that has been running on W2K/IIS5 quite happily for several years. The sysadmin team are currently setting up a W2K3 box for the app, using the same install files, but are running into the dreaded "Could not load type..." error. The type in question is the class (i.e. code behind) for t...
The "Could not load type..." error you're encountering is common when moving a .NET application between different versions of Windows/IIS, especially between IIS 5 and IIS 6/7. Here are several steps you can take to troubleshoot and hopefully resolve the issue: 1. **Check ASP.NET Registration**: Ensure that ASP.NET is...
20,408
[ { "from": "human", "value": "I have a c# .NET 2.0 application that has been running on W2K/IIS5 quite happily for several years. The sysadmin team are currently setting up a W2K3 box for the app, using the same install files, but are running into the dreaded \"Could not load type...\" error. The type in que...
I've created a language pack for a site before, but I'm not sure if what I'm doing is the best method. Basically, all I have is a file with variables defining string constants. Usually a set of arrays where an array usually refers to a particular elements of the site. Then the site code just includes the appropriate f...
Creating a language pack using arrays for string constants is a common approach, but there are several ways you can enhance your implementation to reduce maintenance headaches and improve performance. Here are some strategies: ### 1. **Use a Standardized Format:** Instead of using PHP arrays, consider using standardiz...
16,822
[ { "from": "human", "value": "I've created a language pack for a site before, but I'm not sure if what I'm doing is the best method.\nBasically, all I have is a file with variables defining string constants. Usually a set of arrays where an array usually refers to a particular elements of the site.\nThen th...
I am trying to generate equivalent MD5 hashes in both JavaScript and .Net. Not having done either, I decided to use against a third party calculation - this web site for the word "password". I will add in salts later, but at the moment, I can't get the .net version to match up with the web site's hash: 5f4dcc3b5aa765...
To generate equivalent MD5 hashes for a given string in both JavaScript and .NET, you need to ensure you're using the same input string and the same encoding method in both implementations. The MD5 hash for the string "password" is indeed `5f4dcc3b5aa765d61d8327deb882cf99`. ### JavaScript Implementation You can use ...
17,368
[ { "from": "human", "value": "I am trying to generate equivalent MD5 hashes in both JavaScript and .Net. Not having done either, I decided to use against a third party calculation - this web site for the word \"password\". I will add in salts later, but at the moment, I can't get the .net version to match ...
I want to create a list of integers from 1 to n. I can do this in Python using range(1, n+1), and in Haskell using: take n (iterate (1+) 1). What is the right OCaml idiom for this?
In OCaml, you can create a list of integers from 1 to `n` using a recursive function or the `List.init` function in newer versions of OCaml. Here's how you can do it: 1. **Using a recursive function**: ```ocaml let rec range n = if n <= 0 then [] else range (n - 1) @ [n] ``` You can call this function with `n` t...
24,798
[ { "from": "human", "value": "I want to create a list of integers from 1 to n. I can do this in Python using range(1, n+1), and in Haskell using: take n (iterate (1+) 1).\nWhat is the right OCaml idiom for this?\n" }, { "from": "gpt", "value": "In OCaml, you can create a list of integers from 1 t...
I had assumed that the canonical form for operator+, assuming the existence of an overloaded operator+= member function, was like this: const T operator+(const T& lhs, const T& rhs) { return T(lhs) +=rhs; } But it was pointed out to me that this would also work: const T operator+ (T lhs, const T& rhs) { return...
Both forms you've presented for the `operator+` implementation are valid and can work correctly, but they do have different characteristics and implications. Let's analyze both approaches. ### First Form ```cpp const T operator+(const T& lhs, const T& rhs) { return T(lhs) += rhs; } ``` #### Characteristics: 1. **T...
12,049
[ { "from": "human", "value": "I had assumed that the canonical form for operator+, assuming the existence of an overloaded operator+= member function, was like this:\nconst T operator+(const T& lhs, const T& rhs)\n{\n return T(lhs) +=rhs;\n}\n\nBut it was pointed out to me that this would also work:\ncons...
I'm writing an winforms app that needs to set internet explorer's proxy settings and then open a new browser window. At the moment, I'm applying the proxy settings by going into the registry: RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);...
Modifying the registry is a common way to change Internet Explorer's settings, but it's not the only method and often not the most recommended due to potential issues, especially in a multi-user environment or where registry permissions might be restrictive. A couple of alternative approaches to consider include: ### ...
20,552
[ { "from": "human", "value": "I'm writing an winforms app that needs to set internet explorer's proxy settings and then open a new browser window. At the moment, I'm applying the proxy settings by going into the registry:\nRegistryKey registry = Registry.CurrentUser.OpenSubKey(\"Software\\\\Microsoft\\\\Wind...
Given a week number, e.g. date -u +%W, how do you calculate the days in that week starting from Monday? Example rfc-3339 output for week 40: 2008-10-06 2008-10-07 2008-10-08 2008-10-09 2008-10-10 2008-10-11 2008-10-12
To calculate the days in a given week number starting from Monday, you can follow these steps in a shell environment like Bash. ### Step-by-Step Instructions 1. **Determine the Year**: You will need to specify the year for which you want to find the days of the given week number. For example, let's use the year 2008....
20,546
[ { "from": "human", "value": "Given a week number, e.g. date -u +%W, how do you calculate the days in that week starting from Monday?\nExample rfc-3339 output for week 40:\n2008-10-06\n2008-10-07\n2008-10-08\n2008-10-09\n2008-10-10\n2008-10-11\n2008-10-12\n\n" }, { "from": "gpt", "value": "To cal...
I'm trying to determine how to open/edit existing SQL Server Reporting Services (SSRS) 2005 report projects (.rptproj) and reports (.rdl) with Visual Studio 2008, without having to install SQL Business Intelligence Development Studio (BIDS) 2005.
Opening and editing existing SQL Server Reporting Services (SSRS) 2005 report projects (.rptproj) and reports (.rdl) using Visual Studio 2008 can be done, but there are certain considerations and steps involved, especially since Visual Studio 2008 does not natively support the older project formats used by SSRS 2005. ...
20,670
[ { "from": "human", "value": "I'm trying to determine how to open/edit existing SQL Server Reporting Services (SSRS) 2005 report projects (.rptproj) and reports (.rdl) with Visual Studio 2008, without having to install SQL Business Intelligence Development Studio (BIDS) 2005.\n" }, { "from": "gpt", ...
Are there any good alternatives that support writing regexps in different flavors and allow you to test them?
Yes, there are several online tools and applications that allow you to write and test regular expressions (regexps) in different flavors. Here are some popular options: 1. **Regex101**: - Supports multiple flavors: PCRE, JavaScript, Python, and Golang. - Provides detailed explanations of your regex patterns. ...
22,354
[ { "from": "human", "value": "Are there any good alternatives that support writing regexps in different flavors and allow you to test them?\n" }, { "from": "gpt", "value": "Yes, there are several online tools and applications that allow you to write and test regular expressions (regexps) in diffe...
I want to return top 10 records from each section in one query. Can anyone help with how to do it? Section is one of the columns in the table. Database is SQL Server 2005. I want to return the top 10 by date entered. Sections are business, local, and feature. For one particular date I want only the top (10) business...
In SQL Server 2005, you can achieve this by using a Common Table Expression (CTE) combined with the `ROW_NUMBER()` function to assign a unique row number to each entry within each section based on the date entered. You can then filter those results to get the top 10 records for each section. Here’s how you can structur...
22,858
[ { "from": "human", "value": "I want to return top 10 records from each section in one query. Can anyone help with how to do it? Section is one of the columns in the table.\nDatabase is SQL Server 2005. I want to return the top 10 by date entered. Sections are business, local, and feature. For one particu...
How do I limit os.walk to only return files in the directory I provide it? def _dir_list(self, dir_name, whitelist): outputList = [] for root, dirs, files in os.walk(dir_name): for f in files: if os.path.splitext(f)[1] in whitelist: outputList.append(os.path.join(root, f)) ...
If you want to modify the `_dir_list` method to limit `os.walk` so that it only returns files that are directly in the specified directory (and not in its subdirectories), you can do this by adjusting how you use `os.walk`. Instead of using `os.walk` which traverses all subdirectories, you can use `os.listdir()` or `os...
22,923
[ { "from": "human", "value": "How do I limit os.walk to only return files in the directory I provide it?\ndef _dir_list(self, dir_name, whitelist):\n outputList = []\n for root, dirs, files in os.walk(dir_name):\n for f in files:\n if os.path.splitext(f)[1] in whitelist:\n ...