content
stringlengths 86
88.9k
| title
stringlengths 0
150
| question
stringlengths 1
35.8k
| answers
sequence | answers_scores
sequence | non_answers
sequence | non_answers_scores
sequence | tags
sequence | name
stringlengths 30
130
|
---|---|---|---|---|---|---|---|---|
Q:
Microsoft Office 2007 file type, Mime types and identifying characters
Where can I find a list of all of the MIME types and the identifying characters for Microsoft Office 2007 files?
I have an upload form that is restricting uploads based on the extensions and identifying characters, but I cannot seem to find the Office 2007 MIME types.
Can anyone help?
A:
Office 2007 MIME Types for IIS
.docm, application/vnd.ms-word.document.macroEnabled.12
.docx, application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotm, application/vnd.ms-word.template.macroEnabled.12
.dotx, application/vnd.openxmlformats-officedocument.wordprocessingml.template
.potm, application/vnd.ms-powerpoint.template.macroEnabled.12
.potx, application/vnd.openxmlformats-officedocument.presentationml.template
.ppam, application/vnd.ms-powerpoint.addin.macroEnabled.12
.ppsm, application/vnd.ms-powerpoint.slideshow.macroEnabled.12
.ppsx, application/vnd.openxmlformats-officedocument.presentationml.slideshow
.pptm, application/vnd.ms-powerpoint.presentation.macroEnabled.12
.pptx, application/vnd.openxmlformats-officedocument.presentationml.presentation
.xlam, application/vnd.ms-excel.addin.macroEnabled.12
.xlsb, application/vnd.ms-excel.sheet.binary.macroEnabled.12
.xlsm, application/vnd.ms-excel.sheet.macroEnabled.12
.xlsx, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltm, application/vnd.ms-excel.template.macroEnabled.12
.xltx, application/vnd.openxmlformats-officedocument.spreadsheetml.template
| Microsoft Office 2007 file type, Mime types and identifying characters | Where can I find a list of all of the MIME types and the identifying characters for Microsoft Office 2007 files?
I have an upload form that is restricting uploads based on the extensions and identifying characters, but I cannot seem to find the Office 2007 MIME types.
Can anyone help?
| [
"Office 2007 MIME Types for IIS\n\n.docm, application/vnd.ms-word.document.macroEnabled.12\n.docx, application/vnd.openxmlformats-officedocument.wordprocessingml.document\n.dotm, application/vnd.ms-word.template.macroEnabled.12\n.dotx, application/vnd.openxmlformats-officedocument.wordprocessingml.template\n.potm, application/vnd.ms-powerpoint.template.macroEnabled.12\n.potx, application/vnd.openxmlformats-officedocument.presentationml.template\n.ppam, application/vnd.ms-powerpoint.addin.macroEnabled.12\n.ppsm, application/vnd.ms-powerpoint.slideshow.macroEnabled.12\n.ppsx, application/vnd.openxmlformats-officedocument.presentationml.slideshow\n.pptm, application/vnd.ms-powerpoint.presentation.macroEnabled.12\n.pptx, application/vnd.openxmlformats-officedocument.presentationml.presentation\n.xlam, application/vnd.ms-excel.addin.macroEnabled.12\n.xlsb, application/vnd.ms-excel.sheet.binary.macroEnabled.12\n.xlsm, application/vnd.ms-excel.sheet.macroEnabled.12\n.xlsx, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\n.xltm, application/vnd.ms-excel.template.macroEnabled.12\n.xltx, application/vnd.openxmlformats-officedocument.spreadsheetml.template\n\n"
] | [
26
] | [] | [] | [
"file_type",
"mime",
"office_2007"
] | stackoverflow_0000000061_file_type_mime_office_2007.txt |
Q:
XSD DataSets and ignoring foreign keys
I have a pretty standard table set-up in a current application using the .NET XSD DataSet and TableAdapter features. My contracts table consists of some standard contract information, with a column for the primary department. This column is a foreign key to my Departments table, where I store the basic department name, id, notes. This is all setup and functioning in my SQL Server.
When I use the XSD tool, I can drag both tables in at once and it auto detects/creates the foreign key I have between these two tables. This works great when I'm on my main page and am viewing contract data.
However, when I go to my administrative page to modify the department data, I typically do something like this:
Dim dtDepartment As New DepartmentDataTable()
Dim taDepartment As New DepartmentTableAdapter()
taDepartment.Fill(dtDepartment)
However, at this point an exception is thrown saying to the effect that there is a foreign key reference broken here, I'm guessing since I don't have the Contract DataTable filled.
How can I fix this problem? I know I can simply remove the foreign key from the XSD to make things work fine, but having the additional integrity check there and having the XSD schema match the SQL schema in the database is nice.
A:
You can try turning Check-constraints off on the DataSet (it's in its properties), or altering the properties of that relationship, and change the key to a simple reference - up to you.
| XSD DataSets and ignoring foreign keys | I have a pretty standard table set-up in a current application using the .NET XSD DataSet and TableAdapter features. My contracts table consists of some standard contract information, with a column for the primary department. This column is a foreign key to my Departments table, where I store the basic department name, id, notes. This is all setup and functioning in my SQL Server.
When I use the XSD tool, I can drag both tables in at once and it auto detects/creates the foreign key I have between these two tables. This works great when I'm on my main page and am viewing contract data.
However, when I go to my administrative page to modify the department data, I typically do something like this:
Dim dtDepartment As New DepartmentDataTable()
Dim taDepartment As New DepartmentTableAdapter()
taDepartment.Fill(dtDepartment)
However, at this point an exception is thrown saying to the effect that there is a foreign key reference broken here, I'm guessing since I don't have the Contract DataTable filled.
How can I fix this problem? I know I can simply remove the foreign key from the XSD to make things work fine, but having the additional integrity check there and having the XSD schema match the SQL schema in the database is nice.
| [
"You can try turning Check-constraints off on the DataSet (it's in its properties), or altering the properties of that relationship, and change the key to a simple reference - up to you.\n"
] | [
13
] | [] | [] | [
".net",
"database",
"xsd"
] | stackoverflow_0000000134_.net_database_xsd.txt |
Q:
What is the meaning of the type safety warning in certain Java generics casts?
What is the meaning of the Java warning?
Type safety: The cast from Object to List<Integer> is actually checking against the erased type List
I get this warning when I try to cast an Object to a type with generic information, such as in the following code:
Object object = getMyList();
List<Integer> list = (List<Integer>) object;
A:
This warning is there because Java is not actually storing type information at run-time in an object that uses generics. Thus, if object is actually a List<String>, there will be no ClassCastException at run-time except until an item is accessed from the list that doesn't match the generic type defined in the variable.
This can cause further complications if items are added to the list, with this incorrect generic type information. Any code still holding a reference to the list but with the correct generic type information will now have an inconsistent list.
To remove the warning, try:
List<?> list = (List<?>) object;
However, note that you will not be able to use certain methods such as add because the compiler doesn't know if you are trying to add an object of incorrect type. The above will work in a lot of situations, but if you have to use add, or some similarly restricted method, you will just have to suffer the yellow underline in Eclipse (or a SuppressWarning annotation).
| What is the meaning of the type safety warning in certain Java generics casts? | What is the meaning of the Java warning?
Type safety: The cast from Object to List<Integer> is actually checking against the erased type List
I get this warning when I try to cast an Object to a type with generic information, such as in the following code:
Object object = getMyList();
List<Integer> list = (List<Integer>) object;
| [
"This warning is there because Java is not actually storing type information at run-time in an object that uses generics. Thus, if object is actually a List<String>, there will be no ClassCastException at run-time except until an item is accessed from the list that doesn't match the generic type defined in the variable. \nThis can cause further complications if items are added to the list, with this incorrect generic type information. Any code still holding a reference to the list but with the correct generic type information will now have an inconsistent list. \nTo remove the warning, try:\nList<?> list = (List<?>) object;\n\nHowever, note that you will not be able to use certain methods such as add because the compiler doesn't know if you are trying to add an object of incorrect type. The above will work in a lot of situations, but if you have to use add, or some similarly restricted method, you will just have to suffer the yellow underline in Eclipse (or a SuppressWarning annotation).\n"
] | [
53
] | [] | [] | [
"casting",
"generics",
"java",
"type_safety",
"warnings"
] | stackoverflow_0000000382_casting_generics_java_type_safety_warnings.txt |
Q:
Floating Point Number parsing: Is there a Catch All algorithm?
One of the fun parts of multi-cultural programming is number formats.
Americans use 10,000.50
Germans use 10.000,50
French use 10 000,50
My first approach would be to take the string, parse it backwards until I encounter a separator and use this as my decimal separator. There is an obvious flaw with that: 10.000 would be interpreted as 10.
Another approach: if the string contains 2 different non-numeric characters, use the last one as the decimal separator and discard the others. If I only have one, check if it occurs more than once and discards it if it does. If it only appears once, check if it has 3 digits after it. If yes, discard it, otherwise, use it as decimal separator.
The obvious "best solution" would be to detect the User's culture or Browser, but that does not work if you have a Frenchman using an en-US Windows/Browser.
Does the .net Framework contain some mythical black magic floating point parser that is better than Double.(Try)Parse() in trying to auto-detect the number format?
A:
I think the best you can do in this case is to take their input and then show them what you think they meant. If they disagree, show them the format you're expecting and get them to enter it again.
A:
I don't know the ASP.NET side of the problem but .NET has a pretty powerful class: System.Globalization.CultureInfo. You can use the following code to parse a string containing a double value:
double d = double.Parse("100.20", CultureInfo.CurrentCulture);
// -- OR --
double d = double.Parse("100.20", CultureInfo.CurrentUICulture);
If ASP.NET somehow (i.e. using HTTP Request headers) passes current user's CultureInfo to either CultureInfo.CurrentCulture or CultureInfo.CurrentUICulture, these will work fine.
A:
You can't please everyone. If I enter ten as 10.000, and someone enters ten thousand as 10.000, you cannot handle that without some knowledge of the culture of the input. Detect the culture somehow (browser, system setting - what is the use case? ASP? Internal app, or open to the world?), or provide an example of the expected formatting, and use the most lenient parser you can. Probably something like:
double d = Double.Parse("5,000.00", NumberStyles.Any, CultureInfo.InvariantCulture);
A:
The difference between 12.345 in French and English is a factor of 1000. If you supply an expected range where max < 1000*min, you can easily guess.
Take for example the height of a person (including babies and children) in mm.
By using a range of 200-3000, an input of 1.800 or 1,800 can unambiguously be interpreted as 1 meter and 80 centimeters, whereas an input of 912.300 or 912,300 can unambiguously be interpreted as 91 centimeters and 2.3 millimeters.
| Floating Point Number parsing: Is there a Catch All algorithm? | One of the fun parts of multi-cultural programming is number formats.
Americans use 10,000.50
Germans use 10.000,50
French use 10 000,50
My first approach would be to take the string, parse it backwards until I encounter a separator and use this as my decimal separator. There is an obvious flaw with that: 10.000 would be interpreted as 10.
Another approach: if the string contains 2 different non-numeric characters, use the last one as the decimal separator and discard the others. If I only have one, check if it occurs more than once and discards it if it does. If it only appears once, check if it has 3 digits after it. If yes, discard it, otherwise, use it as decimal separator.
The obvious "best solution" would be to detect the User's culture or Browser, but that does not work if you have a Frenchman using an en-US Windows/Browser.
Does the .net Framework contain some mythical black magic floating point parser that is better than Double.(Try)Parse() in trying to auto-detect the number format?
| [
"I think the best you can do in this case is to take their input and then show them what you think they meant. If they disagree, show them the format you're expecting and get them to enter it again.\n",
"I don't know the ASP.NET side of the problem but .NET has a pretty powerful class: System.Globalization.CultureInfo. You can use the following code to parse a string containing a double value:\ndouble d = double.Parse(\"100.20\", CultureInfo.CurrentCulture);\n// -- OR --\ndouble d = double.Parse(\"100.20\", CultureInfo.CurrentUICulture);\n\nIf ASP.NET somehow (i.e. using HTTP Request headers) passes current user's CultureInfo to either CultureInfo.CurrentCulture or CultureInfo.CurrentUICulture, these will work fine.\n",
"You can't please everyone. If I enter ten as 10.000, and someone enters ten thousand as 10.000, you cannot handle that without some knowledge of the culture of the input. Detect the culture somehow (browser, system setting - what is the use case? ASP? Internal app, or open to the world?), or provide an example of the expected formatting, and use the most lenient parser you can. Probably something like:\ndouble d = Double.Parse(\"5,000.00\", NumberStyles.Any, CultureInfo.InvariantCulture);\n\n",
"The difference between 12.345 in French and English is a factor of 1000. If you supply an expected range where max < 1000*min, you can easily guess. \nTake for example the height of a person (including babies and children) in mm.\nBy using a range of 200-3000, an input of 1.800 or 1,800 can unambiguously be interpreted as 1 meter and 80 centimeters, whereas an input of 912.300 or 912,300 can unambiguously be interpreted as 91 centimeters and 2.3 millimeters.\n"
] | [
31,
27,
12,
10
] | [] | [] | [
".net",
"asp.net",
"c#",
"globalization",
"internationalization"
] | stackoverflow_0000000192_.net_asp.net_c#_globalization_internationalization.txt |
Q:
Homegrown consumption of web services
I've been writing a few web services for a .net app, now I'm ready to consume them. I've seen numerous examples where there is homegrown code for consuming the service as opposed to using the auto generated methods that Visual Studio creates when adding the web reference.
Is there some advantages to this?
A:
No, what you're doing is fine. Don't let those people confuse you.
If you've written the web services with .net then the reference proxies generated by .net are going to be quite suitable. The situation you describe (where you are both producer and consumer) is the ideal situation.
If you need to connect to a web services that is unknown at compile time, then you would want a more dynamic approach, where you deduce the 'shape' of the web service.
But start by using the auto generated proxy class, and don't worry about it until you hit a limitation. And when you do -- come back to stack overflow ;-)
| Homegrown consumption of web services | I've been writing a few web services for a .net app, now I'm ready to consume them. I've seen numerous examples where there is homegrown code for consuming the service as opposed to using the auto generated methods that Visual Studio creates when adding the web reference.
Is there some advantages to this?
| [
"No, what you're doing is fine. Don't let those people confuse you.\nIf you've written the web services with .net then the reference proxies generated by .net are going to be quite suitable. The situation you describe (where you are both producer and consumer) is the ideal situation.\nIf you need to connect to a web services that is unknown at compile time, then you would want a more dynamic approach, where you deduce the 'shape' of the web service. \nBut start by using the auto generated proxy class, and don't worry about it until you hit a limitation. And when you do -- come back to stack overflow ;-)\n"
] | [
11
] | [] | [] | [
".net",
"web_services"
] | stackoverflow_0000000470_.net_web_services.txt |
Q:
Lucene Score results
In Lucene if you had multiple indexes that covered only one partition each. Why does the same search on different indexes return results with different scores? The results from different servers match exactly.
i.e. if I searched for :
Name - John Smith
DOB - 11/11/1934
Partition 0 would return a score of 0.345
Partition 1 would return a score of 0.337
Both match exactly on name and DOB.
A:
The scoring contains the Inverse Document Frequency(IDF). If the term "John Smith" is in one partition, 0, 100 times and in partition 1, once. The score for searching for John Smith would be higher search in partition 1 as the term is more scarce.
To get round this you would wither have to have your index being over all partitions, or you would need to override the IDF.
A:
Because the score is determined on the index if I am not completely mistaken.
If you have different indexes (more/less or different data that was indexed), the score will differ:
http://lucene.apache.org/core/3_6_0/scoring.html
(Warning: Contains Math :-))
A:
You may also be interested in the output of the explain() method, and the resulting Explanation object, which will give you an idea of how things are scored the way they are.
| Lucene Score results | In Lucene if you had multiple indexes that covered only one partition each. Why does the same search on different indexes return results with different scores? The results from different servers match exactly.
i.e. if I searched for :
Name - John Smith
DOB - 11/11/1934
Partition 0 would return a score of 0.345
Partition 1 would return a score of 0.337
Both match exactly on name and DOB.
| [
"The scoring contains the Inverse Document Frequency(IDF). If the term \"John Smith\" is in one partition, 0, 100 times and in partition 1, once. The score for searching for John Smith would be higher search in partition 1 as the term is more scarce.\nTo get round this you would wither have to have your index being over all partitions, or you would need to override the IDF.\n",
"Because the score is determined on the index if I am not completely mistaken. \nIf you have different indexes (more/less or different data that was indexed), the score will differ:\nhttp://lucene.apache.org/core/3_6_0/scoring.html\n(Warning: Contains Math :-))\n",
"You may also be interested in the output of the explain() method, and the resulting Explanation object, which will give you an idea of how things are scored the way they are.\n"
] | [
20,
13,
9
] | [] | [] | [
"lucene",
"search"
] | stackoverflow_0000000387_lucene_search.txt |
Q:
How to write to Web.Config in Medium Trust?
Uploading my first decently sized web app to my shared host provided me with a fresh set of challenges, by which I mean, sleepless nights. The issue was that I had most certainly not developed my application for medium trust (or had any clue what that was.)
I mitigated all of the issues, save one.
I had written an installer for the admin to be able to specify their connection string and other preferences, but I cannot find a way to write to a web.config in medium trust. Does anyone have a solution, or should I just be putting preferences in another file?
A:
That actually sounds like IIS's Low level. If it is, then you won't be able to write to any file, not just the web.config.
Here are the levels from IIS's help file:
Full (internal) - Specifies unrestricted permissions. Grants the ASP.NET application permissions to access any resource that is subject to operating system security. All privileged operations are supported.
High (web_hightrust.config) - Specifies a high level of code access security, which means that the application cannot do any one of the following things by default:
Call unmanaged code.
Call serviced components.
Write to the event log.
Access Message Queuing service queues.
Access ODBC, OleDb, or Oracle data sources.
Medium (web_mediumtrust.config) - Specifies a medium level of code access security, which means that, in addition to High Trust Level restrictions, the ASP.NET application cannot do any of the following things by default:
Access files outside the application directory.
Access the registry.
Make network or Web service calls.
Low (web_lowtrust.config) - Specifies a low level of code access security, which means that, in addition to Medium Trust Level restrictions, the application cannot do any of the following things by default:
Write to the file system.
Call the Assert method.
Minimal (web_minimaltrust.config) - Specifies a minimal level of code access security, which means that the application has only execute permissions.
I would suggest that if you are dead set on having an installer, have it create a web.config in memory that the user can save locally and FTP up afterward.
| How to write to Web.Config in Medium Trust? | Uploading my first decently sized web app to my shared host provided me with a fresh set of challenges, by which I mean, sleepless nights. The issue was that I had most certainly not developed my application for medium trust (or had any clue what that was.)
I mitigated all of the issues, save one.
I had written an installer for the admin to be able to specify their connection string and other preferences, but I cannot find a way to write to a web.config in medium trust. Does anyone have a solution, or should I just be putting preferences in another file?
| [
"That actually sounds like IIS's Low level. If it is, then you won't be able to write to any file, not just the web.config.\nHere are the levels from IIS's help file:\n\n\n\nFull (internal) - Specifies unrestricted permissions. Grants the ASP.NET application permissions to access any resource that is subject to operating system security. All privileged operations are supported.\n\nHigh (web_hightrust.config) - Specifies a high level of code access security, which means that the application cannot do any one of the following things by default:\n\nCall unmanaged code.\nCall serviced components.\nWrite to the event log.\nAccess Message Queuing service queues.\nAccess ODBC, OleDb, or Oracle data sources.\n\n\nMedium (web_mediumtrust.config) - Specifies a medium level of code access security, which means that, in addition to High Trust Level restrictions, the ASP.NET application cannot do any of the following things by default:\n\nAccess files outside the application directory.\nAccess the registry.\nMake network or Web service calls.\n\n\nLow (web_lowtrust.config) - Specifies a low level of code access security, which means that, in addition to Medium Trust Level restrictions, the application cannot do any of the following things by default:\n\nWrite to the file system.\nCall the Assert method.\n\n\nMinimal (web_minimaltrust.config) - Specifies a minimal level of code access security, which means that the application has only execute permissions.\n\n\n\nI would suggest that if you are dead set on having an installer, have it create a web.config in memory that the user can save locally and FTP up afterward.\n"
] | [
24
] | [] | [] | [
"asp.net",
"c#",
"medium_trust"
] | stackoverflow_0000000562_asp.net_c#_medium_trust.txt |
Q:
Visual Studio Setup Project - Per User Registry Settings
I'm trying to maintain a Setup Project in Visual Studio 2003 (yes, it's a legacy application). The problem we have at the moment is that we need to write registry entries to HKCU for every user on the computer. They need to be in the HKCU rather than HKLM because they are the default user settings, and they do change per user. My feeling is that
This isn't possible
This isn't something the installer should be doing, but something the application should be doing (after all what happens when a user profile is created after the install?).
With that in mind, I still want to change as little as possible in the application, so my question is, is it possible to add registry entries for every user in a Visual Studio 2003 setup project?
And, at the moment the project lists five registry root keys (HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS, and User/Machine Hive). I don't really know anything about the Users root key, and haven't seen User/Machine Hive. Can anyone enlighten me on what they are? Perhaps they could solve my problem above.
A:
First: Yes, this is something that belongs in the Application for the exact reson you specified: What happens after new user profiles are created? Sure, if you're using a domain it's possible to have some stuff put in the registry on creation, but this is not really a use case. The Application should check if there are seetings and use the default settings if not.
That being said, it IS possible to change other users Keys through the HKEY_USERS Hive.
I have no experience with the Visual Studio 2003 Setup Project, so here is a bit of (totally unrelated) VBScript code that might just give you an idea where to look:
const HKEY_USERS = &H80000003
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = ""
objReg.EnumKey HKEY_USERS, strKeyPath, arrSubKeys
strKeyPath = "\Software\Microsoft\Windows\CurrentVersion\WinTrust\Trust Providers\Software Publishing"
For Each subkey In arrSubKeys
objReg.SetDWORDValue HKEY_USERS, subkey & strKeyPath, "State", 146944
Next
(Code Courtesy of Jeroen Ritmeijer)
A:
I'm guessing that because you want to set it for all users, that you're on some kind of shared computer, which is probably running under a domain?
HERE BE DRAGONS
Let's say Joe and Jane regularly log onto the computer, then they will each have 'registries'.
You'll then install your app, and the installer will employ giant hacks and disgusting things to set items under HKCU for them.
THEN, bob will come along and log on (he, and 500 other people have accounts in the domain and so can do this). He's never used this computer before, so he has no registry. The first time he logs in, windows creates him one, but he won't have your setting.
Your app then falls over or behaves incorrectly, and bob complains loudly about those crappy products from raynixon incorporated.
The correct answer is to just have some default settings in your app, which can write them to the registry if it doesn't find them. It's general good practice that your app should never depend on the registry, and should create things as needed, for any registry entry, not just HKCU, anyway
A:
I'm partway to my solution with this entry on MSDN (don't know how I couldn't find it before).
User/Machine Hive
Subkeys and values entered under this hive will be installed under the HKEY_CURRENT_USER hive when a user chooses "Just Me" or the HKEY_USERS hive or when a user chooses "Everyone" during installation.
Registry Editor Archive of MSDN Article
A:
Despite what the MSDN article Archive of MSDN Article says about User/Machine Hive, it doesn't write to HKEY_USERS. Rather it writes to HKCU if you select Just Me and HKLM if you select everyone.
So my solution is going to be to use the User/Machine Hive, and then in the application it checks if the registry entries are in HKCU and if not, copies them from HKLM. I know this probably isn't the most ideal way of doing it, but it has the least amount of changes.
| Visual Studio Setup Project - Per User Registry Settings | I'm trying to maintain a Setup Project in Visual Studio 2003 (yes, it's a legacy application). The problem we have at the moment is that we need to write registry entries to HKCU for every user on the computer. They need to be in the HKCU rather than HKLM because they are the default user settings, and they do change per user. My feeling is that
This isn't possible
This isn't something the installer should be doing, but something the application should be doing (after all what happens when a user profile is created after the install?).
With that in mind, I still want to change as little as possible in the application, so my question is, is it possible to add registry entries for every user in a Visual Studio 2003 setup project?
And, at the moment the project lists five registry root keys (HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS, and User/Machine Hive). I don't really know anything about the Users root key, and haven't seen User/Machine Hive. Can anyone enlighten me on what they are? Perhaps they could solve my problem above.
| [
"First: Yes, this is something that belongs in the Application for the exact reson you specified: What happens after new user profiles are created? Sure, if you're using a domain it's possible to have some stuff put in the registry on creation, but this is not really a use case. The Application should check if there are seetings and use the default settings if not.\nThat being said, it IS possible to change other users Keys through the HKEY_USERS Hive.\nI have no experience with the Visual Studio 2003 Setup Project, so here is a bit of (totally unrelated) VBScript code that might just give you an idea where to look:\nconst HKEY_USERS = &H80000003\nstrComputer = \".\"\nSet objReg=GetObject(\"winmgmts:{impersonationLevel=impersonate}!\\\\\" & strComputer & \"\\root\\default:StdRegProv\")\nstrKeyPath = \"\"\nobjReg.EnumKey HKEY_USERS, strKeyPath, arrSubKeys\nstrKeyPath = \"\\Software\\Microsoft\\Windows\\CurrentVersion\\WinTrust\\Trust Providers\\Software Publishing\"\nFor Each subkey In arrSubKeys\n objReg.SetDWORDValue HKEY_USERS, subkey & strKeyPath, \"State\", 146944\nNext\n\n(Code Courtesy of Jeroen Ritmeijer)\n",
"I'm guessing that because you want to set it for all users, that you're on some kind of shared computer, which is probably running under a domain?\nHERE BE DRAGONS\nLet's say Joe and Jane regularly log onto the computer, then they will each have 'registries'.\nYou'll then install your app, and the installer will employ giant hacks and disgusting things to set items under HKCU for them.\nTHEN, bob will come along and log on (he, and 500 other people have accounts in the domain and so can do this). He's never used this computer before, so he has no registry. The first time he logs in, windows creates him one, but he won't have your setting. \nYour app then falls over or behaves incorrectly, and bob complains loudly about those crappy products from raynixon incorporated.\nThe correct answer is to just have some default settings in your app, which can write them to the registry if it doesn't find them. It's general good practice that your app should never depend on the registry, and should create things as needed, for any registry entry, not just HKCU, anyway\n",
"I'm partway to my solution with this entry on MSDN (don't know how I couldn't find it before).\nUser/Machine Hive\nSubkeys and values entered under this hive will be installed under the HKEY_CURRENT_USER hive when a user chooses \"Just Me\" or the HKEY_USERS hive or when a user chooses \"Everyone\" during installation.\nRegistry Editor Archive of MSDN Article\n",
"Despite what the MSDN article Archive of MSDN Article says about User/Machine Hive, it doesn't write to HKEY_USERS. Rather it writes to HKCU if you select Just Me and HKLM if you select everyone.\nSo my solution is going to be to use the User/Machine Hive, and then in the application it checks if the registry entries are in HKCU and if not, copies them from HKLM. I know this probably isn't the most ideal way of doing it, but it has the least amount of changes.\n"
] | [
6,
6,
3,
2
] | [] | [] | [
"installation",
"registry",
"visual_studio",
"windows"
] | stackoverflow_0000000810_installation_registry_visual_studio_windows.txt |
Q:
Client collation and SQL Server 2005
We're upgrading an existing program from Win2k/SQL Server 2k to Windows 2003 and SQL Server 2005 as well as purchasing a new program that also uses 2k3/2k5. The vendor says that for us to host both databases we need to get the Enterprise version because the softwares clients use different collation for the connections and only Enterprise supports this.
I cannot find anything on MS's site to support this and, honestly, don't want to pay the extra for Enterprise if the Standard edition works. Am I missing some not talked about feature of SQL Server or is this, as I suspect, a vendor trying to upsell me?
A:
All editions of SQL Server 2000/2005/2008 support having multiple databases, each using their own collation sequence. You don't need the Enterprise version.
When you have a database that uses a collation sequence that is different from default collation for the database server, you will need to take some extra precautions if you use temporary tables and/or table variables. Temp tables/variables live in the tempdb database, which uses the collation seqyuence used by by the master databases. Just remember to use "COLLATE database_default" when defining character fields in the temp tables/variables. I blogged about that not too long ago, if you want some more details.
| Client collation and SQL Server 2005 | We're upgrading an existing program from Win2k/SQL Server 2k to Windows 2003 and SQL Server 2005 as well as purchasing a new program that also uses 2k3/2k5. The vendor says that for us to host both databases we need to get the Enterprise version because the softwares clients use different collation for the connections and only Enterprise supports this.
I cannot find anything on MS's site to support this and, honestly, don't want to pay the extra for Enterprise if the Standard edition works. Am I missing some not talked about feature of SQL Server or is this, as I suspect, a vendor trying to upsell me?
| [
"All editions of SQL Server 2000/2005/2008 support having multiple databases, each using their own collation sequence. You don't need the Enterprise version. \nWhen you have a database that uses a collation sequence that is different from default collation for the database server, you will need to take some extra precautions if you use temporary tables and/or table variables. Temp tables/variables live in the tempdb database, which uses the collation seqyuence used by by the master databases. Just remember to use \"COLLATE database_default\" when defining character fields in the temp tables/variables. I blogged about that not too long ago, if you want some more details.\n"
] | [
7
] | [] | [] | [
"sql_server",
"sql_server_2005",
"windows_server_2003"
] | stackoverflow_0000000905_sql_server_sql_server_2005_windows_server_2003.txt |
Q:
Upgrading SQL Server 6.5
Yes, I know. The existence of a running copy of SQL Server 6.5 in 2008 is absurd.
That stipulated, what is the best way to migrate from 6.5 to 2005? Is there any direct path? Most of the documentation I've found deals with upgrading 6.5 to 7.
Should I forget about the native SQL Server upgrade utilities, script out all of the objects and data, and try to recreate from scratch?
I was going to attempt the upgrade this weekend, but server issues pushed it back till next. So, any ideas would be welcomed during the course of the week.
Update. This is how I ended up doing it:
Back up the database in question and Master on 6.5.
Execute SQL Server 2000's instcat.sql against 6.5's Master. This allows SQL Server 2000's OLEDB provider to connect to 6.5.
Use SQL Server 2000's standalone "Import and Export Data" to create a DTS package, using OLEDB to connect to 6.5. This successfully copied all 6.5's tables to a new 2005 database (also using OLEDB).
Use 6.5's Enterprise Manager to script out all of the database's indexes and triggers to a .sql file.
Execute that .sql file against the new copy of the database, in 2005's Management Studio.
Use 6.5's Enterprise Manager to script out all of the stored procedures.
Execute that .sql file against the 2005 database. Several dozen sprocs had issues making them incompatible with 2005. Mainly non-ANSI joins and quoted identifier issues.
Corrected all of those issues and re-executed the .sql file.
Recreated the 6.5's logins in 2005 and gave them appropriate permissions.
There was a bit of rinse/repeat when correcting the stored procedures (there were hundreds of them to correct), but the upgrade went great otherwise.
Being able to use Management Studio instead of Query Analyzer and Enterprise Manager 6.5 is such an amazing difference. A few report queries that took 20-30 seconds on the 6.5 database are now running in 1-2 seconds, without any modification, new indexes, or anything. I didn't expect that kind of immediate improvement.
A:
Hey, I'm still stuck in that camp too. The third party application we have to support is FINALLY going to 2K5, so we're almost out of the wood. But I feel your pain 8^D
That said, from everything I heard from our DBA, the key is to convert the database to 8.0 format first, and then go to 2005. I believe they used the built in migration/upgrade tools for this. There are some big steps between 6.5 and 8.0 that are better solved there than going from 6.5 to 2005 directly.
Your BIGGEST pain, if you didn't know already, is that DTS is gone in favor of SSIS. There is a shell type module that will run your existing DTS packages, but you're going to want to manually recreate them all in SSIS. Ease of this will depend on the complexity of the packages themselves, but I've done a few at work so far and they've been pretty smooth.
A:
You can upgrade 6.5 to SQL Server 2000. You may have an easier time getting a hold of SQL Server or the 2000 version of the MSDE. Microsoft has a page on going from 6.5 to 2000. Once you have the database in 2000 format, SQL Server 2005 will have no trouble upgrading it to the 2005 format.
If you don't have SQL Server 2000, you can download the MSDE 2000 version directly from Microsoft.
A:
I am by no means authoritative, but I believe the only supported path is from 6.5 to 7. Certainly that would be the most sane route, then I believe you can migrate from 7 directly to 2005 pretty painlessly.
As for scripting out all the objects - I would advise against it as you will inevitably miss something (unless your database is truly trivial).
A:
If you can find a professional or some other super-enterprise version of Visual Studio 6.0 - it came with a copy of MSDE (Basically the predecessor to SQL Express). I believe MSDE 2000 is still available as a free download from Microsoft, but I don't know if you can migrate directly from 6.5 to 2000.
I think in concept, you won't likely face any danger. Years of practice however tell me that you will always miss some object, permission, or other database item that won't manifest itself immediately. If you can script out the entire dump, the better. As you will be less likely to miss something - and if you do miss something, it can be easily added to the script and fixed. I would avoid any manual steps (other than hitting the enter key once) like the plague.
| Upgrading SQL Server 6.5 | Yes, I know. The existence of a running copy of SQL Server 6.5 in 2008 is absurd.
That stipulated, what is the best way to migrate from 6.5 to 2005? Is there any direct path? Most of the documentation I've found deals with upgrading 6.5 to 7.
Should I forget about the native SQL Server upgrade utilities, script out all of the objects and data, and try to recreate from scratch?
I was going to attempt the upgrade this weekend, but server issues pushed it back till next. So, any ideas would be welcomed during the course of the week.
Update. This is how I ended up doing it:
Back up the database in question and Master on 6.5.
Execute SQL Server 2000's instcat.sql against 6.5's Master. This allows SQL Server 2000's OLEDB provider to connect to 6.5.
Use SQL Server 2000's standalone "Import and Export Data" to create a DTS package, using OLEDB to connect to 6.5. This successfully copied all 6.5's tables to a new 2005 database (also using OLEDB).
Use 6.5's Enterprise Manager to script out all of the database's indexes and triggers to a .sql file.
Execute that .sql file against the new copy of the database, in 2005's Management Studio.
Use 6.5's Enterprise Manager to script out all of the stored procedures.
Execute that .sql file against the 2005 database. Several dozen sprocs had issues making them incompatible with 2005. Mainly non-ANSI joins and quoted identifier issues.
Corrected all of those issues and re-executed the .sql file.
Recreated the 6.5's logins in 2005 and gave them appropriate permissions.
There was a bit of rinse/repeat when correcting the stored procedures (there were hundreds of them to correct), but the upgrade went great otherwise.
Being able to use Management Studio instead of Query Analyzer and Enterprise Manager 6.5 is such an amazing difference. A few report queries that took 20-30 seconds on the 6.5 database are now running in 1-2 seconds, without any modification, new indexes, or anything. I didn't expect that kind of immediate improvement.
| [
"Hey, I'm still stuck in that camp too. The third party application we have to support is FINALLY going to 2K5, so we're almost out of the wood. But I feel your pain 8^D\nThat said, from everything I heard from our DBA, the key is to convert the database to 8.0 format first, and then go to 2005. I believe they used the built in migration/upgrade tools for this. There are some big steps between 6.5 and 8.0 that are better solved there than going from 6.5 to 2005 directly.\nYour BIGGEST pain, if you didn't know already, is that DTS is gone in favor of SSIS. There is a shell type module that will run your existing DTS packages, but you're going to want to manually recreate them all in SSIS. Ease of this will depend on the complexity of the packages themselves, but I've done a few at work so far and they've been pretty smooth.\n",
"You can upgrade 6.5 to SQL Server 2000. You may have an easier time getting a hold of SQL Server or the 2000 version of the MSDE. Microsoft has a page on going from 6.5 to 2000. Once you have the database in 2000 format, SQL Server 2005 will have no trouble upgrading it to the 2005 format. \nIf you don't have SQL Server 2000, you can download the MSDE 2000 version directly from Microsoft.\n",
"I am by no means authoritative, but I believe the only supported path is from 6.5 to 7. Certainly that would be the most sane route, then I believe you can migrate from 7 directly to 2005 pretty painlessly.\nAs for scripting out all the objects - I would advise against it as you will inevitably miss something (unless your database is truly trivial).\n",
"If you can find a professional or some other super-enterprise version of Visual Studio 6.0 - it came with a copy of MSDE (Basically the predecessor to SQL Express). I believe MSDE 2000 is still available as a free download from Microsoft, but I don't know if you can migrate directly from 6.5 to 2000.\nI think in concept, you won't likely face any danger. Years of practice however tell me that you will always miss some object, permission, or other database item that won't manifest itself immediately. If you can script out the entire dump, the better. As you will be less likely to miss something - and if you do miss something, it can be easily added to the script and fixed. I would avoid any manual steps (other than hitting the enter key once) like the plague.\n"
] | [
11,
6,
3,
3
] | [] | [] | [
"migration",
"sql_server"
] | stackoverflow_0000000194_migration_sql_server.txt |
Q:
Why doesn't SQL Full Text Indexing return results for words containing #?
For instance, my query is like the following using SQL Server 2005:
SELECT * FROM Table WHERE FREETEXT(SearchField, 'c#')
I have a full text index defined to use the column SearchField which returns results when using:
SELECT * FROM Table WHERE SearchField LIKE '%c#%'
I believe # is a special letter, so how do I allow FREETEXT to work correctly for the query above?
A:
The # char is indexed as punctuation and therefore ignored, so it looks like we'll remove the letter C from our word indexing ignore lists.
Tested it locally after doing that and rebuilding the indexes and I get results!
Looking at using a different word breaker language on the indexed column, so that those special characters aren't ignored.
EDIT: I also found this information:
c# is indexed as c (if c is not in your noise word list, see more on noise word lists later), but C# is indexed as C# (in SQL 2005 and SQL 2000 running on Win2003 regardless if C or c is in your noise word list). It is not only C# that is stored as C#, but any capital letter followed by #. Conversely, c++ ( and any other lower-cased letter followed by a ++) is indexed as c (regardless of whether c is in your noise word list).
A:
Quoting a much-replicated help page about Indexing Service query language:
To use specially treated characters such as &, |, ^, #, @, $, (, ), in a query, enclose your query in quotation marks (“).
As far as I know, full text search in MSSQL is also done by the Indexing Service, so this might help.
| Why doesn't SQL Full Text Indexing return results for words containing #? | For instance, my query is like the following using SQL Server 2005:
SELECT * FROM Table WHERE FREETEXT(SearchField, 'c#')
I have a full text index defined to use the column SearchField which returns results when using:
SELECT * FROM Table WHERE SearchField LIKE '%c#%'
I believe # is a special letter, so how do I allow FREETEXT to work correctly for the query above?
| [
"The # char is indexed as punctuation and therefore ignored, so it looks like we'll remove the letter C from our word indexing ignore lists.\nTested it locally after doing that and rebuilding the indexes and I get results!\nLooking at using a different word breaker language on the indexed column, so that those special characters aren't ignored.\nEDIT: I also found this information:\n\nc# is indexed as c (if c is not in your noise word list, see more on noise word lists later), but C# is indexed as C# (in SQL 2005 and SQL 2000 running on Win2003 regardless if C or c is in your noise word list). It is not only C# that is stored as C#, but any capital letter followed by #. Conversely, c++ ( and any other lower-cased letter followed by a ++) is indexed as c (regardless of whether c is in your noise word list).\n\n",
"Quoting a much-replicated help page about Indexing Service query language:\n\nTo use specially treated characters such as &, |, ^, #, @, $, (, ), in a query, enclose your query in quotation marks (“).\n\nAs far as I know, full text search in MSSQL is also done by the Indexing Service, so this might help.\n"
] | [
14,
1
] | [] | [] | [
"full_text_search",
"indexing",
"sql",
"sql_server",
"sql_server_2005"
] | stackoverflow_0000001042_full_text_search_indexing_sql_sql_server_sql_server_2005.txt |
Q:
Displaying Flash content in a C# WinForms application
What is the best way to display Flash content in a C# WinForms application? I would like to create a user control (similar to the current PictureBox) that will be able to display images and flash content.
It would be great to be able to load the flash content from a stream of sorts rather than a file on disk.
A:
While I haven't used a flash object inside a windows form application myself, I do know that it's possible.
In Visual studio on your toolbox, choose to add a new component.
Then in the new window that appears choose the "COM Components" tab to get a list in which you can find the "Shockwave Flash Object"
Once added to the toolbox, simply use the control as you would use any other "standard" control from visual studio.
three simple commands are available to interact with the control:
AxShockwaveFlash1.Stop()
AxShockwaveFlash1.Movie = FilePath &
"\FileName.swf"
AxShockwaveFlash1.Play()
which, I think, are all self explanatory.
It would be great to be able to load
the flash content from a stream of
sorts rather than a file on disk.
I just saw you are also looking for a means to load the content from a stream,
and because I'm not really sure that is possible with the shockwave flash object I will give you another option (two actually).
the first is the one I would advise you to use only when necessary, as it uses the full blown "webbrowser component" (also available as an extra toolbox item), which is like trying to shoot a fly with a bazooka.
of course it will work, as the control will act as a real browser window (actually the internet explorer browser), but its not really meant to be used in the way you need it.
the second option is to use something I just discovered while looking for more information about playing flash content inside a windows form. F-IN-BOX is a commercial solution that will also play content from a given website URL. (The link provided will direct you to the .NET code you have to use).
A:
Sven, you reached the same conclusion as I did: I found the Shockwave Flash Object, all be it from a slightly different route, but was stumped on how to load the files from somewhere other than file on disk/URL. The F-IN-BOX, although just a wrapper of the Shockwave Flash Object seems to provide much more functionality, which may just help me!
Shooting flys with bazookas may be fun, but an embeded web brower is not the path that I am looking for. :)
There was a link on Adobe's site that talked about "Embedding and Communicating with the Macromedia Flash Player in C# Windows Applications" but they seem to have removed it :(
| Displaying Flash content in a C# WinForms application | What is the best way to display Flash content in a C# WinForms application? I would like to create a user control (similar to the current PictureBox) that will be able to display images and flash content.
It would be great to be able to load the flash content from a stream of sorts rather than a file on disk.
| [
"While I haven't used a flash object inside a windows form application myself, I do know that it's possible.\nIn Visual studio on your toolbox, choose to add a new component.\nThen in the new window that appears choose the \"COM Components\" tab to get a list in which you can find the \"Shockwave Flash Object\"\nOnce added to the toolbox, simply use the control as you would use any other \"standard\" control from visual studio.\nthree simple commands are available to interact with the control:\n\nAxShockwaveFlash1.Stop()\nAxShockwaveFlash1.Movie = FilePath &\n\"\\FileName.swf\"\nAxShockwaveFlash1.Play()\n\nwhich, I think, are all self explanatory.\n\nIt would be great to be able to load\n the flash content from a stream of\n sorts rather than a file on disk.\n\nI just saw you are also looking for a means to load the content from a stream,\nand because I'm not really sure that is possible with the shockwave flash object I will give you another option (two actually).\nthe first is the one I would advise you to use only when necessary, as it uses the full blown \"webbrowser component\" (also available as an extra toolbox item), which is like trying to shoot a fly with a bazooka.\nof course it will work, as the control will act as a real browser window (actually the internet explorer browser), but its not really meant to be used in the way you need it.\nthe second option is to use something I just discovered while looking for more information about playing flash content inside a windows form. F-IN-BOX is a commercial solution that will also play content from a given website URL. (The link provided will direct you to the .NET code you have to use).\n",
"Sven, you reached the same conclusion as I did: I found the Shockwave Flash Object, all be it from a slightly different route, but was stumped on how to load the files from somewhere other than file on disk/URL. The F-IN-BOX, although just a wrapper of the Shockwave Flash Object seems to provide much more functionality, which may just help me!\nShooting flys with bazookas may be fun, but an embeded web brower is not the path that I am looking for. :)\nThere was a link on Adobe's site that talked about \"Embedding and Communicating with the Macromedia Flash Player in C# Windows Applications\" but they seem to have removed it :(\n"
] | [
33,
8
] | [] | [] | [
"adobe",
"c#",
"flash",
"macromedia",
"winforms"
] | stackoverflow_0000001037_adobe_c#_flash_macromedia_winforms.txt |
Q:
ViewState invalid only in Safari
One of the sites I maintain relies heavily on the use of ViewState (it isn't my code). However, on certain pages where the ViewState is extra-bloated, Safari throws a "Validation of viewstate MAC failed" error.
This appears to only happen in Safari. Firefox, IE and Opera all load successfully in the same scenario.
A:
While I second the Channel 9 solution, also be aware that in some hosted environments Safari is not considered an up-level browser. You may need to add it to your application's browscap in order to make use of some ASP.Net features.
That was the root cause of some headaches we had for a client's site that used the ASP Menu control.
A:
My first port of call would be to go through the elements on the page and see which controls:
Will still work when I switch ViewState off
Can be moved out of the page and into an AJAX call to be loaded when required
Failing that, and here's the disclaimer - I've never used this solution on a web-facing site - but in the past where I've wanted to eliminate massive ViewStates in limited-audience applications I have stored the ViewState in the Session.
It has worked for me because the hit to memory isn't significant for the number of users, but if you're running a fairly popular site I wouldn't recommend this approach. However, if the Session solution works for Safari you could always detect the user agent and fudge appropriately.
A:
I've been doing a little research into this and whilst I'm not entirely sure its the cause I believe it is because Safari is not returning the full result set (hence cropping it).
I have been in dicussion with another developer and found the following post on Channel 9 as well which recommends making use of the SQL State service to store the viewstate avoiding the postback issue and also page size.
http://channel9.msdn.com/forums/TechOff/250549-ASPNET-ViewState-flawed-architecture/?CommentID=270477#263702
Does this seem like the best solution?
| ViewState invalid only in Safari | One of the sites I maintain relies heavily on the use of ViewState (it isn't my code). However, on certain pages where the ViewState is extra-bloated, Safari throws a "Validation of viewstate MAC failed" error.
This appears to only happen in Safari. Firefox, IE and Opera all load successfully in the same scenario.
| [
"While I second the Channel 9 solution, also be aware that in some hosted environments Safari is not considered an up-level browser. You may need to add it to your application's browscap in order to make use of some ASP.Net features. \nThat was the root cause of some headaches we had for a client's site that used the ASP Menu control.\n",
"My first port of call would be to go through the elements on the page and see which controls:\n\nWill still work when I switch ViewState off\nCan be moved out of the page and into an AJAX call to be loaded when required\n\nFailing that, and here's the disclaimer - I've never used this solution on a web-facing site - but in the past where I've wanted to eliminate massive ViewStates in limited-audience applications I have stored the ViewState in the Session.\nIt has worked for me because the hit to memory isn't significant for the number of users, but if you're running a fairly popular site I wouldn't recommend this approach. However, if the Session solution works for Safari you could always detect the user agent and fudge appropriately.\n",
"I've been doing a little research into this and whilst I'm not entirely sure its the cause I believe it is because Safari is not returning the full result set (hence cropping it).\nI have been in dicussion with another developer and found the following post on Channel 9 as well which recommends making use of the SQL State service to store the viewstate avoiding the postback issue and also page size.\nhttp://channel9.msdn.com/forums/TechOff/250549-ASPNET-ViewState-flawed-architecture/?CommentID=270477#263702\nDoes this seem like the best solution?\n"
] | [
5,
3,
2
] | [] | [] | [
".net",
"c#",
"safari",
"viewstate"
] | stackoverflow_0000001189_.net_c#_safari_viewstate.txt |
Q:
Using MSTest with CruiseControl.NET
We have been using CruiseControl for quite a while with NUnit and NAnt. For a recent project we decided to use the testing framework that comes with Visual Studio, which so far has been adequate.
I'm attempting to get the solution running in CruiseControl. I've finally got the build itself to work; however, I have been unable to get any tests to show up in the CruiseControl interface despite adding custom build tasks and components designed to do just that. Does anyone have a definitive link out there to instructions on getting this set up?
A:
Not sure if that helps (i found the ccnet Documentation somewhat unhelpful at times):
Using CruiseControl.NET with MSTest
A:
The CC.Net interface is generated via an XSL transform on your XML files put together as specified in the ccnet.config file for your projects. The XSL is already written for things like FxCop - check your server's CC xsl directory for examples - shouldn't be too hard to write your own to add in the info - just remember to add the XML output from your tests into the main log.
| Using MSTest with CruiseControl.NET | We have been using CruiseControl for quite a while with NUnit and NAnt. For a recent project we decided to use the testing framework that comes with Visual Studio, which so far has been adequate.
I'm attempting to get the solution running in CruiseControl. I've finally got the build itself to work; however, I have been unable to get any tests to show up in the CruiseControl interface despite adding custom build tasks and components designed to do just that. Does anyone have a definitive link out there to instructions on getting this set up?
| [
"Not sure if that helps (i found the ccnet Documentation somewhat unhelpful at times):\nUsing CruiseControl.NET with MSTest\n",
"The CC.Net interface is generated via an XSL transform on your XML files put together as specified in the ccnet.config file for your projects. The XSL is already written for things like FxCop - check your server's CC xsl directory for examples - shouldn't be too hard to write your own to add in the info - just remember to add the XML output from your tests into the main log.\n"
] | [
5,
1
] | [] | [] | [
"build_process",
"cruisecontrol.net",
"msbuild"
] | stackoverflow_0000001314_build_process_cruisecontrol.net_msbuild.txt |
Q:
How can I get the authenticated user name under Apache using plain HTTP authentication and PHP?
First, let's get the security considerations out of the way. I'm using simple authentication under Apache for a one-off, internal use only, non-internet connected LAN, PHP web app.
How can get I the HTTP authenticated user name in PHP?
A:
I think that you are after this
$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
| How can I get the authenticated user name under Apache using plain HTTP authentication and PHP? | First, let's get the security considerations out of the way. I'm using simple authentication under Apache for a one-off, internal use only, non-internet connected LAN, PHP web app.
How can get I the HTTP authenticated user name in PHP?
| [
"I think that you are after this\n$username = $_SERVER['PHP_AUTH_USER'];\n$password = $_SERVER['PHP_AUTH_PW'];\n\n"
] | [
40
] | [] | [] | [
"apache",
"authentication",
"http_authentication",
"php"
] | stackoverflow_0000001417_apache_authentication_http_authentication_php.txt |
Q:
Integrating Visual Studio Test Project with Cruise Control
I'm looking into using Visual Studio 2008's built in unit test projects instead of NUnit and I was wondering if anyone has any experience in trying to integrate this type of unit test project with Cruise Control.Net.
A:
From some of the initial research it doesn't appear to be a super simple solution.
It appears that doing this involves having Visual Studio 2008 actually installed on the continuous integration server, which could be a deal breaker.
Then configure the MSTest.exe to run in the tasks list, but first you'll have to make a batch file to delete the results files from previous passes as this file's existence causes an error.
Then create a xslt to format the results and put it into the dashboard.config file.
The code project article I found has a lot more detail.
Integrating Visual Studio Team System 2008 Unit Tests with CruiseControl.NET
| Integrating Visual Studio Test Project with Cruise Control | I'm looking into using Visual Studio 2008's built in unit test projects instead of NUnit and I was wondering if anyone has any experience in trying to integrate this type of unit test project with Cruise Control.Net.
| [
"From some of the initial research it doesn't appear to be a super simple solution. \nIt appears that doing this involves having Visual Studio 2008 actually installed on the continuous integration server, which could be a deal breaker.\nThen configure the MSTest.exe to run in the tasks list, but first you'll have to make a batch file to delete the results files from previous passes as this file's existence causes an error.\nThen create a xslt to format the results and put it into the dashboard.config file.\nThe code project article I found has a lot more detail.\nIntegrating Visual Studio Team System 2008 Unit Tests with CruiseControl.NET\n"
] | [
10
] | [] | [] | [
"continuous_integration",
"cruisecontrol.net",
"unit_testing",
"visual_studio"
] | stackoverflow_0000001503_continuous_integration_cruisecontrol.net_unit_testing_visual_studio.txt |
Q:
Register Windows program with the mailto protocol programmatically
How do I make it so mailto: links will be registered with my program?
How would I then handle that event in my program?
Most of the solutions I found from a quick Google search are how to do this manually, but I need to do this automatically for users of my program if they click a button, such as "set as default email client".
#Edit:
Removed reference to Delphi, because the answer is independent of your language.
A:
@Dillie-O: Your answer put me in the right direction (I should have expected it to just be a registry change) and I got this working. But I'm going to mark this as the answer because I'm going to put some additional information that I found while working on this.
The solution to this question really doesn't depend on what programming language you're using, as long as there's some way to modify Windows registry settings.
Finally, here's the answer:
To associate a program with the mailto protocol for all users on a computer, change the HKEY_CLASSES_ROOT\mailto\shell\open\command Default value to:
"Your program's executable" "%1"
To associate a program with the mailto protocol for the current user, change the HKEY_CURRENT_USER\Software\Classes\mailto\shell\open\command Default value to:
"Your program's executable" "%1"
The %1 will be replaced with the entire mailto URL. For example, given the link:
<a href="mailto:[email protected]">Email me</a>
The following will be executed:
"Your program's executable" "mailto:[email protected]"
Update (via comment by shellscape):
As of Windows 8, this method no longer works as expected. Win8 enforces the following key: HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\URLAssociations\MAILTO\UserChoice for which the ProgID of the selected app is hashed and can't be forged. It's a royal PITA.
A:
From what I've seen, there are a few registry keys that set the default mail client. One of them is:
System Key: [HKEY_CLASSES_ROOT\mailto\shell\open\command]
Value Name: (Default)
Data Type: REG_SZ (String Value)
Value Data: Mail program command-line.
I'm not familiar with Delphi 7, but I'm sure there are some registry editing libraries there that you could use to modify this value.
Some places list more than this key, others just this key, so you may need to test a little bit to find the proper one(s).
| Register Windows program with the mailto protocol programmatically | How do I make it so mailto: links will be registered with my program?
How would I then handle that event in my program?
Most of the solutions I found from a quick Google search are how to do this manually, but I need to do this automatically for users of my program if they click a button, such as "set as default email client".
#Edit:
Removed reference to Delphi, because the answer is independent of your language.
| [
"@Dillie-O: Your answer put me in the right direction (I should have expected it to just be a registry change) and I got this working. But I'm going to mark this as the answer because I'm going to put some additional information that I found while working on this.\nThe solution to this question really doesn't depend on what programming language you're using, as long as there's some way to modify Windows registry settings.\nFinally, here's the answer:\n\nTo associate a program with the mailto protocol for all users on a computer, change the HKEY_CLASSES_ROOT\\mailto\\shell\\open\\command Default value to:\n\"Your program's executable\" \"%1\"\nTo associate a program with the mailto protocol for the current user, change the HKEY_CURRENT_USER\\Software\\Classes\\mailto\\shell\\open\\command Default value to:\n\"Your program's executable\" \"%1\"\n\nThe %1 will be replaced with the entire mailto URL. For example, given the link:\n<a href=\"mailto:[email protected]\">Email me</a>\n\nThe following will be executed:\n\"Your program's executable\" \"mailto:[email protected]\"\nUpdate (via comment by shellscape):\nAs of Windows 8, this method no longer works as expected. Win8 enforces the following key: HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\URLAssociations\\MAILTO\\UserChoice for which the ProgID of the selected app is hashed and can't be forged. It's a royal PITA.\n",
"From what I've seen, there are a few registry keys that set the default mail client. One of them is:\nSystem Key: [HKEY_CLASSES_ROOT\\mailto\\shell\\open\\command]\nValue Name: (Default)\nData Type: REG_SZ (String Value)\nValue Data: Mail program command-line.\nI'm not familiar with Delphi 7, but I'm sure there are some registry editing libraries there that you could use to modify this value.\nSome places list more than this key, others just this key, so you may need to test a little bit to find the proper one(s).\n"
] | [
19,
13
] | [] | [] | [
"mailto",
"windows"
] | stackoverflow_0000000231_mailto_windows.txt |
Q:
How do I make a menu that does not require the user to press [enter] to make a selection?
I've got a menu in Python. That part was easy. I'm using raw_input() to get the selection from the user.
The problem is that raw_input (and input) require the user to press Enter after they make a selection. Is there any way to make the program act immediately upon a keystroke? Here's what I've got so far:
import sys
print """Menu
1) Say Foo
2) Say Bar"""
answer = raw_input("Make a selection> ")
if "1" in answer: print "foo"
elif "2" in answer: print "bar"
It would be great to have something like
print menu
while lastKey = "":
lastKey = check_for_recent_keystrokes()
if "1" in lastKey: #do stuff...
A:
On Windows:
import msvcrt
answer=msvcrt.getch()
A:
On Linux:
set raw mode
select and read the keystroke
restore normal settings
import sys
import select
import termios
import tty
def getkey():
old_settings = termios.tcgetattr(sys.stdin)
tty.setraw(sys.stdin.fileno())
select.select([sys.stdin], [], [], 0)
answer = sys.stdin.read(1)
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_settings)
return answer
print """Menu
1) Say Foo
2) Say Bar"""
answer=getkey()
if "1" in answer: print "foo"
elif "2" in answer: print "bar"
A:
Wow, that took forever. Ok, here's what I've ended up with
#!C:\python25\python.exe
import msvcrt
print """Menu
1) Say Foo
2) Say Bar"""
while 1:
char = msvcrt.getch()
if char == chr(27): #escape
break
if char == "1":
print "foo"
break
if char == "2":
print "Bar"
break
It fails hard using IDLE, the python...thing...that comes with python. But once I tried it in DOS (er, CMD.exe), as a real program, then it ran fine.
No one try it in IDLE, unless you have Task Manager handy.
I've already forgotten how I lived with menus that arn't super-instant responsive.
A:
The reason msvcrt fails in IDLE is because IDLE is not accessing the library that runs msvcrt. Whereas when you run the program natively in cmd.exe it works nicely. For the same reason that your program blows up on Mac and Linux terminals.
But I guess if you're going to be using this specifically for windows, more power to ya.
| How do I make a menu that does not require the user to press [enter] to make a selection? | I've got a menu in Python. That part was easy. I'm using raw_input() to get the selection from the user.
The problem is that raw_input (and input) require the user to press Enter after they make a selection. Is there any way to make the program act immediately upon a keystroke? Here's what I've got so far:
import sys
print """Menu
1) Say Foo
2) Say Bar"""
answer = raw_input("Make a selection> ")
if "1" in answer: print "foo"
elif "2" in answer: print "bar"
It would be great to have something like
print menu
while lastKey = "":
lastKey = check_for_recent_keystrokes()
if "1" in lastKey: #do stuff...
| [
"On Windows:\nimport msvcrt\nanswer=msvcrt.getch()\n\n",
"On Linux:\n\nset raw mode\nselect and read the keystroke\nrestore normal settings\n\n\nimport sys\nimport select\nimport termios\nimport tty\n\ndef getkey():\n old_settings = termios.tcgetattr(sys.stdin)\n tty.setraw(sys.stdin.fileno())\n select.select([sys.stdin], [], [], 0)\n answer = sys.stdin.read(1)\n termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_settings)\n return answer\n\nprint \"\"\"Menu\n1) Say Foo\n2) Say Bar\"\"\"\n\nanswer=getkey()\n\nif \"1\" in answer: print \"foo\"\nelif \"2\" in answer: print \"bar\"\n\n\n",
"Wow, that took forever. Ok, here's what I've ended up with \n#!C:\\python25\\python.exe\nimport msvcrt\nprint \"\"\"Menu\n1) Say Foo \n2) Say Bar\"\"\"\nwhile 1:\n char = msvcrt.getch()\n if char == chr(27): #escape\n break\n if char == \"1\":\n print \"foo\"\n break\n if char == \"2\":\n print \"Bar\"\n break\n\nIt fails hard using IDLE, the python...thing...that comes with python. But once I tried it in DOS (er, CMD.exe), as a real program, then it ran fine.\nNo one try it in IDLE, unless you have Task Manager handy.\nI've already forgotten how I lived with menus that arn't super-instant responsive.\n",
"The reason msvcrt fails in IDLE is because IDLE is not accessing the library that runs msvcrt. Whereas when you run the program natively in cmd.exe it works nicely. For the same reason that your program blows up on Mac and Linux terminals.\nBut I guess if you're going to be using this specifically for windows, more power to ya.\n"
] | [
10,
9,
4,
0
] | [] | [] | [
"python"
] | stackoverflow_0000001829_python.txt |
Q:
Can a Windows dll retrieve its own filename?
A Windows process created from an exe file has access to the command string which invoked it, including its file's path and filename. eg. C:\MyApp\MyApp.exe --help.
But this is not so for a dll invoked via LoadLibrary. Does anyone know of a way for a function loaded via dll to find out what its path and filename is?
Specifically I'm interested in a Delphi solution, but I suspect that the answer would be pretty much the same for any language.
A:
I think you're looking for GetModuleFileName.
http://www.swissdelphicenter.ch/torry/showcode.php?id=143:
{
If you are working on a DLL and are interested in the filename of the
DLL rather than the filename of the application, then you can use this function:
}
function GetModuleName: string;
var
szFileName: array[0..MAX_PATH] of Char;
begin
FillChar(szFileName, SizeOf(szFileName), #0);
GetModuleFileName(hInstance, szFileName, MAX_PATH);
Result := szFileName;
end;
Untested though, been some time since I worked with Delphi :)
| Can a Windows dll retrieve its own filename? | A Windows process created from an exe file has access to the command string which invoked it, including its file's path and filename. eg. C:\MyApp\MyApp.exe --help.
But this is not so for a dll invoked via LoadLibrary. Does anyone know of a way for a function loaded via dll to find out what its path and filename is?
Specifically I'm interested in a Delphi solution, but I suspect that the answer would be pretty much the same for any language.
| [
"I think you're looking for GetModuleFileName.\nhttp://www.swissdelphicenter.ch/torry/showcode.php?id=143:\n{\n If you are working on a DLL and are interested in the filename of the\n DLL rather than the filename of the application, then you can use this function:\n}\n\nfunction GetModuleName: string;\nvar\n szFileName: array[0..MAX_PATH] of Char;\nbegin\n FillChar(szFileName, SizeOf(szFileName), #0);\n GetModuleFileName(hInstance, szFileName, MAX_PATH);\n Result := szFileName;\nend;\n\nUntested though, been some time since I worked with Delphi :)\n"
] | [
39
] | [] | [] | [
"delphi",
"dll",
"winapi",
"windows"
] | stackoverflow_0000002043_delphi_dll_winapi_windows.txt |
Q:
How to get the value of built, encoded ViewState?
I need to grab the base64-encoded representation of the ViewState. Obviously, this would not be available until fairly late in the request lifecycle, which is OK.
For example, if the output of the page includes:
<input type="hidden" name="__VIEWSTATE"
id="__VIEWSTATE" value="/wEPDwUJODU0Njc5MD...==" />
I need a way on the server-side to get the value "/wEPDwUJODU0Njc5MD...=="
To clarify, I need this value when the page is being rendered, not on PostBack. e.g. I need to know the ViewState value that is being sent to the client, not the ViewState I'm getting back from them.
A:
Rex, I suspect a good place to start looking is solutions that compress the ViewState -- they're grabbing ViewState on the server before it's sent down to the client and gzipping it. That's exactly where you want to be.
Scott Hanselman on ViewState Compression (2005)
ViewState Compression with System.IO.Compression (2007)
A:
See this blog post where the author describes a method for overriding the default behavior for generating the ViewState and instead shows how to save it on the server Session object.
In ASP.NET 2.0, ViewState is saved by
a descendant of PageStatePersister
class. This class is an abstract class
for saving and loading ViewsState and
there are two implemented descendants
of this class in .Net Framework, named
HiddenFieldPageStatePersister and
SessionPageStatePersister. By default
HiddenFieldPageStatePersister is used
to save/load ViewState information,
but we can easily get the
SessionPageStatePersister to work and
save ViewState in Session object.
Although I did not test his code, it seems to show exactly what you want: a way to gain access to ViewState code while still on the server, before postback.
A:
I enabled compression following similar articles to those posted above. The key to accessing the ViewState before the application sends it was overriding this method;
protected override void SavePageStateToPersistenceMedium(object viewState)
You can call the base method within this override and then add whatever additional logic you require to handle the ViewState.
| How to get the value of built, encoded ViewState? | I need to grab the base64-encoded representation of the ViewState. Obviously, this would not be available until fairly late in the request lifecycle, which is OK.
For example, if the output of the page includes:
<input type="hidden" name="__VIEWSTATE"
id="__VIEWSTATE" value="/wEPDwUJODU0Njc5MD...==" />
I need a way on the server-side to get the value "/wEPDwUJODU0Njc5MD...=="
To clarify, I need this value when the page is being rendered, not on PostBack. e.g. I need to know the ViewState value that is being sent to the client, not the ViewState I'm getting back from them.
| [
"Rex, I suspect a good place to start looking is solutions that compress the ViewState -- they're grabbing ViewState on the server before it's sent down to the client and gzipping it. That's exactly where you want to be.\n\nScott Hanselman on ViewState Compression (2005)\nViewState Compression with System.IO.Compression (2007)\n\n",
"See this blog post where the author describes a method for overriding the default behavior for generating the ViewState and instead shows how to save it on the server Session object.\n\nIn ASP.NET 2.0, ViewState is saved by\n a descendant of PageStatePersister\n class. This class is an abstract class\n for saving and loading ViewsState and\n there are two implemented descendants\n of this class in .Net Framework, named\n HiddenFieldPageStatePersister and\n SessionPageStatePersister. By default\n HiddenFieldPageStatePersister is used\n to save/load ViewState information,\n but we can easily get the\n SessionPageStatePersister to work and\n save ViewState in Session object.\n\nAlthough I did not test his code, it seems to show exactly what you want: a way to gain access to ViewState code while still on the server, before postback. \n",
"I enabled compression following similar articles to those posted above. The key to accessing the ViewState before the application sends it was overriding this method;\nprotected override void SavePageStateToPersistenceMedium(object viewState)\n\nYou can call the base method within this override and then add whatever additional logic you require to handle the ViewState.\n"
] | [
13,
4,
2
] | [] | [] | [
"asp.net",
"c#",
"viewstate"
] | stackoverflow_0000001010_asp.net_c#_viewstate.txt |
Q:
How can I change the background of a masterpage from the code behind of a content page?
I specifically want to add the style of background-color to the <body> tag of a master page, from the code behind (C#) of a content page that uses that master page.
I have different content pages that need to make the master page has different colors depending on which content page is loaded, so that the master page matches the content page's theme.
I have a solution below:
I'm looking for something more like:
Master.Attributes.Add("style", "background-color: 2e6095");
Inside of the page load function of the content page. But I can't get the above line to work. I only need to change the background-color for the <body> tag of the page.
A:
What I would do for the particular case is:
i. Define the body as a server side control
<body runat="server" id="masterpageBody">
ii. In your content aspx page, register the MasterPage with the register:
<% MasterPageFile="..." %>
iii. In the Content Page, you can now simply use
Master.FindControl("masterpageBody")
and have access to the control. Now, you can change whatever properties/style that you like!
A:
This is what I came up with:
In the page load function:
HtmlGenericControl body = (HtmlGenericControl)Master.FindControl("default_body");
body.Style.Add(HtmlTextWriterStyle.BackgroundColor, "#2E6095");
Where
default_body = the id of the body tag.
A:
I believe you are talking about a content management system. The way I have delt with this situation in the past is to either:
Allow a page/content to define an extra custom stylesheet or
Allow a page/content to define inline style tags
| How can I change the background of a masterpage from the code behind of a content page? | I specifically want to add the style of background-color to the <body> tag of a master page, from the code behind (C#) of a content page that uses that master page.
I have different content pages that need to make the master page has different colors depending on which content page is loaded, so that the master page matches the content page's theme.
I have a solution below:
I'm looking for something more like:
Master.Attributes.Add("style", "background-color: 2e6095");
Inside of the page load function of the content page. But I can't get the above line to work. I only need to change the background-color for the <body> tag of the page.
| [
"What I would do for the particular case is:\ni. Define the body as a server side control\n<body runat=\"server\" id=\"masterpageBody\">\n\nii. In your content aspx page, register the MasterPage with the register:\n<% MasterPageFile=\"...\" %>\n\niii. In the Content Page, you can now simply use \nMaster.FindControl(\"masterpageBody\")\n\nand have access to the control. Now, you can change whatever properties/style that you like!\n",
"This is what I came up with:\nIn the page load function:\nHtmlGenericControl body = (HtmlGenericControl)Master.FindControl(\"default_body\");\nbody.Style.Add(HtmlTextWriterStyle.BackgroundColor, \"#2E6095\");\n\nWhere \n\ndefault_body = the id of the body tag.\n\n",
"I believe you are talking about a content management system. The way I have delt with this situation in the past is to either:\n\nAllow a page/content to define an extra custom stylesheet or\nAllow a page/content to define inline style tags\n\n"
] | [
10,
1,
0
] | [] | [] | [
".net",
"asp.net",
"c#",
"master_pages"
] | stackoverflow_0000002209_.net_asp.net_c#_master_pages.txt |
Q:
Add Custom Tag to Visual Studio Validation
How can I add rules to Visual Studio (2005 and up) for validating property markup (HTML) for a vendor's proprietary controls?
My client uses a control which requires several properties to be set as tags in the aspx file which generates something like 215 validation errors on each build. It's not preventing me from building, but real errors are getting lost in the noise.
A:
Right-click on the Source view of an HTML / ASP page and select "Formatting and Validation".
Click "Tag Specific Options".
Expand "Client HTML Tags" and select the heading.
Click "New Tag...".
And just fill it in!
I wish that I could add custom CSS values as well.
| Add Custom Tag to Visual Studio Validation | How can I add rules to Visual Studio (2005 and up) for validating property markup (HTML) for a vendor's proprietary controls?
My client uses a control which requires several properties to be set as tags in the aspx file which generates something like 215 validation errors on each build. It's not preventing me from building, but real errors are getting lost in the noise.
| [
"Right-click on the Source view of an HTML / ASP page and select \"Formatting and Validation\".\n\nClick \"Tag Specific Options\".\nExpand \"Client HTML Tags\" and select the heading.\nClick \"New Tag...\".\nAnd just fill it in!\n\nI wish that I could add custom CSS values as well.\n"
] | [
5
] | [] | [] | [
"visual_studio"
] | stackoverflow_0000002279_visual_studio.txt |
Q:
How do I turn on line numbers by default in TextWrangler on the Mac?
I am fed up having to turn them on every time I open the application.
A:
Go to TextWrangler > Preferences.
Choose Text Status Display in the category pane, then check the option "Show line numbers" and close the preferences. This should now be on by default when you open existing documents.
| How do I turn on line numbers by default in TextWrangler on the Mac? | I am fed up having to turn them on every time I open the application.
| [
"Go to TextWrangler > Preferences.\nChoose Text Status Display in the category pane, then check the option \"Show line numbers\" and close the preferences. This should now be on by default when you open existing documents.\n"
] | [
28
] | [] | [] | [
"macos",
"textwrangler"
] | stackoverflow_0000002332_macos_textwrangler.txt |
Q:
How to filter and combine 2 datasets in C#
I am building a web page to show a customer what software they purchased and to give them a link to download said software. Unfortunately, the data on what was purchased and the download information are in separate databases so I can't just take care of it with joins in an SQL query.
The common item is SKU. I'll be pulling a list of SKUs from the customer purchases database and on the download table is a comma delineated list of SKUs associated with that download. My intention, at the moment, is to create from this one datatable to populate a GridView.
Any suggestions on how to do this efficiently would be appreciated. If it helps, I can pretty easily pull back the data as a DataSet or a DataReader, if either one would be better for this purpose.
A:
As long as the two databases are on the same physical server (assuming MSSQL) and the username/password being used in the connection string has rights to both DBs, then you should be able to perform a join across the two databases. Example:
select p.Date,
p.Amount,
d.SoftwareName,
d.DownloadLink
from PurchaseDB.dbo.Purchases as p
join ProductDB.dbo.Products as d on d.sku = p.sku
where p.UserID = 12345
A:
Why not create a Domain object based approach to this problem:
public class CustomerDownloadInfo
{
private string sku;
private readonly ICustomer customer;
public CustomerDownloadInfo(ICustomer Customer){
customer = Customer;
}
public void AttachSku(string Sku){
sku = Sku;
}
public string Sku{
get { return sku; }
}
public string Link{
get{
// etc... etc...
}
}
}
There are a million variations on this, but once you aggregate this information, wouldn't it be easier to present?
A:
I am thinking off the top of my head here. If you load both as Data Tables in the same Data Sets, and define a relation between the two over SKU, and then run a query on the Data Set which produces the desired result.
| How to filter and combine 2 datasets in C# | I am building a web page to show a customer what software they purchased and to give them a link to download said software. Unfortunately, the data on what was purchased and the download information are in separate databases so I can't just take care of it with joins in an SQL query.
The common item is SKU. I'll be pulling a list of SKUs from the customer purchases database and on the download table is a comma delineated list of SKUs associated with that download. My intention, at the moment, is to create from this one datatable to populate a GridView.
Any suggestions on how to do this efficiently would be appreciated. If it helps, I can pretty easily pull back the data as a DataSet or a DataReader, if either one would be better for this purpose.
| [
"As long as the two databases are on the same physical server (assuming MSSQL) and the username/password being used in the connection string has rights to both DBs, then you should be able to perform a join across the two databases. Example: \nselect p.Date,\n p.Amount,\n d.SoftwareName,\n d.DownloadLink\nfrom PurchaseDB.dbo.Purchases as p\njoin ProductDB.dbo.Products as d on d.sku = p.sku\nwhere p.UserID = 12345\n\n",
"Why not create a Domain object based approach to this problem:\npublic class CustomerDownloadInfo\n{\n private string sku;\n private readonly ICustomer customer;\n\n public CustomerDownloadInfo(ICustomer Customer){\n customer = Customer;\n }\n\n public void AttachSku(string Sku){\n sku = Sku;\n }\n\n public string Sku{\n get { return sku; }\n }\n\n public string Link{\n get{ \n // etc... etc... \n }\n }\n}\n\nThere are a million variations on this, but once you aggregate this information, wouldn't it be easier to present?\n",
"I am thinking off the top of my head here. If you load both as Data Tables in the same Data Sets, and define a relation between the two over SKU, and then run a query on the Data Set which produces the desired result.\n"
] | [
3,
2,
0
] | [] | [] | [
".net",
"c#"
] | stackoverflow_0000002267_.net_c#.txt |
Q:
Binary file layout reference
Where are some good sources of information on binary file layout structures?
If I wanted to pull in a BTrieve index file, parse MP3 headers, etc. Where does one get reliable information?
A:
I'm not sure if there's a general information source for this kind of information. I always just search on google or wikipedia for that particular file type. The binary file layout structure information should be included.
For example, http://en.wikipedia.org/wiki/MP3#File_structure">MP3 file layout structure
| Binary file layout reference | Where are some good sources of information on binary file layout structures?
If I wanted to pull in a BTrieve index file, parse MP3 headers, etc. Where does one get reliable information?
| [
"I'm not sure if there's a general information source for this kind of information. I always just search on google or wikipedia for that particular file type. The binary file layout structure information should be included.\nFor example, http://en.wikipedia.org/wiki/MP3#File_structure\">MP3 file layout structure\n"
] | [
1
] | [] | [] | [
"binary",
"data_structures",
"file",
"language_agnostic"
] | stackoverflow_0000002405_binary_data_structures_file_language_agnostic.txt |
Q:
How to map a latitude/longitude to a distorted map?
I have a bunch of latitude/longitude pairs that map to known x/y coordinates on a (geographically distorted) map.
Then I have one more latitude/longitude pair. I want to plot it on the map as best is possible. How do I go about doing this?
At first I decided to create a system of linear equations for the three nearest lat/long points and compute a transformation from these, but this doesn't work well at all. Since that's a linear system, I can't use more nearby points either.
You can't assume North is up: all you have is the existing lat/long->x/y mappings.
EDIT: it's not a Mercator projection, or anything like that. It's arbitrarily distorted for readability (think subway map). I want to use only the nearest 5 to 10 mappings so that distortion on other parts of the map doesn't affect the mapping I'm trying to compute.
Further, the entire map is in a very small geographical area so there's no need to worry about the globe--flat-earth assumptions are good enough.
A:
Are there any more specific details on the kind of distortion? If, for example, your latitudes and longitudes are "distorted" onto your 2D map using a Mercator projection, the conversion math is readily available.
If the map is distorted truly arbitrarily, there are lots of things you could try, but the simplest would probably be to compute a weighted average from your existing point mappings. Your weights could be the squared inverse of the x/y distance from your new point to each of your existing points.
Some pseudocode:
estimate-latitude-longitude (x, y)
numerator-latitude := 0
numerator-longitude := 0
denominator := 0
for each point,
deltaX := x - point.x
deltaY := y - point.y
distSq := deltaX * deltaX + deltaY * deltaY
weight := 1 / distSq
numerator-latitude += weight * point.latitude
numerator-longitude += weight * point.longitude
denominator += weight
return (numerator-latitude / denominator, numerator-longitude / denominator)
This code will give a relatively simple approximation. If you can be more precise about the way the projection distorts the geographical coordinates, you can probably do much better.
A:
Alright. From a theoretical point of view, given that the distortion is "arbitrary", and any solution requires you to model this arbitrary distortion, you obviously can't get an "answer". However, any solution is going to involve imposing (usually implicitly) some model of the distortion that may or may not reflect the reality of the situation.
Since you seem to be most interested in models that presume some sort of local continuity of the distortion mapping, the most obvious choice is the one you've already tried: linear interpolaton between the nearest points. Going beyond that is going to require more sophisticated mathematical and numerical analysis knowledge.
You are incorrect, however, in presuming you cannot expand this to more points. You can by using a least-squared error approach. Find the linear answer that minimizes the error of the other points. This is probably the most straight-forward extension. In other words, take the 5 nearest points and try to come up with a linear approximation that minimizes the error of those points. And use that. I would try this next.
If that doesn't work, then the assumption of linearity over the area of N points is broken. At that point you'll need to upgrade to either a quadratic or cubic model. The math is going to get hectic at that point.
A:
the problem is that the sphere can be distorted a number of ways, and having all those points known on the equator, lets say, wont help you map points further away.
You need better 'close' points, then you can assume these three points are on a plane with the fourth and do the interpolation --knowing that the distance of longitudes is a function, not a constant.
A:
Ummm. Maybe I am missing something about the question here, but if you have long/lat info, you also have the direction of north?
It seems you need to map geodesic coordinates to a projected coordinates system. For example osgb to wgs84.
The maths involved is non-trivial, but the code comes out a only a few lines. If I had more time I'd post more but I need a shower so I will be boring and link to the wikipedia entry which is pretty good.
Note: Post shower edited.
| How to map a latitude/longitude to a distorted map? | I have a bunch of latitude/longitude pairs that map to known x/y coordinates on a (geographically distorted) map.
Then I have one more latitude/longitude pair. I want to plot it on the map as best is possible. How do I go about doing this?
At first I decided to create a system of linear equations for the three nearest lat/long points and compute a transformation from these, but this doesn't work well at all. Since that's a linear system, I can't use more nearby points either.
You can't assume North is up: all you have is the existing lat/long->x/y mappings.
EDIT: it's not a Mercator projection, or anything like that. It's arbitrarily distorted for readability (think subway map). I want to use only the nearest 5 to 10 mappings so that distortion on other parts of the map doesn't affect the mapping I'm trying to compute.
Further, the entire map is in a very small geographical area so there's no need to worry about the globe--flat-earth assumptions are good enough.
| [
"Are there any more specific details on the kind of distortion? If, for example, your latitudes and longitudes are \"distorted\" onto your 2D map using a Mercator projection, the conversion math is readily available.\nIf the map is distorted truly arbitrarily, there are lots of things you could try, but the simplest would probably be to compute a weighted average from your existing point mappings. Your weights could be the squared inverse of the x/y distance from your new point to each of your existing points.\nSome pseudocode:\nestimate-latitude-longitude (x, y)\n\n numerator-latitude := 0\n numerator-longitude := 0\n denominator := 0\n\n for each point,\n deltaX := x - point.x\n deltaY := y - point.y\n distSq := deltaX * deltaX + deltaY * deltaY\n weight := 1 / distSq\n\n numerator-latitude += weight * point.latitude\n numerator-longitude += weight * point.longitude\n denominator += weight\n\n return (numerator-latitude / denominator, numerator-longitude / denominator)\n\nThis code will give a relatively simple approximation. If you can be more precise about the way the projection distorts the geographical coordinates, you can probably do much better.\n",
"Alright. From a theoretical point of view, given that the distortion is \"arbitrary\", and any solution requires you to model this arbitrary distortion, you obviously can't get an \"answer\". However, any solution is going to involve imposing (usually implicitly) some model of the distortion that may or may not reflect the reality of the situation.\nSince you seem to be most interested in models that presume some sort of local continuity of the distortion mapping, the most obvious choice is the one you've already tried: linear interpolaton between the nearest points. Going beyond that is going to require more sophisticated mathematical and numerical analysis knowledge.\nYou are incorrect, however, in presuming you cannot expand this to more points. You can by using a least-squared error approach. Find the linear answer that minimizes the error of the other points. This is probably the most straight-forward extension. In other words, take the 5 nearest points and try to come up with a linear approximation that minimizes the error of those points. And use that. I would try this next.\nIf that doesn't work, then the assumption of linearity over the area of N points is broken. At that point you'll need to upgrade to either a quadratic or cubic model. The math is going to get hectic at that point.\n",
"the problem is that the sphere can be distorted a number of ways, and having all those points known on the equator, lets say, wont help you map points further away.\nYou need better 'close' points, then you can assume these three points are on a plane with the fourth and do the interpolation --knowing that the distance of longitudes is a function, not a constant.\n",
"Ummm. Maybe I am missing something about the question here, but if you have long/lat info, you also have the direction of north?\nIt seems you need to map geodesic coordinates to a projected coordinates system. For example osgb to wgs84.\nThe maths involved is non-trivial, but the code comes out a only a few lines. If I had more time I'd post more but I need a shower so I will be boring and link to the wikipedia entry which is pretty good.\nNote: Post shower edited.\n"
] | [
8,
2,
0,
0
] | [] | [] | [
"latitude_longitude",
"mapping",
"maps",
"math"
] | stackoverflow_0000001908_latitude_longitude_mapping_maps_math.txt |
Q:
File size differences after copying a file to a server vía FTP
I have created a PHP-script to update a web server that is live inside a local directory.
I'm migrating the script into Python. It works fine for the most part, but after a PUT command, the size of the file appears to change. Thus, the size of the file is different from that of the file on the server.
Once I download again the file from the FTP server, the only difference is the CR/LF mark. This annoys me because the same script is comparing the size of the files to update. Also, in case it means anything, the script works perfectly in PHP vía ftp_put.
from ftplib import FTP
ftpserver = "myserver"
ftpuser = "myuser"
ftppass = "mypwd"
locfile = "g:/test/style.css"
ftpfile = "/temp/style.css"
try:
ftp = FTP(ftpserver, ftpuser, ftppass)
except:
exit ("Cannot connect")
f = open (locfile, "r")
try:
ftp.delete (ftpfile)
except:
pass
# ftp.sendcmd ("TYPE I")
# ftp.storlines("STOR %s" % ftpfile, f)
ftp.storbinary("STOR %s" % ftpfile, f)
f.close()
ftp.dir (ftpfile)
ftp.quit()
Any suggestions?
A:
Do you need to open the locfile in binary using rb?
f = open (locfile, "rb")
A:
Well if you go under the properties of your file in Windows or a *nix environment, you will notice two sizes. One is the sector size, and one is the actual size. The sector size is the number of sectors in bytes that are used up on your hard disk. That is because two files cannot be in the same sector with most modern file systems, so if your file fills up half of the sector the whole sector is marked as filled.
So you might be comparing the sector file size to the actual file size on the FTP server or vice versa.
A:
Small files take up a whole node on the file system whatever the size is.
My host tends to report all small files as 4KB in ftp but gives an accurate size in a shell so it might be a 'feature' common to ftp clients.
| File size differences after copying a file to a server vía FTP | I have created a PHP-script to update a web server that is live inside a local directory.
I'm migrating the script into Python. It works fine for the most part, but after a PUT command, the size of the file appears to change. Thus, the size of the file is different from that of the file on the server.
Once I download again the file from the FTP server, the only difference is the CR/LF mark. This annoys me because the same script is comparing the size of the files to update. Also, in case it means anything, the script works perfectly in PHP vía ftp_put.
from ftplib import FTP
ftpserver = "myserver"
ftpuser = "myuser"
ftppass = "mypwd"
locfile = "g:/test/style.css"
ftpfile = "/temp/style.css"
try:
ftp = FTP(ftpserver, ftpuser, ftppass)
except:
exit ("Cannot connect")
f = open (locfile, "r")
try:
ftp.delete (ftpfile)
except:
pass
# ftp.sendcmd ("TYPE I")
# ftp.storlines("STOR %s" % ftpfile, f)
ftp.storbinary("STOR %s" % ftpfile, f)
f.close()
ftp.dir (ftpfile)
ftp.quit()
Any suggestions?
| [
"Do you need to open the locfile in binary using rb?\nf = open (locfile, \"rb\")\n\n",
"Well if you go under the properties of your file in Windows or a *nix environment, you will notice two sizes. One is the sector size, and one is the actual size. The sector size is the number of sectors in bytes that are used up on your hard disk. That is because two files cannot be in the same sector with most modern file systems, so if your file fills up half of the sector the whole sector is marked as filled.\nSo you might be comparing the sector file size to the actual file size on the FTP server or vice versa.\n",
"Small files take up a whole node on the file system whatever the size is.\nMy host tends to report all small files as 4KB in ftp but gives an accurate size in a shell so it might be a 'feature' common to ftp clients.\n"
] | [
17,
3,
0
] | [] | [] | [
"ftp",
"ftplib",
"php",
"python",
"webserver"
] | stackoverflow_0000002311_ftp_ftplib_php_python_webserver.txt |
Q:
Decoding T-SQL CAST in C#/VB.NET
Recently our site has been deluged with the resurgence of the Asprox botnet SQL injection attack. Without going into details, the attack attempts to execute SQL code by encoding the T-SQL commands in an ASCII encoded BINARY string. It looks something like this:
DECLARE%20@S%20NVARCHAR(4000);SET%20@S=CAST(0x44004500...06F007200%20AS%20NVARCHAR(4000));EXEC(@S);--
I was able to decode this in SQL, but I was a little wary of doing this since I didn't know exactly what was happening at the time.
I tried to write a simple decode tool, so I could decode this type of text without even touching SQL Server. The main part I need to be decoded is:
CAST(0x44004500...06F007200 AS
NVARCHAR(4000))
I've tried all of the following commands with no luck:
txtDecodedText.Text =
System.Web.HttpUtility.UrlDecode(txtURLText.Text);
txtDecodedText.Text =
Encoding.ASCII.GetString(Encoding.ASCII.GetBytes(txtURLText.Text));
txtDecodedText.Text =
Encoding.Unicode.GetString(Encoding.Unicode.GetBytes(txtURLText.Text));
txtDecodedText.Text =
Encoding.ASCII.GetString(Encoding.Unicode.GetBytes(txtURLText.Text));
txtDecodedText.Text =
Encoding.Unicode.GetString(Convert.FromBase64String(txtURLText.Text));
What is the proper way to translate this encoding without using SQL Server? Is it possible? I'll take VB.NET code since I'm familiar with that too.
Okay, I'm sure I'm missing something here, so here's where I'm at.
Since my input is a basic string, I started with just a snippet of the encoded portion - 4445434C41 (which translates to DECLA) - and the first attempt was to do this...
txtDecodedText.Text = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(txtURL.Text));
...and all it did was return the exact same thing that I put in since it converted each character into is a byte.
I realized that I need to parse every two characters into a byte manually since I don't know of any methods yet that will do that, so now my little decoder looks something like this:
while (!boolIsDone)
{
bytURLChar = byte.Parse(txtURLText.Text.Substring(intParseIndex, 2));
bytURL[intURLIndex] = bytURLChar;
intParseIndex += 2;
intURLIndex++;
if (txtURLText.Text.Length - intParseIndex < 2)
{
boolIsDone = true;
}
}
txtDecodedText.Text = Encoding.UTF8.GetString(bytURL);
Things look good for the first couple of pairs, but then the loop balks when it gets to the "4C" pair and says that the string is in the incorrect format.
Interestingly enough, when I step through the debugger and to the GetString method on the byte array that I was able to parse up to that point, I get ",-+" as the result.
How do I figure out what I'm missing - do I need to do a "direct cast" for each byte instead of attempting to parse it?
A:
I went back to Michael's post, did some more poking and realized that I did need to do a double conversion, and eventually worked out this little nugget:
Convert.ToString(Convert.ToChar(Int32.Parse(EncodedString.Substring(intParseIndex, 2), System.Globalization.NumberStyles.HexNumber)));
From there I simply made a loop to go through all the characters 2 by 2 and get them "hexified" and then translated to a string.
To Nick, and anybody else interested, I went ahead and posted my little application over in CodePlex. Feel free to use/modify as you need.
A:
Try removing the 0x first and then call Encoding.UTF8.GetString. I think that may work.
Essentially: 0x44004500
Remove the 0x, and then always two bytes are one character:
44 00 = D
45 00 = E
6F 00 = o
72 00 = r
So it's definitely a Unicode/UTF format with two bytes/character.
| Decoding T-SQL CAST in C#/VB.NET | Recently our site has been deluged with the resurgence of the Asprox botnet SQL injection attack. Without going into details, the attack attempts to execute SQL code by encoding the T-SQL commands in an ASCII encoded BINARY string. It looks something like this:
DECLARE%20@S%20NVARCHAR(4000);SET%20@S=CAST(0x44004500...06F007200%20AS%20NVARCHAR(4000));EXEC(@S);--
I was able to decode this in SQL, but I was a little wary of doing this since I didn't know exactly what was happening at the time.
I tried to write a simple decode tool, so I could decode this type of text without even touching SQL Server. The main part I need to be decoded is:
CAST(0x44004500...06F007200 AS
NVARCHAR(4000))
I've tried all of the following commands with no luck:
txtDecodedText.Text =
System.Web.HttpUtility.UrlDecode(txtURLText.Text);
txtDecodedText.Text =
Encoding.ASCII.GetString(Encoding.ASCII.GetBytes(txtURLText.Text));
txtDecodedText.Text =
Encoding.Unicode.GetString(Encoding.Unicode.GetBytes(txtURLText.Text));
txtDecodedText.Text =
Encoding.ASCII.GetString(Encoding.Unicode.GetBytes(txtURLText.Text));
txtDecodedText.Text =
Encoding.Unicode.GetString(Convert.FromBase64String(txtURLText.Text));
What is the proper way to translate this encoding without using SQL Server? Is it possible? I'll take VB.NET code since I'm familiar with that too.
Okay, I'm sure I'm missing something here, so here's where I'm at.
Since my input is a basic string, I started with just a snippet of the encoded portion - 4445434C41 (which translates to DECLA) - and the first attempt was to do this...
txtDecodedText.Text = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(txtURL.Text));
...and all it did was return the exact same thing that I put in since it converted each character into is a byte.
I realized that I need to parse every two characters into a byte manually since I don't know of any methods yet that will do that, so now my little decoder looks something like this:
while (!boolIsDone)
{
bytURLChar = byte.Parse(txtURLText.Text.Substring(intParseIndex, 2));
bytURL[intURLIndex] = bytURLChar;
intParseIndex += 2;
intURLIndex++;
if (txtURLText.Text.Length - intParseIndex < 2)
{
boolIsDone = true;
}
}
txtDecodedText.Text = Encoding.UTF8.GetString(bytURL);
Things look good for the first couple of pairs, but then the loop balks when it gets to the "4C" pair and says that the string is in the incorrect format.
Interestingly enough, when I step through the debugger and to the GetString method on the byte array that I was able to parse up to that point, I get ",-+" as the result.
How do I figure out what I'm missing - do I need to do a "direct cast" for each byte instead of attempting to parse it?
| [
"I went back to Michael's post, did some more poking and realized that I did need to do a double conversion, and eventually worked out this little nugget:\nConvert.ToString(Convert.ToChar(Int32.Parse(EncodedString.Substring(intParseIndex, 2), System.Globalization.NumberStyles.HexNumber)));\n\nFrom there I simply made a loop to go through all the characters 2 by 2 and get them \"hexified\" and then translated to a string.\nTo Nick, and anybody else interested, I went ahead and posted my little application over in CodePlex. Feel free to use/modify as you need.\n",
"Try removing the 0x first and then call Encoding.UTF8.GetString. I think that may work.\nEssentially: 0x44004500\nRemove the 0x, and then always two bytes are one character:\n44 00 = D\n\n45 00 = E\n\n6F 00 = o\n\n72 00 = r\n\nSo it's definitely a Unicode/UTF format with two bytes/character.\n"
] | [
24,
8
] | [] | [] | [
"ascii",
"c#",
"hex",
"sql",
"vb.net"
] | stackoverflow_0000000109_ascii_c#_hex_sql_vb.net.txt |
Q:
What sites offer free, quality web site design templates?
Let's aggregate a list of free quality web site design templates. There are a million of these sites out there, but most are repetitive and boring.
I'll start with freeCSStemplates.org
I also think other sites should follow some sort of standards, for example here are freeCSStemplates standards
Released for FREE under the Creative Commons Attribution 2.5 license
Very lightweight in terms of images
Tables-free (ie. they use no tables for layout purposes)
W3C standards compliant and valid (XHTML Strict)
Provided with public domain photos, generously provided by PDPhoto.org and Wikimedia Commons
A:
Check out:
Open Source Web Designs
CSS Remix
Best Web Gallery
CSS Based
CSS Beauty
CSS Genius
A:
The Open Design Community is a great resource.
A:
http://www.csszengarden.com/
The images are not Creative Commons, but the CSS is.
A:
+1 for Zen garden.
I like the resources at inobscuro.com
A:
http://www.opensourcetemplates.org/ has nice designs, just not enough selection.
| What sites offer free, quality web site design templates? | Let's aggregate a list of free quality web site design templates. There are a million of these sites out there, but most are repetitive and boring.
I'll start with freeCSStemplates.org
I also think other sites should follow some sort of standards, for example here are freeCSStemplates standards
Released for FREE under the Creative Commons Attribution 2.5 license
Very lightweight in terms of images
Tables-free (ie. they use no tables for layout purposes)
W3C standards compliant and valid (XHTML Strict)
Provided with public domain photos, generously provided by PDPhoto.org and Wikimedia Commons
| [
"Check out:\n\nOpen Source Web Designs\nCSS Remix\nBest Web Gallery\nCSS Based\nCSS Beauty\nCSS Genius\n\n",
"The Open Design Community is a great resource.\n",
"http://www.csszengarden.com/\nThe images are not Creative Commons, but the CSS is.\n",
"+1 for Zen garden.\nI like the resources at inobscuro.com\n",
"http://www.opensourcetemplates.org/ has nice designs, just not enough selection.\n"
] | [
12,
3,
2,
0,
0
] | [] | [] | [
"css",
"templates"
] | stackoverflow_0000002711_css_templates.txt |
Q:
Is there a keyboard shortcut to view all open documents in Visual Studio 2008
I am trying to learn the keyboard shortcuts in Visual Studio in order to be more productive. So I downloaded a document showing many of the default keybindings in Visual Basic when using the VS 2008 IDE from Microsoft.
When I tried what they say is the keyboard shortcut to view all open documents (CTRL + ALT + DOWN ARROW), I got a completely unexpected result on my XP machine; my entire screen display was flipped upside down!
Was this a prank by someone at Microsoft? I can't imagine what practical value this flipping of the screen would have.
Does anyone know what the correct keyboard shortcut is to view all open documents in VS 2008?
Oh and if you try the above shortcut and it flips your display the way it did mine, do a CTRL + ALT + UP ARROW to switch it back.
A:
This is a conflict between your graphics driver and Visual Studio. Go to your driver settings page (Control panel) and disable the display rotation shortcuts. With this conflict removed, the shortcut will work in Visual Studio.
| Is there a keyboard shortcut to view all open documents in Visual Studio 2008 | I am trying to learn the keyboard shortcuts in Visual Studio in order to be more productive. So I downloaded a document showing many of the default keybindings in Visual Basic when using the VS 2008 IDE from Microsoft.
When I tried what they say is the keyboard shortcut to view all open documents (CTRL + ALT + DOWN ARROW), I got a completely unexpected result on my XP machine; my entire screen display was flipped upside down!
Was this a prank by someone at Microsoft? I can't imagine what practical value this flipping of the screen would have.
Does anyone know what the correct keyboard shortcut is to view all open documents in VS 2008?
Oh and if you try the above shortcut and it flips your display the way it did mine, do a CTRL + ALT + UP ARROW to switch it back.
| [
"This is a conflict between your graphics driver and Visual Studio. Go to your driver settings page (Control panel) and disable the display rotation shortcuts. With this conflict removed, the shortcut will work in Visual Studio.\n"
] | [
15
] | [] | [] | [
"keyboard",
"shortcut",
"visual_studio"
] | stackoverflow_0000002765_keyboard_shortcut_visual_studio.txt |
Q:
Can't get a Console to VMs
I've followed this otherwise excellent tutorial on getting Xen working with Ubuntu but am not able to get a console into my virtual machine (domU). I've got the extra = '2 console=xvc0' line in my /etc/xen/hostname_here.cfg file like they say, but am not able to get a console on it.
If I statically assign an IP to the VM I can SSH to it, but for now I need to be able to use DHCP to give it an address (and since that's what I'm trying to debug, there's the problem). I know I've got a free DHCP address (although I'm getting more at the moment), so I don't think that's the problem. I've looked on Google and the Xen forums to no avail as well.
Any ideas?
A:
I had followed a different tutorial on setting up my xen on ubuntu before 8.04 but now upgraded to 8.04. I used the extra line in my cfg as folows:
extra = ' TERM=xterm xencons=tty console=tty1'
It allows me to "xm console hostname" from dom0. I think this was from a problem with the xen setup in the version prior to 8.04 (I'm not sure which version that was). I'm not sure if the same change is necessary in 8.04 as I'm an upgrade and didn't change any of my domU configs after the upgrade.
| Can't get a Console to VMs | I've followed this otherwise excellent tutorial on getting Xen working with Ubuntu but am not able to get a console into my virtual machine (domU). I've got the extra = '2 console=xvc0' line in my /etc/xen/hostname_here.cfg file like they say, but am not able to get a console on it.
If I statically assign an IP to the VM I can SSH to it, but for now I need to be able to use DHCP to give it an address (and since that's what I'm trying to debug, there's the problem). I know I've got a free DHCP address (although I'm getting more at the moment), so I don't think that's the problem. I've looked on Google and the Xen forums to no avail as well.
Any ideas?
| [
"I had followed a different tutorial on setting up my xen on ubuntu before 8.04 but now upgraded to 8.04. I used the extra line in my cfg as folows:\nextra = ' TERM=xterm xencons=tty console=tty1'\n\nIt allows me to \"xm console hostname\" from dom0. I think this was from a problem with the xen setup in the version prior to 8.04 (I'm not sure which version that was). I'm not sure if the same change is necessary in 8.04 as I'm an upgrade and didn't change any of my domU configs after the upgrade.\n"
] | [
5
] | [] | [] | [
"ubuntu",
"virtualization",
"xen"
] | stackoverflow_0000002773_ubuntu_virtualization_xen.txt |
Q:
How to curl or wget a web page?
I would like to make a nightly cron job that fetches my stackoverflow page and diffs it from the previous day's page, so I can see a change summary of my questions, answers, ranking, etc.
Unfortunately, I couldn't get the right set of cookies, etc, to make this work. Any ideas?
Also, when the beta is finished, will my status page be accessible without logging in?
A:
Your status page is available now without logging in (click logout and try it). When the beta-cookie is disabled, there will be nothing between you and your status page.
For wget:
wget --no-cookies --header "Cookie: soba=(LookItUpYourself)" https://stackoverflow.com/users/30/myProfile.html
A:
From Mark Harrison
And here's what works...
curl -s --cookie soba=. https://stackoverflow.com/users
And for wget:
wget --no-cookies --header "Cookie: soba=(LookItUpYourself)" https://stackoverflow.com/users/30/myProfile.html
A:
Nice idea :)
I presume you've used wget's
--load-cookies (filename)
might help a little but it might be easier to use something like Mechanize (in Perl or python) to mimic a browser more fully to get a good spider.
A:
I couldn't figure out how to get the cookies to work either, but I was able to get to my status page in my browser while I was logged out, so I assume this will work once stackoverflow goes public.
This is an interesting idea, but won't you also pick up diffs of the underlying html code? Do you have a strategy to avoid ending up with a diff of the html and not the actual content?
A:
And here's what works...
curl -s --cookie soba=. http://stackoverflow.com/users
| How to curl or wget a web page? | I would like to make a nightly cron job that fetches my stackoverflow page and diffs it from the previous day's page, so I can see a change summary of my questions, answers, ranking, etc.
Unfortunately, I couldn't get the right set of cookies, etc, to make this work. Any ideas?
Also, when the beta is finished, will my status page be accessible without logging in?
| [
"Your status page is available now without logging in (click logout and try it). When the beta-cookie is disabled, there will be nothing between you and your status page.\nFor wget:\nwget --no-cookies --header \"Cookie: soba=(LookItUpYourself)\" https://stackoverflow.com/users/30/myProfile.html\n\n",
"From Mark Harrison\n\nAnd here's what works...\ncurl -s --cookie soba=. https://stackoverflow.com/users\n\nAnd for wget:\nwget --no-cookies --header \"Cookie: soba=(LookItUpYourself)\" https://stackoverflow.com/users/30/myProfile.html\n\n",
"Nice idea :)\nI presume you've used wget's\n--load-cookies (filename)\n\nmight help a little but it might be easier to use something like Mechanize (in Perl or python) to mimic a browser more fully to get a good spider.\n",
"I couldn't figure out how to get the cookies to work either, but I was able to get to my status page in my browser while I was logged out, so I assume this will work once stackoverflow goes public.\nThis is an interesting idea, but won't you also pick up diffs of the underlying html code? Do you have a strategy to avoid ending up with a diff of the html and not the actual content?\n",
"And here's what works...\ncurl -s --cookie soba=. http://stackoverflow.com/users\n\n"
] | [
9,
6,
3,
2,
2
] | [] | [] | [
"curl",
"http"
] | stackoverflow_0000002815_curl_http.txt |
Q:
Using ASP.NET Dynamic Data / LINQ to SQL, how do you have two table fields have a relationship to the same foreign key?
I am using ASP.NET Dynamic Data for a project and I have a table that has two seperate fields that link to the same foreign key in a different table.
This relationship works fine in SQL Server.
However, in the LINQ to SQL model in the ASP.NET Dynamic Data model, only the first field's relationship is reflected. If I attempt to add the second relationship manually, it complains that it "Cannot create an association "ForeignTable_BaseTable". The same property is listed more than once: "Id"."
This MSDN article gives such helpful advice as:
Examine the message and note the property specified in the message.
Click OK to dismiss the message box.
Inspect the Association Properties and remove the duplicate entries.
Click OK.
A:
The solution is to delete and re-add BOTH tables to the LINQ to SQL diagram, not just the one you have added the second field and keys to.
Alternatively, it appears you can make two associations using the LINQ to SQL interface - just don't try and bundle them into a single association.
| Using ASP.NET Dynamic Data / LINQ to SQL, how do you have two table fields have a relationship to the same foreign key? | I am using ASP.NET Dynamic Data for a project and I have a table that has two seperate fields that link to the same foreign key in a different table.
This relationship works fine in SQL Server.
However, in the LINQ to SQL model in the ASP.NET Dynamic Data model, only the first field's relationship is reflected. If I attempt to add the second relationship manually, it complains that it "Cannot create an association "ForeignTable_BaseTable". The same property is listed more than once: "Id"."
This MSDN article gives such helpful advice as:
Examine the message and note the property specified in the message.
Click OK to dismiss the message box.
Inspect the Association Properties and remove the duplicate entries.
Click OK.
| [
"The solution is to delete and re-add BOTH tables to the LINQ to SQL diagram, not just the one you have added the second field and keys to.\nAlternatively, it appears you can make two associations using the LINQ to SQL interface - just don't try and bundle them into a single association.\n"
] | [
5
] | [] | [] | [
"asp.net",
"dynamic_data"
] | stackoverflow_0000003004_asp.net_dynamic_data.txt |
Q:
How can you tell when a user last pressed a key (or moved the mouse)?
In a Win32 environment, you can use the GetLastInputInfo API call in Microsoft documentation. Basically, this method returns the last tick that corresponds with when the user last provided input, and you have to compare that to the current tick to determine how long ago that was.
Xavi23cr has a good example for C# at codeproject.
Any suggestions for other environments?
A:
As for Linux, I know that Pidgin has to determine idle time to change your status to away after a certain amount of time. You might open the source and see if you can find the code that does what you need it to do.
A:
You seem to have answered your own question there Nathan ;-)
"GetLastInputInfo" is the way to go.
One trick is that if your application is running on the desktop, and the user connects to a virtual machine, then GetLastInputInfo will report no activity (since there is no activity on the host machine).
This can be different to the behaviour you want, depending on how you wish to apply the user input.
| How can you tell when a user last pressed a key (or moved the mouse)? | In a Win32 environment, you can use the GetLastInputInfo API call in Microsoft documentation. Basically, this method returns the last tick that corresponds with when the user last provided input, and you have to compare that to the current tick to determine how long ago that was.
Xavi23cr has a good example for C# at codeproject.
Any suggestions for other environments?
| [
"As for Linux, I know that Pidgin has to determine idle time to change your status to away after a certain amount of time. You might open the source and see if you can find the code that does what you need it to do.\n",
"You seem to have answered your own question there Nathan ;-)\n\"GetLastInputInfo\" is the way to go.\nOne trick is that if your application is running on the desktop, and the user connects to a virtual machine, then GetLastInputInfo will report no activity (since there is no activity on the host machine).\nThis can be different to the behaviour you want, depending on how you wish to apply the user input.\n"
] | [
3,
1
] | [] | [] | [
"language_agnostic"
] | stackoverflow_0000002709_language_agnostic.txt |
Q:
How should I translate from screen space coordinates to image space coordinates in a WinForms PictureBox?
I have an application that displays an image inside of a Windows Forms PictureBox control. The SizeMode of the control is set to Zoom so that the image contained in the PictureBox will be displayed in an aspect-correct way regardless of the dimensions of the PictureBox.
This is great for the visual appearance of the application because you can size the window however you want and the image will always be displayed using its best fit. Unfortunately, I also need to handle mouse click events on the picture box and need to be able to translate from screen-space coordinates to image-space coordinates.
It looks like it's easy to translate from screen space to control space, but I don't see any obvious way to translate from control space to image space (i.e. the pixel coordinate in the source image that has been scaled in the picture box).
Is there an easy way to do this, or should I just duplicate the scaling math that they're using internally to position the image and do the translation myself?
A:
I wound up just implementing the translation manually. The code's not too bad, but it did leave me wishing that they provided support for it directly. I could see such a method being useful in a lot of different circumstances.
I guess that's why they added extension methods :)
In pseudocode:
// Recompute the image scaling the zoom mode uses to fit the image on screen
imageScale ::= min(pictureBox.width / image.width, pictureBox.height / image.height)
scaledWidth ::= image.width * imageScale
scaledHeight ::= image.height * imageScale
// Compute the offset of the image to center it in the picture box
imageX ::= (pictureBox.width - scaledWidth) / 2
imageY ::= (pictureBox.height - scaledHeight) / 2
// Test the coordinate in the picture box against the image bounds
if pos.x < imageX or imageX + scaledWidth < pos.x then return null
if pos.y < imageY or imageY + scaledHeight < pos.y then return null
// Compute the normalized (0..1) coordinates in image space
u ::= (pos.x - imageX) / imageScale
v ::= (pos.y - imageY) / imageScale
return (u, v)
To get the pixel position in the image, you'd just multiply by the actual image pixel dimensions, but the normalized coordinates allow you to address the original responder's point about resolving ambiguity on a case-by-case basis.
A:
Depending on the scaling, the relative image pixel could be anywhere in a number of pixels. For example, if the image is scaled down significantly, pixel 2, 10 could represent 2, 10 all the way up to 20, 100), so you'll have to do the math yourself and take full responsibility for any inaccuracies! :-)
| How should I translate from screen space coordinates to image space coordinates in a WinForms PictureBox? | I have an application that displays an image inside of a Windows Forms PictureBox control. The SizeMode of the control is set to Zoom so that the image contained in the PictureBox will be displayed in an aspect-correct way regardless of the dimensions of the PictureBox.
This is great for the visual appearance of the application because you can size the window however you want and the image will always be displayed using its best fit. Unfortunately, I also need to handle mouse click events on the picture box and need to be able to translate from screen-space coordinates to image-space coordinates.
It looks like it's easy to translate from screen space to control space, but I don't see any obvious way to translate from control space to image space (i.e. the pixel coordinate in the source image that has been scaled in the picture box).
Is there an easy way to do this, or should I just duplicate the scaling math that they're using internally to position the image and do the translation myself?
| [
"I wound up just implementing the translation manually. The code's not too bad, but it did leave me wishing that they provided support for it directly. I could see such a method being useful in a lot of different circumstances.\nI guess that's why they added extension methods :)\nIn pseudocode:\n// Recompute the image scaling the zoom mode uses to fit the image on screen\nimageScale ::= min(pictureBox.width / image.width, pictureBox.height / image.height)\n\nscaledWidth ::= image.width * imageScale\nscaledHeight ::= image.height * imageScale\n\n// Compute the offset of the image to center it in the picture box\nimageX ::= (pictureBox.width - scaledWidth) / 2\nimageY ::= (pictureBox.height - scaledHeight) / 2\n\n// Test the coordinate in the picture box against the image bounds\nif pos.x < imageX or imageX + scaledWidth < pos.x then return null\nif pos.y < imageY or imageY + scaledHeight < pos.y then return null\n\n// Compute the normalized (0..1) coordinates in image space\nu ::= (pos.x - imageX) / imageScale\nv ::= (pos.y - imageY) / imageScale\nreturn (u, v)\n\nTo get the pixel position in the image, you'd just multiply by the actual image pixel dimensions, but the normalized coordinates allow you to address the original responder's point about resolving ambiguity on a case-by-case basis.\n",
"Depending on the scaling, the relative image pixel could be anywhere in a number of pixels. For example, if the image is scaled down significantly, pixel 2, 10 could represent 2, 10 all the way up to 20, 100), so you'll have to do the math yourself and take full responsibility for any inaccuracies! :-)\n"
] | [
6,
2
] | [] | [] | [
"c#",
"picturebox",
"winforms"
] | stackoverflow_0000002804_c#_picturebox_winforms.txt |
Q:
'Best' Diff Algorithm
I need to implement a Diff algorithm in VB.NET to find the changes between two different versions of a piece of text. I've had a scout around the web and have found a couple of different algorithms.
Does anybody here know of a 'best' algorithm that I could implement?
A:
Well I've used the c# version on codeproject and its really good for what I wanted...
http://www.codeproject.com/KB/recipes/diffengine.aspx
You can probably get this translated into VB.net via an online converter if you can't do it yourself...
A:
I like An O(ND) Difference Algorithm and Its Variations by Eugene Myers. I believe it's the algorithm that was used in GNU diff. For a good background see Wikipedia.
This is quite theoretical and you might wish to find source code, but I'm not aware of any in VB.
A:
I don't know for sure if it's the best diff algorithms but you might want to check out those links that talks about SOCT4 and SOCT6
http://dev.libresource.org/home/doc/so6-user-manual/concepts
and also:
http://www.loria.fr/~molli/pmwiki/uploads/Main/so6group03.pdf
http://www.loria.fr/~molli/pmwiki/uploads/Main/diffalgo.pdf
| 'Best' Diff Algorithm | I need to implement a Diff algorithm in VB.NET to find the changes between two different versions of a piece of text. I've had a scout around the web and have found a couple of different algorithms.
Does anybody here know of a 'best' algorithm that I could implement?
| [
"Well I've used the c# version on codeproject and its really good for what I wanted...\nhttp://www.codeproject.com/KB/recipes/diffengine.aspx\nYou can probably get this translated into VB.net via an online converter if you can't do it yourself...\n",
"I like An O(ND) Difference Algorithm and Its Variations by Eugene Myers. I believe it's the algorithm that was used in GNU diff. For a good background see Wikipedia. \nThis is quite theoretical and you might wish to find source code, but I'm not aware of any in VB.\n",
"I don't know for sure if it's the best diff algorithms but you might want to check out those links that talks about SOCT4 and SOCT6\nhttp://dev.libresource.org/home/doc/so6-user-manual/concepts\nand also:\nhttp://www.loria.fr/~molli/pmwiki/uploads/Main/so6group03.pdf\nhttp://www.loria.fr/~molli/pmwiki/uploads/Main/diffalgo.pdf\n"
] | [
7,
7,
3
] | [] | [] | [
"diff",
"vb.net"
] | stackoverflow_0000003144_diff_vb.net.txt |
Q:
Is there an Unobtrusive Captcha for web forms?
What is the best unobtrusive CAPTCHA for web forms? One that does not involve a UI, rather a non-UI Turing test. I have seen a simple example of a non UI CAPTCHA like the Nobot control from Microsoft. I am looking for a CAPTCHA that does not ask the user any question in any form. No riddles, no what's in this image.
A:
I think you might be alluding to an "invisible" captcha. Check out the Subkismet project for an invisible captcha implementation.
http://www.codeplex.com/subkismet
A:
Try akismet from wp guys
A:
I think asking the user simple questions like:
"How many legs does a dog have?"
Would be much more effective that any CAPTCHA systems out there at the moment. Not only is it very difficult for the computer to answer that question, but it is very easy for a human to answer!
A:
Eric Meyer implemented a very similar thing as a WordPress plugin called WP-GateKeeper that asks human-readable questions like "What colour is an orange?". He did have some issues around asking questions that a non-native English speaker would be able to answer simply, though.
There are a few posts on his blog about it.
A:
@KP
After your update to the original question, the only real option available to you is to do some jiggery-pokery in Javascript on the client. The only issue with that would be provicing graceful degredation for non-javascript enabled clients.
e.g. You could add some AJAX-y goodness that reads a hidden form filed value, requests a verification key from the server, and sends that back along with the response, but that will never be populated if javascript is blocked/disabled. You could always implement a more traditional captcha type interface which could be disabled by javascript, and ignored by the server if the scripted field if filled in...
Depends how far you want to go with it, though. Good luck
| Is there an Unobtrusive Captcha for web forms? | What is the best unobtrusive CAPTCHA for web forms? One that does not involve a UI, rather a non-UI Turing test. I have seen a simple example of a non UI CAPTCHA like the Nobot control from Microsoft. I am looking for a CAPTCHA that does not ask the user any question in any form. No riddles, no what's in this image.
| [
"I think you might be alluding to an \"invisible\" captcha. Check out the Subkismet project for an invisible captcha implementation.\nhttp://www.codeplex.com/subkismet\n",
"Try akismet from wp guys \n",
"I think asking the user simple questions like:\n\"How many legs does a dog have?\"\nWould be much more effective that any CAPTCHA systems out there at the moment. Not only is it very difficult for the computer to answer that question, but it is very easy for a human to answer!\n",
"Eric Meyer implemented a very similar thing as a WordPress plugin called WP-GateKeeper that asks human-readable questions like \"What colour is an orange?\". He did have some issues around asking questions that a non-native English speaker would be able to answer simply, though. \nThere are a few posts on his blog about it.\n",
"@KP\nAfter your update to the original question, the only real option available to you is to do some jiggery-pokery in Javascript on the client. The only issue with that would be provicing graceful degredation for non-javascript enabled clients. \ne.g. You could add some AJAX-y goodness that reads a hidden form filed value, requests a verification key from the server, and sends that back along with the response, but that will never be populated if javascript is blocked/disabled. You could always implement a more traditional captcha type interface which could be disabled by javascript, and ignored by the server if the scripted field if filled in...\nDepends how far you want to go with it, though. Good luck\n"
] | [
4,
4,
2,
1,
1
] | [] | [] | [
"captcha",
"security",
"usability"
] | stackoverflow_0000003027_captcha_security_usability.txt |
Q:
How can I modify .xfdl files? (Update #1)
The .XFDL file extension identifies XFDL Formatted Document files. These belong to the XML-based document and template formatting standard. This format is exactly like the XML file format however, contains a level of encryption for use in secure communications.
I know how to view XFDL files using a file viewer I found here. I can also modify and save these files by doing File:Save/Save As. I'd like, however, to modify these files on the fly. Any suggestions? Is this even possible?
Update #1: I have now successfully decoded and unziped a .xfdl into an XML file which I can then edit. Now, I am looking for a way to re-encode the modified XML file back into base64-gzip (using Ruby or the command line)
A:
If the encoding is base64 then this is the solution I've stumbled upon on the web:
"Decoding XDFL files saved with 'encoding=base64'.
Files saved with:
application/vnd.xfdl;content-encoding="base64-gzip"
are simple base64-encoded gzip files. They can be easily restored to XML by first decoding and then unzipping them. This can be done as follows on Ubuntu:
sudo apt-get install uudeview
uudeview -i yourform.xfdl
gunzip -S "" < UNKNOWN.001 > yourform-unpacked.xfdl
The first command will install uudeview, a package that can decode base64, among others. You can skip this step once it is installed.
Assuming your form is saved as 'yourform.xfdl', the uudeview command will decode the contents as 'UNKNOWN.001', since the xfdl file doesn't contain a file name. The '-i' option makes uudeview uninteractive, remove that option for more control.
The last command gunzips the decoded file into a file named 'yourform-unpacked.xfdl'.
Another possible solution - here
Side Note: Block quoted < code > doesn't work for long strings of code
A:
The only answer I can think of right now is - read the manual for uudeview.
As much as I would like to help you, I am not an expert in this area, so you'll have to wait for someone more knowledgable to come down here and help you.
Meanwhile I can give you links to some documents that might help you:
UUDeview Home Page
Using XDFLengine
Gettting started with the XDFL Engine
Sorry if this doesn't help you.
A:
You don't have to get out of Ruby to do this, can use the Base64 module in Ruby to encode the document like this:
irb(main):005:0> require 'base64'
=> true
irb(main):007:0> Base64.encode64("Hello World")
=> "SGVsbG8gV29ybGQ=\n"
irb(main):008:0> Base64.decode64("SGVsbG8gV29ybGQ=\n")
=> "Hello World"
And you can call gzip/gunzip using Kernel#system:
system("gzip foo.something")
system("gunzip foo.something.gz")
| How can I modify .xfdl files? (Update #1) | The .XFDL file extension identifies XFDL Formatted Document files. These belong to the XML-based document and template formatting standard. This format is exactly like the XML file format however, contains a level of encryption for use in secure communications.
I know how to view XFDL files using a file viewer I found here. I can also modify and save these files by doing File:Save/Save As. I'd like, however, to modify these files on the fly. Any suggestions? Is this even possible?
Update #1: I have now successfully decoded and unziped a .xfdl into an XML file which I can then edit. Now, I am looking for a way to re-encode the modified XML file back into base64-gzip (using Ruby or the command line)
| [
"If the encoding is base64 then this is the solution I've stumbled upon on the web:\n\"Decoding XDFL files saved with 'encoding=base64'.\nFiles saved with: \napplication/vnd.xfdl;content-encoding=\"base64-gzip\"\n\nare simple base64-encoded gzip files. They can be easily restored to XML by first decoding and then unzipping them. This can be done as follows on Ubuntu:\nsudo apt-get install uudeview\nuudeview -i yourform.xfdl\ngunzip -S \"\" < UNKNOWN.001 > yourform-unpacked.xfdl \n\nThe first command will install uudeview, a package that can decode base64, among others. You can skip this step once it is installed.\nAssuming your form is saved as 'yourform.xfdl', the uudeview command will decode the contents as 'UNKNOWN.001', since the xfdl file doesn't contain a file name. The '-i' option makes uudeview uninteractive, remove that option for more control.\nThe last command gunzips the decoded file into a file named 'yourform-unpacked.xfdl'.\nAnother possible solution - here\nSide Note: Block quoted < code > doesn't work for long strings of code\n",
"The only answer I can think of right now is - read the manual for uudeview.\nAs much as I would like to help you, I am not an expert in this area, so you'll have to wait for someone more knowledgable to come down here and help you.\nMeanwhile I can give you links to some documents that might help you:\n\nUUDeview Home Page\nUsing XDFLengine\nGettting started with the XDFL Engine\n\nSorry if this doesn't help you.\n",
"You don't have to get out of Ruby to do this, can use the Base64 module in Ruby to encode the document like this:\nirb(main):005:0> require 'base64'\n=> true\n\nirb(main):007:0> Base64.encode64(\"Hello World\")\n=> \"SGVsbG8gV29ybGQ=\\n\"\n\nirb(main):008:0> Base64.decode64(\"SGVsbG8gV29ybGQ=\\n\")\n=> \"Hello World\"\n\nAnd you can call gzip/gunzip using Kernel#system:\nsystem(\"gzip foo.something\")\nsystem(\"gunzip foo.something.gz\")\n\n"
] | [
5,
2,
1
] | [] | [] | [
"language_agnostic",
"ruby",
"xfdl"
] | stackoverflow_0000001615_language_agnostic_ruby_xfdl.txt |
Q:
SQL query for a database scheme
In SQL Server how do you query a database to bring back all the tables that have a field of a specific name?
A:
The following query will bring back a unique list of tables where Column_Name is equal to the column you are looking for:
SELECT Table_Name
FROM INFORMATION_SCHEMA.COLUMNS
WHERE Column_Name = 'Desired_Column_Name'
GROUP BY Table_Name
A:
SELECT Table_Name
FROM Information_Schema.Columns
WHERE Column_Name = 'YourFieldName'
A:
I'm old-school:
SELECT DISTINCT object_name(id)
FROM syscolumns
WHERE name = 'FIELDNAME'
| SQL query for a database scheme | In SQL Server how do you query a database to bring back all the tables that have a field of a specific name?
| [
"The following query will bring back a unique list of tables where Column_Name is equal to the column you are looking for:\nSELECT Table_Name\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE Column_Name = 'Desired_Column_Name'\nGROUP BY Table_Name\n\n",
"SELECT Table_Name\nFROM Information_Schema.Columns\nWHERE Column_Name = 'YourFieldName'\n\n",
"I'm old-school:\nSELECT DISTINCT object_name(id)\nFROM syscolumns\nWHERE name = 'FIELDNAME'\n\n"
] | [
7,
0,
0
] | [] | [] | [
"sql",
"sql_server"
] | stackoverflow_0000003567_sql_sql_server.txt |
Q:
Looking for code to render a form that displays a view of an object
I've got the task of displaying a web form to represent the properties in a .NET class. In WinForms, there's a pre-fab control named PropertyGrid that is a lot like what I need. I'm just looking for something to display a simple layout of property names next to an appropriate control like a textbox for strings or a dropdownlist for enum properties.
Does anything like this already exist for ASP.NET, or will I be rolling my own here?
A:
ASP.Net PropertyGrid
| Looking for code to render a form that displays a view of an object | I've got the task of displaying a web form to represent the properties in a .NET class. In WinForms, there's a pre-fab control named PropertyGrid that is a lot like what I need. I'm just looking for something to display a simple layout of property names next to an appropriate control like a textbox for strings or a dropdownlist for enum properties.
Does anything like this already exist for ASP.NET, or will I be rolling my own here?
| [
"ASP.Net PropertyGrid\n"
] | [
8
] | [] | [] | [
"asp.net",
"controls",
"propertygrid"
] | stackoverflow_0000003757_asp.net_controls_propertygrid.txt |
Q:
Setup Visual Studio 2005 to print line numbers
How can I get line numbers to print in Visual Studio 2005 when printing code listings?
A:
Isn't there an option in the Print Dialog?
Edit: There is. Go to File => Print, and then in the bottom left there is "Print what" and then "Include line Numbers"
A:
There is an option in the Print Dialog to do the same (in VS 2005 and 2008 atleast)!
| Setup Visual Studio 2005 to print line numbers | How can I get line numbers to print in Visual Studio 2005 when printing code listings?
| [
"Isn't there an option in the Print Dialog?\nEdit: There is. Go to File => Print, and then in the bottom left there is \"Print what\" and then \"Include line Numbers\"\n",
"There is an option in the Print Dialog to do the same (in VS 2005 and 2008 atleast)!\n"
] | [
7,
5
] | [] | [] | [
"line_numbers",
"visual_studio",
"visual_studio_2005"
] | stackoverflow_0000003809_line_numbers_visual_studio_visual_studio_2005.txt |
Q:
More vs. Faster Cores on a Webserver
The discussion of Dual vs. Quadcore is as old as the Quadcores itself and the answer is usually "it depends on your scenario". So here the scenario is a Web Server (Windows 2003 (not sure if x32 or x64), 4 GB RAM, IIS, ASP.net 3.0).
My impression is that the CPU in a Webserver does not need to be THAT fast because requests are usually rather lightweight, so having more (slower) cores should be a better choice as we got many small requests.
But since I do not have much experience with IIS load balancing and since I don't want to spend a lot of money only to find out I've made the wrong choice, can someone who has a bit more experience comment on whether or not More Slower or Fewer Faster cores is better?
A:
For something like a webserver, dividing up the tasks of handling each connection is (relatively) easy. I say it's safe to say that web servers is one of the most common (and ironed out) uses of parallel code. And since you are able to split up much of the processing into multiple discrete threads, more cores actually does benefit you. This is one of the big reasons why shared hosting is even possible. If server software like IIS and Apache couldn't run requests in parallel it would mean that every page request would have to be dished out in a queue fashion...likely making load times unbearably slow.
This also why high end server Operating Systems like Windows 2008 Server Enterprise support something like 64 cores and 2TB of RAM. These are applications that can actually take advantage of that many cores.
Also, since each request is likely has low CPU load, you can probably (for some applications) get away with more slower cores. But obviously having each core faster can mean being able to get each task done quicker and, in theory, handle more tasks and more server requests.
A:
We use apache on linux, which forks a process to handle requests. We've found that more cores help our throughput, since they reduce the latency of processes waiting to be placed on the run queue. I don't have much experience with IIS, but I imagine the same scenario applies with its thread pool.
A:
Mark Harrison said:
I don't have much experience with IIS, but I imagine the same scenario applies with its thread pool.
Indeed - more cores = more threads running concurrently. IIS is inherently multithreaded, and takes easy advantage of this.
A:
The more the better. As programming languages start to become more complex and abstract, the more processing power that will be required.
Atleat Jeff believes Quadcore is better.
| More vs. Faster Cores on a Webserver | The discussion of Dual vs. Quadcore is as old as the Quadcores itself and the answer is usually "it depends on your scenario". So here the scenario is a Web Server (Windows 2003 (not sure if x32 or x64), 4 GB RAM, IIS, ASP.net 3.0).
My impression is that the CPU in a Webserver does not need to be THAT fast because requests are usually rather lightweight, so having more (slower) cores should be a better choice as we got many small requests.
But since I do not have much experience with IIS load balancing and since I don't want to spend a lot of money only to find out I've made the wrong choice, can someone who has a bit more experience comment on whether or not More Slower or Fewer Faster cores is better?
| [
"For something like a webserver, dividing up the tasks of handling each connection is (relatively) easy. I say it's safe to say that web servers is one of the most common (and ironed out) uses of parallel code. And since you are able to split up much of the processing into multiple discrete threads, more cores actually does benefit you. This is one of the big reasons why shared hosting is even possible. If server software like IIS and Apache couldn't run requests in parallel it would mean that every page request would have to be dished out in a queue fashion...likely making load times unbearably slow.\nThis also why high end server Operating Systems like Windows 2008 Server Enterprise support something like 64 cores and 2TB of RAM. These are applications that can actually take advantage of that many cores.\nAlso, since each request is likely has low CPU load, you can probably (for some applications) get away with more slower cores. But obviously having each core faster can mean being able to get each task done quicker and, in theory, handle more tasks and more server requests.\n",
"We use apache on linux, which forks a process to handle requests. We've found that more cores help our throughput, since they reduce the latency of processes waiting to be placed on the run queue. I don't have much experience with IIS, but I imagine the same scenario applies with its thread pool.\n",
"Mark Harrison said:\n\nI don't have much experience with IIS, but I imagine the same scenario applies with its thread pool.\n\nIndeed - more cores = more threads running concurrently. IIS is inherently multithreaded, and takes easy advantage of this.\n",
"The more the better. As programming languages start to become more complex and abstract, the more processing power that will be required.\nAtleat Jeff believes Quadcore is better.\n"
] | [
16,
3,
3,
1
] | [] | [] | [
"asp.net",
"hardware",
"iis",
"windows"
] | stackoverflow_0000003801_asp.net_hardware_iis_windows.txt |
Q:
How do I best detect an ASP.NET expired session?
I need to detect when a session has expired in my Visuial Basic web application. This is what I'm using...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If CurrentSession.IsNew AndAlso (Not Page.Request.Headers("Cookie") Is Nothing) AndAlso (Page.Request.Headers("Cookie").IndexOf("ASP.NET_SessionId") >= 0) Then
Response.Redirect("TimeOut.aspx")
End If
...do something...
End Sub
Note: CurrentSession.IsNew returns HttpContext.Current.Session.IsNewSession
This seems to work well for Internet Explorer, but seems to fail with Firefox.
A:
Try the following
If Session("whatever") IsNot Nothing Then
| How do I best detect an ASP.NET expired session? | I need to detect when a session has expired in my Visuial Basic web application. This is what I'm using...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If CurrentSession.IsNew AndAlso (Not Page.Request.Headers("Cookie") Is Nothing) AndAlso (Page.Request.Headers("Cookie").IndexOf("ASP.NET_SessionId") >= 0) Then
Response.Redirect("TimeOut.aspx")
End If
...do something...
End Sub
Note: CurrentSession.IsNew returns HttpContext.Current.Session.IsNewSession
This seems to work well for Internet Explorer, but seems to fail with Firefox.
| [
"Try the following\nIf Session(\"whatever\") IsNot Nothing Then\n\n"
] | [
10
] | [] | [] | [
"asp.net",
"http",
"session"
] | stackoverflow_0000003831_asp.net_http_session.txt |
Q:
How do you typeset code elements in normal text?
What is the best way to typeset a function with arguments for readibility, brevity, and accuracy? I tend to put empty parentheses after the function name like func(), even if there are actually arguments for the function. I have trouble including the arguments and still feeling like the paragraph is readable.
Any thoughts on best practices for this?
A:
I usually take that approach, but if I feel like it's going to cause confusion, I'll use ellipses like: myFunction(...)
I guess if I were good, I would use those any time I was omitting parameters from a function in text.
A:
I would simply be a little more careful with the name of my variables and parameters, most people will then be able to guess much more accurately what type of data you want to hold in it.
| How do you typeset code elements in normal text? | What is the best way to typeset a function with arguments for readibility, brevity, and accuracy? I tend to put empty parentheses after the function name like func(), even if there are actually arguments for the function. I have trouble including the arguments and still feeling like the paragraph is readable.
Any thoughts on best practices for this?
| [
"I usually take that approach, but if I feel like it's going to cause confusion, I'll use ellipses like: myFunction(...)\nI guess if I were good, I would use those any time I was omitting parameters from a function in text.\n",
"I would simply be a little more careful with the name of my variables and parameters, most people will then be able to guess much more accurately what type of data you want to hold in it.\n"
] | [
3,
1
] | [] | [] | [
"format",
"language_agnostic"
] | stackoverflow_0000003802_format_language_agnostic.txt |
Q:
Adobe Flex component events
I wrote a component that displays a filename, a thumbnail and has a button to load/play the file. The component is databound to a repeater. How can I make it so that the button event fires to the main application and tells it which file to play?
A:
Figured it out (finally)
Custom Component
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" x="0" y="0" width="215" height="102" styleName="leftListItemPanel" backgroundColor="#ECECEC" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Script>
<![CDATA[
[Bindable] public var Title:String = "";
[Bindable] public var Description:String = "";
[Bindable] public var Icon:String = "";
[Bindable] public var FileID:String = "";
private function viewClickHandler():void{
dispatchEvent(new Event("viewClick", true));// bubble to parent
}
]]>
</mx:Script>
<mx:Metadata>
[Event(name="viewClick", type="flash.events.Event")]
</mx:Metadata>
<mx:Label x="11" y="9" text="{String(Title)}" styleName="listItemLabel"/>
<mx:TextArea x="11" y="25" height="36" width="170" backgroundAlpha="0.0" alpha="0.0" styleName="listItemDesc" wordWrap="true" editable="false" text="{String(Description)}"/>
<mx:Button x="20" y="65" label="View" click="viewClickHandler();" styleName="listItemButton" height="22" width="60"/>
<mx:LinkButton x="106" y="68" label="Details..." styleName="listItemLink" height="18"/>
<mx:HRule x="0" y="101" width="215"/>
The Repeater
<mx:Canvas id="pnlSpotlight" label="SPOTLIGHT" height="100%" width="100%" horizontalScrollPolicy="off">
<mx:VBox width="100%" height="80%" paddingTop="2" paddingBottom="1" verticalGap="1">
<mx:Repeater id="rptrSpotlight" dataProvider="{aSpotlight}">
<sm:SmallCourseListItem
viewClick="PlayFile(event.currentTarget.getRepeaterItem().fileName);"
Description="{rptrSpotlight.currentItem.fileDescription}"
FileID = "{rptrRecentlyViewed.currentItem.fileName}"
Title="{rptrSpotlight.currentItem.fileTitle}" />
</mx:Repeater>
</mx:VBox>
</mx:Canvas>
Handling function
private function PlayFile(fileName:String):void{
Alert.show(fileName.toString());
}
A:
On your custom component you can listen to the button click event and then generate a custom event that holds information about the file you want to play. You can then set the bubbles property to true on the event and dispatch the custom event from your custom component. The bubbles property will make your event float up the display list and reach your main application. Now on your main application you can listen to that event and play the correct file. Hope this helps.
| Adobe Flex component events | I wrote a component that displays a filename, a thumbnail and has a button to load/play the file. The component is databound to a repeater. How can I make it so that the button event fires to the main application and tells it which file to play?
| [
"Figured it out (finally)\nCustom Component\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<mx:Canvas xmlns:mx=\"http://www.adobe.com/2006/mxml\" x=\"0\" y=\"0\" width=\"215\" height=\"102\" styleName=\"leftListItemPanel\" backgroundColor=\"#ECECEC\" horizontalScrollPolicy=\"off\" verticalScrollPolicy=\"off\">\n<mx:Script>\n <![CDATA[\n [Bindable] public var Title:String = \"\";\n [Bindable] public var Description:String = \"\";\n [Bindable] public var Icon:String = \"\"; \n [Bindable] public var FileID:String = \"\";\n private function viewClickHandler():void{\n dispatchEvent(new Event(\"viewClick\", true));// bubble to parent\n }\n ]]>\n</mx:Script>\n<mx:Metadata>\n [Event(name=\"viewClick\", type=\"flash.events.Event\")]\n</mx:Metadata>\n<mx:Label x=\"11\" y=\"9\" text=\"{String(Title)}\" styleName=\"listItemLabel\"/>\n<mx:TextArea x=\"11\" y=\"25\" height=\"36\" width=\"170\" backgroundAlpha=\"0.0\" alpha=\"0.0\" styleName=\"listItemDesc\" wordWrap=\"true\" editable=\"false\" text=\"{String(Description)}\"/>\n<mx:Button x=\"20\" y=\"65\" label=\"View\" click=\"viewClickHandler();\" styleName=\"listItemButton\" height=\"22\" width=\"60\"/>\n<mx:LinkButton x=\"106\" y=\"68\" label=\"Details...\" styleName=\"listItemLink\" height=\"18\"/>\n<mx:HRule x=\"0\" y=\"101\" width=\"215\"/>\n\n\nThe Repeater\n<mx:Canvas id=\"pnlSpotlight\" label=\"SPOTLIGHT\" height=\"100%\" width=\"100%\" horizontalScrollPolicy=\"off\">\n <mx:VBox width=\"100%\" height=\"80%\" paddingTop=\"2\" paddingBottom=\"1\" verticalGap=\"1\">\n <mx:Repeater id=\"rptrSpotlight\" dataProvider=\"{aSpotlight}\"> \n <sm:SmallCourseListItem \n viewClick=\"PlayFile(event.currentTarget.getRepeaterItem().fileName);\"\n Description=\"{rptrSpotlight.currentItem.fileDescription}\"\n FileID = \"{rptrRecentlyViewed.currentItem.fileName}\" \n Title=\"{rptrSpotlight.currentItem.fileTitle}\" />\n </mx:Repeater>\n </mx:VBox>\n</mx:Canvas>\n\nHandling function\nprivate function PlayFile(fileName:String):void{\n Alert.show(fileName.toString());\n}\n\n",
"On your custom component you can listen to the button click event and then generate a custom event that holds information about the file you want to play. You can then set the bubbles property to true on the event and dispatch the custom event from your custom component. The bubbles property will make your event float up the display list and reach your main application. Now on your main application you can listen to that event and play the correct file. Hope this helps.\n"
] | [
1,
1
] | [] | [] | [
"actionscript_3",
"apache_flex"
] | stackoverflow_0000003856_actionscript_3_apache_flex.txt |
Q:
Is this a good way to determine OS Architecture?
Since the WMI class Win32_OperatingSystem only includes OSArchitecture in Windows Vista, I quickly wrote up a method using the registry to try and determine whether or not the current system is a 32 or 64bit system.
private Boolean is64BitOperatingSystem()
{
RegistryKey localEnvironment = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment");
String processorArchitecture = (String) localEnvironment.GetValue("PROCESSOR_ARCHITECTURE");
if (processorArchitecture.Equals("x86")) {
return false;
}
else {
return true;
}
}
It's worked out pretty well for us so far, but I'm not sure how much I like looking through the registry. Is this a pretty standard practice or is there a better method?
Edit: Wow, that code looks a lot prettier in the preview. I'll consider linking to a pastebin or something, next time.
A:
Take a look at Raymond Chens solution:
How to detect programmatically whether you are running on 64-bit Windows
and here's the PINVOKE for .NET:
IsWow64Process (kernel32)
Update: I'd take issue with checking for 'x86'. Who's to say what intel's or AMD's next 32 bit processor may be designated as. The probability is low but it is a risk. You should ask the OS to determine this via the correct API's, not by querying what could be a OS version/platform specific value that may be considered opaque to the outside world. Ask yourself the questions, 1 - is the registry entry concerned properly documented by MS, 2 - If it is do they provide a definitive list of possible values that is guaranteed to permit you as a developer to make the informed decision between whether you are running 32 bit or 64 bit. If the answer is no, then call the API's, yeah it's a but more long winded but it is documented and definitive.
A:
The easiest way to test for 64-bit under .NET is to check the value of IntPtr.Size.
I believe the value of IntPtr.Size is 4 for a 32bit app that's running under WOW, isn't it?
Edit: @Edit: Yeah. :)
A:
Looking into the registry is perfectly valid, so long as you can be sure that the user of the application will always have access to what you need.
A:
The easiest way to test for 64-bit under .NET is to check the value of IntPtr.Size.
EDIT: Doh! This will tell you whether or not the current process is 64-bit, not the OS as a whole. Sorry!
| Is this a good way to determine OS Architecture? | Since the WMI class Win32_OperatingSystem only includes OSArchitecture in Windows Vista, I quickly wrote up a method using the registry to try and determine whether or not the current system is a 32 or 64bit system.
private Boolean is64BitOperatingSystem()
{
RegistryKey localEnvironment = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment");
String processorArchitecture = (String) localEnvironment.GetValue("PROCESSOR_ARCHITECTURE");
if (processorArchitecture.Equals("x86")) {
return false;
}
else {
return true;
}
}
It's worked out pretty well for us so far, but I'm not sure how much I like looking through the registry. Is this a pretty standard practice or is there a better method?
Edit: Wow, that code looks a lot prettier in the preview. I'll consider linking to a pastebin or something, next time.
| [
"Take a look at Raymond Chens solution:\nHow to detect programmatically whether you are running on 64-bit Windows\nand here's the PINVOKE for .NET:\nIsWow64Process (kernel32)\nUpdate: I'd take issue with checking for 'x86'. Who's to say what intel's or AMD's next 32 bit processor may be designated as. The probability is low but it is a risk. You should ask the OS to determine this via the correct API's, not by querying what could be a OS version/platform specific value that may be considered opaque to the outside world. Ask yourself the questions, 1 - is the registry entry concerned properly documented by MS, 2 - If it is do they provide a definitive list of possible values that is guaranteed to permit you as a developer to make the informed decision between whether you are running 32 bit or 64 bit. If the answer is no, then call the API's, yeah it's a but more long winded but it is documented and definitive. \n",
"\nThe easiest way to test for 64-bit under .NET is to check the value of IntPtr.Size.\n\nI believe the value of IntPtr.Size is 4 for a 32bit app that's running under WOW, isn't it?\nEdit: @Edit: Yeah. :)\n",
"Looking into the registry is perfectly valid, so long as you can be sure that the user of the application will always have access to what you need.\n",
"The easiest way to test for 64-bit under .NET is to check the value of IntPtr.Size.\nEDIT: Doh! This will tell you whether or not the current process is 64-bit, not the OS as a whole. Sorry!\n"
] | [
8,
2,
1,
1
] | [] | [] | [
"c#",
"registry",
"windows"
] | stackoverflow_0000003903_c#_registry_windows.txt |
Q:
Multi-Paradigm Languages
In a language such as (since I'm working in it now) PHP, which supports procedural and object-oriented paradigms.
Is there a good rule of thumb for determining which paradigm best suits a new project? If not, how can you make the decision?
A:
It all depends on the problem you're trying to solve. Obviously you can solve any problem in either style (procedural or OO), but you usually can figure out in the planning stages before you start writing code which style suits you better.
Some people like to write up use cases and if they see a lot of the same nouns showing up over and over again (e.g., a person withdraws money from the bank), then they go the OO route and use the nouns as their objects. Conversely, if you don't see a lot of nouns and there's really more verbs going on, then procedural or functional may be the way to go.
Steve Yegge has a great but long post as usual that touches on this from a different perspective that you may find helpful as well.
A:
If you're doing something for yourself, or if you're doing just a prototype, or testing an idea... use the free style that script languages gives you.
After that: always think in objects, try to organize your work around the OO paradigm even if you're writing procedural stuff. Then, refactorize, refactorize, refactorize.
| Multi-Paradigm Languages | In a language such as (since I'm working in it now) PHP, which supports procedural and object-oriented paradigms.
Is there a good rule of thumb for determining which paradigm best suits a new project? If not, how can you make the decision?
| [
"It all depends on the problem you're trying to solve. Obviously you can solve any problem in either style (procedural or OO), but you usually can figure out in the planning stages before you start writing code which style suits you better.\nSome people like to write up use cases and if they see a lot of the same nouns showing up over and over again (e.g., a person withdraws money from the bank), then they go the OO route and use the nouns as their objects. Conversely, if you don't see a lot of nouns and there's really more verbs going on, then procedural or functional may be the way to go.\nSteve Yegge has a great but long post as usual that touches on this from a different perspective that you may find helpful as well.\n",
"If you're doing something for yourself, or if you're doing just a prototype, or testing an idea... use the free style that script languages gives you. \nAfter that: always think in objects, try to organize your work around the OO paradigm even if you're writing procedural stuff. Then, refactorize, refactorize, refactorize.\n"
] | [
11,
2
] | [] | [] | [
"oop",
"paradigms",
"php",
"procedural"
] | stackoverflow_0000003978_oop_paradigms_php_procedural.txt |
Q:
How do I configure a Vista Ultimate (64bit) account so it can access a SMB share on OSX?
I have Windows File sharing enabled on an OS X 10.4 computer. It's accessible via \rudy\myshare for all the Windows users on the network, except for one guy running Vista Ultimate 64-bit edition.
All the other users are running Vista or XP, all 32-bit. All the workgroup information is the same, all login with the same username/password.
The Vista 64 guy can see the Mac on the network, but his login is rejected every time.
Now, I imagine that Vista Ultimate is has something configured differently to the Business version and XP but I don't really know where to look. Any ideas?
A:
Try changing the local security policy on that Vista box for "Local Policies\Security Options\Network Security: LAN manager authentication level" from “Send NTLMv2 response only” to “Send LM & NTLM - use NTLMv2 session security if negotiated”.
A:
No I have successfully done this with my Vista 64-bit machine. You may want to try using the IP Address of the machine and try connecting that way. Or maybe check out the log files on the Mac to see what the rejection error was.
| How do I configure a Vista Ultimate (64bit) account so it can access a SMB share on OSX? | I have Windows File sharing enabled on an OS X 10.4 computer. It's accessible via \rudy\myshare for all the Windows users on the network, except for one guy running Vista Ultimate 64-bit edition.
All the other users are running Vista or XP, all 32-bit. All the workgroup information is the same, all login with the same username/password.
The Vista 64 guy can see the Mac on the network, but his login is rejected every time.
Now, I imagine that Vista Ultimate is has something configured differently to the Business version and XP but I don't really know where to look. Any ideas?
| [
"Try changing the local security policy on that Vista box for \"Local Policies\\Security Options\\Network Security: LAN manager authentication level\" from “Send NTLMv2 response only” to “Send LM & NTLM - use NTLMv2 session security if negotiated”.\n",
"No I have successfully done this with my Vista 64-bit machine. You may want to try using the IP Address of the machine and try connecting that way. Or maybe check out the log files on the Mac to see what the rejection error was.\n"
] | [
3,
0
] | [] | [] | [
"macos",
"smb",
"windows_vista"
] | stackoverflow_0000003996_macos_smb_windows_vista.txt |
Q:
Linking two Office documents
Problem:
I have two spreadsheets that each serve different purposes but contain one particular piece of data that needs to be the same in both spreadsheets. This piece of data (one of the columns) gets updated in spreadsheet A but needs to also be updated in spreadsheet B.
Goal:
A solution that would somehow link these two spreadsheets together (keep in mind that they exist on two separate LAN shares on the network) so that when A is updated, B is automatically updated for the corresponding record.
*Note that I understand fully that a database would probably be a better plan for tasks such as these but unfortunately I have no say in that matter.
**Note also that this needs to work for Office 2003 and Office 2007
A:
So you mean that AD743 on spreadsheet B must be equal to AD743 on spreadsheet A? Try this:
Open both spreadsheets on the same
machine.
Go to AD743 on spreadsheet B.
Type =.
Go to spreadsheed A and click on
AD743.
Press enter.
You'll notice that the formula is something like '[path-to-file+file-name].worksheet-name!AD743'.
The value on spreadsheet B will be updated when you open it. In fact, it will ask you if you want to update. Of course, your connection must be up and running for it to update. Also, you can't change the name or the path of spreadsheet A.
A:
I can't say if this is overkill without knowing the details of your usage case, but consider creating a spreadsheet C to hold all data held in common between the two. Links can become dizzyingly complex as spreadsheets age, and having a shared data source might help clear up the confusion.
Perhaps even more "enterprise-y" is the concept of just pasting in all data that otherwise would be shared. That is the official best practice in my company, because external links have caused so much trouble with maintainability. It may seem cumbersome at first, but I've found it may just be the best way to promote maintainability in addition to ease of use, assuming you don't mind the manual intervention.
| Linking two Office documents | Problem:
I have two spreadsheets that each serve different purposes but contain one particular piece of data that needs to be the same in both spreadsheets. This piece of data (one of the columns) gets updated in spreadsheet A but needs to also be updated in spreadsheet B.
Goal:
A solution that would somehow link these two spreadsheets together (keep in mind that they exist on two separate LAN shares on the network) so that when A is updated, B is automatically updated for the corresponding record.
*Note that I understand fully that a database would probably be a better plan for tasks such as these but unfortunately I have no say in that matter.
**Note also that this needs to work for Office 2003 and Office 2007
| [
"So you mean that AD743 on spreadsheet B must be equal to AD743 on spreadsheet A? Try this:\n\nOpen both spreadsheets on the same\nmachine.\nGo to AD743 on spreadsheet B.\nType =.\nGo to spreadsheed A and click on\nAD743.\nPress enter.\n\nYou'll notice that the formula is something like '[path-to-file+file-name].worksheet-name!AD743'.\nThe value on spreadsheet B will be updated when you open it. In fact, it will ask you if you want to update. Of course, your connection must be up and running for it to update. Also, you can't change the name or the path of spreadsheet A.\n",
"I can't say if this is overkill without knowing the details of your usage case, but consider creating a spreadsheet C to hold all data held in common between the two. Links can become dizzyingly complex as spreadsheets age, and having a shared data source might help clear up the confusion.\nPerhaps even more \"enterprise-y\" is the concept of just pasting in all data that otherwise would be shared. That is the official best practice in my company, because external links have caused so much trouble with maintainability. It may seem cumbersome at first, but I've found it may just be the best way to promote maintainability in addition to ease of use, assuming you don't mind the manual intervention.\n"
] | [
5,
0
] | [] | [] | [
"office_2003",
"office_2007"
] | stackoverflow_0000003045_office_2003_office_2007.txt |
Q:
Why doesn't VFP .NET OLEdb provider work in 64 bit Windows?
I wrote a windows service using VB that read some legacy data from Visual Foxpro Databases to be inserted in SQL 2005. The problem is this use to run fine in Windows server 2003 32-Bits, but the client recently moved to Windows 2003 64-Bits and now the service won't work. I'm getting a message the the VFP .NET OLEdb provider is not found. I researched and everything seems to point out that there is no solution. Any Help, please...
A:
Have you tried changing the target CPU to x86 instead of "Any CPU" in the advanced compiler options? I know that this solves some problems with other OLEDB providers by forcing the use of the 32-bit version.
A:
You'll need to compile with the target CPU set to x86 to force your code to use the 32 bit version of the VFP OLE Db provider.
Microsoft has stated that there are no plans on releasing a 64-bit edition of the Visual FoxPro OLE Db provider. For what's worth, Microsoft has also stated that VFP 9 is the final version of Visual FoxPro and support will end in 2015. If you need the OLE DB provider for VFP 9, you can get it here.
A:
Sybase Anywhere has a OLEDB provider for VFP tables. It states in the page that the server supports 64 bit Windows, don't know about the OLEDB provider:
Support 64-bit Windows and Linux Servers
In order to further enhance scalability, support for the x86_64 architecture was added to the Advantage Database Servers for Windows and Linux. On computers with an x86_64 processor and a 64 bit Operating System the Advantage Database Server will now be able to use memory in excess of 4GB. The extra memory will allow more users to access the server concurrently and increase the amount of information the server can cache when processing queries.
I didn't try it by myself, but some people of the VFP newsgroups reports that it works OK.
Link to the Advantage Server / VFP Page
| Why doesn't VFP .NET OLEdb provider work in 64 bit Windows? | I wrote a windows service using VB that read some legacy data from Visual Foxpro Databases to be inserted in SQL 2005. The problem is this use to run fine in Windows server 2003 32-Bits, but the client recently moved to Windows 2003 64-Bits and now the service won't work. I'm getting a message the the VFP .NET OLEdb provider is not found. I researched and everything seems to point out that there is no solution. Any Help, please...
| [
"Have you tried changing the target CPU to x86 instead of \"Any CPU\" in the advanced compiler options? I know that this solves some problems with other OLEDB providers by forcing the use of the 32-bit version.\n",
"You'll need to compile with the target CPU set to x86 to force your code to use the 32 bit version of the VFP OLE Db provider. \nMicrosoft has stated that there are no plans on releasing a 64-bit edition of the Visual FoxPro OLE Db provider. For what's worth, Microsoft has also stated that VFP 9 is the final version of Visual FoxPro and support will end in 2015. If you need the OLE DB provider for VFP 9, you can get it here.\n",
"Sybase Anywhere has a OLEDB provider for VFP tables. It states in the page that the server supports 64 bit Windows, don't know about the OLEDB provider:\n\nSupport 64-bit Windows and Linux Servers\nIn order to further enhance scalability, support for the x86_64 architecture was added to the Advantage Database Servers for Windows and Linux. On computers with an x86_64 processor and a 64 bit Operating System the Advantage Database Server will now be able to use memory in excess of 4GB. The extra memory will allow more users to access the server concurrently and increase the amount of information the server can cache when processing queries.\n\nI didn't try it by myself, but some people of the VFP newsgroups reports that it works OK.\nLink to the Advantage Server / VFP Page\n"
] | [
15,
9,
1
] | [] | [] | [
".net",
"legacy",
"oledb",
"sql_server_2005",
"visual_foxpro"
] | stackoverflow_0000000717_.net_legacy_oledb_sql_server_2005_visual_foxpro.txt |
Q:
Searching directories for tons of files?
I'm using MSVE, and I have my own tiles I'm displaying in layers on top. Problem is, there's a ton of them, and they're on a network server. In certain directories, there are something on the order of 30,000+ files. Initially I called Directory.GetFiles, but once I started testing in a pseudo-real environment, it timed out.
What's the best way to programatically list, and iterate through, this many files?
Edit: My coworker suggested using the MS indexing service. Has anyone tried this approach, and (how) has it worked?
A:
I've worked on a SAN system in the past with telephony audio recordings which had issues with numbers of files in a single folder - that system became unusable somewhere near 5,000 (on Windows 2000 Advanced Server with an application in C#.Net 1.1)- the only sensible solution that we came up with was to change the folder structure so that there were a more reasonable number of files. Interestingly Explorer would also time out!
The convention we came up with was a structure that broke the structure up in years, months and days - but that will depend upon your system and whether you can control the directory structure...
A:
Definitely split them up. That said, stay as far away from the Indexing Service as you can.
A:
None. .NET relies on underlying Windows API calls that really, really hate that amount of files themselves.
As Ronnie says: split them up.
A:
You could use DOS?
DIR /s/b > Files.txt
A:
You could also look at either indexing the files yourself, or getting a third part app like google desktop or copernic to do it and then interface with their index. I know copernic has an API that you can use to search for any file in their index and it also supports mapping network drives.
| Searching directories for tons of files? | I'm using MSVE, and I have my own tiles I'm displaying in layers on top. Problem is, there's a ton of them, and they're on a network server. In certain directories, there are something on the order of 30,000+ files. Initially I called Directory.GetFiles, but once I started testing in a pseudo-real environment, it timed out.
What's the best way to programatically list, and iterate through, this many files?
Edit: My coworker suggested using the MS indexing service. Has anyone tried this approach, and (how) has it worked?
| [
"I've worked on a SAN system in the past with telephony audio recordings which had issues with numbers of files in a single folder - that system became unusable somewhere near 5,000 (on Windows 2000 Advanced Server with an application in C#.Net 1.1)- the only sensible solution that we came up with was to change the folder structure so that there were a more reasonable number of files. Interestingly Explorer would also time out!\nThe convention we came up with was a structure that broke the structure up in years, months and days - but that will depend upon your system and whether you can control the directory structure...\n",
"Definitely split them up. That said, stay as far away from the Indexing Service as you can.\n",
"None. .NET relies on underlying Windows API calls that really, really hate that amount of files themselves.\nAs Ronnie says: split them up.\n",
"You could use DOS?\nDIR /s/b > Files.txt\n\n",
"You could also look at either indexing the files yourself, or getting a third part app like google desktop or copernic to do it and then interface with their index. I know copernic has an API that you can use to search for any file in their index and it also supports mapping network drives.\n"
] | [
6,
2,
1,
1,
1
] | [] | [] | [
"c#",
"directory",
"file_management"
] | stackoverflow_0000003512_c#_directory_file_management.txt |
Q:
Programmatically talking to a Serial Port in OS X or Linux
I have a Prolite LED sign that I like to set up to show scrolling search queries from a apache logs and other fun statistics. The problem is, my G5 does not have a serial port, so I have to use a usb to serial dongle. It shows up as /dev/cu.usbserial and /dev/tty.usbserial .
When i do this everything seems to be hunky-dory:
stty -f /dev/cu.usbserial
speed 9600 baud;
lflags: -icanon -isig -iexten -echo
iflags: -icrnl -ixon -ixany -imaxbel -brkint
oflags: -opost -onlcr -oxtabs
cflags: cs8 -parenb
Everything also works when I use the serial port tool to talk to it.
If I run this piece of code while the above mentioned serial port tool, everthing also works. But as soon as I disconnect the tool the connection gets lost.
#!/usr/bin/python
import serial
ser = serial.Serial('/dev/cu.usbserial', 9600, timeout=10)
ser.write("<ID01><PA> \r\n")
read_chars = ser.read(20)
print read_chars
ser.close()
So the question is, what magicks do I need to perform to start talking to the serial port without the serial port tool? Is that a permissions problem? Also, what's the difference between /dev/cu.usbserial and /dev/tty.usbserial?
Nope, no serial numbers. The thing is, the problem persists even with sudo-running the python script, and the only thing that makes it go through if I open the connection in the gui tool that I mentioned.
A:
/dev/cu.xxxxx is the "callout" device, it's what you use when you establish a connection to the serial device and start talking to it. /dev/tty.xxxxx is the "dialin" device, used for monitoring a port for incoming calls for e.g. a fax listener.
A:
have you tried watching the traffic between the GUI and the serial port to see if there is some kind of special command being sent across? Also just curious, Python is sending ASCII and not UTF-8 or something else right? The reason I ask is because I noticed your quote changes for the strings and in some languages that actually is the difference between ASCII and UTF-8.
| Programmatically talking to a Serial Port in OS X or Linux | I have a Prolite LED sign that I like to set up to show scrolling search queries from a apache logs and other fun statistics. The problem is, my G5 does not have a serial port, so I have to use a usb to serial dongle. It shows up as /dev/cu.usbserial and /dev/tty.usbserial .
When i do this everything seems to be hunky-dory:
stty -f /dev/cu.usbserial
speed 9600 baud;
lflags: -icanon -isig -iexten -echo
iflags: -icrnl -ixon -ixany -imaxbel -brkint
oflags: -opost -onlcr -oxtabs
cflags: cs8 -parenb
Everything also works when I use the serial port tool to talk to it.
If I run this piece of code while the above mentioned serial port tool, everthing also works. But as soon as I disconnect the tool the connection gets lost.
#!/usr/bin/python
import serial
ser = serial.Serial('/dev/cu.usbserial', 9600, timeout=10)
ser.write("<ID01><PA> \r\n")
read_chars = ser.read(20)
print read_chars
ser.close()
So the question is, what magicks do I need to perform to start talking to the serial port without the serial port tool? Is that a permissions problem? Also, what's the difference between /dev/cu.usbserial and /dev/tty.usbserial?
Nope, no serial numbers. The thing is, the problem persists even with sudo-running the python script, and the only thing that makes it go through if I open the connection in the gui tool that I mentioned.
| [
"/dev/cu.xxxxx is the \"callout\" device, it's what you use when you establish a connection to the serial device and start talking to it. /dev/tty.xxxxx is the \"dialin\" device, used for monitoring a port for incoming calls for e.g. a fax listener.\n",
"have you tried watching the traffic between the GUI and the serial port to see if there is some kind of special command being sent across? Also just curious, Python is sending ASCII and not UTF-8 or something else right? The reason I ask is because I noticed your quote changes for the strings and in some languages that actually is the difference between ASCII and UTF-8.\n"
] | [
5,
0
] | [] | [] | [
"linux",
"macos",
"python",
"serial_port"
] | stackoverflow_0000003976_linux_macos_python_serial_port.txt |
End of preview. Expand
in Dataset Viewer.
- Downloads last month
- 570