qid int64 4 19.1M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
417,697 | <p>During an investigation of some client machines losing their connection with SQL Server 2005, I ran into the following line of code on the web:</p>
<p>Select * FROM sys.dm_exec_query_optimizer_info WHERE counter = 'timeout'</p>
<p>When I run this query on our server - we are getting the following results:</p>
<p>counter - occurrence - value</p>
<p>timeout - 9100 - 1</p>
<p>As far as I can determine, this means that the query optimizer is timing out while trying to optimize queries run against our server – 9100 times. We are however, not seeing any timeout errors in the SQL Server error log, and our end-users have not reported any timeout specific errors.</p>
<p>Can anyone tell me what this number of “occurrences” means? Is this an issue we should be concerned about?</p>
| [
{
"answer_id": 417782,
"author": "gbn",
"author_id": 27535,
"author_profile": "https://Stackoverflow.com/users/27535",
"pm_score": 0,
"selected": false,
"text": "SET QUERY_GOVERNOR_COST_LIMIT"
},
{
"answer_id": 32548839,
"author": "Martin Smith",
"author_id": 73226,
"... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14947/"
] |
417,703 | <p>Is there a pythonic way of reading - say - mixed integer and char input without reading the whole input at once and without worrying about linebreaks? For example I have a file with whitespace-separated data of which I only know that there are x integers, then y chars and then z more integers. I don't want to assume anything about linebreaks.</p>
<p>I mean something as mindless as the following in C++:</p>
<p>...</p>
<pre><code>int i, buf;
char cbuf;
vector<int> X, Z;
vector<int> Y;
for (i = 0; i < x; i++) {
cin >> buf;
X.push_back(buf);
}
for (i = 0; i < y; i++) {
cin >> cbuf;
Y.push_back(cbuf);
}
for (i = 0; i < z; i++) {
cin >> buf;
Z.push_back(buf);
}
</code></pre>
<p>EDIT: i forgot to say that I'd like it to behave well under live input from console as well - i.e. there should be no need to press ctrl+d before getting tokens and the function should be able to return them as soon as a line has been entered. :)</p>
| [
{
"answer_id": 417741,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 2,
"selected": false,
"text": ">>> data = \"1 2 3 4 5 6 abcdefg 9 8 7 6 5 4 3\"\n data= someFile.read() >>> fields= data.split()\n>>> x= map(int,fields[:6... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52142/"
] |
417,707 | <p>I need help with an SSIS package. I have a server that populates a DB table as a part of a daily job. Then the server writes to a process status table to let me know that its done.</p>
<p>The process status table looks like this:</p>
<pre><code>Job | Ready | Downloaded
myJob True False
</code></pre>
<p>I want to create a process that will check if the Ready Flag on myJob is True and proceed or if False it will sleep for 30 mintues before trying again and repeating up to 5 times.</p>
<p>I found this article on how to do the sleeping part:
<a href="http://blogs.conchango.com/jamiethomson/archive/2006/10/23/SSIS_3A00_-Put-a-package-to-sleep.aspx" rel="nofollow noreferrer">http://blogs.conchango.com/jamiethomson/archive/2006/10/23/SSIS_3A00_-Put-a-package-to-sleep.aspx</a></p>
<p>I was thinking of using a file system task to access the process status table. Then set a variable to the value of the Ready flag. Then have a For loop Container, if true break out of the for loop and continue and if false run the sleep then run another file system task and set the variable to the value of the Ready flag. The main question I have is how do I set a variable to the value of the ready flag?</p>
| [
{
"answer_id": 417741,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 2,
"selected": false,
"text": ">>> data = \"1 2 3 4 5 6 abcdefg 9 8 7 6 5 4 3\"\n data= someFile.read() >>> fields= data.split()\n>>> x= map(int,fields[:6... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8664/"
] |
417,726 | <p>I have a "docs" folder in a Subversion repository named "project". I've come to the conclusion that it should really be kept under a separate Subversion repository named "project_docs".</p>
<p>I'd like to move the "docs" folder (<strong>and all of its revisions</strong>) to the "project_docs" repository. Is there a way to do this?</p>
| [
{
"answer_id": 417734,
"author": "Peter Stone",
"author_id": 1806,
"author_profile": "https://Stackoverflow.com/users/1806",
"pm_score": 2,
"selected": false,
"text": "svn export svn add $ svn checkout svn://example.net/newrepo .\n$ svn export svn://example.com/oldrepo/mydir ./mydir\n$ s... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11460/"
] |
417,729 | <p>I think I have a solution to this, but is there a better way, or is this going to break on me?</p>
<p>I am constructing a localized web site using global/local resx files. It is a requirement that non-technical users can edit the strings and add new languages through the web app.</p>
<p>This seems easy enough -- I have a form to display strings and the changes are saved with code like this snippet:</p>
<pre><code>string filename = MapPath("App_GlobalResources/strings.hu.resx");
XmlDocument xDoc = new XmlDocument();
XmlNode xNode;
xDoc.Load(filename);
xNode = xDoc.SelectSingleNode("//root/data[@name='PageTitle']/value");
xNode.InnerText = txtNewTitle.Text;
xDoc.Save(filename);
</code></pre>
<p>Is this going to cause problems on a busy site? If it causes a momentary delay for recompilation, that's no big deal. And realistically, this form won't see constant, heavy use. What does the community think?</p>
| [
{
"answer_id": 417809,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "public class GuiResources\n{\n public string PageTitle\n {\n get return _pageTitle;\n }\n\n // Fired once w... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/945/"
] |
417,745 | <p>I'm examining the feasibility of porting an existing Windows MFC control to OS X/Carbon.
My test bed is a C++ Carbon application generated using the XCode 3 Wizard.</p>
<p>I'm looking for a quick way to dump some trace info to the debugger or the OS X equivalent of DbgView. On Win32 I'd use OutputDebugString() - what's the deal on OS X? Is there a way to view test written to std::cout from a Carbon app?</p>
<p>Thanks</p>
<p>Jerry</p>
| [
{
"answer_id": 417846,
"author": "Jason Coco",
"author_id": 34218,
"author_profile": "https://Stackoverflow.com/users/34218",
"pm_score": 5,
"selected": true,
"text": "extern \"C\" {\n\nbool IsDebuggerPresent() {\n int mib[4];\n struct kinfo_proc info;\n size_t size;\n\n info... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52146/"
] |
417,755 | <p>How do I tell NAnt to use the same VB compiler VS2008 uses when it creates .NET 2.0-targeting applications?</p>
<p>I have switched a web application to VS2008 back-targetted to .NET 2.0. I can run NAnt (0.85rc4, 0.85, and 0.86b1) just fine once I do this. When I try to use some of the VB9 syntax, that still compiles just fine back to a .NET 2.0 binary in VS2008, NAnt gets the kind of compile error you would get if you tried to do the new syntax in VS2005 (where it wasn't supported).</p>
<p>In case it helps, here is a simplified version of what I am attempting, just a simple anonymous delegate that works great until I try to use NAnt to build the 2.0 app instead of VS2008.</p>
<pre><code>Public Class SomeObject
Public Name As String
End Class
Private SomeList As List(Of SomeObject) = SomeObject.GetAllSomeObjects()
Public Function FindFirstItemWithSimilarName(ByVal x As String) As SomeObject
Return SomeList.Find(Function(p As SomeObject) p.Name.Contains(x))
End Function
</code></pre>
<p><strong>EDIT:</strong> Unless someone can think of a reason not to, the current setting in my build file is this (since I do indeed want a .NET 2.0 application, just one generated by a more robust VB compiler):</p>
<pre><code><property name="nant.settings.currentframework" value="net-2.0"/>
</code></pre>
| [
{
"answer_id": 417846,
"author": "Jason Coco",
"author_id": 34218,
"author_profile": "https://Stackoverflow.com/users/34218",
"pm_score": 5,
"selected": true,
"text": "extern \"C\" {\n\nbool IsDebuggerPresent() {\n int mib[4];\n struct kinfo_proc info;\n size_t size;\n\n info... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48700/"
] |
417,762 | <p>I have an issue where the parent form will minimize to the task tray (but I don't think it is losing focus because the next form that shows, the Studio IDE, has focus) when I close a dialog/form that was shown by calling <code>ShowDialog(owner)</code>.</p>
<p>The weird thing is that this doesn't happen every time. I don't see how the owner/parent parameter is getting cleared so I don't know why the parent would go away.</p>
| [
{
"answer_id": 15355733,
"author": "aboulfazl azari",
"author_id": 2159855,
"author_profile": "https://Stackoverflow.com/users/2159855",
"pm_score": 1,
"selected": false,
"text": "ChildForm childForm = new ChildForm();\nchildForm.Show(this);\n"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/417762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
417,763 | <p>I have a python script that can approach the 2 GB process limit under Windows XP. On a machine with 2 GB physical memory, that can pretty much lock up the machine, even if the Python script is running at below normal priority.</p>
<p>Is there a way in Python to find out my own process size?</p>
<p>Thanks,
Gerry</p>
| [
{
"answer_id": 418533,
"author": "Igal Serban",
"author_id": 25737,
"author_profile": "https://Stackoverflow.com/users/25737",
"pm_score": 3,
"selected": true,
"text": "import win32process\nprint win32process.GetProcessMemoryInfo(win32process.GetCurrentProcess())\n"
},
{
"answer_... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/372664/"
] |
417,764 | <p>I have heard these two terms "temporary table" and "global temporary table" used pretty much in similar context.</p>
<p>What is the difference between the two?</p>
| [
{
"answer_id": 48852466,
"author": "Lukasz Szozda",
"author_id": 5070879,
"author_profile": "https://Stackoverflow.com/users/5070879",
"pm_score": 3,
"selected": false,
"text": "Oracle 18c -- Private temporary tables must be prefixed as per the database parameter \n-- 'private_temp_table... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38997/"
] |
417,776 | <p>I have a webservice that is called by up to 10 clients. The webservice is built up of 7 differnet asmx-pages and have about 100-200 functions in each page.</p>
<p>All those functions are working against a MSSQL2005 or MS SQL2000 database. Some periods of the day its heavy traffic from the clients and it seems like I run out of connections on the sql-server causing all clients to stop. </p>
<p>In every function I open a connection, do the stuff and then close the connection, sometimes with transactions sometimes without.</p>
<p>On the server I see that it creates a lots of connections, I dont know why they dont goes away, but stays there even after the function is done and over. So I can se that my 10 clients creates over 80 connections from time to time. Sometimes some of them goes away, sometime they are still there hours after used. Is there some kind of pooling going on there?</p>
<p>Question 1:
Are there another way to handle connections I should use, like one connection globally per webservice or any other way?</p>
<p>Question 2:
If its ok to handle connections per function then why does it not close the connection on the server, making the list of open connections larger and larger all the time until I got out of connections-error?</p>
<p>This question is related to my other question but not the same: <a href="https://stackoverflow.com/questions/407320/strange-sql2005-problem-sqlconnection-does-not-support-parallel-transactions">Strange SQL2005 problem. "SqlConnection does not support parallel transactions"</a></p>
<p>I have now narrowing it down to the "out of connections" error.</p>
| [
{
"answer_id": 418245,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 3,
"selected": true,
"text": "using (SqlConnection connection = <connection code>)\n{\n using (SqlCommand command = <command code>)\n {\n // Execu... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19307/"
] |
417,788 | <p>I tried to compile the example posted (<a href="https://stackoverflow.com/questions/412165/c-service-providers">C++ Service Providers</a>) and failed to VS8 VC9. I have little experience with template.<br>
Any suggestions?<br>
Tanks.</p>
<p>These are the errors :<br>
dictionarystl.cpp(40) : error C2663: 'std::_Tree<_Traits>::find' : 2 overloads have no legal conversion for 'this' pointer<br>
dictionarystl.cpp(48) : error C2679: binary '[' : no operator found which takes a right-hand operand of type 'const type_info *__w64 ' (or there is no acceptable conversion)</p>
<pre><code>#include <typeinfo>
#include <map>
#include <string>
using namespace std;
class SomeClass
{
public:
virtual ~SomeClass() {} // virtual function to get a v-table
};
struct type_info_less
{
bool operator() (const std::type_info* lhs, const std::type_info* rhs) const
{
return lhs->before(*rhs) != 0;
}
};
class TypeMap
{
typedef map <type_info *, void *, type_info_less> TypenameToObject;
TypenameToObject ObjectMap;
public:
template <typename T>
T *Get () const
{
TypenameToObject::const_iterator iType = ObjectMap.find(&typeid(T));
if (iType == ObjectMap.end())
return NULL;
return reinterpret_cast<T *>(iType->second);
}
template <typename T>
void Set(T *value)
{
ObjectMap[&typeid(T)] = reinterpret_cast<void *>(value);
}
};
int main()
{
TypeMap Services;
Services.Set<SomeClass>(new SomeClass());
SomeClass *x = Services.Get<SomeClass>();
}
</code></pre>
| [
{
"answer_id": 417804,
"author": "ChrisN",
"author_id": 3853,
"author_profile": "https://Stackoverflow.com/users/3853",
"pm_score": 3,
"selected": true,
"text": "typedef map<type_info *, void *, type_info_less> TypenameToObject;\n typedef map<const type_info *, void *, type_info_less> Ty... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47733/"
] |
417,793 | <p>I'm attempting to capture the output of <code>fputcsv()</code> in order to use <code>gzwrite()</code> to actually write to a tab-delimited file. Basically, I'm querying a database and I want to put these rows into a gzipped CSV file and I'd rather use <code>fputcsv()</code> than actually append <code>"\t"</code> and <code>"\n"</code> everywhere. Can I somehow do this with output buffering or something similar?</p>
<p>Here's the basic outline of what I have:</p>
<pre><code>$results = get_data_from_db();
$fp = gzopen($file_name, 'w');
if($fp) {
foreach ($results as $row) {
???//something with gzwrite() ?
}
gzclose($fp);
}
</code></pre>
<p>Thanks!</p>
<p>EDIT: My understanding was that <code>gzwrite()</code> needs to be used to actually write to the file in order for it to actually be gzipped - is this not correct?</p>
| [
{
"answer_id": 417857,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 3,
"selected": true,
"text": "fputcsv() $results = get_data_from_db();\n$fp = gzopen($file_name, 'w');\nif($fp) {\n foreach ($results as $row) {\n ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30133/"
] |
417,795 | <p>So IE (6, at least) won't help me with <code>$_SERVER["HTTP_REFERER"]</code> that I request with PHP.</p>
<p>But I'm new to JavaScript and have just used a little routine in a pop-up to <em>refresh</em> the page from which the popup was called (i.e. parent). Works beautifully in Firefox, Safari, etc. </p>
<p>There's NO security issue - I'd just like to the user loaded in the window is URL of page from which the pop-up (for editing) was called. (and not the pop-up's URL). </p>
<p>Am I forced to <em>send</em> the URL in a GET when I link to the pop-up?</p>
| [
{
"answer_id": 417810,
"author": "gnud",
"author_id": 27204,
"author_profile": "https://Stackoverflow.com/users/27204",
"pm_score": 2,
"selected": false,
"text": "window.opener.location.reload()\n"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/417795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52148/"
] |
417,798 | <p>I'm parsing simple (no sections) INI file in PowerShell. Here code I've came up with, is there any way to simplify it?</p>
<pre><code>convertfrom-stringdata -StringData ( `
get-content .\deploy.ini `
| foreach-object `
-Begin { $total = "" } `
{ $total += "`n" + $_.ToString() } `
-End { $total } `
).Replace("\", "\\")
</code></pre>
| [
{
"answer_id": 418528,
"author": "Don Jones",
"author_id": 40405,
"author_profile": "https://Stackoverflow.com/users/40405",
"pm_score": 1,
"selected": false,
"text": "$_.ToString() $_ ConvertFrom-StringData key1=value1\nkey2=value2\nkey3=value3\n ConvertFrom-StringData (Get-Content .\\d... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2313/"
] |
417,813 | <p>Anyone known how to polulate a combo with values that depends on the user seleccion, I have to combo, Country and Region, When the user select contry I need to go to the database and get the region of the country, Anyone knwows how to do this, if posibile using AJAX.</p>
<p>Thanks.</p>
| [
{
"answer_id": 418115,
"author": "Adam Lassek",
"author_id": 1249,
"author_profile": "https://Stackoverflow.com/users/1249",
"pm_score": 4,
"selected": true,
"text": "<select id=\"opt1\">\n <option value='1'>Option 1</option>\n <option value='2'>Option 2</option>\n</select>\n\n<select ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1154/"
] |
417,814 | <p>Do you have any idea for a complex exercise that touches and covers most important and major concepts of .NET? (so I can learn while coding and implementation)</p>
<p>The exercise should NOT be for beginners, but for someone who already familiar with .net, but enough complex to teach new features of .NET 2 for example.</p>
<p>Thanks!</p>
| [
{
"answer_id": 417899,
"author": "Rowland Shaw",
"author_id": 50447,
"author_profile": "https://Stackoverflow.com/users/50447",
"pm_score": 2,
"selected": false,
"text": "Clone() ICloneable"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/417814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51338/"
] |
417,823 | <p>I'm at a loss to explain this one:</p>
<p>I am getting an error:</p>
<blockquote>
<p>Error "91" (Object or With block not set) </p>
</blockquote>
<p>on the second line below: </p>
<pre><code>Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT * FROM employees")
</code></pre>
<p>The following also causes it:</p>
<pre><code>`Set rs = CurrentDb.OpenRecordset("employees")`
</code></pre>
<p>Executing <code>?CurrentDb.Name</code> alone in the immediate window causes the error as well.</p>
<p>Now, clearly the database is open since I'm editing the form within it, so what can cause this error here?</p>
| [
{
"answer_id": 418123,
"author": "Philippe Grondier",
"author_id": 11436,
"author_profile": "https://Stackoverflow.com/users/11436",
"pm_score": 2,
"selected": false,
"text": "dim rs as dao.recordset\nset rs = currentDb.openRecordset(your SELECT instruction,...)\n"
},
{
"answer_i... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] |
417,831 | <p>I have a list of objects and I want to reorder them randomly on each request. What is the best way of doing this?</p>
| [
{
"answer_id": 417856,
"author": "Gant",
"author_id": 12460,
"author_profile": "https://Stackoverflow.com/users/12460",
"pm_score": 5,
"selected": true,
"text": "for (int i = cards.Length - 1; i > 0; i--)\n{\n int n = rand.Next(i + 1);\n Swap(ref cards[i], ref cards[n]);\n}\n"
},... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16628/"
] |
417,840 | <p>I have a couple of <code><p></code> tags that I want to right align. Does anyone know how to do this?</p>
| [
{
"answer_id": 417848,
"author": "enobrev",
"author_id": 14651,
"author_profile": "https://Stackoverflow.com/users/14651",
"pm_score": 6,
"selected": true,
"text": "p {\n text-align: right;\n}\n <p style=\"text-align: right\">Some Text</p>\n $('p').css('text-align', 'right');\n var aE... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33690/"
] |
417,842 | <p>InternalsVisibleTo is not working for my managed C++ projects, but it is for my C# projects. Any help would be appreciated. Here is a simplified layout.</p>
<p>Project <strong>A</strong> - C#, has an internal property I want to access from <strong>B/C</strong>.<br>
Project <strong>B</strong> - Managed C++. References <strong>A</strong>.<br>
Project <strong>C</strong> - C#, references <strong>A</strong>. </p>
<p>All projects are signed with the same key. Looking at the compiled assemblies with ILDASM or Reflector show that they are all signed correctly (when I comment out the internal property usage).</p>
<p>In AssemblyInfo.cs in Project <strong>A</strong>, I have the following InternalsVisibleTo;</p>
<pre><code>[assembly: InternalsVisibleTo( "B, " +
"PublicKey=00240000048000009400000006020000002400005253413100040000010001007" +
"50098646D1C04C2A041FAAF801521A769535DE9A04CD3B4DEDCCBF73D1A6456BF4FE5881451" +
"0E84983C72D0460B8BA85C52A9CACDC4A0785A08E247C335884C2049ECFE6B2C5E20A18FE4B" +
"9BFF009ADA232E980D220B3C9586C9C5EE29C29AEE8853DB7BB90CF5A4C704F5244E1A1085C" +
"4306008535049A0EBB00FE47E78DCB" )]
[assembly: InternalsVisibleTo( "C, " +
"PublicKey=00240000048000009400000006020000002400005253413100040000010001007" +
"50098646D1C04C2A041FAAF801521A769535DE9A04CD3B4DEDCCBF73D1A6456BF4FE5881451" +
"0E84983C72D0460B8BA85C52A9CACDC4A0785A08E247C335884C2049ECFE6B2C5E20A18FE4B" +
"9BFF009ADA232E980D220B3C9586C9C5EE29C29AEE8853DB7BB90CF5A4C704F5244E1A1085C" +
"4306008535049A0EBB00FE47E78DCB" )]
</code></pre>
<p>The keys are cut'n'pasted, so I know they are correct.</p>
<p>When I try to compile, <strong>A & C</strong> compile fine, but project <strong>B</strong> fails with </p>
<pre><code>Error 1 error C3767: 'A::MyClass::MyProperty::get': candidate function(s) not accessible c:\Users\<snip>\CppClass.cpp 201 B
</code></pre>
<p>The MSDN docs say this works with C++. Is there a bug or something else I need to do?</p>
<p>Is there another way that I can protect a property so that it can only be used by assemblies signed by me? I know I can protect all of my assembly, but can I do it on a granular level like this?</p>
<p><strong>EDIT</strong></p>
<p>Based on comments in MSDN, I changed the attribute to the following, but that still doesn't work.</p>
<pre><code>[assembly: InternalsVisibleTo( "B, " +
"PublicKey=00240000048000009400000006020000002400005253413100040000010001007" +
"50098646D1C04C2A041FAAF801521A769535DE9A04CD3B4DEDCCBF73D1A6456BF4FE5881451" +
"0E84983C72D0460B8BA85C52A9CACDC4A0785A08E247C335884C2049ECFE6B2C5E20A18FE4B" +
"9BFF009ADA232E980D220B3C9586C9C5EE29C29AEE8853DB7BB90CF5A4C704F5244E1A1085C" +
"4306008535049A0EBB00FE47E78DCB" ),
InternalsVisibleTo( "C, " +
"PublicKey=00240000048000009400000006020000002400005253413100040000010001007" +
"50098646D1C04C2A041FAAF801521A769535DE9A04CD3B4DEDCCBF73D1A6456BF4FE5881451" +
"0E84983C72D0460B8BA85C52A9CACDC4A0785A08E247C335884C2049ECFE6B2C5E20A18FE4B" +
"9BFF009ADA232E980D220B3C9586C9C5EE29C29AEE8853DB7BB90CF5A4C704F5244E1A1085C" +
"4306008535049A0EBB00FE47E78DCB" )]
</code></pre>
| [
{
"answer_id": 420642,
"author": "Rob Prouse",
"author_id": 30827,
"author_profile": "https://Stackoverflow.com/users/30827",
"pm_score": 6,
"selected": true,
"text": "#using <A.dll> as_friend\n"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/417842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30827/"
] |
417,843 | <p>I am encountering an exception cause by the CFINVOKEARGUMENT line of the following snippet:</p>
<pre><code><CFOUTPUT query="cfmx.Messages"><CFSILENT>
<CFINVOKE component="com_VUI_RemoveIllegalChars" method="formatString" returnvariable="cfmx.formattedMessage">
<CFINVOKEARGUMENT name="inString" value="#TTSText#">
</CFINVOKE>
</CFSILENT>
</code></pre>
<p>The exact text of the exception is:</p>
<blockquote>
<p>Error casting an object of type
coldfusion.runtime.NoOperScope cannot
be cast to
coldfusion.runtime.ApplicationScope to
an incompatible type. This usually
indicates a programming error in Java,
although it could also mean you have
tried to use a foreign object in a
different way than it was designed.
coldfusion.runtime.NoOperScope cannot
be cast to
coldfusion.runtime.ApplicationScope</p>
</blockquote>
<p>Notes: </p>
<ul>
<li>cfmx.Messages is an object returned in a CFPROCRESULT, and upon examination via CFDUMP it does contain the expected data</li>
<li>com_VUI_RemoveIllegalChars has not changed at all</li>
<li>TTSText is a valid column in the result set</li>
<li>My suspicion is that this may be a ColdFusion configuration issue</li>
</ul>
<p>Thanks in advance to anyone who can shed any light on what may be causing this problem.</p>
<p>EDIT: Complete dump from the exception log:</p>
<blockquote>
<p>"Error","jrpp-11","01/06/09","15:11:37",,"coldfusion.runtime.NoOperScope
cannot be cast to
coldfusion.runtime.ApplicationScope
The specific sequence of files
included or processed is:
C:\Inetpub\wwwroot\ermsvui\proc_playsitestatus.cfm,
line: 30 "
java.lang.ClassCastException:
coldfusion.runtime.NoOperScope cannot
be cast to
coldfusion.runtime.ApplicationScope
at
coldfusion.runtime.RuntimeServiceImpl.getFullTagName(RuntimeServiceImpl.java:625)
at
coldfusion.runtime.TemplateProxyFactory.getFullName(TemplateProxyFactory.java:1082)
at
coldfusion.runtime.TemplateProxyFactory.resolveName(TemplateProxyFactory.java:184)
at
coldfusion.runtime.TemplateProxyFactory.resolveName(TemplateProxyFactory.java:157)
at
coldfusion.runtime.TemplateProxyFactory.resolveName(TemplateProxyFactory.java:1267)
at
coldfusion.runtime.TemplateProxyFactory.resolveName(TemplateProxyFactory.java:1218)
at
coldfusion.tagext.lang.InvokeTag.doEndTag(InvokeTag.java:358)
at
cfproc_playsitestatus2ecfm1824676963.runPage(C:\Inetpub\wwwroot\ermsvui\proc_playsitestatus.cfm:30)
at
coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:192)
at
coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:366)
at
coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
at
coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:279)
at
coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
at
coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
at
coldfusion.filter.PathFilter.invoke(PathFilter.java:86)
at
coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27)
at
coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
at
coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at
coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
at
coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
at
coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
at
coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at
coldfusion.CfmServlet.service(CfmServlet.java:175)
at
coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
at
jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
at
coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
at
coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
at
jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
at
jrun.servlet.FilterChain.service(FilterChain.java:101)
at
jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
at
jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at
jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:284)
at
jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
at
jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
at
jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
at
jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
at
jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
at
jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)</p>
</blockquote>
<p>The above code snippet contains lines 28 - 32 of proc_playsitestatus.cfm</p>
<p>EDIT:</p>
<p>The value of TTS text is this case is "The message for test is"</p>
<p>The source of com_VUI_RemoveIllegalChars:</p>
<pre><code><CFCOMPONENT displayname="Format a string for use in VoiceXML" hint="returns a string formatted for voiceXML" output="yes">
<CFFUNCTION name="formatString" access="public" returntype="string" displayname="Format String" hint="Formats String for VoiceXML">
<cfargument name="inString" type="string" required="true" displayname="input string" hint="pass in the string to be formatted">
<CFSET v.messageWithoutChars = replace(inString, "<", "", "all")>
<CFSET v.messageWithoutChars = replace(v.messageWithoutChars, ">", "", "all")>
<CFSET v.messageWithoutChars = replace(v.messageWithoutChars, "&", "and", "all")>
<CFSET v.messageWithoutChars = REReplace(v.messageWithoutChars, "\.+", ".", "all")>
<CFSET v.messageWithoutChars = replace(v.messageWithoutChars, "!", ".", "all")>
<CFSET v.messageWithoutChars = replace(v.messageWithoutChars, "\", " ", "all")>
<CFSET v.messageWithoutChars = replace(v.messageWithoutChars, "/", " ", "all")>
<CFSET v.messageWithoutChars = REReplace(v.messageWithoutChars, "[[:punct:]]{2,}", " ", "all")>
<cfreturn v.messageWithoutChars>
</CFFUNCTION>
</CFCOMPONENT>
</code></pre>
| [
{
"answer_id": 420263,
"author": "Adam Tuttle",
"author_id": 751,
"author_profile": "https://Stackoverflow.com/users/751",
"pm_score": 0,
"selected": false,
"text": "com_VUI_RemoveIllegalChars TTSText"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/417843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22670/"
] |
417,876 | <p><strong>EDIT:</strong> I suppose I should clarify, in case it matters. I am on a AIX Unix box, so I am using VAC compilers - no gnu compilers.
<strong>End edit</strong></p>
<hr />
<p>I am pretty rusty in C/C++, so forgive me if this is a simple question.</p>
<p>I would like to take common functions out of a few of my C programs and put them in shared libraries or shared objects. If I was doing this in perl I would put my subs in a perl module and use that module when needed.</p>
<p>For the sake of an example, let's say I have this function:</p>
<pre><code>int giveInteger()
{
return 1034;
}
</code></pre>
<p>Obviously this is not a real world example, but if I wanted to share that function, how would I proceed?</p>
<p>I'm pretty sure I have 2 options:</p>
<ol>
<li>Put my shared function in a file, and have it compile with my main program at compile time. If I ever make changes to my shared function, I would have to recompile my main program.</li>
<li>Put my shared function in a file, and compile it as a shared library (if I have my terms correct), and have my main program link to that shared library. Any changes I make to my shared library (after compiling it) would be integrated into my main program at runtime without re-compiling my main program.</li>
</ol>
<p>Am I correct on that thinking?</p>
<p>If so, how can I complish either/both of those methods? I've searched a lot and I seem to find information how how I could have my own program link to someone else's shared library, but not how to create my own shared functions and compile them in a way I can use them in my own program.</p>
<p>Thanks so much!</p>
<p>Brian</p>
<hr />
<p><strong>EDIT:</strong> <h2> Conclusion</h2>
Thanks everyone for your help! I thought I would add to this post what is working for me (for dynamic shared libraries on AIX) so that others can benefit:</p>
<p>I compile my shared functions:</p>
<pre><code>xlc -c sharedFunctions.c -o sharedFunctions.o
</code></pre>
<p>Then make it a shared object:</p>
<pre><code>xlc -qmkshrobj -qexpfile=exportlist sharedFunctions.o
xlc -G -o libsharedFunctions.so sharedFunctions.o -bE:exportlist
</code></pre>
<p>Then link it another program:</p>
<pre><code>xlc -brtl -o mainProgram mainProgram.c -L. -lsharedFunctions
</code></pre>
<p>And another comment helped me find this link, which also helped:
<a href="http://publib.boulder.ibm.com/infocenter/comphelp/v7v91/topic/com.ibm.vacpp7a.doc/proguide/ref/compile_library.htm" rel="nofollow noreferrer">http://publib.boulder.ibm.com/infocenter/comphelp/v7v91/topic/com.ibm.vacpp7a.doc/proguide/ref/compile_library.htm</a></p>
<p>Thanks again to all who helped me out!</p>
| [
{
"answer_id": 417903,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 2,
"selected": false,
"text": "$ g++ -o myapp myapp.cpp myfunc.c giveint.c\n $ gcc -c myfunc.c\n$ gcc -c giveint.c\n$ g++ -c myapp.cpp\n$ g++ -o m... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40619/"
] |
417,878 | <p>I have a file with the following text inside</p>
<pre>
mimi,m,70
tata,f,60
bobo,m,100
soso,f,30
</pre>
<p>I did the reading from file thing and many many other methods and functions, but how I can get the best male name and his grade according to the grade.</p>
<p>here is the code I wrote. Hope it's not so long</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace practice_Ex
{
class Program
{
public static int[] ReadFile(string FileName, out string[] Name, out char[] Gender)
{
Name = new string[1];
int[] Mark = new int[1];
Gender = new char[1];
if (File.Exists(FileName))
{
FileStream Input = new FileStream(FileName, FileMode.Open, FileAccess.Read);
StreamReader SR = new StreamReader(Input);
string[] Current;
int Counter = 0;
string Str = SR.ReadLine();
while (Str != null)
{
Current = Str.Split(',');
Name[Counter] = Current[0];
Mark[Counter] = int.Parse(Current[2]);
Gender[Counter] = char.Parse(Current[1].ToUpper());
Counter++;
Array.Resize(ref Name, Counter + 1);
Array.Resize(ref Mark, Counter + 1);
Array.Resize(ref Gender, Counter + 1);
Str = SR.ReadLine();
}
}
return Mark;
}
public static int MostFreq(int[] M, out int Frequency)
{
int Counter = 0;
int Frequent = 0;
Frequency = 0;
for (int i = 0; i < M.Length; i++)
{
Counter = 0;
for (int j = 0; j < M.Length; j++)
if (M[i] == M[j])
Counter++;
if (Counter > Frequency)
{
Frequency = Counter;
Frequent = M[i];
}
}
return Frequent;
}
public static int Avg(int[] M)
{
int total = 0;
for (int i = 0; i < M.Length; i++)
total += M[i];
return total / M.Length;
}
public static int AvgCond(char[] G, int[] M, char S)
{
int total = 0;
int counter = 0;
for (int i = 0; i < G.Length; i++)
if (G[i] == S)
{
total += M[i];
counter++;
}
return total / counter;
}
public static int BelowAvg(int[] M, out int AboveAvg)
{
int Bcounter = 0;
AboveAvg = 0;
for (int i = 0; i < M.Length; i++)
{
if (M[i] < Avg(M))
Bcounter++;
else
AboveAvg++;
}
return Bcounter;
}
public static int CheckNames(string[] Name, char C)
{
C = char.Parse(C.ToString().ToLower());
int counter = 0;
string Str;
for (int i = 0; i < Name.Length - 1; i++)
{
Str = Name[i].ToLower();
if (Str[0] == C || Str[Str.Length - 1] == C)
counter++;
}
return counter;
}
public static void WriteFile(string FileName, string[] Output)
{
FileStream FS = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter SW = new StreamWriter(FS);
for (int i = 0; i < Output.Length; i++)
SW.WriteLine(Output[i]);
}
static void Main(string[] args)
{
int[] Mark;
char[] Gender;
string[] Name;
string[] Output = new string[8];
int Frequent, Frequency, AvgAll, MaleAvg, FemaleAvg, BelowAverage, AboveAverage, NamesCheck;
Mark = ReadFile("c:\\IUST1.txt", out Name, out Gender);
Frequent = MostFreq(Mark, out Frequency);
AvgAll = Avg(Mark);
MaleAvg = AvgCond(Gender, Mark, 'M');
FemaleAvg = AvgCond(Gender, Mark, 'F');
BelowAverage = BelowAvg(Mark, out AboveAverage);
NamesCheck = CheckNames(Name, 'T');
Output [0]= "Frequent Mark = " + Frequent.ToString();
Output [1]= "Frequency = " + Frequency.ToString();
Output [2]= "Average Of All = " + AvgAll.ToString();
Output [3]= "Average Of Males = " + MaleAvg.ToString();
Output [4]= "Average Of Females = " + FemaleAvg.ToString();
Output [5]= "Below Average = " + BelowAverage.ToString();
Output [6]= "Above Average = " + AboveAverage.ToString();
Output [7]= "Names With \"T\" = " + NamesCheck.ToString();
WriteFile("c:\\Output.txt", Output);
}
}
}
</code></pre>
| [
{
"answer_id": 417932,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "yield return using System;\nusing System.Collections.Generic;\nusing System.IO;\n\nenum Gender { Male, Female, Unknow... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
417,898 | <p>My understanding of Linq to Sql is it will take my Linq statement and convert it into an equivalent SQL statement.</p>
<p>So</p>
<pre><code>var products = from p in db.Products
where p.Category.CategoryName == "Beverages"
select p
</code></pre>
<p>Just turns into </p>
<pre><code>Select * from Products where CategoryName = 'Beverages'
</code></pre>
<p>If that's the case, I don't see how stored procedures are useful anymore.</p>
| [
{
"answer_id": 417924,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 4,
"selected": false,
"text": "select delete"
},
{
"answer_id": 417942,
"author": "Wouter van Nifterick",
"author_id": 38813,
"auth... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
417,916 | <p>I need to rename files names like this</p>
<pre><code>transform.php?dappName=Test&transformer=YAML&v_id=XXXXX
</code></pre>
<p>to just this</p>
<pre><code>XXXXX.txt
</code></pre>
<p>How can I do it?</p>
<p>I understand that i need more than one <code>mv</code> command because they are at least 25000 files.</p>
| [
{
"answer_id": 417976,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 4,
"selected": false,
"text": "for i in 'transform.php?dappName=Test&transformer=YAML&v_id='*\ndo\n mv $i <modified name>\ndone\n `echo $i | ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
417,954 | <p>When doing a string comparison in C#, what is the difference between doing a </p>
<pre><code>string test = "testvalue";
test.Equals("TESTVALUE", StringComparison.CurrentCultureIgnoreCase);
</code></pre>
<p>and</p>
<pre><code>string test = "testvalue";
test.Equals("TESTVALUE", StringComparison.InvariantCultureIgnoreCase);
</code></pre>
<p>... and is it important to include that extra parameter, anyway? </p>
| [
{
"answer_id": 417992,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 6,
"selected": true,
"text": "InvariantCulture"
},
{
"answer_id": 418086,
"author": "Jon Skeet",
"author_id": 22656,
"author_pro... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19020/"
] |
417,960 | <p>Does anyone know how to export only the changed files from two tags using svn? </p>
<p>Lets say I have tag 1.0 and then later fix bugs in the trunk. Next I am ready for a new patch release so I tag it 1.1. Now I want to export the changed files between tag 1.0 and 1.1. Is this possible? </p>
| [
{
"answer_id": 10950575,
"author": "Erdem",
"author_id": 300079,
"author_profile": "https://Stackoverflow.com/users/300079",
"pm_score": 0,
"selected": false,
"text": "REV=123456\nURL=https://...\nBASEDIR=some_dir\nsvn diff --summarize -c $REV $URL | while read A B; do \n svn cat -r $... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
417,963 | <p>How do I manipulate textfield variables within an iPhone app? I want to have three text fields, formatted to numbers only, and be able to manipulate the data when I press different buttons.</p>
<p>Any help would be appreciated! </p>
| [
{
"answer_id": 418191,
"author": "jpm",
"author_id": 35478,
"author_profile": "https://Stackoverflow.com/users/35478",
"pm_score": 1,
"selected": false,
"text": "NSNumberFormatter"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/417963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
417,988 | <p>I have a datatable which returns around 30,000 records. I am displaying these records in an ASP:GridView control. I have a dropdown control in which I want the user to be able to select the number of records to display in the GridView. The default should be All, but it could also have values such as 20, 50, 100 for example. I am not quite sure how to do this.</p>
<p>What if I don't have Paging turned on. Will PageSize still work?</p>
<p>I hardcoded GridView.PageSize = 1 and it still returned all the records.</p>
| [
{
"answer_id": 418067,
"author": "BFree",
"author_id": 15861,
"author_profile": "https://Stackoverflow.com/users/15861",
"pm_score": 1,
"selected": false,
"text": " //add column with counter\n table.Columns.Add(\"counter\", typeof(int));\n for (int i = 0;... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33690/"
] |
417,996 | <p>I've got a situation where I want to have a master list at the top level of a Sharepoint site, and then allow the sub-sites to see the master list. I've tried working with Content Types, and either I'm slow and just can't get the concept, or it doesn't seem to apply. </p>
<p>Anyone have any luck?</p>
| [
{
"answer_id": 418117,
"author": "Abs",
"author_id": 1245,
"author_profile": "https://Stackoverflow.com/users/1245",
"pm_score": 4,
"selected": true,
"text": "SPWeb Lists"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/417996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21275/"
] |
417,999 | <p>Java does not allow multiple inheritance, meaning that a class cannot inherit from two classes, which does not have anything in common, meaning that they are not on the same inheritance path. However, a class can inherit from more classes, if these classes are super classes of the direct super class of the class. But the class inherits from these classes indirectly, meaning that it does not "see" anything from these upper super classes, right? I was confused when considering constructors (using super() in the constructor). For example, if we have the following classes:</p>
<pre><code>public class A {
public A() {
....
}
}
public class B extends A {
public B() {
super();
....
}
}
public class C extends B {
public C() {
super();
....
}
}
</code></pre>
<p>the constructor of class C invokes first the constructor of class B using super(). When this happens, the constructor of B itself invokes first the constructor of A (with super()), but the constructor of C does not know anything about the constructor of A, right? I mean, the inheritance is only from the direct super class - the first (nearest) class from the inheritance hierarchy. This is my question - with super() we mean only the constructor of the direct super class, no matter how many other classes we have in the inheritance hierarchy.
And this does not apply only for constructors, but for any methods and instance variables..</p>
<p>Regards</p>
| [
{
"answer_id": 418031,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 2,
"selected": false,
"text": "public class A {\n public A() { \n .... \n }\n public A(String foo) { \n .... \n }\n}\n\npublic... | 2009/01/06 | [
"https://Stackoverflow.com/questions/417999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42155/"
] |
418,006 | <p>Is there a way to disable a tab in a <a href="https://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol(v=vs.110).aspx" rel="noreferrer">TabControl</a>?</p>
| [
{
"answer_id": 418033,
"author": "Cédric Guillemette",
"author_id": 43701,
"author_profile": "https://Stackoverflow.com/users/43701",
"pm_score": 7,
"selected": false,
"text": "((Control)this.tabPage).Enabled = false;\n"
},
{
"answer_id": 418043,
"author": "Hans Passant",
... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43907/"
] |
418,027 | <p>Let's say I have a text file created using <a href="http://perldoc.perl.org/Data/Dumper.html" rel="nofollow noreferrer"><code>Data::Dumper</code></a>, along the lines of:</p>
<pre><code>my $x = [ { foo => 'bar', asdf => undef }, 0, -4, [ [] ] ];
</code></pre>
<p>I'd like to read that file back in and get <code>$x</code> back. I tried this:</p>
<pre><code>my $vars;
{
undef $/;
$vars = <FILE>;
}
eval $vars;
</code></pre>
<p>But it didn't seem to work -- <code>$x</code> not only isn't defined, when I try to use it I get a warning that</p>
<blockquote>
<p>Global symbol $x requires explicit package name.</p>
</blockquote>
<p>What's the right way to do this? (And yes, I know it's ugly. It's a quick utility script, not e.g., a life-support system.)</p>
| [
{
"answer_id": 418283,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 3,
"selected": false,
"text": "my eval my $x = [ { foo => 'bar', asdf => undef }, 0, -4, [ [] ] ];\n my $vars;\n{\n undef $/;\n $vars = <FILE>;\n... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91385/"
] |
418,039 | <p>I need to find out the CPU utilization of a service DLL. I have looked in existing samples and we can find CPU utilization for processes.</p>
<p>I think DLL will be loaded by services.exe. So is it possible to find out CPU utilization by DLL.</p>
<p>I am working in C++ on the Windows platform.</p>
| [
{
"answer_id": 418737,
"author": "Patrick Cuff",
"author_id": 7903,
"author_profile": "https://Stackoverflow.com/users/7903",
"pm_score": 1,
"selected": false,
"text": "tasklist /svc"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/418039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33411/"
] |
418,048 | <p>I have a Console application hosting a WCF service:</p>
<p><em>Updated this code to run off the app.config file instead of initialising it programatically</em></p>
<pre><code>Uri baseAddress = new Uri("http://localhost:8000/ChatServer/Service");
ServiceHost myHost = new ServiceHost(typeof(ClientServerChat.ChatServer), baseAddress);
myHost.AddServiceEndpoint(typeof(IChat), new WSHttpBinding(), "ChatService");
ServiceMetadataBehavior mb = new ServiceMetadataBehavior();
ServiceBehaviorAttribute attrib = (ServiceBehaviorAttribute)myHost.Description.Behaviors[0];
attrib.IncludeExceptionDetailInFaults = true;
mb.HttpGetEnabled = true;
myHost.Description.Behaviors.Add(mb);
myHost.Open();
</code></pre>
<p>The Console app compiles and runs. svcutil runs perfectly.</p>
<p><em>Svcutil runs against the new service code perfectly and generates the Client code and the ouput file</em></p>
<p><em>I'm calling svcutil via the Visual Studio Command Prompt like so: svcutil.exe <a href="http://localhost:8000/ChatServer/Service" rel="nofollow noreferrer">http://localhost:8000/ChatServer/Service</a></em></p>
<p>It generates this output.config:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IChat" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8000/ChatServer/Service/ChatService"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IChat"
contract="IChat" name="WSHttpBinding_IChat">
<identity>
<userPrincipalName value="Bedroom-PC\Roberto" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
</code></pre>
<p>Along with the bundled client code (which is in the same directory as the output file, I should add) I should be able to call the service with this:</p>
<pre><code>ChatClient client = new ChatClient();
</code></pre>
<p><em>The new output from svcutil (both code and config) still throws this exception.</em></p>
<p>But it throws an exception saying: </p>
<p>"Could not find default endpoint element that references contract 'IChat' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."</p>
<p>Interestingly, Visual Studio 2008 will crash when adding the same Service reference to a Client project.</p>
<p><em>VS2008 still crashes with the updated code.</em></p>
<p>It will find the service, get all the operations and what not. When I click Add, it crashes.</p>
<p>Any one have a clue whats going on??</p>
<p>Thanks in advance</p>
<p>Roberto</p>
| [
{
"answer_id": 418737,
"author": "Patrick Cuff",
"author_id": 7903,
"author_profile": "https://Stackoverflow.com/users/7903",
"pm_score": 1,
"selected": false,
"text": "tasklist /svc"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/418048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5648/"
] |
418,056 | <p>I would like to be able to send a stream of binary data to an asp .net website from a java applet hosted in the same website.</p>
<p>I found <a href="http://java.sun.com/docs/books/tutorial/networking/urls/readingWriting.html" rel="nofollow noreferrer">this link</a> which talks about this issue, but I am unsure how to actually receive the data on the website.</p>
<p>The streams I will be sending will probably be in the order of 1mb-20mb in size and I will need to send additional information, such as a file name.</p>
<p>I suspect I would implement an IHttpHandler to handle a POST, but I'm unsure how to approach this.</p>
<p>Any ideas anyone?</p>
<p>Thanks.</p>
| [
{
"answer_id": 489481,
"author": "Greg B",
"author_id": 1741868,
"author_profile": "https://Stackoverflow.com/users/1741868",
"pm_score": 1,
"selected": false,
"text": "using System;\nusing System.IO;\nusing System.Web.Services;\n\n[WebService(Namespace = \"http://tempuri.org/\")]\n[WebS... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5449/"
] |
418,064 | <p>I have a few classes such that:</p>
<pre><code>public class XMLStatusMessage extends XMLMessage
{}
public abstract class XMLMessage implements IMessage
{}
public interface IMessageListener
{
public void onMessage( IMessage message );
}
public interface XMLMessageListener <T extends XMLMessage> extends
IMessageListener
{
public void onMessage( T message );
}
public interface XMLStatusMessageListener extends
XMLMessageListener <XMLStatusMessage>
{
@Override
public void onMessage( XMLStatusMessage message );
}
</code></pre>
<p>and</p>
<pre><code>public class AStatusHandler implements XMLStatusMessageListener
{
//...
@Override
public void onMessage( XMLStatusMessage message )
{
//...
}
}
</code></pre>
<p>My problem is that AStatusHandler won't compile because I'm not also implementing public void onMessage(IMessage). I don't see why I should have to implement onMessage(IMessage) also as it already implements onMessage(XMLStatusMessage) and XMLStatusMessage is an IMessage. Is there a simple solution to this problem?</p>
| [
{
"answer_id": 418097,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "new XMLMessageListener().onMessage(new SomeOtherMessage());\n"
},
{
"answer_id": 418184,
"author": "Bent And... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7949/"
] |
418,066 | <p>From the <a href="http://php.net/isset" rel="noreferrer"><code>isset()</code> docs</a>:</p>
<pre><code>isset() will return FALSE if testing a variable that has been set to NULL.
</code></pre>
<p>Basically, <code>isset()</code> doesn't check for whether the variable is set at all, but whether it's set to anything but <code>NULL</code>.</p>
<p>Given that, what's the best way to actually check for the existence of a variable? I tried something like:</p>
<pre><code>if(isset($v) || @is_null($v))
</code></pre>
<p>(the <code>@</code> is necessary to avoid the warning when <code>$v</code> is not set) but <code>is_null()</code> has a similar problem to <code>isset()</code>: it returns <code>TRUE</code> on unset variables! It also appears that:</p>
<pre><code>@($v === NULL)
</code></pre>
<p>works exactly like <code>@is_null($v)</code>, so that's out, too.</p>
<p>How are we supposed to reliably check for the existence of a variable in PHP?</p>
<hr>
<p>Edit: there is clearly a difference in PHP between variables that are not set, and variables that are set to <code>NULL</code>:</p>
<pre><code><?php
$a = array('b' => NULL);
var_dump($a);
</code></pre>
<p>PHP shows that <code>$a['b']</code> exists, and has a <code>NULL</code> value. If you add:</p>
<pre><code>var_dump(isset($a['b']));
var_dump(isset($a['c']));
</code></pre>
<p>you can see the ambiguity I'm talking about with the <code>isset()</code> function. Here's the output of all three of these <code>var_dump()s</code>:</p>
<pre><code>array(1) {
["b"]=>
NULL
}
bool(false)
bool(false)
</code></pre>
<hr>
<p>Further edit: two things.</p>
<p>One, a use case. An array being turned into the data of an SQL <code>UPDATE</code> statement, where the array's keys are the table's columns, and the array's values are the values to be applied to each column. Any of the table's columns can hold a <code>NULL</code> value, signified by passing a <code>NULL</code> value in the array. You <em>need</em> a way to differentiate between an array key not existing, and an array's value being set to <code>NULL</code>; that's the difference between not updating the column's value and updating the column's value to <code>NULL</code>.</p>
<p>Second, <a href="https://stackoverflow.com/questions/418066/best-way-to-test-for-a-variables-existence-in-php-isset-is-clearly-broken#418162">Zoredache's answer</a>, <code>array_key_exists()</code> works correctly, for my above use case and for any global variables:</p>
<pre><code><?php
$a = NULL;
var_dump(array_key_exists('a', $GLOBALS));
var_dump(array_key_exists('b', $GLOBALS));
</code></pre>
<p>outputs:</p>
<pre><code>bool(true)
bool(false)
</code></pre>
<p>Since that properly handles just about everywhere I can see there being any ambiguity between variables that don't exist and variables that are set to <code>NULL</code>, <strong>I'm calling <code>array_key_exists()</code> the official easiest way in PHP to truly check for the existence of a variable</strong>.</p>
<p>(Only other case I can think of is for class properties, for which there's <code>property_exists()</code>, which, according to <a href="http://php.net/property_exists" rel="noreferrer">its docs</a>, works similarly to <code>array_key_exists()</code> in that it properly distinguishes between not being set and being set to <code>NULL</code>.)</p>
| [
{
"answer_id": 418143,
"author": "Beau Simensen",
"author_id": 50453,
"author_profile": "https://Stackoverflow.com/users/50453",
"pm_score": 1,
"selected": false,
"text": "echo '<?php echo $foo; ?>' | php\n PHP Notice: Undefined variable: foo in /home/altern8/- on line 1\n echo '<?php i... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30497/"
] |
418,072 | <p>Is there a way to execute script when an UpdatePanel process is finished.</p>
<p>I have a page that allows "inserting", "copying", and "editing" of a record.
This is all done on an UpdatePanel to prevent a page navigation.
Somewhere else on the page I would like to print a "flash" message - like "You have successfully entered a record." It is not near the UpdatePanel and I'd like to use a jQuery effect on the message so it fades out after 4 seconds. How can I send script back with the UpdatePanel or have it execute after a UpdatePanel refresh? Should I write script to an asp:literal? thoughts?</p>
| [
{
"answer_id": 418136,
"author": "Robert C. Barth",
"author_id": 9209,
"author_profile": "https://Stackoverflow.com/users/9209",
"pm_score": 6,
"selected": true,
"text": "Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);\n function endRequestHandler(sender,... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] |
418,073 | <p>How do I tell my bash to not echo ^C back to terminal?</p>
<p>If I just hit Ctrl+C in bash session, nothing is printed in my terminal window. But if I terminate some program with Ctrl+C, sometimes ^C is echoed and printed in my terminal. Is there any way to tell my bash I do not want echoing back ^C at all?</p>
| [
{
"answer_id": 418112,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 4,
"selected": true,
"text": "CTRL-C tty CTRL-C SIGINT"
},
{
"answer_id": 6674482,
"author": "Aesthir",
"author_id": 831970,
"... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12138/"
] |
418,076 | <p>I want to trigger the submit event of the form the current element is in. A method I know works sometimes is:</p>
<pre><code>this.form.submit();
</code></pre>
<p>I'm wondering if there is a better solution, possibly using jQuery, as I'm not 100% sure method works in every browser.</p>
<p>Edit:</p>
<p>The situation I have is, as follows:</p>
<pre><code><form method="get">
<p><label>Field Label
<select onchange="this.form.submit();">
<option value="blah">Blah</option>
....
</select></label>
</p>
</form>
</code></pre>
<p>I want to be able to submit the form on change of the <code><select></code>.</p>
<p>What I'm looking for is a solution that works on any field within any form without knowing the id or name on the form. <code>$('form:first')</code> and <code>$('form')</code> won't work because the form could be the third on the page. Also, I am using jQuery on the site already, so using a bit of jQuery is not a big deal.</p>
<p>So, is there a way to have jQuery retrieve the form the input/select/textarea is in?</p>
| [
{
"answer_id": 418101,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "$(\"form:first\").trigger(\"submit\")\n"
},
{
"answer_id": 418114,
"author": "patridge",
"author_id": 48700,
... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] |
418,082 | <p>I'm in the process of creating database scripts for an existing database. I'm trying to use SQL Server to generate the scripts for me, but the generated scripts are failing. I'm using the 'Script Table As'>'CREATE To'>'New Query Editor Window' option. I then change the table and constraint names and execute the script. I'm stumped. Can anyone see the issue here?</p>
<p>I get this error: </p>
<pre><code>Msg 170, Level 15, State 1, Line 17
Line 17: Incorrect syntax near '('.
</code></pre>
<p>The generated SQL:</p>
<pre><code>USE [MyDatabase]
GO
/****** Object: Table [dbo].[MyTable2] Script Date: 01/06/2009 14:40:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MyTable2](
[id] [int] IDENTITY(1,1) NOT NULL,
[u_id] [int] NOT NULL,
[prog_number] [varchar](5) NOT NULL,
[trans_id] [varchar](50) NULL,
[code] [varchar](7) NULL,
[user_num] [char](9) NULL,
[is_found] [char](9) NULL,
[status] [char](1) NULL,
[status2] [char](1) NULL,
[inserted_timestamp] [datetime] NULL CONSTRAINT [DF_MyTable2_inserted_timestamp] DEFAULT (getdate()),
[s_id] [varchar](10) NULL,
[p_value] [char](4) NULL,
CONSTRAINT [PK_MyTable2] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
</code></pre>
| [
{
"answer_id": 418118,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 0,
"selected": false,
"text": "use [MyDatabase] tempdb"
},
{
"answer_id": 418357,
"author": "DJ.",
"author_id": 10492,
"author_prof... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33178/"
] |
418,098 | <p>I'm new to VBA and have been throwing together a small macro application for the Office. We've got about 80 users on essentially identical PC setups, and it will be accessed by all but a few users. </p>
<p>I've been playing around with some automation of accessing web pages using the Web Services references, and I've also loaded the Microsoft Scripting Runtime references into the project. I attempted to run it on a test PC and it complained that there were missing references. </p>
<p>I don't particularly want to go around 80 PCs and manually load the references.</p>
<p>My question, basically, is how should I manage the distribution of this macro-app to 80 odd users so as to ensure that the references will load every time for every user.</p>
<p>Thanks!</p>
| [
{
"answer_id": 418215,
"author": "Philippe Grondier",
"author_id": 11436,
"author_profile": "https://Stackoverflow.com/users/11436",
"pm_score": 2,
"selected": false,
"text": "Dim cat as ADOX.catalog \n"
},
{
"answer_id": 418483,
"author": "Fionnuala",
"author_id": 2548,
... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51498/"
] |
418,105 | <p>Is there any api for viewing html content from w/in your blackberry application? To be clear, I don't mean launching the browser on top of my app to view a page. But rather rendering the page w/in my app.</p>
| [
{
"answer_id": 418177,
"author": "Richard Campbell",
"author_id": 12254,
"author_profile": "https://Stackoverflow.com/users/12254",
"pm_score": 3,
"selected": true,
"text": "Field field = browserContent.getDisplayableContent();\n"
},
{
"answer_id": 5067642,
"author": "gmuhamm... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23071/"
] |
418,119 | <p>I am writing an application in C# that needs to run as a service but also have user interaction. I understand that services have no UI, etc, so I've divided up my program into a windows form application and a service that can communicate with each other.</p>
<p>The problem I'm having is that I need the service to make sure the windows form application is always running and restart it if it is not. I'm able to detect if it is running, and restart it with the following code on Windows 2000/XP:</p>
<pre><code>System.Diagnostics.Process.Start("ExePath");
</code></pre>
<p>but on Vista, it runs the new process as a Local/System process which is invisible to the user. Does someone way around this? Is there some way to detect which user is currently logged on and run the new process as that user? I don't need to account for fast-user switching at this point. Something - anything - basic would suffice.</p>
<p>I would be grateful for any help or tips you have on the subject.</p>
<p>I need to clarify that I am setting the "Allow service to interact with desktop" option when the service is installed. This is what allows it to work on 2000/XP. However, Vista still has the aforementioned problem.</p>
| [
{
"answer_id": 2677992,
"author": "Tyson Zwicker",
"author_id": 321638,
"author_profile": "https://Stackoverflow.com/users/321638",
"pm_score": 1,
"selected": false,
"text": "System.Security.SecureString ss = new System.Security.SecureString();\n\nforeach (char c in password)\n ss.Appen... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20801/"
] |
418,120 | <p>In functional programming, it's often important to optimize any "looping" code to be tail recursive. Tail recursive algorithms are usually split between two functions, however - one which sets up the base case, and another that implements the actual loop. A good (albeit academic) example would be the reverse function.</p>
<pre><code>reverse :: [a] -> [a]
reverse = reverse_helper []
reverse_helper :: [a] -> [a] -> [a]
reverse_helper result [] = result
reverse_helper result (x:xs) = reverse_helper (x:result) xs
</code></pre>
<p>"reverse_helper" isn't really a good, descriptive name. However, "reverse_recursive_part" is just awkward.</p>
<p>What naming convention would you use for helper functions like this?</p>
| [
{
"answer_id": 418138,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 1,
"selected": false,
"text": "function whateverSetup() { ... }\nfunction whateverExecute() { ... }\n"
},
{
"answer_id": 418478,
"author... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418120",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32998/"
] |
418,121 | <pre><code> #include "iostream"
#include "vector"
class ABC {
private:
bool m_b;
public:
ABC() : m_b(false) {}
ABC& setBool(bool b) {
m_b = b;
return *this;
}
bool getBool() const {
return m_b;
}
};
void foo(const std::vector<ABC> &vec) {
vec[0].setBool(true);
}
int main(int argc, char*argv[]) {
std::vector<ABC> vecI;
ABC i;
vecI.push_back(i);
foo(vecI);
}
</code></pre>
<p>When I compile it I get this error: passing <code>const ABC</code> as <code>this</code> argument of <code>ABC& ABC::setBool(bool)</code> discards qualifiers</p>
<p>Any ideas why this would happen since the object itelf is not a constant.</p>
| [
{
"answer_id": 418155,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "T& vector<T>::operator[](int); \nT const& vector<T>::operator[](int) const; \n"
},
{
"answer_id": 418165,
"author... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43756/"
] |
418,176 | <p>I have two String.printable mysteries in the one question.</p>
<p>First, in Python 2.6:</p>
<pre><code>>>> string.printable
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
</code></pre>
<p>Look at the end of the string, and you'll find '\x0b\x0c' sticking out like a sore-thumb. Why are they there? I am using a machine set to Australian settings, so there shouldn't be any accented characters or the like.</p>
<p>Next, try running this code:</p>
<pre><code>for x in string.printable: print x,
print
for x in string.printable: print x
</code></pre>
<p>The first line successfully prints all the characters separated by a space. The two odd characters turn out as the Male and Female symbols.</p>
<p>The second line successfully prints all the characters EXCEPT THE LAST separated by a line feed. The Male symbol prints; the female symbol is replaced with a missing character (a box).</p>
<p>I'm sure Python wasn't intended to be gender-biased, so what gives with the difference?</p>
| [
{
"answer_id": 418445,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverflow.com/users/4279",
"pm_score": 3,
"selected": false,
"text": ">>> print '\\x0b'\n♂\n>>> print '\\x0c'\n♀\n>>> print '\\f' # form feed\n♀\n>>> print '\\v' # vertical tab\n♂\n>>>\n >>> print '... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8014/"
] |
418,183 | <p>What is the trick in MySql (Version 4) to write from PHP thtree Inserts and to be sure that we can link tables properly.</p>
<pre><code>[Table1]-[LinkTable]-[Table2]
</code></pre>
<p>In the PHP code I create an Insert that add 1 row in table 1 and an other Insert that add an other row in table 2. I get both rows PK (primary key) with two SELECTs that return me the last row of each tables. This way I get the PK (auto-increment) from Table 1 and Table 2 and I insert it on the link table.</p>
<p>The problem is that is not atomic and now that I get a lot of transaction something it doesn't link properly.</p>
<p>How can I make a link between 2 tables in MySQL 4 that preserve data? I cannot use any stored procedure.</p>
| [
{
"answer_id": 418238,
"author": "Peter Bailey",
"author_id": 8815,
"author_profile": "https://Stackoverflow.com/users/8815",
"pm_score": 2,
"selected": false,
"text": "<?php\n\n// Start a transaction\nmysql_query( 'begin' );\n\n// Execute the queries\nif ( mysql_query( \"insert into t... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13913/"
] |
418,186 | <p>I have a database assignment which I have to create some relational algebra for two problems. I feel fairly all right with the majority of it, but I just get confused when trying to project attributes out of a table which is joined to another table.</p>
<p>for example is this correct?</p>
<p>Q1) List the details of incidences with no calls made, so that the receptionist knows
which incidents still need to be called in. </p>
<pre><code>RESULT <-- PROJECT<STUDENT.FirstName, STUDENT.LastName, STAFF.FirstName,
STAFF.INCIDENT.LastName, INCIDENT.DateTimeReported,
INCIDENT.NatureOfIllness(SELECTINCIDENT.DecisionMade =
''(Staff RIGHT JOIN<STAFF.StaffID = INCIDENT.StaffID>
(INCIDENT LEFT JOIN<INCIDENT.StudentID = STUDENT.StudentID>(STUDENT))))
</code></pre>
<p>The SQL which I am trying to interpret into relational algebra is:</p>
<pre><code>SELECT
s.FirstName, s.LastName, st.FirstName, st.LastName
, i.DateTimeReported, i.NatureOfIllness
FROM Student s
RIGHT JOIN Incident i ON s.StudentID = i.StudentID
LEFT JOIN Staff st ON st.StaffID = i.StaffID
WHERE i.DecisionMade = ''
</code></pre>
<p>Any points of advice would be much appreciated.</p>
| [
{
"answer_id": 418348,
"author": "Federico A. Ramponi",
"author_id": 18770,
"author_profile": "https://Stackoverflow.com/users/18770",
"pm_score": 2,
"selected": true,
"text": "RESULT <--- \n PROJECT <STUDENT.FirstName, STUDENT.LastName, \n STAFF.FirstName, STAFF.La... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50913/"
] |
418,187 | <p>I would like to convert the below "foreach" statement to a LINQ query that returns a substring of the file name into a list:</p>
<pre><code>IList<string> fileNameSubstringValues = new List<string>();
//Find all assemblies with mapping files.
ICollection<FileInfo> files = codeToGetFileListGoesHere;
//Parse the file name to get the assembly name.
foreach (FileInfo file in files)
{
string fileName = file.Name.Substring(0, file.Name.Length - (file.Name.Length - file.Name.IndexOf(".config.xml")));
fileNameSubstringValues.Add(fileName);
}
</code></pre>
<p>The end result would be something similar to the following:</p>
<pre><code>IList<string> fileNameSubstringValues = files.LINQ-QUERY-HERE;
</code></pre>
| [
{
"answer_id": 418205,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 2,
"selected": false,
"text": "IList<string> fileNameSubstringValues =\n (\n from \n file in codeToGetFileListGoesHere\n select \n fil... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52194/"
] |
418,197 | <p>Assuming I have a class A as follows:</p>
<pre><code>class A{
int id;
int getId(){};
void setId(int id){};
}
</code></pre>
<p>And a class B as follows:</p>
<pre><code>@Entity
@Table(name="B")
class B extends A{
string name;
@Column(length=20)
string getName(){}
void setName(){}
}
</code></pre>
<p>How can I annotate the inherited id field from A so that Hibernate/JPA knows it is the Id
for the entity? I tried simply placing @Id on the field in A but this didn't work. I
tried making A an entity as well and this also didn't work.</p>
| [
{
"answer_id": 418214,
"author": "Dave L.",
"author_id": 3093,
"author_profile": "https://Stackoverflow.com/users/3093",
"pm_score": 4,
"selected": true,
"text": "@MappedSuperclass @MappedSuperclass\nclass A{\n int id;\n @Id\n int getId(){};\n void setId(int id){};\n}\n"
},
{... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17337/"
] |
418,204 | <p>How to check with python if a path has the sticky bit set?</p>
| [
{
"answer_id": 418243,
"author": "Zach Hirsch",
"author_id": 50773,
"author_profile": "https://Stackoverflow.com/users/50773",
"pm_score": 4,
"selected": true,
"text": "import os\ndef is_sticky(path):\n return os.stat(path).st_mode & 01000 == 01000\n"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/418204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36131/"
] |
418,210 | <p>What are the things I should be looking for when I produce a dependency graph?</p>
<p>Or to put it another way, what are the characteristics of a good looking graph vs a bad one?</p>
<p>Edit: The context here is my first look at my assemblies in NDepend.</p>
| [
{
"answer_id": 419625,
"author": "Patrick from NDepend team",
"author_id": 27194,
"author_profile": "https://Stackoverflow.com/users/27194",
"pm_score": 3,
"selected": true,
"text": "// <Name>UI layer shouldn't use directly DB types</Name>\nwarnif count > 0\n\n// UI layer is made of type... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/337/"
] |
418,218 | <p>I have a really cool website that allows people to upload images. Sometimes there images are really large, as seen in the below div:</p>
<p><code>![Overflow][1]</code></p>
<p>Is there a style that can I add to my DIVs to fix this?</p>
<p><a href="http://img242.imageshack.us/img242/6711/overflowds1.png" rel="nofollow noreferrer">Link</a></p>
| [
{
"answer_id": 418233,
"author": "Joe Phillips",
"author_id": 20471,
"author_profile": "https://Stackoverflow.com/users/20471",
"pm_score": 4,
"selected": true,
"text": "overflow: auto; /* Adds scrollbars only when necessary */\noverflow: scroll; /* Adds inactive scrollbars until nee... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/245/"
] |
418,223 | <p>Is it possible to freeze a grid column in Dynamics Ax so that as the user scrolls to the right the first column or two continues to show and doesn't scroll out of view?</p>
| [
{
"answer_id": 418233,
"author": "Joe Phillips",
"author_id": 20471,
"author_profile": "https://Stackoverflow.com/users/20471",
"pm_score": 4,
"selected": true,
"text": "overflow: auto; /* Adds scrollbars only when necessary */\noverflow: scroll; /* Adds inactive scrollbars until nee... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2404/"
] |
418,230 | <p>I'm trying to implement <a href="http://msdn.microsoft.com/en-us/library/ms537079(VS.85).aspx" rel="nofollow noreferrer">IInternetZoneManager</a> in .NET with Webbrowser Control but I have no clue what to do.</p>
<p>I couldn't find any managed code example about this implementation. I'm pretty bad about OLE stuff.</p>
<p>Can anyone provide a sample on this? I spend about 2 days with no luck.</p>
| [
{
"answer_id": 418349,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 2,
"selected": true,
"text": "public class Constants\n{\n public const int MAX_PATH = 260;\n public const int MAX_ZONE_PATH = 260;\n public co... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40322/"
] |
418,265 | <p>This pertains to C# & the .NET Framework specifically.</p>
<p>It's best practice not to initialize the following types in the .NET framework because the CLR initializes them for you:</p>
<p>int,
bool, etc.</p>
<p>and same for setting an object to null (I believe).</p>
<p>For example you do not need to do this and in fact it's a performance hit (drops in the bucket or not):</p>
<pre><code>int Myvar = 0;
</code></pre>
<p>Just need <code>int Myvar;</code> and that's it. the CLR will initialize it to int.</p>
<p>I obviously just "know" from programming that int is set to 0 by default and bool to false.</p>
<p>And also setting an object to null because the CLR does it for you.
But how can you tell what those primitive types are set to. I tried opening up Reflector to take a look at int32 and bool but could not figure out how they are initialized by default.</p>
<p>I looked on msdn and I don't see it there either. Maybe I'm just missing it.</p>
| [
{
"answer_id": 418296,
"author": "arul",
"author_id": 15409,
"author_profile": "https://Stackoverflow.com/users/15409",
"pm_score": 0,
"selected": false,
"text": "default( T )\n"
},
{
"answer_id": 418363,
"author": "regex",
"author_id": 23869,
"author_profile": "https... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
418,266 | <p>I am running through a memory block of binary data byte-wise.</p>
<p>Currently I am doing something like this:</p>
<pre><code>for (i = 0; i < data->Count; i++)
{
byte = &data->Data[i];
((*byte & Masks[0]) == Masks[0]) ? Stats.FreqOf1++; // syntax incorrect but you get the point.
((*byte & Masks[1]) == Masks[1]) ? Stats.FreqOf1++;
((*byte & Masks[2]) == Masks[2]) ? Stats.FreqOf1++;
((*byte & Masks[3]) == Masks[3]) ? Stats.FreqOf1++;
((*byte & Masks[4]) == Masks[4]) ? Stats.FreqOf1++;
((*byte & Masks[5]) == Masks[5]) ? Stats.FreqOf1++;
((*byte & Masks[6]) == Masks[6]) ? Stats.FreqOf1++;
((*byte & Masks[7]) == Masks[7]) ? Stats.FreqOf1++;
}
</code></pre>
<p>Where Masks is:</p>
<pre><code>for (i = 0; i < 8; i++)
{
Masks[i] = 1 << i;
}
</code></pre>
<p>(I somehow did not manage to do it as fast in a loop or in an inlined function, so I wrote it out.)</p>
<p>Does anyone have any suggestions on how to to improve this first loop? I am rather inexperienced with getting down to bits.</p>
<p>This may seem like a stupid thing to do. But I am in the process of implementing a compression algorithm. I just want to have the bit accessing part down right.</p>
<p>Thanks!</p>
<p>PS: This is in on the Visual Studio 2008 compiler. So it would be nice if the suggestions applied to that compiler.</p>
<p>PPS: I just realized, that I don't need to increment two counts. One would be enough. Then compute the difference to the total bits at the end.
But that would be specific to just counting. What I really want done fast is the bit extraction.</p>
<p>EDIT:
The lookup table idea that was brought forward is nice.
I realize though that I posed the question wrong in the title.
Because in the end what I want to do is not count the bits, but access each bit as fast as possible.</p>
<p>ANOTHER EDIT:
Is it possible to advance a pointer by just one bit in the data?</p>
<p>ANOTHER EDIT:
Thank you for all your answers so far.</p>
<p>What I want to implement in the next steps is a nonsophisticated binary arithmetic coder that does not analyze the context. So I am only interested in single bits for now. Eventually it will become a Context-adaptive BAC but I will leave that for later.</p>
<p>Processing 4 bytes instead of 1 byte could be an option. But a loop over 32 bits is costly as well, isn't it?</p>
| [
{
"answer_id": 418290,
"author": "frankodwyer",
"author_id": 42404,
"author_profile": "https://Stackoverflow.com/users/42404",
"pm_score": 2,
"selected": false,
"text": "static int bitcount_lookup[256] = { ..... } ; /* or make it a global and compute the values in code */\n\n...\n\nfor( ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51710/"
] |
418,270 | <p>Dead code is easily recognised and eliminated by having code reviews, however, when it comes to images - unused images still get into our version control. Is there any clean way of organising graphic content so that a direct correlation exists between web pages and image files?</p>
<p>In our current project, we use create master PNG files then export the required layers for development purpose. Recently I figured out that there is some bloat in the images folder. Doing a search for image names in code helps but it is very painful when it needs to be done for hundred odd images. So asking the forum for suggestions</p>
| [
{
"answer_id": 418421,
"author": "Chris Nava",
"author_id": 45163,
"author_profile": "https://Stackoverflow.com/users/45163",
"pm_score": 1,
"selected": false,
"text": "grep -o -e \\w*?\\.png (caution: untested regex)\n"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/418270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25210/"
] |
418,280 | <p>I'm writing a small shell script that needs to reverse the lines of a text file. Is there a standard filter command to do this sort of thing?</p>
<p>My specific application is that I'm getting a list of Git commit identifiers, and I want to process them in reverse order:</p>
<pre><code>git log --pretty=oneline work...master | grep -v DEBUG: | cut -d' ' -f1 | reverse
</code></pre>
<p>The best I've come up with is to implement <code>reverse</code> like this:</p>
<pre><code>... | cat -b | sort -rn | cut -f2-
</code></pre>
<p>This uses <code>cat</code> to number every line, then <code>sort</code> to sort them in descending numeric order (which ends up reversing the whole file), then <code>cut</code> to remove the unneeded line number.</p>
<p>The above works for my application, but may fail in the general case because <code>cat -b</code> only numbers nonblank lines.</p>
<p>Is there a better, more general way to do this?</p>
| [
{
"answer_id": 418286,
"author": "Hynek -Pichi- Vychodil",
"author_id": 49197,
"author_profile": "https://Stackoverflow.com/users/49197",
"pm_score": 5,
"selected": false,
"text": "tac sed sed 'x;1!H;$!d;x'\n perl -e'print reverse<>'\n"
},
{
"answer_id": 418607,
"author": "Jo... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/893/"
] |
418,284 | <p>I was wondering the best practice for unit-testing controller actions that utilize model binding.</p>
<pre><code>[AcceptVerbs(HttpVerbs.Get)]
public ActionResult AddProduct(Product product)
{
}
</code></pre>
<p>I was wondering how you invoke the controller's method for unit testing. If you try something like this...</p>
<pre><code>public void Catalog_AddProduct()
{
CatalogController controller = new CatalogController();
// some mocking for controller context, setting form values etc...
controller.AddProduct(// ?);
}
</code></pre>
<p>Some might suggest removing Product as a parameter but, I also have another AddProduct controller action that is used for just HTTP-Gets. The only solution I could think of is maybe accepting a namevalue collection (form data) and just using UpdateModel/TryUpdateModel.</p>
<p>I also want to test the model binding itself is working properly so I'd like to put the responsibility of creating the new product to the model binder.</p>
| [
{
"answer_id": 418404,
"author": "Odd",
"author_id": 11908,
"author_profile": "https://Stackoverflow.com/users/11908",
"pm_score": 3,
"selected": true,
"text": "[TestMethod()]\npublic void AddProductTest()\n{\n CatalogController target = new CatalogController(/*testing variables*/);\n... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25416/"
] |
418,288 | <p>I know the Google Search Appliance has access to this information (as this factors into the PageRank Algorithm), but is there a way to export this information from the crawler appliance?</p>
<p>External tools won't work because a significant portion of the content is for a corporate intranet.</p>
| [
{
"answer_id": 420216,
"author": "Liam",
"author_id": 18333,
"author_profile": "https://Stackoverflow.com/users/18333",
"pm_score": 1,
"selected": false,
"text": "grep sed sort uniq"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/418288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1551/"
] |
418,308 | <p>I was reading Algorithms in a Nutshell (O'Reilly) and came across this symbol in a class diagram. My guess is that it means the member is protected, but I wanted to see if anyone knows for sure what it means.</p>
| [
{
"answer_id": 418328,
"author": "Mike Hofer",
"author_id": 47580,
"author_profile": "https://Stackoverflow.com/users/47580",
"pm_score": 8,
"selected": true,
"text": "- + #"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/418308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47923/"
] |
418,316 | <p>I am working on a Word VBA macro app for 80 or so users. The office has high staff turnover, so training suffers, and so one of the self imposed requirements for this project is comprehensive, friendly documentation. However, to supplement this, and to save newbies having to open up a 100 page document when they want to try something new, I want a status bar on every userform (there are five) that provides contextual help. I find tooltips annoying.</p>
<p>I don't have a lot of experience, so I was wanting to</p>
<p>Essentially, I have a file containing every status string. (This is currently a text file, but I was wondering if I should use a spreadsheet or csv for ease of editing by other staff in future.) Every control has a MouseMove event which refers to a function: getStatus(cID) that opens the file, grabs the line and displays it in the status label. It also grabs a few parameters from the same line in the file, such as whether the label is clickable (to link to a page in the help file), and what colour the label should be.</p>
<p>So a few questions really:</p>
<p>Will the application be slow if a userform is constantly referring to a file? It feels fine to me, but I've been in it far too long, and I'm the only user accessing that file. There will be 80 constantly accessing it.</p>
<p>Is MouseMove over a control the best way? Should I instead use co-ordinates?</p>
<p>Most importantly (in terms of me having to do as little work as possible) is there some way to do this so that I do not have to have a MouseMove event on every single control? I have a good few hundred or so controls, each with their own identifier (well, not yet, but they will if this is the only way to do it). Maybe when the form loads I could load ALL the possible status lines so they're ready for whenever the control is moused over. But then, maybe the loading time is negligible?</p>
<p>Appreciate any ideas or thoughts - especially if VBA already has a whole range of functions to do this already and I'm just trying to reinvent the wheel. I can't use the application status bar, because the user rarely sees the application itself.</p>
<p>Thanks!</p>
<p>EDIT: </p>
<p>It is for both data entry, clicking around and a bit of document generation. </p>
<p>It is a controlled environment so macro security issues aren't a big concern for me - and if something goes wrong it's someone else's fault or problem :)</p>
| [
{
"answer_id": 418400,
"author": "DJ.",
"author_id": 10492,
"author_profile": "https://Stackoverflow.com/users/10492",
"pm_score": 3,
"selected": true,
"text": "Sub Control_MouseMove()\n DisplayStatus(Control)\nEnd sub\n"
},
{
"answer_id": 418420,
"author": "Fionnuala",
... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51498/"
] |
418,318 | <p>I have a SQL query that takes a date parameter (if I were to throw it into a function) and I need to run it on every day of the last year.</p>
<p>How to generate a list of the last 365 days, so I can use straight-up SQL to do this?</p>
<p>Obviously generating a list 0..364 would work, too, since I could always:</p>
<pre><code>SELECT SYSDATE - val FROM (...);
</code></pre>
| [
{
"answer_id": 418360,
"author": "George Mauer",
"author_id": 5056,
"author_profile": "https://Stackoverflow.com/users/5056",
"pm_score": 2,
"selected": false,
"text": "select SYSDATE - ROWNUM\nfrom shipment_weights sw\nwhere ROWNUM < 365;\n"
},
{
"answer_id": 418441,
"author... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] |
418,320 | <p>I guess this could also be asked as to how long the created type name is attached to an anonymous type. Here's the issue:</p>
<p>A blog had something like this:</p>
<pre><code>var anonymousMagic = new {test.UserName};
lblShowText.Text = lblShowText
.Text
.Format("{UserName}", test);
</code></pre>
<p>As sort of a wish list and a couple ways to go at it. Being bored and adventurous I took to creating an string extension method that could handle this:</p>
<pre><code>var anonymousMagic = new {test.UserName, test.UserID};
lblShowText.Text = "{UserName} is user number {UserID}"
.FormatAdvanced(anonymousMagic);
</code></pre>
<p>With the idea that I would get the property info from the anonymous type and match that to the bracketted strings. Now with property info comes reflection, so I would want to save the property info the first time the type came through so that I wouldn't have to get it again. So I did something like this:</p>
<pre><code> public static String FormatAdvanced(this String stringToFormat, Object source)
{
Dictionary<String, PropertyInfo> info;
Type test;
String typeName;
//
currentType = source.GetType();
typeName = currentType.Name;
//
//info list is a static list for the class holding this method
if (infoList == null)
{
infoList = new Dictionary<String, Dictionary<String, PropertyInfo>>();
}
//
if (infoList.ContainsKey(typeName))
{
info = infoList[typeName];
}
else
{
info = test.GetProperties()
.ToDictionary(item => item.Name);
infoList.Add(typeName, info);
}
//
foreach (var propertyInfoPair in info)
{
String currentKey;
String replacement;
replacement = propertyInfoPair.Value.GetValue(source, null).ToString();
currentKey = propertyInfoPair.Key;
if (stringToFormat.Contains("{" + currentKey + "}"))
{
stringToFormat = stringToFormat
.Replace("{" + currentKey + "}", replacement);
}
}
//
return stringToFormat;
}
</code></pre>
<p>Now in testing, it seems to keep the name it created for the anonymous type so that the second time through it doesn't get the property info off the type but off the dictionary. </p>
<p>If multiple people are hitting this method at the same time, is it pretty much going to work in a Session like fassion; IE the names of the types will be specific to each instance of the program? Or would it be even worse than that? At what point does that name get chucked and overwritten?</p>
| [
{
"answer_id": 418760,
"author": "configurator",
"author_id": 9536,
"author_profile": "https://Stackoverflow.com/users/9536",
"pm_score": 1,
"selected": false,
"text": "Dictionary<Type, Dictionary<String, PropertyInfo>>"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/418320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21691/"
] |
418,329 | <p>I have a problem within my CakePHP application: I use the Authorization Component for the login/logout mechanisms. Unfortunately users are logged out automatically when they try to open two or more php pages at the same moment. Thats happening very often because we tend to use the middle mouse button to open many tabs in short intervals.</p>
<p>Has anybody an idea? Could it be CakePHP or is there a php setting for allowing useres to make multiple requests at the same time?</p>
<p>georg</p>
| [
{
"answer_id": 418739,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "Configure::write('Session.cookie', 'I_like_to_make_this_unique');\nConfigure::write('Security.salt', 'this_should_be_unique');... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42130/"
] |
418,347 | <p>On Perl 5.8.5 I am seeing the error listed in the question.</p>
<p>I am running these version modules:</p>
<ul>
<li>Math::BigInt: 1.89</li>
<li>Math::BigInt::FastCalc: 0.19</li>
<li>Math::BigInt::GMP: 1.24</li>
<li>Math::BigInt::Pari: 1.13</li>
<li>Math::BigRat: 0.22</li>
<li>bignum: 0.22 </li>
</ul>
<p>The module producing the error is Math::Pari. This is all in an attempt to get Net::SFTP working to put a file on a remote host.</p>
<p>Thanks for any insight, oh CPAN gurus. :)</p>
<hr>
<p>Thanks, nothingmuch, I tried those things but when I remove Math::Pari, Net::SSH::Perl::Util::SSH2MP complains because it is using it as such:</p>
<pre><code>use Math::Pari qw( PARI floor pari2num Mod lift );
</code></pre>
<p>The Math::Pari version is 2.010800</p>
<p>I wish I understood the CPAN build process better so I could know if this was worth reporting to the maintainer of Net::SFTP.</p>
| [
{
"answer_id": 419233,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "use Math::BigInt only => \"GMP\";\n"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/418347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26848/"
] |
418,354 | <p>I am new to C and I am using MS Visual C++ 6.0 for now.
I am currently working on sorting algorithms and i want to track the values of each variable automatically. This may provide me insight on how the algorithm does the hard work. That is, I don't want to write what is produced by what on a paper :)
Are there are any operators or functions for debugging purposes such as var_dump() in PHP? or How can I improve my debugging abilities? Any other debugging tools for newbies? or any good tutorials on using Visual C++'s built-in debugger?
Thank you!..</p>
| [
{
"answer_id": 418381,
"author": "sastanin",
"author_id": 25450,
"author_profile": "https://Stackoverflow.com/users/25450",
"pm_score": 0,
"selected": false,
"text": "printf fprintf"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/418354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
418,358 | <p>Currently, Boost only implements the <code>random_device</code> class for Linux (maybe *nix) systems. Does anyone know of existing implementations for other OS-es? Ideally, these implementations would be open-source.</p>
<p>If none exist, how should I go about implementing a non-deterministic RNG for Windows as well as Mac OS X? Do API calls exist in either environment that would provide this functionality? Thanks (and sorry for all the questions)!</p>
| [
{
"answer_id": 1224094,
"author": "Marsh Ray",
"author_id": 116270,
"author_profile": "https://Stackoverflow.com/users/116270",
"pm_score": 0,
"selected": false,
"text": "#include <openssl/rand.h>\n...\ntime_t now = time(NULL);\nRAND_seed(&now, sizeof(now)); // before first number you ne... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16457/"
] |
418,365 | <p>I would like to edit text in boustrophedon in emacs. For those of you who don't know boustrophedon text direction goes "like an ox turns" in a field or like a printer inkjet. For the same reasons this is efficient on a farm or in a printer this text is very efficient to read once you get used to it (which doesn't take too long).</p>
<p>more on boustrophedon typesetting/layout:
<a href="http://www.ntg.nl/pipermail/aleph/2004-March/000094.html" rel="nofollow noreferrer">http://www.ntg.nl/pipermail/aleph/2004-March/000094.html</a></p>
<p>To my knowledge there are no implementations of this typesetting style and I am stumped on how to implement it.</p>
<p>Any ideas as to how this could be done?</p>
<p>Thanks,
Andreas</p>
| [
{
"answer_id": 34580250,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "sed rev rev alias boustrophedon='sed -n \"1{p;b a};{/\\n/!G;s/\\(.\\)\\(.*\\n\\)/&\\2\\1/;//D;s/.//;p};n;p;:a\"' $> echo -en... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44016/"
] |
418,366 | <p>Is it considered better practice to post back to the same controller that did the rendering and redirecting from original controller if necessary? Or is it just the same if one jumps to different controllers from the view?</p>
| [
{
"answer_id": 421733,
"author": "Mike Scott",
"author_id": 43649,
"author_profile": "https://Stackoverflow.com/users/43649",
"pm_score": 3,
"selected": true,
"text": " public ViewResult Foo()\n {\n return View();\n }\n\n [AcceptVerbs(HttpVerbs.Post)]\n public ViewResult Foo( For... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49632/"
] |
418,386 | <p>Perl's <a href="http://search.cpan.org/dist/Data-Rmap" rel="nofollow noreferrer">Data::Rmap</a> allows you to recursively evaluate a BLOCK over a list of data structures (locally setting $_ to each element) and return the list composed of the results of such evaluations. $_ can be used to modify the elements.</p>
<p>This is useful for iterating over things like nested hashes, or hierarchies of arrays of hashes and the like.</p>
| [
{
"answer_id": 419081,
"author": "James A. Rosen",
"author_id": 1190,
"author_profile": "https://Stackoverflow.com/users/1190",
"pm_score": 3,
"selected": true,
"text": "Enumerable Enumerable#map [ {...}, {...}, {...}, ... ].map do |hash|\n hash.something\n do_other_stuff_with(hash)\n ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42223/"
] |
418,399 | <p>For full control of your application, do you prefer a GridView or a HTML table?
And why?</p>
<p>For instance, I need to create on-the-fly hyperlinks-per-row in a GridView/HTML table. What object would be more easy to add that feature (or others like this one)? </p>
<p>Note: I'm creating programmatically my datasets</p>
| [
{
"answer_id": 418434,
"author": "Matt Peterson",
"author_id": 19036,
"author_profile": "https://Stackoverflow.com/users/19036",
"pm_score": 1,
"selected": false,
"text": "<asp:Table>"
},
{
"answer_id": 418795,
"author": "tanathos",
"author_id": 51295,
"author_profile... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2019426/"
] |
418,406 | <p>I'm writing a Catalyst application that's required to have a fairly short session expiration (15 minutes). I'm using the standard Catalyst framework authentication modules, so the user data is stored in the session -- i.e., when your session expires, you get logged out.</p>
<p>Many of the uses of this application will require >15 minutes to complete, so users will frequently submit a form only to find their session state is gone and they're required to log back in.</p>
<p>If this happens I want to preserve the original form submission, and if they log in successfully, continue on and carry out the form submission just as if the session had not expired.</p>
<p>I've got the authentication stuff being handled by an auto() method in the controller -- if you request an action that requires authentication and you're not currently logged in, you get redirected to the login() method, which displays the login form and then processes it once it's submitted. It seems like it should be possible to store the request and any form parameters when the auto method redirects to the login(), and then pull them back out if the login() succeeds -- but I'm not entirely sure of the best way to grab or store this information in a generic/standard/reusable way. (I'm figuring on storing it in the session and then deleting it once it's pulled back out; if that seems like a bad idea, that's something else to address.)</p>
<p>Is there a standard "best practices" or cookbook way to do this?</p>
<p>(One wrinkle: these forms are being submitted via POST.)</p>
| [
{
"answer_id": 418848,
"author": "RET",
"author_id": 14750,
"author_profile": "https://Stackoverflow.com/users/14750",
"pm_score": 2,
"selected": false,
"text": "Catalyst::Plugin::Session->delete_session $c->request->body_parameters create_session delete_session auto Catalyst::Plugin::Se... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39933/"
] |
418,423 | <p>The short form of this question: When, if ever, is it appropriate to use the Forms.Timer in a multithreaded WinForms application?</p>
<p>More specifically, I am architecting an application that uses multiple System.Threading.Timers to launch processes asynchronously, check queues containing the results of those asynchronous processes, and update the statistics to be shown by the application's main form.</p>
<p>In an application like that, is it appropriate to use a Forms.Timer to actually check the application statistics and draw them to the main form or would that just throw a wrench into the application's smooth running?</p>
| [
{
"answer_id": 418453,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 6,
"selected": true,
"text": "Forms.Timer System.Threading.Timer Forms.Timer Threading.Timer"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/418423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5287/"
] |
418,428 | <p>I'm not getting any errors as such just a minor performance issue.</p>
<pre><code>EXPLAIN
SELECT
a.nid,
a.title,
a.uid,
b.parent,
b.weight,
c.name,
d.value
FROM table1 AS a INNER JOIN table2 AS b ON a.vid = b.vid AND a.status = 1
INNER JOIN table3 AS c ON c.uid = a.uid
INNER JOIN table4 AS d ON d.content_id = a.nid AND d.value_type = 'percent' AND d.function = 'average'
</code></pre>
<p>When I look at which tables are being referenced, everything is fine, but from table4 where it should only be selecting the "value" field, I'm getting an ALL being called...</p>
<pre><code>id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE a ref PRIMARY,vid,status,uid,node_status_type,nid status 4 const 1
1 SIMPLE b eq_ref PRIMARY PRIMARY 4 databasename.a.vid 1
1 SIMPLE c eq_ref PRIMARY PRIMARY 4 databasename.a.uid 1 Using where
1 SIMPLE d ALL NULL NULL NULL NULL 2 Using where
</code></pre>
<p>As you can see, it's selecting * from the final table (d). Why is it doing this when I only need ONE field selected from it? Can anyone help me out?</p>
| [
{
"answer_id": 418435,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 4,
"selected": true,
"text": "ALL"
},
{
"answer_id": 423513,
"author": "scronide",
"author_id": 22844,
"author_profile": "https://Stacko... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52214/"
] |
418,430 | <p>After reading the Jinja2 documentation, I'm interested in employing it in future Django projects. However, I'm wondering if anyone has encountered any drawbacks or gotchas when using Jinja2 templates with Django? If so, how did you work around them?</p>
<p>I wouldn't mind hearing about positive experiences either, just to get a good cross section of the best and worst of Jinja2.</p>
| [
{
"answer_id": 7563043,
"author": "Sean",
"author_id": 736571,
"author_profile": "https://Stackoverflow.com/users/736571",
"pm_score": 1,
"selected": false,
"text": "{% spaceless %} # In shell:\nfetch -o myapp/jinja2htmlcompress.py https://raw.github.com/mitsuhiko/jinja2-htmlcompress/mas... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46914/"
] |
418,452 | <p>I am not talking about the highlight colors but the actual colors. I got a color scheme with light background color but the braces/parentheses are barely visible. Anyone knows how to change this?</p>
<p>Btw this is for C# because C++ seems to color braces/parentheses using operator color.</p>
| [
{
"answer_id": 43994785,
"author": "Youngjae",
"author_id": 361100,
"author_profile": "https://Stackoverflow.com/users/361100",
"pm_score": 3,
"selected": false,
"text": "Silver Default"
},
{
"answer_id": 50883012,
"author": "Legends",
"author_id": 2581562,
"author_pr... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51816/"
] |
418,467 | <p>Say I've got a bunch of files that are all >100 lines long. I'd like to trim off the top 14 lines and the bottom 9 lines, leaving only the lines in the middle. This command will trim off the top fourteen:</p>
<pre><code>cat myfile.txt | tail -n +15
</code></pre>
<p>Is there another command I can pipe through to trim off the bottom 9 without explicitly passing the length of the file?</p>
<p>Edited to add: My version of head (Mac OS 10.5) doesn't accept a negative number of lines as a parameter.</p>
| [
{
"answer_id": 418473,
"author": "Jeremy Bourque",
"author_id": 2192597,
"author_profile": "https://Stackoverflow.com/users/2192597",
"pm_score": 0,
"selected": false,
"text": "head tail"
},
{
"answer_id": 418481,
"author": "Rob Hruska",
"author_id": 29995,
"author_pr... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20021/"
] |
418,497 | <p>I need to load an XML file and convert the contents into an object-oriented Python structure. I want to take this:</p>
<pre><code><main>
<object1 attr="name">content</object>
</main>
</code></pre>
<p>And turn it into something like this:</p>
<pre><code>main
main.object1 = "content"
main.object1.attr = "name"
</code></pre>
<p>The XML data will have a more complicated structure than that and I can't hard code the element names. The attribute names need to be collected when parsing and used as the object properties.</p>
<p>How can I convert XML data into a Python object?</p>
| [
{
"answer_id": 418728,
"author": "Soviut",
"author_id": 46914,
"author_profile": "https://Stackoverflow.com/users/46914",
"pm_score": 3,
"selected": false,
"text": "from BeautifulSoup import BeautifulSoup\n\nxml = \"\"\"\n<main>\n <object attr=\"name\">content</object>\n</main>\n\"\"\... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46981/"
] |
418,503 | <p>Is there a decent way with static HTML/XHTML to create common header/footer files to be displayed on each page of a site? I know you can obviously do this with PHP or server side directives, but is there any way of doing this with absolutely no dependencies on the server stitching everything together for you?</p>
<p>Edit: All very good answers and was what I expected. HTML is static, period. No real way to change that without something running server side or client side. I've found that Server Side Includes seem to be my best option as they are very simple and don't require scripting.</p>
| [
{
"answer_id": 418519,
"author": "Keltia",
"author_id": 16143,
"author_profile": "https://Stackoverflow.com/users/16143",
"pm_score": 1,
"selected": false,
"text": "sed m4"
},
{
"answer_id": 418540,
"author": "DanSingerman",
"author_id": 43965,
"author_profile": "http... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194/"
] |
418,521 | <p>We need to poll a web page every 5 minutes and the web page is growing rather large. The web page is a directory listing and we need the last line (to get a file name). What is the best way to get just this last line?</p>
<p>(If this was a local file I could position back a little relative to the end of file and read).</p>
| [
{
"answer_id": 418547,
"author": "Soviut",
"author_id": 46914,
"author_profile": "https://Stackoverflow.com/users/46914",
"pm_score": 0,
"selected": false,
"text": "import urllib2\nfrom BeautifulSoup import BeautifulSoup\n\npage = urllib2.urlopen(url)\nhtml = page.read()\nsoup = Beautifu... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
418,529 | <p>I've gotten to play a single sound in the iPhone app I've started, but I now desire to play multiple sounds based on a button. To create a separate set of .m and .h files for each audio sounds, and then including them all, doesn't seem the most efficient way to tackle this in terms of coding...then again, I'm just starting out with Cocoa and only just completed my first app ever.</p>
<p>Any help is appreciated. The key here is multiple sounds, each triggered by its own button or image. Thanks.</p>
| [
{
"answer_id": 418718,
"author": "Michael Pryor",
"author_id": 245,
"author_profile": "https://Stackoverflow.com/users/245",
"pm_score": 2,
"selected": false,
"text": "-(void)Play:(NSString*)sSoundFile {\n // play sound file here\n}\n"
},
{
"answer_id": 418754,
"author": "... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
418,545 | <p>I'm in need of a C++ (pseudo, i don't care) random number generator that can get me different numbers every time I call the function. This could be simply the way I seed it, maybe there's a better method, but every random generator I've got doesn't generate a new number every time it's called. I've got a need to get several random numbers per second on occasion, and any RNG i plug in tends to get the same number several times in a row.
Of course, I know why, because it's seeded by the second, so it only generates a new number every second, but I need to, somehow, get a new number on every call. Can anyone point me in the right direction? </p>
| [
{
"answer_id": 418554,
"author": "Eclipse",
"author_id": 8701,
"author_profile": "https://Stackoverflow.com/users/8701",
"pm_score": 3,
"selected": false,
"text": "srand() rand()"
},
{
"answer_id": 418555,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"autho... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48957/"
] |
418,588 | <p>I read that compiler can enforce dbc at compile time.. How does it do it?</p>
| [
{
"answer_id": 418608,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 0,
"selected": false,
"text": " foo(a);\n function foo(a:int) is\n assert 0 < a && a < 128\n ...\n end\n"
},
{
"answer_id": 41... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30917/"
] |
418,591 | <p>It's been a while since I used GTK+, and the last time I did was in C, not using gtkmm and C++ as I am now. Anyway, I have what I think should be an easy problem to solve:</p>
<p>I have a pop-up menu consisting of a list of radio buttons, and when I click one of them I want some action to occur. The code goes like this:</p>
<pre><code> Gtk::RadioMenuItem::Group group;
for ( size_t i = 1; i < LH_MAX; ++i )
{
Gtk::RadioMenuItem* pItem = new Gtk::RadioMenuItem( group, names[i], names[i] );
pItem->set_name( names[i] );
pItem->signal_activate().connect( sigc::mem_fun(*this, &MyClass::on_item_activated) );
pItem->show();
m_Menu.append( *Gtk::manage(pItem) );
}
</code></pre>
<p>The only problem I see is that <code>MyClass::on_item_activated</code> gets called twice when a previously-unselected radio button is chosen from the menu. It's called only once when the already-selected radio button is clicked.</p>
<p>I'm guessing that the first firing is to say "something is no longer activate," and the second is for the new radio button activation. Whether I'm right or wrong, the question is the same: how best can I have my handler only take action once per click? Either I need the handler to get called only once, or I need something to check from inside it to know if the callback is a "duplicate" or not.</p>
| [
{
"answer_id": 430541,
"author": "jonner",
"author_id": 78437,
"author_profile": "https://Stackoverflow.com/users/78437",
"pm_score": 0,
"selected": false,
"text": "signal_toggled() signal_activate()"
},
{
"answer_id": 438608,
"author": "Community",
"author_id": -1,
"... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4323/"
] |
418,596 | <p>How do I increment a step value to be processed when the page loads? For example, in the code below the viewstate variable is not incremented until after Page_Load, due to the ASP.NET page lifecycle.</p>
<pre><code>protected void Page_Load(object sender, EventArgs e)
{
switch ((int)ViewState["step"])
{
//do something different for each step
}
}
protected void btnIncrementStep_Click(object sender, EventArgs e)
{
//when the button is clicked, this does not fire
//until after page_load finishes
ViewState["step"] = (int)ViewState["step"] + 1;
}
</code></pre>
| [
{
"answer_id": 418689,
"author": "M4N",
"author_id": 19635,
"author_profile": "https://Stackoverflow.com/users/19635",
"pm_score": 0,
"selected": false,
"text": "private int Step\n{\n get { return (int)Session[\"step\"]; }\n set { Session[\"step\"] = value; }\n}\n\nprotected void Page_... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29426/"
] |
418,600 | <p>How does the transaction scope work? How does it know when there is another context being used already and how might I implement another kind of scope in my code.</p>
<p>I'm primarily a vb.net developer but I can read the c# if you write in that.</p>
<p>In case the above was too vague:</p>
<p>I understand what system.transactions does and how to use it. What I want to know is how to create something similar, my own library that I can wrap around some code that can handle it in the same manner as the system.transactions scope does. I plan on using this with a caching model and it would greatly enhance it. I'm looking for details on how transaction scope knows for example that there is a parent scope and so it can attach to it and such, or that a commit then needs to take place at a higher level or in a higher contact.</p>
<p>For example, if I have the following</p>
<pre><code>using scope1 as new system.transactions.scope
using scope2 as new system.transactions.scope
using scope3 as new system.transactions.scope
scope3.commit
end using
scope2.commit
end using
end using
</code></pre>
<p>Scope1 will not commit and so neither will scope2 or scope3 since the parent to them all is the context of scope1. I'd like to be able to set this up with my own libraries.</p>
| [
{
"answer_id": 423388,
"author": "MandyK",
"author_id": 52717,
"author_profile": "https://Stackoverflow.com/users/52717",
"pm_score": 0,
"selected": false,
"text": "[ThreadStatic]\nprivate static Context scopeContextThingy;\n scopeContextThingy == null"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/418600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35331/"
] |
418,609 | <p>Here's an example of the query I'm trying to convert to LINQ:</p>
<pre><code>SELECT *
FROM Users
WHERE Users.lastname LIKE '%fra%'
AND Users.Id IN (
SELECT UserId
FROM CompanyRolesToUsers
WHERE CompanyRoleId in (2,3,4) )
</code></pre>
<p>There is a FK relationship between <code>CompanyRolesToUsers</code> and <code>Users</code>, but it's a many to many relationship and <code>CompanyRolesToUsers</code> is the junction table.</p>
<p>We already have most of our site built, and we already have most of the filtering working by building Expressions using a PredicateExtensions class.</p>
<p>The code for the straightforward filters looks something like this:</p>
<pre><code> if (!string.IsNullOrEmpty(TextBoxLastName.Text))
{
predicateAnd = predicateAnd.And(c => c.LastName.Contains(
TextBoxLastName.Text.Trim()));
}
e.Result = context.Users.Where(predicateAnd);
</code></pre>
<p>I'm trying to add a predicate for a subselect in another table. (<code>CompanyRolesToUsers</code>)</p>
<p>What I'd like to be able to add is something that does this:</p>
<pre><code>int[] selectedRoles = GetSelectedRoles();
if( selectedRoles.Length > 0 )
{
//somehow only select the userid from here ???:
var subquery = from u in CompanyRolesToUsers
where u.RoleID in selectedRoles
select u.UserId;
//somehow transform this into an Expression ???:
var subExpression = Expression.Invoke(subquery);
//and add it on to the existing expressions ???:
predicateAnd = predicateAnd.And(subExpression);
}
</code></pre>
<p>Is there any way to do this? It's frustrating because I can write the stored procedure easily, but I'm new to this LINQ thing and I have a deadline. I haven't been able to find an example that matches up, but I'm sure it's there somewhere.</p>
| [
{
"answer_id": 418638,
"author": "Noah",
"author_id": 47496,
"author_profile": "https://Stackoverflow.com/users/47496",
"pm_score": 3,
"selected": false,
"text": "from u in Users\njoin c in (\n from crt in CompanyRolesToUsers\n where CompanyRoleId == 2\n || CompanyRoleId == 3\n ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52236/"
] |
418,613 | <p>In the VS debugger, un-caught exceptions result in the program breaking at the point the exception is throw (or near enough) and in a state that lets you look at all the stack frames and there local variables up to that point.</p>
<p>Is there a way to get this same result (break at throw) but for an exception is caught at a particular point? I'm not interested in doing this for ALL exceptions or even all exception of a given type (that could get useless real quick) but if I could do it for a single try or catch block I'd be happy</p>
<p>somewhat related:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/201182/">How to work around ‘Break when thrown’</a> (Is per class and I'm looking for per try/catch block)</li>
</ul>
| [
{
"answer_id": 418666,
"author": "jcollum",
"author_id": 30946,
"author_profile": "https://Stackoverflow.com/users/30946",
"pm_score": 2,
"selected": false,
"text": "try { }\ncatch (Exception exc)\n{ \n throw; // <-- breakpoint here\n} \n"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/418613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] |
418,622 | <p>For various reasons, I'm stuck in Access 97 and need to get only the path part of a full pathname.</p>
<p>For example, the name</p>
<pre><code>c:\whatever dir\another dir\stuff.mdb
</code></pre>
<p>should become</p>
<pre><code>c:\whatever dir\another dir\
</code></pre>
<p>This site has some suggestions on how to do it:
<a href="http://www.ammara.com/access_image_faq/parse_path_filename.html" rel="noreferrer">http://www.ammara.com/access_image_faq/parse_path_filename.html</a></p>
<p>But they seem rather hideous. There must be a better way, right?</p>
| [
{
"answer_id": 419224,
"author": "John Mo",
"author_id": 38988,
"author_profile": "https://Stackoverflow.com/users/38988",
"pm_score": 5,
"selected": false,
"text": "FileSystemObject Microsoft Scripting Runtime Function StripFilename(sPathFile As String) As String\n\n'given a full path a... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42219/"
] |
418,650 | <p>In an oscommerce site I have the following:</p>
<p>Server response = Content-type: text/html;charset=UTF-8</p>
<p>and I want: Content-type: text/html;charset=ISO-8859-1</p>
<p>How and where do I set this up. </p>
<hr>
<p>Html looks like this on the page:</p>
<pre><code><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="LTR" lang="nl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</code></pre>
<p>Changing it to: utf-8 doesnt solve the problem. </p>
| [
{
"answer_id": 419224,
"author": "John Mo",
"author_id": 38988,
"author_profile": "https://Stackoverflow.com/users/38988",
"pm_score": 5,
"selected": false,
"text": "FileSystemObject Microsoft Scripting Runtime Function StripFilename(sPathFile As String) As String\n\n'given a full path a... | 2009/01/06 | [
"https://Stackoverflow.com/questions/418650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30600/"
] |
418,674 | <p>In PHP you have the create_function() function which creates a unique named lambda function like this:</p>
<pre><code>$myFunction = create_function('$foo', 'return $foo;');
$myFunction('bar'); //Returns bar
</code></pre>
<p>Is this actually any better (apart from being more easy) then just doing:</p>
<pre><code>do{
$myFunction = 'createdFunction_'.rand();
}
while(function_exists($myFunction));
eval("function $myFunction(\$foo) { return \$foo; }");
$myFunction('bar'); //Returns bar
</code></pre>
<p>Is create_function really better? (apart from the fact that it is more easy)</p>
| [
{
"answer_id": 418713,
"author": "dreamlax",
"author_id": 10320,
"author_profile": "https://Stackoverflow.com/users/10320",
"pm_score": 2,
"selected": false,
"text": "create_function eval"
}
] | 2009/01/06 | [
"https://Stackoverflow.com/questions/418674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35197/"
] |
418,741 | <p>I'm looking for details on the DEBUG HTTP verb.<br>
It's clear to me that this is used for remote debugging - though I'm not even sure if it's for IIS or ASP.NET... </p>
<p>If I want to access this interface directly - i.e. not through Visual Studio, but sending these commands manually - what do I need to know? What are the commands for it?<br>
I'm also interested in misuse cases, if you have any information on that...</p>
| [
{
"answer_id": 2278963,
"author": "AviD",
"author_id": 10080,
"author_profile": "https://Stackoverflow.com/users/10080",
"pm_score": 4,
"selected": true,
"text": "DEBUG DEBUG start-debug stop-debug DEBUG <compilation debug=\"true\"> DEBUG /foo.aspx HTTP/1.0\nAccept: */ *\nHost: www.examp... | 2009/01/07 | [
"https://Stackoverflow.com/questions/418741",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10080/"
] |
418,743 | <p>I am working with legacy systems at the moment, and a lot of work involves breaking up delimited strings and testing against certain rules.</p>
<p>With this string, how could I return "Active" in a back reference and search terms, stopping when it hits the first caret (^)?:<br /></p>
<pre><code>Active^20080505^900^LT^100
</code></pre>
<p>Can it be done with an inclusion in the regex of this "<code>(.+)</code>" ? The reason I ask is that the actual regex "<code>(.+)</code>" is defined in a database as cutting up these messages and their associated rules can be set from a front-end system. The content could be anything ('Active' in this case), that's why ".+" has been used in this case.</p>
<p>Rule: The caret sign cannot feature between the brackets, as that would result with it being stored in the database field too, and it is defined elsewhere in another system field.</p>
<p>If you have a better suggestion than "<code>(.+)</code>" will be happy to hear it.</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 418745,
"author": "Gordon Wilson",
"author_id": 23071,
"author_profile": "https://Stackoverflow.com/users/23071",
"pm_score": 4,
"selected": true,
"text": "(.+?)\\^\n (.+) (.+?)\\^(.+)\n"
},
{
"answer_id": 418753,
"author": "dreamlax",
"author_id": 10320,
... | 2009/01/07 | [
"https://Stackoverflow.com/questions/418743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41211/"
] |
418,744 | <p>I'm writing an app with a MySQL table that indexes 3 columns. I'm concerned that after the table reaches a significant amount of records, the time to save a new record will be slow. Please inform how best to approach the indexing of columns.</p>
<p>UPDATE</p>
<blockquote>
<p>I am indexing a point_value, the
user_id, and an event_id, all required
for client-facing purposes. For an
instance such as scoring baseball runs
by player id and game id. What would
be the cost of inserting about 200 new
records a day, after the table holds
records for two seasons, say 72,000
runs, and after 5 seasons, maybe a
quarter million records? Only for
illustration, but I'm expecting to
insert between 25 and 200 records a
day.</p>
</blockquote>
| [
{
"answer_id": 418785,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 5,
"selected": true,
"text": "point_value user_id event_id"
}
] | 2009/01/07 | [
"https://Stackoverflow.com/questions/418744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33287/"
] |
418,749 | <p>I have an ASM script that displays date(day, month, year) and time(hours, minutes, seconds).</p>
<p>This prints the current datetime on the DOS-box.
Thing is, it's static. What I want to do is make it dynamic, meaning I have to write the new value in the exact place where the current value is standing on the screen. How do you do this in ASM?</p>
<p>I don't have any clue at all and google hasn't been my friend for this.</p>
| [
{
"answer_id": 419008,
"author": "BoltBait",
"author_id": 20848,
"author_profile": "https://Stackoverflow.com/users/20848",
"pm_score": 3,
"selected": true,
"text": " MOV DX,1629H ; (LINE 16H, COL 29H)\n MOV AH,2 ; Move cursor to DH... | 2009/01/07 | [
"https://Stackoverflow.com/questions/418749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11795/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.