instruction
stringlengths
14
27.6k
completion
stringlengths
3
38.3k
__original_row_idx
int64
0
50k
conversations
listlengths
2
2
Question as stated in the title.
It seems like your question is incomplete. Could you please provide more context or specify the title you're referring to? I'm here to help!
158
[ { "from": "human", "value": "Question as stated in the title.\n" }, { "from": "gpt", "value": "It seems like your question is incomplete. Could you please provide more context or specify the title you're referring to? I'm here to help!" } ]
Can it be done and if so, how?
Sure! I can help with that, but I’ll need more specific information about what you're asking. Can you provide more details or clarify what you want to know if it can be done?
257
[ { "from": "human", "value": "Can it be done and if so, how? \n" }, { "from": "gpt", "value": "Sure! I can help with that, but I’ll need more specific information about what you're asking. Can you provide more details or clarify what you want to know if it can be done?" } ]
What is the SQL query to select all of the MSSQL Server's logins? Thank you. More than one of you had the answer I was looking for: SELECT * FROM syslogins
To select all of the logins in Microsoft SQL Server, the query you provided (`SELECT * FROM syslogins`) is an older method and may not be supported in more recent versions of SQL Server. Instead, you can use the more current view `sys.server_principals`. Here’s the recommended SQL query to get all logins: ```sql SELE...
234
[ { "from": "human", "value": "What is the SQL query to select all of the MSSQL Server's logins?\nThank you. More than one of you had the answer I was looking for:\nSELECT * FROM syslogins \n\n" }, { "from": "gpt", "value": "To select all of the logins in Microsoft SQL Server, the query you provi...
I assume it doesn't connect to anything (other than the satelite I guess), is this right? Or it does and has some kind of charge?
It sounds like you're asking about a satellite communication device, such as a satellite phone or a satellite internet terminal. In general, these devices primarily connect to satellites in orbit to send and receive data or voice communications. 1. **Connection**: They usually do not connect to traditional terrestria...
625
[ { "from": "human", "value": "I assume it doesn't connect to anything (other than the satelite I guess), is this right? Or it does and has some kind of charge?\n" }, { "from": "gpt", "value": "It sounds like you're asking about a satellite communication device, such as a satellite phone or a sate...
I wrote a piece of code to convert PHP's striplashes into valid Python [backslash] escapes: cleaned = stringwithslashes cleaned = cleaned.replace('\\n', '\n') cleaned = cleaned.replace('\\r', '\n') cleaned = cleaned.replace('\\', '') How can I condense it?
You can condense your code using the `str.translate()` method along with a translation table, or you can use a single call to `str.replace()` combined with a loop. However, since your example involves multiple replacements, a more straightforward approach is to use a regular expression. Here's a condensed version usin...
242
[ { "from": "human", "value": "I wrote a piece of code to convert PHP's striplashes into valid Python [backslash] escapes:\ncleaned = stringwithslashes\ncleaned = cleaned.replace('\\\\n', '\\n')\ncleaned = cleaned.replace('\\\\r', '\\n')\ncleaned = cleaned.replace('\\\\', '')\n\nHow can I condense it? \n" }...
I want to assign the decimal variable "trans" to the double variable "this.Opacity". decimal trans = trackBar1.Value / 5000; this.Opacity = trans; When I build the app it gives the following error: Cannot implicitly convert type decimal to double
The error you are encountering is due to the fact that the `Opacity` property in Windows Forms is of type `double`, while you are trying to assign it a `decimal` value. To resolve this, you need to explicitly convert the `decimal` variable `trans` to `double`. Here's how you can do that: ```csharp decimal trans = tra...
58
[ { "from": "human", "value": "I want to assign the decimal variable \"trans\" to the double variable \"this.Opacity\".\ndecimal trans = trackBar1.Value / 5000;\nthis.Opacity = trans;\n\nWhen I build the app it gives the following error:\n\nCannot implicitly convert type decimal to double\n\n" }, { "f...
I have an array in Perl: my @my_array = ("one","two","three","two","three"); How do I remove the duplicates from the array?
To remove duplicates from an array in Perl, you can use a hash to track unique values since hashes do not allow duplicate keys. Here’s one way to do it: ```perl my @my_array = ("one", "two", "three", "two", "three"); # Create a hash to store unique values my %seen; my @unique_array; # Iterate through the original ar...
223
[ { "from": "human", "value": "I have an array in Perl:\nmy @my_array = (\"one\",\"two\",\"three\",\"two\",\"three\");\n\nHow do I remove the duplicates from the array?\n" }, { "from": "gpt", "value": "To remove duplicates from an array in Perl, you can use a hash to track unique values since hash...
I am trying to set a flag to show or hide a page element, but it always displays even when the expression is false. $canMerge = ($condition1 && $condition2) ? 'true' : 'false'; ... <?php if ($canMerge) { ?>Stuff<?php } ?> What's up?
The issue you're experiencing is due to the way you are assigning the value to `$canMerge`. In your code, you are setting `$canMerge` to the string `'true'` or `'false'`, rather than a boolean value. As a result, even when `$canMerge` is `'false'`, it is still considered truthy in a boolean context. Here's how you can...
541
[ { "from": "human", "value": "I am trying to set a flag to show or hide a page element, but it always displays even when the expression is false. \n$canMerge = ($condition1 && $condition2) ? 'true' : 'false';\n...\n<?php if ($canMerge) { ?>Stuff<?php } ?>\n\nWhat's up?\n" }, { "from": "gpt", "val...
I am using SQL Server 2005. I have a table with a text column and I have many rows in the table where the value of this column is not null, but it is empty. Trying to compare against '' yields this response: The data types text and varchar are incompatible in the not equal to operator. Is there a special function t...
In SQL Server 2005, the `text` data type is used for storing large amounts of text data. However, the `text` data type does not support direct comparison with string literals (like `''`) as you've discovered. To check whether a `text` column is not null but empty, you can use the `DATALENGTH` function combined with a `...
323
[ { "from": "human", "value": "I am using SQL Server 2005. I have a table with a text column and I have many rows in the table where the value of this column is not null, but it is empty. Trying to compare against '' yields this response:\n\nThe data types text and varchar are incompatible in the not equal ...
Here's a basic regex technique that I've never managed to remember. Let's say I'm using a fairly generic regex implementation (e.g., grep or grep -E). If I were to do a list of files and match any that end in either .sty or .cls, how would I do that?
You can use a regex pattern that utilizes the alternation operator (`|`) to match either of the two file extensions. When using `grep` or `grep -E` (the latter allows extended regex syntax), you can write the pattern as follows: ```bash grep -E '\.sty$|\.cls$' ``` In this pattern: - `\.` matches a literal dot (`.`). ...
27
[ { "from": "human", "value": "Here's a basic regex technique that I've never managed to remember. Let's say I'm using a fairly generic regex implementation (e.g., grep or grep -E). If I were to do a list of files and match any that end in either .sty or .cls, how would I do that?\n" }, { "from": "gpt...
I'm trying to find the correct names for these 2 "types" of coding expressions in LINQ so that I can refer to them correctly. I want to say that the first is called "Fluent Style"? var selectVar = arrayVar.Select( (a,i) => new { Line = a }); var selectVar = from s in arrayVar select new { Line = s };
You are correct in your terminology! In LINQ (Language Integrated Query), the two coding styles you provided are known as: 1. **Fluent Syntax** (or Fluent API): This is the method-based approach where you use method chaining to build queries. Your first example (`arrayVar.Select((a, i) => new { Line = a });`) is an ex...
156
[ { "from": "human", "value": "I'm trying to find the correct names for these 2 \"types\" of coding expressions in LINQ so that I can refer to them correctly. I want to say that the first is called \"Fluent Style\"?\nvar selectVar = arrayVar.Select( (a,i) => new { Line = a });\n\nvar selectVar =\n from s i...
In Visual C++ a DWORD is just an unsigned long that is machine, platform, and SDK dependent. However, since DWORD is a double word (that is 2 * 16), is a DWORD still 32-bit on 64-bit architectures?
Yes, in Visual C++, a `DWORD` is defined as a 32-bit unsigned integer, regardless of whether the application is running on a 32-bit or 64-bit architecture. The name "DWORD" stands for "double word," which traditionally refers to a data type that is 32 bits (2 * 16 bits). In the Windows API and most applications using...
519
[ { "from": "human", "value": "In Visual C++ a DWORD is just an unsigned long that is machine, platform, and SDK dependent. However, since DWORD is a double word (that is 2 * 16), is a DWORD still 32-bit on 64-bit architectures?\n" }, { "from": "gpt", "value": "Yes, in Visual C++, a `DWORD` is de...
I have a DataTable with a Name column. I want to generate a collection of the unique names ordered alphabetically. The following query ignores the order by clause. var names = (from DataRow dr in dataTable.Rows orderby (string)dr["Name"] select (string)dr["Name"]).Distinct(); Why does the orderby not get e...
The issue you're encountering is due to the fact that the `Distinct()` method is being called after the `orderby` clause in the query. When you call `Distinct()`, it creates a new collection with unique elements, but it does not maintain the order specified by `orderby`. Instead, it returns the elements in a non-determ...
197
[ { "from": "human", "value": "I have a DataTable with a Name column. I want to generate a collection of the unique names ordered alphabetically. The following query ignores the order by clause.\nvar names =\n (from DataRow dr in dataTable.Rows\n orderby (string)dr[\"Name\"]\n select (string)dr[\"Nam...
Does anyone remember the XMP tag? What was it used for and why was it deprecated?
XMP, or Extensible Metadata Platform, is a standard created by Adobe that allows for the embedding of metadata into digital documents and files. XMP tags are used to store information such as copyright data, camera settings, descriptions, keywords, and other descriptive metadata within files like images, videos, and do...
164
[ { "from": "human", "value": "Does anyone remember the XMP tag?\nWhat was it used for and why was it deprecated?\n" }, { "from": "gpt", "value": "XMP, or Extensible Metadata Platform, is a standard created by Adobe that allows for the embedding of metadata into digital documents and files. XMP ta...
I would like to test a string containing a path to a file for existence of that file (something like the -e test in Perl or the os.path.exists() in Python) in C#.
In C#, you can check for the existence of a file using the `System.IO.File.Exists` method. This method returns a boolean value indicating whether the specified file exists. Below is an example of how you can use this method: ```csharp using System; using System.IO; class Program { static void Main() { ...
25
[ { "from": "human", "value": "I would like to test a string containing a path to a file for existence of that file (something like the -e test in Perl or the os.path.exists() in Python) in C#.\n" }, { "from": "gpt", "value": "In C#, you can check for the existence of a file using the `System.IO.F...
I'm working on a quick setup program in Visual Studio and wanted to change the banner bitmap. Anyone know off-hand what the ideal (or the required) dimensions are for the new banner image? Thanks.
In Visual Studio, if you're working on a setup project and want to change the banner bitmap, the recommended dimensions for the banner image are **468 x 60 pixels**. This size ensures that your image fits properly in the designated banner area of the installer. Make sure the image is in a compatible format, like BMP, ...
1,048
[ { "from": "human", "value": "I'm working on a quick setup program in Visual Studio and wanted to change the banner bitmap. Anyone know off-hand what the ideal (or the required) dimensions are for the new banner image? Thanks.\n" }, { "from": "gpt", "value": "In Visual Studio, if you're working o...
What's the best Python idiom for this C construct? while ((x = next()) != END) { .... } I don't have the ability to recode next(). update: and the answer from seems to be: for x in iter(next, END): ....
Your update is correct! In Python, the idiom you've mentioned is indeed the most Pythonic way to translate that C construct. The C loop you provided: ```c while ((x = next()) != END) { .... } ``` can be translated into Python using the `iter()` function with a sentinel value like this: ```python for x in iter(n...
490
[ { "from": "human", "value": "What's the best Python idiom for this C construct?\nwhile ((x = next()) != END) {\n ....\n}\n\nI don't have the ability to recode next().\nupdate: and the answer from seems to be:\nfor x in iter(next, END):\n ....\n\n" }, { "from": "gpt", "value": "Your update...
I recently printed out Jeff Atwood's Understanding The Hardware blog post and plan on taking it to Fry's Electronics and saying to them "Give me all the parts on these sheets so I can put this together." However, I'm going to be installing 64bit Windows Server 2008 on this machine so before I get all the parts: Will al...
When building a new computer and installing Windows Server 2008, it's crucial to ensure that all hardware components have compatible drivers for that specific operating system. Here are some general steps and tips to check compatibility: 1. **Check the Hardware Specifications**: For each component (motherboard, CPU, R...
11
[ { "from": "human", "value": "I recently printed out Jeff Atwood's Understanding The Hardware blog post and plan on taking it to Fry's Electronics and saying to them \"Give me all the parts on these sheets so I can put this together.\" However, I'm going to be installing 64bit Windows Server 2008 on this mac...
Does anyone have a definitive answer to whether Sql Server Management Objects is compatible with Sql Server 7.0? The docs state: Because SMO is compatible with SQL Server version 7.0, SQL Server 2000, SQL Server 2005, and SQL Server 2008, you easily manage a multi-version environment. But trying to connect to a Sql 7...
SQL Server Management Objects (SMO) is primarily designed for SQL Server 2000 and later versions. While the documentation states that SMO is compatible with SQL Server 7.0, it is important to note that the support may be limited. In practice, many users have experienced issues when attempting to connect to SQL Server 7...
365
[ { "from": "human", "value": "Does anyone have a definitive answer to whether Sql Server Management Objects is compatible with Sql Server 7.0?\nThe docs state:\n\nBecause SMO is compatible with SQL Server version 7.0, SQL Server 2000, SQL Server 2005, and SQL Server 2008, you easily manage a multi-version en...
How do I get Perl to read the contents of a given directory into an array? Backticks can do it, but is there some method using 'scandir' or a similar term?
In Perl, you can use the `scandir` function, which is part of the `File::Glob` module, to read the contents of a directory into an array. However, the most common way to do this in Perl is by using the `opendir` and `readdir` functions. Here's how you can do it using both methods: ### Method 1: Using `opendir` and `re...
194
[ { "from": "human", "value": "How do I get Perl to read the contents of a given directory into an array?\nBackticks can do it, but is there some method using 'scandir' or a similar term?\n" }, { "from": "gpt", "value": "In Perl, you can use the `scandir` function, which is part of the `File::Glob...
I am using LINQ to query a generic dictionary and then use the result as the datasource for my ListView (WebForms). Simplified code: Dictionary<Guid, Record> dict = GetAllRecords(); myListView.DataSource = dict.Values.Where(rec => rec.Name == "foo"); myListView.DataBind(); I thought that would work but in fact it thro...
The issue you're facing stems from the fact that the result of `dict.Values.Where(rec => rec.Name == "foo")` is a `WhereEnumerableIterator<Record>`, which does not implement `ICollection`. The `ListView` control requires a data source that implements `ICollection` (or provides other paging mechanisms) in order to manag...
421
[ { "from": "human", "value": "I am using LINQ to query a generic dictionary and then use the result as the datasource for my ListView (WebForms).\nSimplified code:\nDictionary<Guid, Record> dict = GetAllRecords();\nmyListView.DataSource = dict.Values.Where(rec => rec.Name == \"foo\");\nmyListView.DataBind();...
I'd like some sorthand for this: Map rowToMap(row) { def rowMap = [:]; row.columns.each{ rowMap[it.name] = it.val } return rowMap; } given the way the GDK stuff is, I'd expect to be able to do something like: Map rowToMap(row) { row.columns.collectMap{ [it.name,it.val] } } but I haven't seen anything ...
You're on the right track with wanting to use `collectMap`, which is a Groovy method that can simplify the creation of a map from a collection. The syntax you provided is almost correct, but you don't need to create an array for each entry. Instead, you can directly return a map entry inside the closure. Here's the co...
909
[ { "from": "human", "value": "I'd like some sorthand for this:\nMap rowToMap(row) {\n def rowMap = [:];\n row.columns.each{ rowMap[it.name] = it.val }\n return rowMap;\n}\n\ngiven the way the GDK stuff is, I'd expect to be able to do something like:\nMap rowToMap(row) {\n row.columns.collectMap{ ...
I want to merge two dictionaries into a new dictionary. x = {'a': 1, 'b': 2} y = {'b': 3, 'c': 4} z = merge(x, y) >>> z {'a': 1, 'b': 3, 'c': 4} Whenever a key k is present in both dictionaries, only the value y[k] should be kept.
You can merge two dictionaries in Python using dictionary comprehension or the `dict.update()` method. To achieve the desired output where the value from the second dictionary (`y`) takes precedence when a key is present in both dictionaries, you can use the following approach: ### Using Dictionary Comprehension ```py...
26
[ { "from": "human", "value": "I want to merge two dictionaries into a new dictionary.\nx = {'a': 1, 'b': 2}\ny = {'b': 3, 'c': 4}\nz = merge(x, y)\n\n>>> z\n{'a': 1, 'b': 3, 'c': 4}\n\nWhenever a key k is present in both dictionaries, only the value y[k] should be kept.\n" }, { "from": "gpt", "va...
I've spent a good amount of time coming up with solution to this problem, so in the spirit of this post, I'm posting it here, since I think it might be useful to others. If anyone has a better script, or anything to add, please post it. Edit: Yes guys, I know how to do it in Management Studio - but I needed to be able...
It sounds like you're sharing a script that you've developed to solve a problem related to SQL Server or a similar database system. Sharing solutions and scripts can indeed be incredibly helpful for others who might face the same issues. If you'd like to provide your script, I would be happy to take a look at it and gi...
1,026
[ { "from": "human", "value": "I've spent a good amount of time coming up with solution to this problem, so in the spirit of this post, I'm posting it here, since I think it might be useful to others. \nIf anyone has a better script, or anything to add, please post it.\nEdit: Yes guys, I know how to do it in ...
Using SqlServer, and trying to update rows from within the same table. I want to use a table alias for readability. This is the way I am doing it at the moment: UPDATE ra SET ra.ItemValue = rb.ItemValue FROM dbo.Rates ra, dbo.Rates rb WHERE ra.ResourceID = rb.ResourceID AND ra.PriceSched = 't8' AND rb.PriceSched = 't9...
Yes, there is a cleaner and more readable way to perform the update in SQL Server, especially when you want to use table aliases. Instead of using the old-style join syntax in your `FROM` clause, you can use the `JOIN` syntax, which is generally recommended for better clarity and maintainability. Here’s how you can rew...
148
[ { "from": "human", "value": "Using SqlServer, and trying to update rows from within the same table. I want to use a table alias for readability.\nThis is the way I am doing it at the moment:\nUPDATE ra \nSET ra.ItemValue = rb.ItemValue\nFROM dbo.Rates ra, dbo.Rates rb\nWHERE ra.ResourceID = rb.ResourceID\nA...
I have a perl variable $results that gets returned from a service. The value is supposed to be an array, and $results should be an array reference. However, when the array has only one item in it, $results will be set to that value, and not a referenced array that contains that one item. I want to do a foreach loop o...
You can handle the situation where `$results` might be either a scalar or an array reference by using the `UNIVERSAL::can` function. This allows you to avoid checking the reference directly. Instead, you can use the `Scalar::Util` module to determine if `$results` is a reference, and if it is not, you can wrap it into ...
355
[ { "from": "human", "value": "I have a perl variable $results that gets returned from a service. The value is supposed to be an array, and $results should be an array reference. However, when the array has only one item in it, $results will be set to that value, and not a referenced array that contains tha...
I'm using TortoiseSVN against the SourceForge SVN repository. I'd like to move a file from one folder to another in order to maintain its revision history. Is this possible? If so, how do you do it? (My current strategy has been to copy the file into the new folder and check it in and then delete the file from the curr...
Yes, it is indeed possible to move a file from one folder to another in Subversion (SVN) while maintaining its revision history. Instead of copying and then deleting the file, you should use the `svn move` command (or its equivalent in TortoiseSVN) to accomplish this. Here’s how you can do it: ### Using TortoiseSVN: ...
91
[ { "from": "human", "value": "I'm using TortoiseSVN against the SourceForge SVN repository. I'd like to move a file from one folder to another in order to maintain its revision history. Is this possible? If so, how do you do it?\n(My current strategy has been to copy the file into the new folder and check it...
What is the difference between Math.Floor() and Math.Truncate() in .NET?
In .NET, both `Math.Floor()` and `Math.Truncate()` are methods used to manipulate floating-point numbers, but they have different behaviors regarding how they handle the decimal portion of a number. ### Math.Floor() - **Definition**: `Math.Floor(double value)` returns the largest integer less than or equal to the spe...
105
[ { "from": "human", "value": "What is the difference between Math.Floor() and Math.Truncate() in .NET?\n" }, { "from": "gpt", "value": "In .NET, both `Math.Floor()` and `Math.Truncate()` are methods used to manipulate floating-point numbers, but they have different behaviors regarding how they ha...
If I've got a table containing Field1 and Field2 can I generate a new field in the select statement? For example, a normal query would be: SELECT Field1, Field2 FROM Table And I want to also create Field3 and have that returned in the resultset... something along the lines of this would be ideal: SELECT Field1, Field...
Yes, you can generate a new field in your SELECT statement and assign it a value directly in the query. The exact syntax may vary slightly depending on the SQL database system you are using, but here are some common ways to achieve this across various SQL dialects. ### SQL Server (T-SQL) In SQL Server, you can use th...
21
[ { "from": "human", "value": "If I've got a table containing Field1 and Field2 can I generate a new field in the select statement? For example, a normal query would be:\nSELECT Field1, Field2 FROM Table \n\nAnd I want to also create Field3 and have that returned in the resultset... something along the lines ...
In C#, if I have an inherited class with a default constructor, do I have to explicitly call the base class' constructor or will it be implicitly called? class BaseClass { public BaseClass() { // ... some code } } class MyClass : BaseClass { public MyClass() // Do I need to put ": base()" here o...
In C#, when you create a derived class (like `MyClass` in your example) that has a default constructor and the base class (like `BaseClass`) also has a default constructor, the base class's constructor is called implicitly. You do not need to explicitly call the base class constructor using `: base()`, because the co...
262
[ { "from": "human", "value": "In C#, if I have an inherited class with a default constructor, do I have to explicitly call the base class' constructor or will it be implicitly called?\nclass BaseClass\n{\n public BaseClass()\n {\n // ... some code\n }\n}\nclass MyClass : BaseClass\n{\n pub...
Is there a standard way for a web server to be able to determine a user's timezone within a web page? Perhaps from an HTTP header or part of the user-agent string?
There isn't a standard HTTP header or part of the user-agent string that directly conveys a user's timezone to a web server. Timezone information is not typically sent by browsers as part of requests. However, there are a few common approaches to determine a user's timezone within a web application: 1. **JavaScript**:...
62
[ { "from": "human", "value": "Is there a standard way for a web server to be able to determine a user's timezone within a web page? \nPerhaps from an HTTP header or part of the user-agent string?\n" }, { "from": "gpt", "value": "There isn't a standard HTTP header or part of the user-agent string ...
I need to decrement a Javascript date by 1 day, so that it rolls back across months/years correctly. That is, if I have a date of 'Today', I want to get the date for 'Yesterday'. It always seems to take more code than necessary when I do this, so I'm wondering if there's any simpler way. What's the simplest way of d...
In JavaScript, you can easily decrement a date by one day using the `Date` object. The simplest way to do this is to use the `setDate` method, which adjusts the day of the month automatically across month and year boundaries. Here's how you can do it: ```javascript // Get today's date let today = new Date(); // Decre...
973
[ { "from": "human", "value": "I need to decrement a Javascript date by 1 day, so that it rolls back across months/years correctly. That is, if I have a date of 'Today', I want to get the date for 'Yesterday'.\nIt always seems to take more code than necessary when I do this, so I'm wondering if there's any s...
I'm setting up a dedicated SQL Server 2005 box on Windows Server 2008 this week, and would like to pare it down to be as barebones as possible while still being fully functional. To that end, the "Server Core" option sounds appealing, but I'm not clear about whether or not I can run SQL Server on that SKU. Several ser...
SQL Server 2005 cannot be installed on Windows Server 2008 Server Core. While Windows Server 2008 does offer a Server Core installation option, SQL Server 2005 is not supported in that environment. The primary reason for this is that SQL Server 2005 relies on several graphical components and features that are not avail...
209
[ { "from": "human", "value": "I'm setting up a dedicated SQL Server 2005 box on Windows Server 2008 this week, and would like to pare it down to be as barebones as possible while still being fully functional.\nTo that end, the \"Server Core\" option sounds appealing, but I'm not clear about whether or not I ...
Assuming such a query exists, I would greatly appreciate the help. I'm trying to develop a permissions script that will grant "select" and "references" permissions on the user tables and views in a database. My hope is that executing the "grant" commands on each element in such a set will make it easier to keep permis...
Certainly! To create a script that grants `SELECT` and `REFERENCES` permissions on all user tables and views in a database, you can use dynamic SQL. Below is an example script for SQL Server that does this. The script will generate `GRANT` commands for each user table and view and execute them. ### SQL Server Script ...
80
[ { "from": "human", "value": "Assuming such a query exists, I would greatly appreciate the help.\nI'm trying to develop a permissions script that will grant \"select\" and \"references\" permissions on the user tables and views in a database. My hope is that executing the \"grant\" commands on each element ...
In a installation of WebSphere Application Server with Network Deployment, a node is: a physical machine an instance of operative system a logical set of WAS instances that is independent of physical machine or OS instance
In a WebSphere Application Server (WAS) with Network Deployment (ND), a **node** is best described as **a logical set of WAS instances that is independent of physical machine or OS instance**. This means that a node can encompass multiple server instances (application servers) and can span across physical machines or...
1,369
[ { "from": "human", "value": "In a installation of WebSphere Application Server with Network Deployment, a node is:\n\na physical machine\nan instance of operative system\na logical set of WAS instances that is independent of physical machine or OS instance\n\n" }, { "from": "gpt", "value": "In a...
I heard that if you use port 443 (the port usually used for https) for ssh, the encrypted packets look the same to your isp. Could this be a way to avoid traffic shaping/throttling?
Using port 443 for SSH can indeed help you evade some forms of traffic shaping or throttling. Traffic shaping typically relies on deep packet inspection (DPI) to analyze the contents of packets and determine the type of traffic. By running SSH over port 443, which is commonly used for HTTPS traffic, the packets might a...
160
[ { "from": "human", "value": "I heard that if you use port 443 (the port usually used for https) for ssh, the encrypted packets look the same to your isp.\nCould this be a way to avoid traffic shaping/throttling?\n" }, { "from": "gpt", "value": "Using port 443 for SSH can indeed help you evade so...
Is it true that the only way to handle default function arguments is through function overloading? For example, in PHP I can do this: function foo($x, $y=0) { } Would the best way to handle it in C# be this? void foo(int x) { foo(x, 0); } void foo(int x, int y) { } Example lifted from here Edit Made the C# example...
In C#, there is no direct equivalent to default function arguments like there is in languages such as PHP or Python. However, you can achieve similar behavior using method overloading, as you correctly demonstrated in your example. ### Example in C#: Here’s how you can implement default arguments using method overlo...
215
[ { "from": "human", "value": "Is it true that the only way to handle default function arguments is through function overloading?\nFor example, in PHP I can do this:\nfunction foo($x, $y=0)\n{\n}\n\nWould the best way to handle it in C# be this?\nvoid foo(int x)\n{\n foo(x, 0);\n}\n\nvoid foo(int x, int y)\n...
I'm looking for a testing framework for the Windows kernel environment. So far, I've found cfix. Has any one tried it? Are there alternatives?
cfix is indeed one of the testing frameworks specifically designed for the Windows kernel environment. It provides a framework for writing and running unit tests for kernel-mode drivers, and it integrates well with the Windows Driver Kit (WDK). cfix allows developers to catch bugs early in the development cycle and can...
339
[ { "from": "human", "value": "I'm looking for a testing framework for the Windows kernel environment. So far, I've found cfix. Has any one tried it? Are there alternatives?\n" }, { "from": "gpt", "value": "cfix is indeed one of the testing frameworks specifically designed for the Windows kernel e...
If I have data like this: Key Name 1 Dan 2 Tom 3 Jon 4 Tom 5 Sam 6 Dan What is the SQL query to bring back the records where Name is repeated 2 or more times? So the result I would want is Tom Dan
To retrieve the names that are repeated 2 or more times from your data, you can use the following SQL query. This query will group the records by `Name`, count the occurrences of each name, and then filter the results to include only those names that have a count of 2 or more. Here's the SQL query: ```sql SELECT Name...
904
[ { "from": "human", "value": "If I have data like this:\n\n\n\n\nKey\nName\n\n\n\n\n1\nDan\n\n\n2\nTom\n\n\n3\nJon\n\n\n4\nTom\n\n\n5\nSam\n\n\n6\nDan\n\n\n\n\nWhat is the SQL query to bring back the records where Name is repeated 2 or more times?\nSo the result I would want is\n\n\n\n\nTom\n\n\n\n\nDan\n\n\...
Can you cast a List<int> to List<string> somehow? I know I could loop through and .ToString() the thing, but a cast would be awesome. I'm in C# 2.0 (so no LINQ).
In C# 2.0, you cannot directly cast a `List<int>` to a `List<string>` since they are different types. However, since you want to convert each integer in the list to a string, you will need to create a new `List<string>` and populate it by looping through the `List<int>`. Here is an example of how you can do this: ```...
544
[ { "from": "human", "value": "Can you cast a List<int> to List<string> somehow?\nI know I could loop through and .ToString() the thing, but a cast would be awesome.\nI'm in C# 2.0 (so no LINQ).\n" }, { "from": "gpt", "value": "In C# 2.0, you cannot directly cast a `List<int>` to a `List<string>` ...
I want to loop over the contents of a text file and do a search and replace on some lines and write the result back to the file. I could first load the whole file in memory and then write it back, but that probably is not the best way to do it. What is the best way to do this, within the following code? f = open(file) ...
The approach you're considering—reading a file line by line and replacing text—is common, but you need to be cautious when writing back to the same file while reading from it. One way to handle this is to read the contents into memory, make your changes, and then write the changes back to the file in one go. However,...
40
[ { "from": "human", "value": "I want to loop over the contents of a text file and do a search and replace on some lines and write the result back to the file. I could first load the whole file in memory and then write it back, but that probably is not the best way to do it.\nWhat is the best way to do this, ...
I need to find out how to format numbers as strings. My code is here: return str(hours)+":"+str(minutes)+":"+str(seconds)+" "+ampm Hours and minutes are integers, and seconds is a float. the str() function will convert all of these numbers to the tenths (0.1) place. So instead of my string outputting "5:30:59.07 pm"...
To format your numbers as strings in a way that avoids the conversion of integers to floating point representation (e.g., "5" being displayed as "5.0"), you can use Python's formatted string literals (also known as f-strings) or the `.format()` method. You should ensure that you are formatting each number to show the a...
616
[ { "from": "human", "value": "I need to find out how to format numbers as strings. My code is here:\nreturn str(hours)+\":\"+str(minutes)+\":\"+str(seconds)+\" \"+ampm\n\nHours and minutes are integers, and seconds is a float. the str() function will convert all of these numbers to the tenths (0.1) place. ...
In C, are the shift operators (<<, >>) arithmetic or logical?
In C, the behavior of the shift operators (`<<` for left shift and `>>` for right shift) depends on the type of the operand being shifted. 1. **Left Shift (`<<`)**: - The left shift operator (`<<`) always performs a logical shift. It shifts the bits to the left and fills the vacated bits on the right with zeros, r...
165
[ { "from": "human", "value": "In C, are the shift operators (<<, >>) arithmetic or logical?\n" }, { "from": "gpt", "value": "In C, the behavior of the shift operators (`<<` for left shift and `>>` for right shift) depends on the type of the operand being shifted. \n\n1. **Left Shift (`<<`)**:\n ...
I've heard rumors that PHP is planning on introducing a "goto" command. What is it supposed to be doing? I've tried searching a bit, but haven't found anything awfully descriptive. I understand that it won't be a "GOTO 10"-like command...
Yes, there has been discussion in the PHP community about introducing a `goto` statement, which is intended to provide a way to jump to a specific point in the code. However, it's worth noting that the `goto` statement is generally not favored in modern programming practices due to its potential to create unmanageable ...
151
[ { "from": "human", "value": "I've heard rumors that PHP is planning on introducing a \"goto\" command. What is it supposed to be doing?\nI've tried searching a bit, but haven't found anything awfully descriptive. I understand that it won't be a \"GOTO 10\"-like command...\n" }, { "from": "gpt", ...
VC++ makes functions which are implemented within the class declaration inline functions. If I declare a class Foo as follows, then are the CONSTRUCTOR and DESTRUCTOR inline functions? class Foo { int* p; public: Foo() { p = new char[0x00100000]; } ~Foo() { delete [] p; } }; { Foo f; (f); }
In C++, functions defined within a class definition are indeed treated as inline functions. This applies to constructors and destructors as well. In your example, both the constructor `Foo()` and the destructor `~Foo()` are defined directly within the class definition. Here’s the breakdown: ```cpp class Foo { i...
901
[ { "from": "human", "value": "VC++ makes functions which are implemented within the class declaration inline functions.\nIf I declare a class Foo as follows, then are the CONSTRUCTOR and DESTRUCTOR inline functions?\nclass Foo \n{\n int* p;\npublic:\n Foo() { p = new char[0x00100000]; }\n ~Foo() { d...
When looking at a SSI printenv dump I see a variable URI_REQUEST. When reading the Apache mod_include docs I see DOCUMENT_URI which they define as "The (%-decoded) URL path of the document requested by the user." Anyone know the difference between the two? TIA.
In the context of Apache server and Server Side Includes (SSI), both `URI_REQUEST` and `DOCUMENT_URI` are used to refer to the URL of the resource being accessed, but they serve slightly different purposes and are populated differently. ### `DOCUMENT_URI` - `DOCUMENT_URI` is a standard variable in SSI that provides th...
125
[ { "from": "human", "value": "When looking at a SSI printenv dump I see a variable URI_REQUEST.\nWhen reading the Apache mod_include docs I see DOCUMENT_URI which they define as \"The (%-decoded) URL path of the document requested by the user.\"\nAnyone know the difference between the two?\nTIA.\n" }, { ...
I was reading this question about how to parse URLs out of web pages and had a question about the accepted answer which offered this solution: ((mailto\:|(news|(ht|f)tp(s?))\://){1}\S+) The solution was offered by csmba and he credited it to regexlib.com. Whew. Credits done. I think this is a fairly naive regular expr...
You're correct that the `{1}` quantifier in the context of a regular expression indicates "exactly one occurrence" of the preceding element. However, in many regex implementations, if you do not specify a quantifier, it defaults to "exactly one" as well. Therefore, including `{1}` in this case is redundant. So to addr...
263
[ { "from": "human", "value": "I was reading this question about how to parse URLs out of web pages and had a question about the accepted answer which offered this solution:\n((mailto\\:|(news|(ht|f)tp(s?))\\://){1}\\S+)\n\nThe solution was offered by csmba and he credited it to regexlib.com. Whew. Credits do...
Given a string of JSON data, how can I safely turn that string into a JavaScript object? Obviously I can do this unsafely with something like: var obj = eval("(" + json + ')'); but that leaves me vulnerable to the JSON string containing other code, which it seems very dangerous to simply eval.
To safely convert a JSON string into a JavaScript object, you should use the built-in `JSON.parse()` method, which is specifically designed for parsing JSON strings. This method only processes valid JSON and does not execute any JavaScript code, making it a safe alternative to using `eval()`. Here’s how you can do it: ...
951
[ { "from": "human", "value": "Given a string of JSON data, how can I safely turn that string into a JavaScript object?\nObviously I can do this unsafely with something like:\nvar obj = eval(\"(\" + json + ')');\n\nbut that leaves me vulnerable to the JSON string containing other code, which it seems very dan...
I have 2 hosts and I would like to point a subdomain on host one to a subdomain on host two: subdomain.hostone.com --> subdomain.hosttwo.com I added a CNAME record to host one that points to subdomain.hosttwo.com but all I get is a '400 Bad Request' Error. Can anyone see what I'm doing wrong?
To point a subdomain from one host to another using a CNAME record, you need to make sure a few things are correctly configured. Here’s a step-by-step approach to troubleshoot your issue: 1. **CNAME Record Configuration**: Make sure your CNAME record for `subdomain.hostone.com` is configured correctly. The CNAME shoul...
68
[ { "from": "human", "value": "I have 2 hosts and I would like to point a subdomain on host one to a subdomain on host two:\nsubdomain.hostone.com --> subdomain.hosttwo.com\n\nI added a CNAME record to host one that points to subdomain.hosttwo.com but all I get is a '400 Bad Request' Error.\nCan anyone see wh...
In the SSW rules to better SQL Server Database there is an example of a full database maintenance plan: SSW. In the example they run both a Reorganize Index and then a Rebuild Index and then Update Statistics. Is there any point to this? I thought Reorganize Index was a fast but less effective version of Rebuild Index?...
You are correct in your understanding of the differences between index reorganize and index rebuild operations in SQL Server. ### Key Differences: 1. **Index Reorganize**: - This is a lightweight, online operation that can be performed without locking the table. - It addresses fragmentation by physically reorga...
128
[ { "from": "human", "value": "In the SSW rules to better SQL Server Database there is an example of a full database maintenance plan: SSW. In the example they run both a Reorganize Index and then a Rebuild Index and then Update Statistics. Is there any point to this? I thought Reorganize Index was a fast but...
I want to create a Java application bundle for Mac without using Mac. According to Java Deployment Options for Mac OS X, I can do this by using Xcode, Jar Bundler, or from the command line. Once the files and folders are set up, all I need for the command line method is to call /Developer/Tools/SetFile. Is there a SetF...
To create a Java application bundle for macOS without using a Mac, you will encounter some challenges since the standard tools for creating macOS applications are designed to run on macOS itself. However, you can explore a few alternatives: ### 1. **Using Wine:** You can install **Wine** on Linux or Windows, which all...
53
[ { "from": "human", "value": "I want to create a Java application bundle for Mac without using Mac.\nAccording to Java Deployment Options for Mac OS X, I can do this by using Xcode, Jar Bundler, or from the command line. Once the files and folders are set up, all I need for the command line method is to call...
Anyone know of a way to capture keyboard events (keyup / keydown) in Portable IE under Window mobile? I noticed that key events are not supported in JS, and would like to come up with a solution that works without any client side additions.
Capturing keyboard events in Portable Internet Explorer (IE) on Windows Mobile can be challenging due to the limited support for certain JavaScript events. Unfortunately, as you've discovered, the keyup and keydown events may not be fully supported in this environment. Here are a few alternative approaches you might c...
392
[ { "from": "human", "value": "Anyone know of a way to capture keyboard events (keyup / keydown) in Portable IE under Window mobile? I noticed that key events are not supported in JS, and would like to come up with a solution that works without any client side additions.\n" }, { "from": "gpt", "va...
I'm attempting to use Mono to load a bitmap and print it on Linux but I'm getting an exception. Does Mono support printing on Linux? The code/exception are below: EDIT: No longer getting the exception, but I'm still curious what kind of support there is. Leaving the code for posterity or something. private void btnP...
Mono does provide support for printing on Linux, but the implementation may not be as robust or feature-complete as on Windows, primarily because the .NET printing model was originally designed with Windows in mind. Here are a few important points regarding printing in Mono on Linux: 1. **Printing API**: The System.Dr...
367
[ { "from": "human", "value": "I'm attempting to use Mono to load a bitmap and print it on Linux but I'm getting an exception. Does Mono support printing on Linux? The code/exception are below:\nEDIT: No longer getting the exception, but I'm still curious what kind of support there is. Leaving the code for...
I just requested a hotfix from support.microsoft.com and put in my email address, but I haven't received the email yet. The splash page I got after I requested the hotfix said: Hotfix Confirmation We will send these hotfixes to the following e-mail address: (my correct email address) Usually, our hotfix e-mail is de...
Typically, after requesting a hotfix from Microsoft, the confirmation email is sent promptly, usually within a few minutes. However, delays can occur for various reasons, including issues with email delivery systems, server load, or technical problems on their end. Here are a few points to consider while you wait: 1....
673
[ { "from": "human", "value": "I just requested a hotfix from support.microsoft.com and put in my email address, but I haven't received the email yet. The splash page I got after I requested the hotfix said:\n\nHotfix Confirmation\nWe will send these hotfixes to the following e-mail address:\n (my correct ema...
So I have a Sybase stored proc that takes 1 parameter that's a comma separated list of strings and runs a query with in in an IN() clause: CREATE PROCEDURE getSomething @keyList varchar(4096) AS SELECT * FROM mytbl WHERE name IN (@keyList) How do I call my stored proc with more than 1 value in the list? So far I've tr...
To pass a comma-separated list of strings to your Sybase stored procedure and use it within the `IN()` clause, you need to ensure that your `@keyList` string is formatted correctly so that SQL can interpret it as a list of strings. When calling your stored procedure, you'll want to pass the list as a single string wher...
74
[ { "from": "human", "value": "So I have a Sybase stored proc that takes 1 parameter that's a comma separated list of strings and runs a query with in in an IN() clause:\nCREATE PROCEDURE getSomething @keyList varchar(4096)\nAS\nSELECT * FROM mytbl WHERE name IN (@keyList)\n\nHow do I call my stored proc with...
Is there a way to find the number of files of a specific type without having to loop through all results inn a Directory.GetFiles() or similar method? I am looking for something like this: int ComponentCount = MagicFindFileCount(@"c:\windows\system32", "*.dll"); I know that I can make a recursive function to call Dire...
In .NET, there isn't a built-in method that directly returns the count of files of a specific type without iterating over them in some form. The `Directory.GetFiles` method retrieves an array of file paths that match the specified search pattern, and typically you would need to call `.Length` on the result to get the c...
450
[ { "from": "human", "value": "Is there a way to find the number of files of a specific type without having to loop through all results inn a Directory.GetFiles() or similar method? I am looking for something like this:\nint ComponentCount = MagicFindFileCount(@\"c:\\windows\\system32\", \"*.dll\");\n\nI know...
I need the name of the current logged in user in my Air/Flex application. The application will only be deployed on Windows machines. I think I could attain this by regexing the User directory, but am open to other ways.
In an Adobe Air/Flex application, you can retrieve the name of the currently logged-in user on a Windows machine without the need for regex or parsing the user directory. Instead, you can use the `File` class in the `flash.filesystem` package to access the user directory directly. Here's a simple way to achieve this:...
191
[ { "from": "human", "value": "I need the name of the current logged in user in my Air/Flex application. The application will only be deployed on Windows machines. I think I could attain this by regexing the User directory, but am open to other ways.\n" }, { "from": "gpt", "value": "In an Adobe Ai...
We've been using the 32bit linux version of the JavaServiceWrapper for quite a while now and it's working perfectly. We are now considering also using it on 64bit linux systems. There are downloads for 64bit binaries on the website, but looking into Makefile for the 64bit version I found the following comment, though: ...
As of my last knowledge update in October 2023, I cannot confirm the current state of the 64-bit version of JavaServiceWrapper or the validity of that specific comment in the Makefile you referenced. Software development projects, especially open-source ones, can evolve rapidly, and the status of a feature or a build p...
451
[ { "from": "human", "value": "We've been using the 32bit linux version of the JavaServiceWrapper for quite a while now and it's working perfectly. We are now considering also using it on 64bit linux systems. There are downloads for 64bit binaries on the website, but looking into Makefile for the 64bit versio...
How can I permanently enable line numbers in IntelliJ IDEA?
To permanently enable line numbers in IntelliJ IDEA, follow these steps: 1. **Open IntelliJ IDEA**: Start the application. 2. **Go to Settings**: - On Windows/Linux: Click on `File` in the menu bar, then select `Settings`. - On macOS: Click on `IntelliJ IDEA` in the menu bar, then select `Preferences`. 3. **Na...
1,097
[ { "from": "human", "value": "How can I permanently enable line numbers in IntelliJ IDEA?\n" }, { "from": "gpt", "value": "To permanently enable line numbers in IntelliJ IDEA, follow these steps:\n\n1. **Open IntelliJ IDEA**: Start the application.\n\n2. **Go to Settings**:\n - On Windows/Linux...
I have a (potentially dumb) question about the C++ STL. When I make a container (vector, set, map, etc), is it allocated on the stack or on the heap? If I make a set and put 5 million strings, will I have to worry about a stack overflow?
That's a great question, and it's important to understand the difference between stack and heap memory in C++ when working with containers from the Standard Template Library (STL). When you create a container like a `std::vector`, `std::set`, or `std::map`, the container itself can be allocated either on the stack or ...
240
[ { "from": "human", "value": "I have a (potentially dumb) question about the C++ STL. When I make a container (vector, set, map, etc), is it allocated on the stack or on the heap? If I make a set and put 5 million strings, will I have to worry about a stack overflow?\n" }, { "from": "gpt", "val...
I am using the basic-auth twitter API (no longer available) to integrate twitter with my blog's commenting system. The problem with this and many other web APIs out there is that they require the user's username and password to do anything useful. I don't want to deal with the hassle and cost of installing a SSL cert...
Your approach to encrypting the user's password before sending it over an insecure channel addresses some security concerns, but there are significant vulnerabilities and risks associated with this method. Here are some critical points to consider: 1. **JavaScript Key Exposure**: By outputting the encryption key to a ...
8
[ { "from": "human", "value": "I am using the basic-auth twitter API (no longer available) to integrate twitter with my blog's commenting system. The problem with this and many other web APIs out there is that they require the user's username and password to do anything useful. I don't want to deal with the...
Right now, I keep all of my projects on my laptop. I'm thinking that I shouldn't do this, but instead use a version control system and check them in/out from an external hosting repository (Google Code, SourceForge, etc). I see several benefits here - first, I don't have to worry about losing my code if my computer cra...
Yes, using a version control system (VCS) and hosting your projects on an external repository is an excellent idea for several reasons, as you've already mentioned. It enhances the safety of your code, facilitates collaboration, and allows you to track changes more efficiently. Here are some other project hosting opti...
447
[ { "from": "human", "value": "Right now, I keep all of my projects on my laptop. I'm thinking that I shouldn't do this, but instead use a version control system and check them in/out from an external hosting repository (Google Code, SourceForge, etc). I see several benefits here - first, I don't have to worr...
In Ruby, given an array in one of the following forms... [apple, 1, banana, 2] [[apple, 1], [banana, 2]] ...what is the best way to convert this into a hash in the form of... {apple => 1, banana => 2}
You can convert the given array into a hash in Ruby using different approaches depending on the format of the input array. ### For the first format: `[apple, 1, banana, 2]` You can use `each_slice` to group elements into pairs and then convert them into a hash using `to_h`: ```ruby array = [:apple, 1, :banana, 2] # ...
629
[ { "from": "human", "value": "In Ruby, given an array in one of the following forms...\n[apple, 1, banana, 2]\n[[apple, 1], [banana, 2]]\n\n...what is the best way to convert this into a hash in the form of...\n{apple => 1, banana => 2}\n\n" }, { "from": "gpt", "value": "You can convert the given...
Is it possible to develop a plug-in for Internet Explorer that can replace the existing favorites functionality?
Yes, it is possible to develop a plug-in for Internet Explorer that can modify or replace the existing favorites functionality, although there are some important considerations: 1. **Development Environment**: Internet Explorer supports ActiveX controls and Browser Helper Objects (BHOs) as methods for extending its fu...
399
[ { "from": "human", "value": "Is it possible to develop a plug-in for Internet Explorer that can replace the existing favorites functionality?\n" }, { "from": "gpt", "value": "Yes, it is possible to develop a plug-in for Internet Explorer that can modify or replace the existing favorites function...
So I've looked at this use of the freebase API and I was really impressed with the translations of the name that it found. IE Rome, Roma, Rom, Rzym, Rooma,로마, 罗马市. This is because I have a database of some 5000+ location names and I would very much like all French, German or Korean translations for these English names....
It's great to hear that you're impressed with Freebase and the multilingual capabilities it offers! However, it's important to note that Freebase was officially shut down in 2016, and its data has largely been migrated to Wikidata, a collaborative knowledge base that also supports multilingual information. If you're l...
394
[ { "from": "human", "value": "So I've looked at this use of the freebase API and I was really impressed with the translations of the name that it found. IE Rome, Roma, Rom, Rzym, Rooma,로마, 罗马市. This is because I have a database of some 5000+ location names and I would very much like all French, German or Kor...
Winform on CF is a bit heavy, initialising a lot of windows handles takes serious time and memory. Another issue is the lack of inbuilt double buffering and lack of control you have over the UI rendering means that during processor intensive operations the UI might leave the user staring at a half rendered screen. Nice...
If you're looking for a lightweight control framework for WinForms on Compact Framework (CF), the options are somewhat limited due to the constraints of the environment. However, there are a few approaches you can consider: ### 1. **Custom Control Development** Since you want full control over the painting of controls...
78
[ { "from": "human", "value": "Winform on CF is a bit heavy, initialising a lot of windows handles takes serious time and memory. Another issue is the lack of inbuilt double buffering and lack of control you have over the UI rendering means that during processor intensive operations the UI might leave the use...
Obviously, that's 64-bit windows. Also, what's the maximum amount of memory a single 64-bit process can use? I was kind of counting on using it all... (Yes, I know what I'm doing, please don't tell me that if I need that much RAM i must be doing something wrong) Also, is this the same for a .Net 2.0 process? Or is the...
On a 64-bit version of Windows, the theoretical maximum amount of memory that a single 64-bit process can use is 16 exabytes (EB), which is 2^64 bytes. However, this is not practically achievable due to operating system limitations, hardware constraints, and other factors. In practice, the maximum addressable space fo...
599
[ { "from": "human", "value": "Obviously, that's 64-bit windows.\nAlso, what's the maximum amount of memory a single 64-bit process can use?\nI was kind of counting on using it all... \n(Yes, I know what I'm doing, please don't tell me that if I need that much RAM i must be doing something wrong)\nAlso, is th...
Is there any way to check whether a file is locked without using a try/catch block? Right now, the only way I know of is to just open the file and catch any System.IO.IOException.
Yes, you can check if a file is locked without using a try/catch block in C#. One common approach is to use the `FileStream` class with specific access and sharing options. By attempting to open the file with `FileShare.None`, you can check if the file is locked by other processes. However, it still requires some excep...
114
[ { "from": "human", "value": "Is there any way to check whether a file is locked without using a try/catch block? \nRight now, the only way I know of is to just open the file and catch any System.IO.IOException.\n" }, { "from": "gpt", "value": "Yes, you can check if a file is locked without usin...
What is the best way to include an html entity in XSLT? <xsl:template match="/a/node"> <xsl:value-of select="."/> <xsl:text>&nbsp;</xsl:text> </xsl:template> this one returns a XsltParseError
When working with XSLT, if you want to include an HTML entity such as `&nbsp;` (non-breaking space), you should use the proper syntax for XML entities. In XSLT, the `&nbsp;` entity is not recognized since it's an HTML entity and XML does not support it directly. Instead, you should use the appropriate numeric characte...
858
[ { "from": "human", "value": "What is the best way to include an html entity in XSLT?\n<xsl:template match=\"/a/node\">\n <xsl:value-of select=\".\"/>\n <xsl:text>&nbsp;</xsl:text>\n</xsl:template>\n\nthis one returns a XsltParseError\n" }, { "from": "gpt", "value": "When working with XSLT,...
The ones that stick out and make life usefull.
It sounds like you're referring to key concepts, principles, or tools that enhance our lives and make them more meaningful or practical. Here are a few that often resonate with people: 1. **Mindfulness**: Practicing mindfulness can help you become more aware of the present moment, reducing stress and enhancing your ov...
418
[ { "from": "human", "value": "The ones that stick out and make life usefull.\n" }, { "from": "gpt", "value": "It sounds like you're referring to key concepts, principles, or tools that enhance our lives and make them more meaningful or practical. Here are a few that often resonate with people:\n\...
Is there a way to select a parent element based on the class of a child element in the class? The example that is relevant to me relating to HTML output by a nice menu plugin for http://drupal.org. The output renders like this: <ul class="menu"> <li> <a class="active">Active Page</a> </li> ...
In CSS, there isn't a direct way to select a parent element based on the class of a child element. CSS selectors operate in a way that does not allow for "parent selection." This means you cannot select a `<li>` based on the class of an `<a>` within it. However, there are some workarounds you might consider: ### 1. U...
855
[ { "from": "human", "value": "Is there a way to select a parent element based on the class of a child element in the class? The example that is relevant to me relating to HTML output by a nice menu plugin for http://drupal.org. The output renders like this: \n<ul class=\"menu\"> \n <li> \n <a ...
I'm trying to do this (which produces an unexpected T_VARIABLE error): public function createShipment($startZip, $endZip, $weight = $this->getDefaultWeight()){} I don't want to put a magic number in there for weight since the object I am using has a "defaultWeight" parameter that all new shipments get if you don't sp...
The error you're encountering is due to the way PHP handles default parameter values. In PHP, you cannot use a method call or any non-static expression to set a default value for a function parameter. Default parameter values must be constant expressions. Given your requirements, you have a couple of options. The appr...
254
[ { "from": "human", "value": "I'm trying to do this (which produces an unexpected T_VARIABLE error):\npublic function createShipment($startZip, $endZip, $weight = \n$this->getDefaultWeight()){}\n\nI don't want to put a magic number in there for weight since the object I am using has a \"defaultWeight\" param...
After reading Jeff's blog post on Protecting Your Cookies: HttpOnly. I'd like to implement HttpOnly cookies in my web application. How do you tell tomcat to use http only cookies for sessions?
To configure Tomcat to use HttpOnly cookies for sessions, you need to set the `useHttpOnly` attribute in the `context.xml` configuration file or directly in the web application's `web.xml` file. Here’s how you can do it: ### Option 1: Using `context.xml` 1. Open your `context.xml` file, which is usually located in t...
324
[ { "from": "human", "value": "After reading Jeff's blog post on Protecting Your Cookies: HttpOnly. I'd like to implement HttpOnly cookies in my web application.\nHow do you tell tomcat to use http only cookies for sessions?\n" }, { "from": "gpt", "value": "To configure Tomcat to use HttpOnly cook...
Original Question I am looking for a function that attempts to quantify how "distant" (or distinct) two colors are. This question is really in two parts: What color space best represents human vision? What distance metric in that space best represents human vision (euclidean?)
To quantify how "distant" or distinct two colors are in a way that aligns with human perception, we can break down the question into two parts: ### 1. Color Space **Best Color Space for Human Vision**: - **CIE L*a*b***: This color space is often considered the most perceptually uniform space. It was designed to be ...
145
[ { "from": "human", "value": "Original Question\nI am looking for a function that attempts to quantify how \"distant\" (or distinct) two colors are. This question is really in two parts: \n\nWhat color space best represents human vision?\nWhat distance metric in that space best represents human vision (eucli...
I need to deploy a few files that were checked in sometime ago (can't remember the exact ones), so I'm looking to get a list so I can deploy just those files. What is the svn command to do this?
To get a list of files that were changed in a specific revision in SVN (Subversion), you can use the `svn diff` command with the `--summarize` option. This will show you the list of changed files, including additions, deletions, and modifications. Here's how you can do it: 1. First, identify the revision number you wa...
1,005
[ { "from": "human", "value": "I need to deploy a few files that were checked in sometime ago (can't remember the exact ones), so I'm looking to get a list so I can deploy just those files. What is the svn command to do this?\n" }, { "from": "gpt", "value": "To get a list of files that were change...
Is there any way to apply an attribute to a model file in ASP.NET Dynamic Data to hide the column? For instance, I can currently set the display name of a column like this: [DisplayName("Last name")] public object Last_name { get; set; } Is there a similar way to hide a column? Edit: Many thanks to Christian Hagelid f...
Yes, you can hide a column in an ASP.NET Dynamic Data model by using the `ScaffoldColumn` attribute. When you apply this attribute to a property in your model and set it to `false`, it tells the Dynamic Data framework not to display this column in the generated UI. Here is how you can do it: ```csharp using System.Co...
1,062
[ { "from": "human", "value": "Is there any way to apply an attribute to a model file in ASP.NET Dynamic Data to hide the column?\nFor instance, I can currently set the display name of a column like this:\n[DisplayName(\"Last name\")]\npublic object Last_name { get; set; }\n\nIs there a similar way to hide a ...
I’m thinking about trying some development for the iPhone, is it possible to install Leopard inside VMWare? I already have a pretty high spec PC with a comfy setup that I’d like to use, or do I need to buy a real Mac?
Running macOS, including Leopard (macOS 10.5), inside VMware on a non-Apple hardware is technically possible, but it comes with legal and technical challenges. Here are some points to consider: 1. **Legal Issues**: Apple's End User License Agreement (EULA) restricts the installation of macOS to Apple-branded hardware....
585
[ { "from": "human", "value": "I’m thinking about trying some development for the iPhone, is it possible to install Leopard inside VMWare? I already have a pretty high spec PC with a comfy setup that I’d like to use, or do I need to buy a real Mac?\n" }, { "from": "gpt", "value": "Running macOS, i...
I have a list of integers, List<Integer> and I'd like to convert all the integer objects into Strings, thus finishing up with a new List<String>. Naturally, I could create a new List<String> and loop through the list calling String.valueOf() for each integer, but I was wondering if there was a better (read: more automa...
Yes, you can use Java Streams to convert a `List<Integer>` to a `List<String>` in a more concise and elegant way without manually looping through the list. Here’s how you can achieve this: ```java import java.util.List; import java.util.stream.Collectors; public class Main { public static void main(String[] args)...
852
[ { "from": "human", "value": "I have a list of integers, List<Integer> and I'd like to convert all the integer objects into Strings, thus finishing up with a new List<String>.\nNaturally, I could create a new List<String> and loop through the list calling String.valueOf() for each integer, but I was wonderin...
I have an SQL query that takes the following form: UPDATE foo SET flag=true WHERE id=? I also have a PHP array which has a list of IDs. What is the best way to accomplish this other than with parsing, as follows, ... foreach($list as $item){ $querycondition = $querycondition . " OR " . $item; } ... and using ...
You can optimize your SQL query by using the `IN` clause instead of building a long `OR` condition. This is more efficient and cleaner. Here’s how you can do it using a prepared statement in PHP with the `IN` clause: 1. Use `implode()` to create a comma-separated string of placeholders. 2. Prepare the SQL statement ...
773
[ { "from": "human", "value": "I have an SQL query that takes the following form:\nUPDATE foo\nSET flag=true\nWHERE id=?\n\nI also have a PHP array which has a list of IDs. What is the best way to accomplish this other than with parsing, as follows, ...\nforeach($list as $item){ \n $querycondition = $quer...
I'm writing a LINQ to SQL statement, and I'm after the standard syntax for a normal inner join with an ON clause in C#. How do you represent the following in LINQ to SQL: select DealerContact.* from Dealer inner join DealerContact on Dealer.DealerID = DealerContact.DealerID
In LINQ to SQL, you can represent an inner join using the `join` keyword followed by the `on` clause to specify the join condition. Below is how you can write the equivalent of your SQL statement using LINQ in C#: ```csharp using (var context = new YourDataContext()) { var results = from dealerContact in context.D...
919
[ { "from": "human", "value": "I'm writing a LINQ to SQL statement, and I'm after the standard syntax for a normal inner join with an ON clause in C#.\nHow do you represent the following in LINQ to SQL:\nselect DealerContact.*\nfrom Dealer \ninner join DealerContact on Dealer.DealerID = DealerContact.DealerID...
(y/N) Edit: Read-only access is fine.
Yes.
2,527
[ { "from": "human", "value": "(y/N)\nEdit: Read-only access is fine.\n" }, { "from": "gpt", "value": "Yes." } ]
I'm trying to build a grammar with the following: NUMERIC: INTEGER | FLOAT | INFINITY | PI ... INFINITY: '∞' PI: 'π' But Antlr refuses to load the grammar.
It looks like you're trying to define a grammar in ANTLR for numeric values that include integers, floats, infinity, and pi. However, ANTLR may have trouble with the way the tokens are defined, particularly with how certain characters are treated. Here's a simple example of how you could define your grammar to includ...
65
[ { "from": "human", "value": "I'm trying to build a grammar with the following:\nNUMERIC: INTEGER | FLOAT | INFINITY | PI\n...\nINFINITY: '∞'\nPI: 'π'\nBut Antlr refuses to load the grammar.\n" }, { "from": "gpt", "value": "It looks like you're trying to define a grammar in ANTLR for numeric valu...
Let's say you create a wizard in an HTML form. One button goes back, and one goes forward. Since the back button appears first in the markup when you press Enter, it will use that button to submit the form. Example: <form> <!-- Put your cursor in this field and press Enter --> <input type="text" name="field1" /...
To control which button is activated when the user presses Enter in an HTML form, you don't necessarily need to use `tabindex`. Instead, you can set one of the buttons to be the default button by changing the order of the buttons in your markup or using JavaScript to handle the form submission behavior. ### Option 1: ...
171
[ { "from": "human", "value": "Let's say you create a wizard in an HTML form. One button goes back, and one goes forward. Since the back button appears first in the markup when you press Enter, it will use that button to submit the form.\nExample:\n\n\n<form>\r\n <!-- Put your cursor in this field and press ...
I want to check out all files in all subdirectories of a specified folder. (And it is painful to do this using the GUI, because there is no recursive checkout option).
To check out all files in all subdirectories of a specified folder from a version control system like Git or SVN, you can use command-line commands to perform the operation recursively. Here's how to do this for both systems: ### Git If you're using Git and want to check out all files, you can simply use the `git chec...
467
[ { "from": "human", "value": "I want to check out all files in all subdirectories of a specified folder.\n(And it is painful to do this using the GUI, because there is no recursive checkout option).\n" }, { "from": "gpt", "value": "To check out all files in all subdirectories of a specified folde...
What .NET namespace or class includes both Context.Handler and Server.Transfer? I think one may include both and my hunt on MSDN returned null.
In ASP.NET, both `Context.Handler` and `Server.Transfer` are part of the `System.Web` namespace. - `Context.Handler` is used to get or set the `IHttpHandler` instance that is responsible for handling the current request. - `Server.Transfer` is a method of the `HttpServerUtility` class (which can be accessed through `...
747
[ { "from": "human", "value": "What .NET namespace or class includes both Context.Handler and Server.Transfer?\nI think one may include both and my hunt on MSDN returned null. \n" }, { "from": "gpt", "value": "In ASP.NET, both `Context.Handler` and `Server.Transfer` are part of the `System.Web` na...
I'm writing a manual and some important keywords are repeated in several pages. In the project's index I defined the keywords like this: <LI> <OBJECT type="text/sitemap"> <param name="Name" value="Stackoverflow"> <param name="Name" value="Overview"> <param name="Local" value="overview.html#stackoverflow"> ...
To display the title of the pages in the dialog instead of repeating the keyword and project name, you need to ensure that you are using the proper attributes in your `<OBJECT>` structure. Specifically, you can set the `Name` value to a combination of the keyword and the corresponding page title. Here’s an updated ve...
845
[ { "from": "human", "value": "I'm writing a manual and some important keywords are repeated in several pages. In the project's index I defined the keywords like this:\n<LI> <OBJECT type=\"text/sitemap\">\n <param name=\"Name\" value=\"Stackoverflow\">\n <param name=\"Name\" value=\"Overview\">\n <pa...
Is it currently possible with pre release of ironruby to run rubygems? It seems as if I have to set an environment variable to find them?
As of the pre-release versions of IronRuby, there were certain limitations and challenges when it came to running Ruby gems. IronRuby is an implementation of the Ruby programming language on the .NET framework, and it aimed to provide compatibility with the Ruby ecosystem. However, not all gems were compatible, especia...
724
[ { "from": "human", "value": "Is it currently possible with pre release of ironruby to run rubygems? It seems as if I have to set an environment variable to find them? \n" }, { "from": "gpt", "value": "As of the pre-release versions of IronRuby, there were certain limitations and challenges when ...
I have more than one OpenID as I have tried out numerous. As people take up OpenID different suppliers are going to emerge I may want to switch provinders. As all IDs are me, and all are authenticated against the same email address, shouldn't I be able to log into stack overflow with any of them and be able to hit th...
In theory, if all your OpenIDs are authenticated against the same email address, you could expect that using any of those OpenIDs would allow you to access the same account on Stack Overflow or any other platform that supports OpenID. However, how an account is linked to OpenIDs can vary from site to site. Here are so...
880
[ { "from": "human", "value": "I have more than one OpenID as I have tried out numerous. As people take up OpenID different suppliers are going to emerge I may want to switch provinders. As all IDs are me, and all are authenticated against the same email address, shouldn't I be able to log into stack overfl...
I wanted some of those spiffy rounded corners for a web project that I'm currently working on. I thought I'd try to accomplish it using javascript and not CSS in an effort to keep the requests for image files to a minimum (yes, I know that it's possible to combine all required rounded corner shapes into one image) and ...
Your approach to checking for `-moz-border-radius` support is creative and can work effectively to determine if a browser supports those specific CSS properties. While your solution is functional, there are alternative approaches that may streamline the process or enhance its compatibility. ### Alternative Solutions ...
116
[ { "from": "human", "value": "I wanted some of those spiffy rounded corners for a web project that I'm currently working on.\nI thought I'd try to accomplish it using javascript and not CSS in an effort to keep the requests for image files to a minimum (yes, I know that it's possible to combine all required ...
How do you express an integer as a binary number with Python literals? I was easily able to find the answer for hex: >>> 0x12AF 4783 >>> 0x100 256 and octal: >>> 01267 695 >>> 0100 64 How do you use literals to express binary in Python? Summary of Answers Python 2.5 and earlier: can express binary using int('010101...
In Python, you can express binary numbers using binary literals, which were introduced in Python 2.6 and are available in all subsequent versions, including Python 3. The syntax for a binary literal is to prefix the number with `0b` or `0B`. Here’s how you can use binary literals in Python: ### Example of Using Binary...
261
[ { "from": "human", "value": "How do you express an integer as a binary number with Python literals?\nI was easily able to find the answer for hex:\n>>> 0x12AF\n4783\n>>> 0x100\n256\n\nand octal:\n>>> 01267\n695\n>>> 0100\n64\n\nHow do you use literals to express binary in Python?\n\nSummary of Answers\n\nPy...
I've been interacting with Amazon S3 through S3Fox and I can't seem to delete my buckets. I select a bucket, hit delete, confirm the delete in a popup, and... nothing happens. Is there another tool that I should use?
If you're having trouble deleting buckets in Amazon S3 using S3Fox, it could be due to several reasons, such as permissions issues or bucket policies. Here are some steps you can take and alternative tools you can use: ### Troubleshooting S3Fox: 1. **Permissions**: Ensure that your IAM user has the necessary permissio...
161
[ { "from": "human", "value": "I've been interacting with Amazon S3 through S3Fox and I can't seem to delete my buckets. I select a bucket, hit delete, confirm the delete in a popup, and... nothing happens. Is there another tool that I should use?\n" }, { "from": "gpt", "value": "If you're having ...
What is the difference between early and late binding?
Early binding and late binding are terms often used in programming to describe when the method or function to be executed is determined in the program execution process. Here’s a breakdown of the two concepts: ### Early Binding - **Definition**: In early binding, the method or function to be invoked is determined at c...
419
[ { "from": "human", "value": "What is the difference between early and late binding?\n" }, { "from": "gpt", "value": "Early binding and late binding are terms often used in programming to describe when the method or function to be executed is determined in the program execution process. Here’s a ...
I would like to filter an array of items by using the map() function. Here is a code snippet: var filteredItems = items.map(function(item) { if( ...some condition... ) { return item; } }); The problem is that filtered out items still uses space in the array and I would like to completely wipe them ...
If you're looking to filter an array while using the `map()` function, you might be misunderstanding its intended purpose. The `map()` function is meant for transforming elements of an array and will always return an array with the same length as the original. To filter out items from an array completely, you should u...
1,023
[ { "from": "human", "value": "I would like to filter an array of items by using the map() function. Here is a code snippet:\nvar filteredItems = items.map(function(item)\n{\n if( ...some condition... )\n {\n return item;\n }\n});\n\nThe problem is that filtered out items still uses space in t...
This is kinda oddball, but I was poking around with the GNU assembler today (I want to be able to at least read the syntax), and was trying to get this little contrived example of mine to work. Namely I just want to go from 0 to 100, printing out numbers all the while. So a few minutes later I come up with this: # coun...
The issue you're encountering is likely related to how you're using the `printf` function and how you're handling the arguments on the stack. Here’s a corrected version of your code with explanations to help you understand the adjustments: ```asm # count.s: print the numbers from 0 to 100. .text .globl _main ...
329
[ { "from": "human", "value": "This is kinda oddball, but I was poking around with the GNU assembler today (I want to be able to at least read the syntax), and was trying to get this little contrived example of mine to work. Namely I just want to go from 0 to 100, printing out numbers all the while. So a few ...
I use Delphi for many years, and although I have now moved on to Visual Studio I still fondly remember numbered bookmarks (CTRL+K+1 to set bookmark 1, CTRL+Q+1 to goto bookmark 1). Is there a Visual Studio equivalent? I'm find the dumb bookmarks in VS a chore after Delphi. I want to bookmark then return to a specific p...
Visual Studio does not have a built-in feature for numbered bookmarks like Delphi, but you can use a couple of alternative methods to achieve a similar functionality. ### 1. **Using Task List Comments**: You can use special comments in your code to create a task list. For example, if you type `// TODO: Bookmark1`, `//...
1
[ { "from": "human", "value": "I use Delphi for many years, and although I have now moved on to Visual Studio I still fondly remember numbered bookmarks (CTRL+K+1 to set bookmark 1, CTRL+Q+1 to goto bookmark 1).\nIs there a Visual Studio equivalent? I'm find the dumb bookmarks in VS a chore after Delphi. I wa...
I want to do this: //*fu which returns all nodes whose name ends in fu, such as <tarfu /> and <snafu />, but not <fubar />
To select all nodes whose names end with "fu" using XPath, you can use the following expression: ```xpath //*[substring(name(), string-length(name()) - string-length('fu') + 1) = 'fu'] ``` ### Explanation: - `*`: This selects all elements regardless of their name. - `name()`: This function returns the name of the cur...
817
[ { "from": "human", "value": "I want to do this: \n\n//*fu\n\nwhich returns all nodes whose name ends in fu, such as <tarfu /> and <snafu />, but not <fubar />\n" }, { "from": "gpt", "value": "To select all nodes whose names end with \"fu\" using XPath, you can use the following expression:\n\n`...
I ended up writing a quick little script for this in Python, but I was wondering if there was a utility you could feed text into which would prepend each line with some text -- in my specific case, a timestamp. Ideally, the use would be something like: cat somefile.txt | prepend-timestamp (Before you answer sed, I tr...
You can create a simple utility in Python that reads from standard input, prepends a timestamp to each line, and outputs the modified lines. Below is a script that accomplishes that. You can save this script as `prepend-timestamp.py` and then use it in the way you described. Here's the Python script: ```python #!/usr...
1,029
[ { "from": "human", "value": "I ended up writing a quick little script for this in Python, but I was wondering if there was a utility you could feed text into which would prepend each line with some text -- in my specific case, a timestamp. Ideally, the use would be something like:\ncat somefile.txt | prepe...
I am trying to grab the capital letters of a couple of words and wrap them in span tags. I am using preg_replace for extract and wrapping purposes, but it's not outputting anything. preg_replace("/[A-Z]/", "<span class=\"initial\">$1</span>", $str)
It looks like you're trying to wrap each capital letter in a string with `<span>` tags using `preg_replace`, but there are a couple of issues with your regular expression and replacement string. 1. In your regex pattern, you don't need to use `$1` because you aren't using any capturing groups. You're simply matching t...
528
[ { "from": "human", "value": "I am trying to grab the capital letters of a couple of words and wrap them in span tags. I am using preg_replace for extract and wrapping purposes, but it's not outputting anything.\npreg_replace(\"/[A-Z]/\", \"<span class=\\\"initial\\\">$1</span>\", $str)\n\n" }, { "fr...
The Entity Framework does not support the Expression.Invoke operator. You receive the following exception when trying to use it: "The LINQ expression node type 'Invoke' is not supported in LINQ to Entities. Has anyone got a workaround for this missing functionality? I would like to use the PredicateBuilder detailed ...
The issue you are encountering with `Expression.Invoke` not being supported in Entity Framework (EF) is common when working with dynamic LINQ expressions. While EF does support many LINQ operations, it does not support invoking expressions due to the complexity it introduces for translating the query to SQL. To work a...
178
[ { "from": "human", "value": "The Entity Framework does not support the Expression.Invoke operator. You receive the following exception when trying to use it:\n\n\"The LINQ expression node type 'Invoke' is not supported in LINQ to Entities.\n\nHas anyone got a workaround for this missing functionality? I wo...
In opening up the .xap file that is generated as output from a Silverlight application I've been tinkering with lately, I noticed a file called AppManifest.xaml. I've also noticed an option in the property pages for the Silverlight project that appears to allow you to optionally not output AppManifest.xaml for the proj...
The `AppManifest.xaml` file is a crucial component of a Silverlight application. It serves several important purposes: 1. **Application Metadata**: The `AppManifest.xaml` file contains metadata about your Silverlight application, including its version, permissions, and entry points. This metadata is essential for the ...
830
[ { "from": "human", "value": "In opening up the .xap file that is generated as output from a Silverlight application I've been tinkering with lately, I noticed a file called AppManifest.xaml.\nI've also noticed an option in the property pages for the Silverlight project that appears to allow you to optionall...