qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
305,519 | <p>In an impersonation scenario related to Sharepoint I need to execute some code in a separate process (the process will run in the context of a certain user). I do not want to launch a separate application, basically I want to do a "run as" on just a method.</p>
| [
{
"answer_id": 305558,
"author": "Gunnar Steinn",
"author_id": 33468,
"author_profile": "https://Stackoverflow.com/users/33468",
"pm_score": 2,
"selected": false,
"text": "...\nWrapperImpersonationContext context = new WrapperImpersonationContext(domain, username, password);\ncontext.Ent... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1360/"
] |
305,523 | <p>I am writing a QT application and I need to embed a terminal (we say,xterm) within a QDialog, like some KDE application (see kdevelop/kate/...).</p>
<p>I've been trying with:
- QX11EmbedContainer placed into the QLayout of my QDialog
- QProcess for the program I want to excecute</p>
<p>I expect the QProcess running within the QX11EmbedContainer, but it does not work.</p>
<p>The problem is that I can't put the xterm into the QX11EmbedContainer, the only thing I obtain is an xterm window (unfortunately separated from my QDialog).
Does anybody got the same problem?</p>
| [
{
"answer_id": 307752,
"author": "David Dibben",
"author_id": 5022,
"author_profile": "https://Stackoverflow.com/users/5022",
"pm_score": 0,
"selected": false,
"text": " QProcess process(&container);\n QString executable(app.arguments()[1]);\n QStringList arguments;\n arguments << \"-int... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39339/"
] |
305,527 | <p>I cannot figure out a way to disable a container AND its children in Swing. Is Swing really missing this basic feature?</p>
<p>If I do setEnabled(false) on a container, its children are still enabled.</p>
<p>My GUI structure is pretty complex, and doing a traversion of all elements below the container is not an option. Neither is a GlassPane on top of the container (the container is not the entire window).</p>
| [
{
"answer_id": 305551,
"author": "Michael Myers",
"author_id": 13531,
"author_profile": "https://Stackoverflow.com/users/13531",
"pm_score": 4,
"selected": false,
"text": "JXLayer.setLocked(true)"
},
{
"answer_id": 2214729,
"author": "Dylan",
"author_id": 267889,
"aut... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15932/"
] |
305,529 | <p>Greetings to all! This is my first question here on stackoverflow. I have a WPF application that I am writing for the fellow developers in my department, and there are a couple of settings that I need to check for at startup and update if they are not set (one is the location of an executable on the users computer, we all have it, just not in the same place). So when my app starts up for the first time, I need to pop a filechooser to have them select the location.</p>
<p>What I need to do is write the location of that to the appSettings, but I just can't seem to get it, and I searched Google pretty hard last night trying to find a way to do it. Most answers I saw involved reading the app.config file as straight XML, and that doesn't seem right.</p>
<p>So, I just need a way to update values in the appSettings for my application. I can read from them just fine, just haven't figured out how to write to them. Thanks so much!</p>
<p>James</p>
| [
{
"answer_id": 305547,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 6,
"selected": true,
"text": "Configuration oConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);\noConfig.AppSettings.Settings[\"... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39337/"
] |
305,536 | <pre><code>// A Mutex allows threads mutually exclusive access to a resource.
//-----------------------------------------------------------------------
class Mutex
{
private:
CRITICAL_SECTION m_mutex;
public:
Mutex() { InitializeCriticalSection(&m_mutex); }
~Mutex() { DeleteCriticalSection(&m_mutex); }
void acquire() { EnterCriticalSection(&m_mutex); }
void release() { LeaveCriticalSection(&m_mutex); }
};
</code></pre>
<p>Using the Entrek Codesnitch software to debug and test for any memory leaks, etc., it reports the following error:</p>
<pre><code>InitializeCriticalSection Error: lpCriticalSection (0x000387d4) points to an invalid
memory location (0x00018984) Mutex::Mutex in lockmutex.h, line 29
</code></pre>
<p>Maybe all my sleepless nights are finally getting to me. But I don't understand what it's exactly complaining about. Any ideas?</p>
| [
{
"answer_id": 305704,
"author": "Tim Lesher",
"author_id": 14942,
"author_profile": "https://Stackoverflow.com/users/14942",
"pm_score": 3,
"selected": false,
"text": "struct Customer {\n char * name;\n};\n\nextern void greetCustomer(Customer* c);\n\nclass CheckoutLine {\n private:\... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7599/"
] |
305,538 | <p>I'm working on a webserver that I didn't totally set up and I'm trying to figure out which parts of a web page are being sent encrypted and which aren't. Firefox tells me that parts of the page are encrypted, but I want to know what, specifically, is encrypted.</p>
| [
{
"answer_id": 7691014,
"author": "Professor Falken",
"author_id": 888986,
"author_profile": "https://Stackoverflow.com/users/888986",
"pm_score": 4,
"selected": false,
"text": "Response Headers \nServer nginx/0.8.54\nDate Fri, 07 Oct 2011 17:35:16 GMT\nContent-Type text/html\nCo... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8092/"
] |
305,552 | <p>Need to locate the following pattern:</p>
<p>The letter I followed by a space then three alpha numerics followed by a space</p>
<p>"I ALN "
"I H21 "
"I 31M "</p>
<p>these items are also followed by a lat/lon that is trapped by this expression:</p>
<p>Dim regex As New Regex("\d{6} \d{7}")</p>
<p>Can the expressions be combined to return a match that would look like:</p>
<p>"H21 ###### #######"</p>
<p>Thanks,</p>
<p>Dave</p>
| [
{
"answer_id": 305560,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 1,
"selected": false,
"text": "I ([a-zA-Z\\d]{3} \\d{6} \\d{7})\n"
},
{
"answer_id": 305573,
"author": "shelfoo",
"author_id": 3444,
... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38349/"
] |
305,554 | <p>Assume I have a function like this:</p>
<pre><code>MyClass &MyFunction(void)
{
static MyClass *ptr = 0;
if (ptr == 0)
ptr = new MyClass;
return MyClass;
}
</code></pre>
<p>The question is at program exit time, will the ptr variable ever become invalid (i.e. the contents of that ptr are cleaned up by the exiting process)? I realize that this function leaks, but it is only an example for simplicity.</p>
<p>The same question also applies to other primitives besides pointers as well. How about if I have a static integer, does the value of that integer always persist throughout exit or is variable due to static destruction order issues?</p>
<p>EDIT:</p>
<p>Just to clarify, I want to know what actually happens to the contents of the static pointer (or any other primitive type like an int or a float) and not to the memory it is pointing to. For instance, imagine that the ptr points to some memory address which I want to check in the destructor of some other static class. Can I rely on the fact that the contents of the ptr won't be changed (i.e. that the pointer value won't be cleaned up during the static destruction process)?</p>
<p>Thanks,
Joe</p>
| [
{
"answer_id": 305569,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://Stackoverflow.com/users/33686",
"pm_score": 2,
"selected": false,
"text": "MyClass"
},
{
"answer_id": 306018,
"author": "Martin York",
"author_id": 14065,
"author_profile": "htt... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7587/"
] |
305,555 | <p>How to get the last selected item in a .Net Forms multiselect ListBox? Apparently if I select an item in the listbox and then select another 10 the selected item is the first one.</p>
<p>I would like to obtain the last element that I selected/deselected.</p>
| [
{
"answer_id": 305597,
"author": "flesh",
"author_id": 27805,
"author_profile": "https://Stackoverflow.com/users/27805",
"pm_score": 3,
"selected": false,
"text": "ListItem i = list.SelectedItems[list.SelectedItems.Length-1];\n"
},
{
"answer_id": 305601,
"author": "Tomalak",
... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18631/"
] |
305,568 | <p>Excuting the line of SQL:</p>
<pre><code>SELECT *
INTO assignment_20081120
FROM assignment ;
</code></pre>
<p>against a database in oracle to back up a table called assignment gives me the following ORACLE error:
ORA-00905: Missing keyword</p>
| [
{
"answer_id": 305584,
"author": "Justin Cave",
"author_id": 10397,
"author_profile": "https://Stackoverflow.com/users/10397",
"pm_score": 5,
"selected": false,
"text": "ASSIGNMENT"
},
{
"answer_id": 1485696,
"author": "Uwe Keim",
"author_id": 107625,
"author_profile"... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
305,574 | <p>This question follows on from <a href="https://stackoverflow.com/questions/299114/can-i-search-for-php-class-members-and-methods-with-vim-star-search">this vim search question</a></p>
<p>I have a setting in my .vimrc which excludes $ as a valid part of a word:</p>
<pre><code>set iskeyword-=$
</code></pre>
<p>This works fine for most files but isn't working in PHP. I assume it is being overwritten by a php plugin, but since plugins are loaded after .vimrc I can't work out how to overwrite this setting. I'd prefer not to have to type </p>
<pre><code>:set isk-=$
</code></pre>
<p>every time I load a PHP file.</p>
<p>Any suggestions?</p>
<p>( Ubuntu 8.04 / Vim 7.1.138 if it matters )</p>
<p><strong>Summary</strong></p>
<p>Two excellent answers, thank you!</p>
<p>I went with <a href="https://stackoverflow.com/users/18771/tomalak">tomalak</a>'s because it was less effort, and added the following to my ~/.vimrc</p>
<pre><code>autocmd FileType php setlocal isk-=$
</code></pre>
<p>but thanks also to <a href="https://stackoverflow.com/questions/305574/can-i-stop-settings-in-vimrc-from-being-overwritten-by-plugins#305820">Luc Hermitte</a>. Putting the settings in a ~/vim/after/ftplugin/php.vim file also worked.</p>
<p><em>:help autocmd</em> and <em>:help after-directory</em> both helped too</p>
| [
{
"answer_id": 305627,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 4,
"selected": true,
"text": "set isk-=$"
},
{
"answer_id": 305820,
"author": "Luc Hermitte",
"author_id": 15934,
"author_profile": "... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20074/"
] |
305,579 | <p>In your practice, how do you effectively track and manage technical debt? </p>
<p>Is there a specific metric, like <a href="http://jamesshore.com/Blog/An-Approximate-Measure-of-Technical-Debt.html" rel="nofollow noreferrer">SLOC</a>, that you use?</p>
<p>How do you visually display your results to stakeholders and management? </p>
<p>What benefits have you seen in the process?</p>
| [
{
"answer_id": 310809,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 1,
"selected": false,
"text": "@todo"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/305579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
305,591 | <p>This seems like something simple, but I can't seem to figure it out! I'm trying to get 2-way data-binding to work on an ASP.net page with a check box as one of the columns. How do I get the updated values (from check boxes) back from the gridview ?????</p>
<p>Here is my data type:</p>
<pre><code>[Serializable]
public class UserRequirements
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string UserId { get; set; }
public string Email { get; set; }
public bool ThingRequired { get; set; }
}
</code></pre>
<p>My markup looks something like this:</p>
<pre><code><form id="form1" method="post" runat="server" >
<asp:GridView ID="UserTable" runat="server" AutoGenerateColumns="false" >
<Columns>
...
<asp:TemplateField HeaderText="Required ?">
<ItemTemplate>
<asp:CheckBox id="chkBox1" runat="server" on
Text ="Required"
checked='<%# DataBinder.Eval(Container.DataItem,"ThingRequired") %>'>
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button id="thebutton" Text="Save Changes" OnClick="UpdateRequirements" runat="server" CausesValidation=false />
</form>
</code></pre>
<p>My code behind looks something like this:</p>
<pre><code> List<UserRequirements > _userList = new List<UserRequirements >();
protected void Page_Load(object sender, EventArgs e)
{
_userList = data_layer.GetUserRequirments();
this.UserTable.DataSource = _userList;
this.UserTable.DataBind();
}
</code></pre>
<p>Eventually, I will call something like this, but I don't know where this should go or how to get the values back from the gridview:</p>
<pre><code>void UpdateRequirements(object sender, EventArgs e)
{
_userList = ???????????? // How do I get the data?
data_layer.UpdateUserRequirements( _userList );
}
</code></pre>
| [
{
"answer_id": 305617,
"author": "MysticSlayer",
"author_id": 28139,
"author_profile": "https://Stackoverflow.com/users/28139",
"pm_score": 2,
"selected": false,
"text": " if (chkBx != null && chkBx.Checked)\n {\n /// put your code here\n }\n }\n"
},... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5208/"
] |
305,605 | <p>I'm writing a simple .bat file and I've run into some weird behavior. There are a couple places where I have to do a simple if/else, but the code inside the blocks don't seem to be working correctly.</p>
<p>Here's a simple case that demonstrates the error:</p>
<pre><code>@echo off
set MODE=FOOBAR
if "%~1"=="" (
set MODE=all
echo mode: %MODE%
) else (
set MODE=%~1
echo mode: %MODE%
)
echo mode: %MODE%
</code></pre>
<p>The output I'm getting is:</p>
<pre><code>C:\>test.bat test
mode: FOOBAR
mode: test
</code></pre>
<p>Why is the echo inside the code block not getting the new value of the variable? In the actual code I'm writing I need to build a few variables and reference them within the scope of the if/else. I could switch this to use labels and gotos instead of an if/else, but that doesn't seem nearly as clean.</p>
<p>What causes this behavior? Is there some kind of limit on variables within code blocks?</p>
| [
{
"answer_id": 305640,
"author": "user33675",
"author_id": 33675,
"author_profile": "https://Stackoverflow.com/users/33675",
"pm_score": 6,
"selected": true,
"text": " set VAR=before\n if \"%VAR%\" == \"before\" (\n set VAR=after\n if \"%VAR%\" == \"after\" @echo If you see this,... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1409/"
] |
305,611 | <p>Does anyone know of any C container libraries? I am looking for something which gives standard implementations of linked lists, arrays, hash tables etc, much in the same way as the C++ STL does. Key concerns are:</p>
<ol>
<li>Client code should be able to create containers for multiple different data types without modifying the library.</li>
<li>The interface for creating and using the containers should be intuitive.</li>
</ol>
| [
{
"answer_id": 902923,
"author": "user105991",
"author_id": 105991,
"author_profile": "https://Stackoverflow.com/users/105991",
"pm_score": 2,
"selected": false,
"text": "#include \"queue.h\""
},
{
"answer_id": 902960,
"author": "Lear",
"author_id": 80223,
"author_pro... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23435/"
] |
305,615 | <p>When measuring network latency (time ack received - time msg sent) in any protocol over TCP, what timer would you recommend to use and why? What resolution does it have? What are other advantages/disadvantages?</p>
<p>Optional: how does it work?</p>
<p>Optional: what timer would you NOT use and why?</p>
<p>I'm looking mostly for Windows / C++ solutions, but if you'd like to comment on other systems, feel free to do so.</p>
<p>(Currently we use GetTickCount(), but it's not a very accurate timer.)</p>
| [
{
"answer_id": 306101,
"author": "grieve",
"author_id": 34329,
"author_profile": "https://Stackoverflow.com/users/34329",
"pm_score": 4,
"selected": true,
"text": "#include <sys/time.h>\n\nint main()\n{\n timespec ts;\n // clock_gettime(CLOCK_MONOTONIC, &ts); // Works on FreeBSD\n ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22724/"
] |
305,637 | <p>I need to signal a running application (Windows service) when certain things happen in SQL Server (2005). Is there a possibility to send a message from a trigger to an external application on the same system?</p>
| [
{
"answer_id": 305660,
"author": "vfilby",
"author_id": 24279,
"author_profile": "https://Stackoverflow.com/users/24279",
"pm_score": 1,
"selected": false,
"text": "CREATE PROC shutdown10\nAS\nEXEC xp_cmdshell 'net send /domain:SQL_USERS ''SQL Server shutting down \n in 10 minutes. No ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
305,647 | <p>My application caches some data on disk. Because the cache may be large, it should not be stored on a network drive. It should persist between invocations of the application. I have a mechanism for the user to choose a location, but would like the default to be sensible and "the right thing" for the platform.</p>
<p>What is the appropriate location for such a cache? Is there an API for determining the appropriate location? How do I call it from Python?</p>
| [
{
"answer_id": 305662,
"author": "Tim Pietzcker",
"author_id": 20670,
"author_profile": "https://Stackoverflow.com/users/20670",
"pm_score": 1,
"selected": false,
"text": "tempfile"
},
{
"answer_id": 305763,
"author": "Tim Pietzcker",
"author_id": 20670,
"author_profi... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17498/"
] |
305,651 | <p>I've seen this syntax a couple times now, and it's beginning to worry me,</p>
<p>For example:</p>
<pre><code>iCalendar iCal = new iCalendar();
Event evt = iCal.Create<Event>();
</code></pre>
| [
{
"answer_id": 305655,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": false,
"text": "public T Create<T>()\n"
},
{
"answer_id": 305675,
"author": "mmx",
"author_id": 33708,
"author_profi... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31765/"
] |
305,665 | <p>Using C# and the .Net framework 2.0. I have an MDI application and need to handle dragover/dragdrop events. I have a list docked to the left on my application and would like to be able to drag an item from the list and drop it in the MDI client area and have the correct MDI child for the item open. I can't seem to figure out where to attach the handler. I've tried attaching to the main form's events and the MdiClient that is part of the form, but neither event handler seems to get called when I expect them to. </p>
<p>I'm also using an Infragistics Tabbed MDI Manager, so I'm not sure if that's affecting it.</p>
| [
{
"answer_id": 4013546,
"author": "Shlomi Loubaton",
"author_id": 428831,
"author_profile": "https://Stackoverflow.com/users/428831",
"pm_score": 0,
"selected": false,
"text": "...\nusing System.Linq;\n...\n\npublic partial class Form1 : Form\n{\n MdiClient mdi_client;\n public For... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33724/"
] |
305,673 | <p>Essentially, I have to get a flat file into a database. The flat files come in with the first two characters on each line indicating which type of record it is.</p>
<p>Do I create a class for each record type with properties matching the fields in the record? Should I just use arrays?</p>
<p>I want to load the data into some sort of data structure before saving it in the database so that I can use unit tests to verify that the data was loaded correctly.</p>
<p>Here's a sample of what I have to work with (BAI2 bank statements):</p>
<pre><code>01,121000358,CLIENT,050312,0213,1,80,1,2/
02,CLIENT-STANDARD,BOFAGB22,1,050311,2359,,/
03,600812345678,GBP,fab1,111319005,,V,050314,0000/
88,fab2,113781251,,V,050315,0000,fab3,113781251,,V,050316,0000/
88,fab4,113781251,,V,050317,0000,fab5,113781251,,V,050318,0000/
88,010,0,,,015,0,,,045,0,,,100,302982205,,,400,302982205,,/
16,169,57626223,V,050311,0000,102 0101857345,/
88,LLOYDS TSB BANK PL 779300 99129797
88,TRF/REF 6008ABS12300015439
88,102 0101857345 K BANK GIRO CREDIT
88,/IVD-11 MAR
49,1778372829,90/
98,1778372839,1,91/
99,1778372839,1,92
</code></pre>
| [
{
"answer_id": 305692,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "https://Stackoverflow.com/users/26479",
"pm_score": 2,
"selected": true,
"text": "record.ClientReference\n"
},
{
"answer_id": 305741,
"author": "Steve B.",
"author_id": 19479,
"autho... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/681/"
] |
305,688 | <p>I'm pretty sure the answer to this is no. I know that I can write</p>
<blockquote>
<p>if lcase(strFoo) = lcase(request.querystring("x")) then...</p>
</blockquote>
<p>or use inStr, but I just want to check there isn't some undocumented setting buried in the registry or somewhere that makes the content of VBScript strings behave consistently with the rest of the scripting language!</p>
<p>Thanks
Dan</p>
| [
{
"answer_id": 305753,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": 3,
"selected": false,
"text": "Dim dicList : Set dicList = CreateObject(\"Scripting.Dictionary\")\nDim strTest\n\ndicList.CompareMode = 0 ' Binary ie case ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21203/"
] |
305,690 | <p>I am working on a tool where I need to convert string values to their proper object types. E.g. convert a string like <code>"2008-11-20T16:33:21Z"</code> to a <code>DateTime</code> value. Numeric values like <code>"42"</code> and <code>"42.42"</code> must be converted to an <code>Int32</code> value and a <code>Double</code> value respectively. </p>
<p>What is the best and most efficient approach to detect if a string is an integer or a number? Are <code>Int32.TryParse</code> or <code>Double.TryParse</code> the way to go? </p>
| [
{
"answer_id": 305703,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "switch"
},
{
"answer_id": 305707,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "h... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27393/"
] |
305,780 | <p>I am porting some queries from Access to T-SQL and those who wrote the queries used the Avg aggregate function on datetime columns. This is not supported in T-SQL and I can understand why - it doesn't make sense. What is getting averaged?</p>
<p>So I was about to start reverse engineering what Access does when it aggregates datetime using Avg, but thought I would throw the question out here first.</p>
| [
{
"answer_id": 305869,
"author": "Scott Ivey",
"author_id": 36297,
"author_profile": "https://Stackoverflow.com/users/36297",
"pm_score": 3,
"selected": true,
"text": "select AverageDate = cast(avg(cast(MyDateColumn as decimal(20, 10))) as datetime)\nfrom MyTable\n"
},
{
"answ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22355/"
] |
305,787 | <p>I have a series of Eclipse projects containing a number of plugins and features that are checked into CVS. I now need to run an automated build of these plugins. Ideally I'd like to do it without having to hardcode large numbers of Eclipse library locations by hand, which has been the problem with the automatically generated Ant files that Eclipse provides. The build also needs to run headlessly.</p>
<p>Does anyone have experience of this sort of set-up with Eclipse, and recommendations for how to achieve it?</p>
| [
{
"answer_id": 305813,
"author": "mendicant",
"author_id": 1800,
"author_profile": "https://Stackoverflow.com/users/1800",
"pm_score": 1,
"selected": false,
"text": "<property file=\"eclipse.libraries.properties\" />\n"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/305787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39368/"
] |
305,797 | <p>The program that I am currently assigned to has a requirement that I copy the contents of a table to a backup table, prior to the real processing.</p>
<p>During code review, a coworker pointed out that</p>
<pre><code>INSERT INTO BACKUP_TABLE
SELECT *
FROM PRIMARY_TABLE
</code></pre>
<p>is unduly risky, as it is possible for the tables to have different columns, and different column orders.</p>
<p>I am also under the constraint to not create/delete/rename tables. ~Sigh~</p>
<p>The columns in the table are expected to change, so simply hard-coding the column names is not really the solution I am looking for.</p>
<p>I am looking for ideas on a reasonable non-risky way to get this job done.</p>
| [
{
"answer_id": 305812,
"author": "gx.",
"author_id": 21580,
"author_profile": "https://Stackoverflow.com/users/21580",
"pm_score": 0,
"selected": false,
"text": "CREATE TABLE secondary_table AS SELECT * FROM primary_table;\n"
},
{
"answer_id": 305831,
"author": "Justin Cave",... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] |
305,805 | <p>I am developing some school grading software and decided to use Github to host the project. After building some code on my Ubuntu box I pushed it to Github and then cloned it down to my MacBook Pro. After editing the code on the MBP I pushed it back to Github. The next morning I tried to update my repo on the Ubuntu box with a <code>git pull</code> and it gave me all kinds of trouble.</p>
<p>Whats the best way to work in this situation? I don't want to fork my own repo and I don't really want to send myself emails or pull requests. Why can't I just treat Github like a master and push/pull from it onto all of my personal repos on different computers?</p>
| [
{
"answer_id": 307742,
"author": "webmat",
"author_id": 6349,
"author_profile": "https://Stackoverflow.com/users/6349",
"pm_score": 4,
"selected": true,
"text": "git pull"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/305805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21512/"
] |
305,817 | <p>I want to be able to read from an unsorted source text file (one record in each line), and insert the line/record into a destination text file by specifying the line number where it should be inserted.</p>
<p>Where to insert the line/record into the destination file will be determined by comparing the incoming line from the incoming file to the already ordered list in the destination file. (The destination file will start as an empty file and the data will be sorted and inserted into it one line at a time as the program iterates over the incoming file lines.)</p>
<p>Incoming File Example:</p>
<pre><code>1 10/01/2008 line1data
2 11/01/2008 line2data
3 10/15/2008 line3data
</code></pre>
<p>Desired Destination File Example:</p>
<pre><code>2 11/01/2008 line2data
3 10/15/2008 line3data
1 10/01/2008 line1data
</code></pre>
<p>I could do this by performing the sort in memory via a linked list or similar, but I want to allow this to scale to very large files. (And I am having fun trying to solve this problem as I am a C++ newbie :).)</p>
<p>One of the ways to do this may be to open 2 file streams with <code>fstream</code> (1 in and 1 out, or just 1 in/out stream), but then I run into the difficulty that it's difficult to find and search the file position because it seems to depend on absolute position from the start of the file rather than line numbers :).</p>
<p>I'm sure problems like this have been tackled before, and I would appreciate advice on how to proceed in a manner that is good practice.</p>
<p>I'm using Visual Studio 2008 Pro C++, and I'm just learning C++.</p>
| [
{
"answer_id": 306003,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 1,
"selected": false,
"text": "sort"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/305817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39360/"
] |
305,835 | <p>I'm trying to understand the differences between Assembly.Load and Assembly.ReflectionOnlyLoad.</p>
<p>In the code below I am attempting to find all of the objects in a given assembly that inherit from a given interface:</p>
<pre><code>var myTypes = new List<Type>();
var assembly = Assembly.Load("MyProject.Components");
foreach (var type in assembly.GetTypes())
{
if (type.GetInterfaces().Contains(typeof(ISuperInterface)))
{
myTypes.Add(type);
}
}
</code></pre>
<p>This code works fine for me, but I was doing some research into other possibly better alternatives and came across Assembly.ReflectionOnlyLoad() method.</p>
<p>I assumed that since I'm not loading or executing any of the objects, essentially just querying on their definitions that I could use ReflectionOnlyLoad for a slight performance increase...</p>
<p>But it turns out that when I change Assembly.Load to Assembly.ReflectionOnlyLoad I get the following error when it calls assembly.GetTypes():</p>
<blockquote>
<pre><code>System.Reflection.ReflectionTypeLoadException:
</code></pre>
<p>Unable to load one or more of the
requested types. Retrieve the
LoaderExceptions property for more
information.</p>
</blockquote>
<p>I assumed that the above code was JUST doing reflection and "looking at" the library... but is this some sort of instance of the Heisenberg Uncertainty Principle whereby looking at the library and the objects in it is actually attempting to instantiate them in some way?</p>
<p>Thanks,
Max</p>
| [
{
"answer_id": 306096,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 6,
"selected": true,
"text": "LoaderExceptions"
},
{
"answer_id": 306293,
"author": "C. Dragon 76",
"author_id": 5682,
"author_pr... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29662/"
] |
305,843 | <p>I have a unit test that works fine locally but when uploaded to TeamCity build server fails with "The process cannot access the file because it is being used by another process."</p>
<ol>
<li>Before I do anything in the Test
I check in the setup if the file
exists and if so try to delete it.
This fails with the same error
message as above</li>
<li>When wriitng the
file, I close the writer then
dispose of it which I believe should
get rid of any resources.</li>
</ol>
<p>So I have a couple queries </p>
<ol>
<li>Has anyone had similar issues and manage to get around them</li>
<li>How can find out programticall what
process has selfishly locked the
file!!!</li>
</ol>
<p>Cheers</p>
| [
{
"answer_id": 305847,
"author": "Mark",
"author_id": 37923,
"author_profile": "https://Stackoverflow.com/users/37923",
"pm_score": 2,
"selected": false,
"text": "Find Handle or DLL"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/305843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11802/"
] |
305,849 | <p>I usually, almost without thinking anymore, use forward declarations so that I won't have to include headers. Something along this example:</p>
<pre><code>//-----------------------
// foo.h
//-----------------------
class foo
{
foo();
~foo();
};
//-----------------------
// bar.h
//-----------------------
class foo; // forward declaration
class bar
{
bar();
~bar();
foo* foo_pointer;
};
</code></pre>
<p>Some developers like to use this method to avoid problems with inclusion circles. I rather use it to minimize the overhead in extensive inclusion hierarchies, an important part of physical design (for larger projects in particular).</p>
<p>However, in some cases I really like to declare members as normal objects instead of pointers to benefit from the automatic construction/destruction mechanism. This leads to the problem that forward declarations can't be used anymore, since the compiler needs the class definition in such case, eg:</p>
<pre><code>//-----------------------
// foo.h
//-----------------------
class foo
{
foo();
~foo();
};
//-----------------------
// bar.h
//-----------------------
class foo; // Not enough given the way we declare "foo_object"..
#include "foo.h" // ..instead this is required
class bar
{
bar();
~bar();
foo foo_object;
};
</code></pre>
<p>So, I would be happy if anyone knows an alternative language construct which can be used here so that I can declare "foo_object" as shown in the example, but without including its header.</p>
<p>Regards</p>
<p>/Robert</p>
| [
{
"answer_id": 305862,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 0,
"selected": false,
"text": "// bar.h\nclass foo;\n\nclass bar {\n foo& foo_;\n\npublic:\n bar();\n ~bar();\n};\n\n// bar.cc\nbar::bar() : foo_(... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7891/"
] |
305,856 | <p>I have a project where multiple developers are using a copy of the same windows Virtual PC image (W2K3 SE SP2). Because our solution is tied to the machine-name (less than ideal, i know) all of the developers have the same machine name.</p>
<p>We use a VPN to connect to a remote system, upon connection we get the "Windows Error: A duplicate name exists on the network" error.</p>
<p>Since all development is happening locally, we're not dependent on other machines connecting to us -- only outbound connections.</p>
<p>I know it's best practice to change the machine name, but what's the reasoning behind this? What impact would this have?</p>
| [
{
"answer_id": 305862,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 0,
"selected": false,
"text": "// bar.h\nclass foo;\n\nclass bar {\n foo& foo_;\n\npublic:\n bar();\n ~bar();\n};\n\n// bar.cc\nbar::bar() : foo_(... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30809/"
] |
305,860 | <p>What do you think is the best way to implement an interactive grid similar to a Sudoku board for a native iPhone application? I did not see an object to fill this need in the SDK.</p>
<p>Should I make a custom control for an individual cell, then initialize as many of them as I need in a grid form?</p>
<p><a href="https://i.stack.imgur.com/o9CSk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o9CSk.jpg" alt="Sudoku grid"></a><br>
<sub>(source: <a href="http://www.sudoku.4thewww.com/Grids/grid.jpg" rel="nofollow noreferrer">4thewww.com</a>)</sub> </p>
<p>Any and all comments are welcome.
Thanks!</p>
| [
{
"answer_id": 306149,
"author": "Svante",
"author_id": 31615,
"author_profile": "https://Stackoverflow.com/users/31615",
"pm_score": 0,
"selected": false,
"text": "hidden"
},
{
"answer_id": 306152,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://S... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39365/"
] |
305,870 | <p>I am attempting to write a Windows Service in C#. I need to find the path to a certain file, which is stored in an environment variable. In a regular C# console application, I can achieve that with the following line:</p>
<pre><code>string t = System.Environment.GetEnvironmentVariable("TIP_HOME");
</code></pre>
<p>If I write that to the console I see that it was successful.</p>
<p>Now, if I try that same code in a Windows Service, the string <code>t</code> is empty.</p>
<p>Any idea why?</p>
| [
{
"answer_id": 306090,
"author": "Brian",
"author_id": 39373,
"author_profile": "https://Stackoverflow.com/users/39373",
"pm_score": 1,
"selected": false,
"text": "foreach(DictionaryEntry de in Environment.GetEnvironmentVariables(tgt))\n{\n key = (string)de.Key;\n value = (string... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39373/"
] |
305,880 | <p>I've got what I think is a simple question. I've seen examples both ways. The question is - "why can't I place my annotations on the field?". Let me give you an example....</p>
<pre><code>@Entity
@Table(name="widget")
public class Widget {
private Integer id;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Integer getId() { return this.id; }
public Integer setId(Integer Id) { this.id = id;}
}
</code></pre>
<p>The above code works fine (assuming there's not a typo in there). When the annotation is placed on the getter of the property everything is perfect.</p>
<p>However, that seems awkward to me. In my mind it's cleaner to place the annotation on the field, like so --</p>
<pre><code>@Entity
@Table(name="widget")
public class Widget {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Integer id;
public Integer getId() { return this.id; }
public Integer setId(Integer Id) { this.id = id;}
}
</code></pre>
<p>I've seen examples of both ways. However, when I run this second example I get the following...</p>
<pre>
java.lang.NullPointerException
at com.widget.util.hibernate.HibernateSessionFactory$ThreadLocalSession.initialValue(HibernateSessionFactory.java:25)
at com.widget.util.hibernate.HibernateSessionFactory$ThreadLocalSession.initialValue(HibernateSessionFactory.java:1)
at java.lang.ThreadLocal$ThreadLocalMap.getAfterMiss(Unknown Source)
at java.lang.ThreadLocal$ThreadLocalMap.get(Unknown Source)
at java.lang.ThreadLocal$ThreadLocalMap.access$000(Unknown Source)
at java.lang.ThreadLocal.get(Unknown Source)
at com.widget.util.hibernate.HibernateSessionFactory.get(HibernateSessionFactory.java:33)
at com.widget.db.dao.AbstractDao.(AbstractDao.java:12)
at com.widget.db.dao.WidgetDao.(WidgetDao.java:9)
at com.widget.db.dao.test.WidgetDaoTest.findById(WidgetDaoTest.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
...
</pre>
<p>Here's the skeleton of <code>HibernateSessionFactory</code> (line 25 is marked) ....</p>
<pre><code>protected Session initialValue() {
SessionFactory sessionFactory = null;
try {
Configuration cfg = new AnnotationConfiguration().configure();
String url = System.getProperty("jdbc.url");
if (url != null) {
cfg.setProperty("hibernate.connection.url", url);
}
sessionFactory = cfg.buildSessionFactory();
}
catch (Exception e) {
}
Session session = sessionFactory.openSession(); // LINE 25
return session;
}
</code></pre>
<p>Anyone have an idea what's going on here?</p>
| [
{
"answer_id": 305902,
"author": "Jonathan",
"author_id": 28209,
"author_profile": "https://Stackoverflow.com/users/28209",
"pm_score": 0,
"selected": false,
"text": "@Entity\n@Table(name=\"widget\")\npublic class Widget {\n @Id\n @GeneratedValue(strategy=GenerationType.AUTO)\n\n ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39374/"
] |
305,886 | <p>For a new project I have to import the pre-existing data from MySql.</p>
<p>In <a href="http://www.connectionstrings.com/?carrier=mysql" rel="noreferrer">this site</a> I have found many options, some including the installation of drivers. What is the fastest & easiest way to do it?</p>
<p>Update: this would be just a one time import</p>
| [
{
"answer_id": 6423238,
"author": "Abdul HaSeeB",
"author_id": 808157,
"author_profile": "https://Stackoverflow.com/users/808157",
"pm_score": 3,
"selected": false,
"text": "-- Create Link Server\n\nEXEC master.dbo.sp_addlinkedserver \n@server = N'MYSQL', \n@srvproduct=N'MySQL', \n@provi... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4264/"
] |
305,894 | <p>I am trying to update an old JavaScript function used to detect support for AJAX (i.e. the XmlHttpRequest object). I've looked online (including SO) and found various solutions but I'm not sure which is the most efficient for simply detecting support.</p>
<p>The current function is:</p>
<pre><code> function IsSyncAJAXSupported()
{
var isSyncAJAXSupported = true;
var xmlHttp = null;
var clsids = ["Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
for(var i=0; i<clsids.length && xmlHttp == null; i++) {
try {
xmlHttp = new ActiveXObject(clsids[i]);
} catch(e){}
}
if(xmlHttp == null && MS.Browser.isIE)
{
isSyncAJAXSupported = false;
}
return isSyncAJAXSupported;
}
</code></pre>
<p>In Firefox 3, the above gives errors because MS is undefined.</p>
<p>I realise that using a library would be better but that's not an option for the short term. We are only supporting IE6 and above + recent versions of Firefox, Safari/WebKit and Opera.</p>
<p>What's the best way of getting a true/false for XmlHttpRequest support?</p>
| [
{
"answer_id": 305926,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 1,
"selected": false,
"text": "function CreateXMLHttpRequest()\n{\n // Firefox and others\n try { return new XMLHttpRequest(); } catch (e) {}\n // Inte... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12124/"
] |
305,905 | <p>What's the best way to kill a process and all its child processes from a Perl script? It should run at least under Linux and Solaris, and not require installation of any additional packages.</p>
<p>My guess would be to get a list of all processes and their parents by parsing files in /proc or by parsing the output of <code>ps</code> (neither of which seems portable between Linux and Solaris); and then killing all processes in the tree (which seems prone to race conditions).</p>
<p>I could live with the race conditions in this particular case, but how do I portably get the process list?</p>
| [
{
"answer_id": 305919,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 3,
"selected": false,
"text": "kill -$signum, $pgid;\n"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/305905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2148773/"
] |
305,911 | <p>Lets say you have a property like:</p>
<pre><code>Person person1;
public Person Captin{
get{
return person1;
}
set{
person1 = value;
}
}
public void SomeFunction(){
Captin.name = "Hook"
}
</code></pre>
<p>In this case if you set the name on the property we know that the new name of Hook will get applied to the underlying value of person1. What if our implementation were a little different say:</p>
<pre><code>public Person Captin{
get{
return ReadCaptinFromDisk();
}
set{
WriteCaptinToDisk(value);
}
}
public void SomeFunction(){
Captin.name = "Hook"
}
</code></pre>
<p>In this case for the underlying value to get set properly we need to have the Captin's set code called as part of the assignment to Captin.name. </p>
<p>I am interested in knowing if the parameter set code will call the set on assignments of field or method calls on property references. especially for this kind of situation where the value needs to be propagated to disk (etc.).</p>
| [
{
"answer_id": 305942,
"author": "JSC",
"author_id": 37311,
"author_profile": "https://Stackoverflow.com/users/37311",
"pm_score": 2,
"selected": false,
"text": "public void SomeFunction() {\n Person p = Captin;\n p.name = \"Hook\";\n Captin = p;\n}\n"
},
{
"answer_id": 115... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4491/"
] |
305,915 | <p>I have a form containing a web browser control. This browser control will load some HTML from disk and display it. I want to be able to have a button in the HTML access C# code in my form. </p>
<p>For example, a button in the HTML might call the Close() method on the form.</p>
<p>Target platform: C# and Windows Forms (any version)</p>
| [
{
"answer_id": 305974,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": " private void MyMethod()\n {\n // do something\n }\n\n private void webBrowser1_Navigating(object sender, W... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636/"
] |
305,924 | <p>I have a function that takes another function as a parameter. If the function is a member of a class, I need to find the name of that class. E.g.</p>
<pre><code>def analyser(testFunc):
print testFunc.__name__, 'belongs to the class, ...
</code></pre>
<p>I thought </p>
<pre><code>testFunc.__class__
</code></pre>
<p>would solve my problems, but that just tells me that testFunc is a function.</p>
| [
{
"answer_id": 305948,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 3,
"selected": false,
"text": "testFunc.__self__.__class__\n"
},
{
"answer_id": 305980,
"author": "Piotr Lesnicki",
"author_id": 38796,
... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11677/"
] |
305,937 | <p>I am creating a C# WinForms application. I would like to have a Custom Form Border. And I want to create a black custom window (with border and controls) like that of Adobe Lightroom. For example -
<a href="https://i.stack.imgur.com/VNDFM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VNDFM.jpg" alt="Border like Adobe Lightroom" /></a>
How do I create it, please help?</p>
| [
{
"answer_id": 12511904,
"author": "Nikita",
"author_id": 1611550,
"author_profile": "https://Stackoverflow.com/users/1611550",
"pm_score": 2,
"selected": false,
"text": " #region Кастомизированное поведение - рамки, активность и т.д.\n private bool isCurrentlyActive = false;\n ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636/"
] |
305,991 | <p>I'm under the impression that the Dot '.' (wild card) character is dangerous to use. Is my fear unfounded? Thanks</p>
| [
{
"answer_id": 306104,
"author": "Claudiu",
"author_id": 15055,
"author_profile": "https://Stackoverflow.com/users/15055",
"pm_score": 0,
"selected": false,
"text": ".*"
},
{
"answer_id": 306154,
"author": "Brian",
"author_id": 18192,
"author_profile": "https://Stacko... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
305,994 | <p>I searched all over this site and the web for a good and <strong>simple</strong> example of autocomplete using jQuery and ASP.NET. I wanted to expose the data used by autocomplete with a webservice (and will probably do that next). In the meantime, I got this working, but it seems a little hacky...</p>
<p>In my page I have a text box:</p>
<pre><code><input id="txtSearch" type="text" />
</code></pre>
<p>I am using jQuery autocomplete, set up per their example:</p>
<pre><code><link rel="stylesheet" href="js/jquery.autocomplete.css" type="text/css" />
<script type="text/javascript" src="js/jquery.bgiframe.js"></script>
<script type="text/javascript" src="js/jquery.dimensions.pack.js"></script>
<script type="text/javascript" src="js/jquery.autocomplete.js"></script>
</code></pre>
<p>Here is where it starts to get hacky... I call a page instead of a webservice:</p>
<pre><code> <script type="text/javascript">
$(document).ready(function(){
$("#txtSearch").autocomplete('autocompletetagdata.aspx');
});
</script>
</code></pre>
<p>In the page I stripped out ALL of the html and just have this (otherwise, various HTML bits show up in the autocomplete dropdown):</p>
<pre><code><%@ Page Language="C#" AutoEventWireup="true" CodeFile="autocompletetagdata.aspx.cs" Inherits="autocompletetagdata" %>
</code></pre>
<p>And in my autocompletetagdata.aspx, I am using SubSonic to query, format and return data from the database (one data item per line):</p>
<pre><code>protected void Page_Load(object sender, EventArgs e)
{
// Note the query strings passed by jquery autocomplete:
//QueryString: {q=a&limit=150&timestamp=1227198175320}
LookupTagCollection tags = Select.AllColumnsFrom<LookupTag>()
.Top(Request.QueryString["limit"])
.Where(LookupTag.Columns.TagDescription).Like(Request.QueryString["q"] + "%")
.OrderAsc(LookupTag.Columns.TagDescription)
.ExecuteAsCollection<LookupTagCollection>();
StringBuilder sb = new StringBuilder();
foreach (LookupTag tag in tags)
{
sb.Append(tag.TagDescription).Append("\n");
}
Response.Write(sb.ToString());
}
</code></pre>
<p>If you don't do a LIKE query, then it returns everything that contains a match for the character(s) you type -- e.g., typing "a" will include "Ask" and "Answer" as well as "March" and "Mega." I just wanted it to do a starts with match.</p>
<p>Anyway, it works and it's pretty easy to set up, but is there a better way?</p>
| [
{
"answer_id": 306037,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 6,
"selected": true,
"text": "<script type=\"text/javascript\">\n $(document).ready(function(){\n $(\"#txtSearch\").autocomplete('autocompletetagdata.... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38787/"
] |
306,012 | <p>There is an actual running Java ServerPages (JSP) application within a *NIX box which I somewhat administer with kind of good permissions. The idea is to create a new but dead simple JSP page to control some Korn Shell scripts I've got running there. So the goal is to make some sort of HTML form that will be writing some kind of scriptStatus.on / scriptStatus.off file:</p>
<pre><code>#!usr/bin/ksh
# coolScript.sh
# This is my cool script that is being launched by cron every 10 minutes.
if [ -e scriptStatus.off ]
then
# monitor disabled
else
# monitor enabled
fi
</code></pre>
<p>which then can be checked for existence within the running script, therefore allowing to easily activate / deactivate it without actually have do deal with cron. Please let me know if all this makes sense and do not hesitate to ask as many questions as needed.</p>
<p>Thanks much in advance! </p>
| [
{
"answer_id": 306083,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 3,
"selected": true,
"text": "File flag = new File(\"/path/scriptStatus.off\");\nString message;\nif (flag.delete())\n message = \"Script enabled.\";\nel... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306012",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6992/"
] |
306,013 | <p>My form does not go to recipient when submitted! I changed the file mail.tpl.txt to direct to my own email address as a test and I got the email just fine.</p>
<p>Client has checked junk mail folder as well and he is just not getting information.</p>
<p>Below is the form code, followed by the code from mail.tpl.txt and then the form's index.php code.</p>
<p>Everything looks okay to me, so I am asking if someone has any idea why he wouldn't be getting the form. He uses qwest for email if that helps any.</p>
<p>Here's the form code:</p>
<pre><code><form id="contactForm" name="form" action="form/index.php" method="post">
<fieldset>
<legend><font color="#000000"><strong>Please fill out the form below if you have any questions.</strong></font></legend>
<div>
<label for="name">Name:* </label>
<input type="text" size="30" name="name" class="txt" id="name" />
</div>
<div>
<label for="label">Phone: </label>
<input type="text" size="30" name="phone" class="txt" id="label" />
</div>
<div>
<label for="email">Email:* </label>
<input type="text" size="30" name="email" class="txt" id="email" />
</div>
<div>
<label for="message">Message: </label>
<textarea rows="6" name="message" id="message" cols="40" class="txt"></textarea>
</div>
<input type="hidden" name="thanks" value="../thanks.php" />
<input type="hidden" name="email_fields" value="email" />
<input type="hidden" name="required_fields" value="name, email" />
<input type="hidden" name="html_template" value="form.tpl.html" />
<input type="hidden" name="mail_template" value="mail.tpl.txt" />
<div class="submit">
<input type="submit" class="btn" value="Send Message" name="Submit" id="Submit" />
</div>
</fieldset>
</form>
</code></pre>
<p>Now the mail.tpl.text code: (I have taken out my client's full address and domain name for the post.)</p>
<pre><code> To: "xxxxxxx Custom Homes" <xxxxxxx@q.com>
From: "{name}" {phone} <{email}> <{message}>
MIME-Version: 1.0
Content-type: text/plain; charset={txt_charset}
Subject: Online Contact Request from Freese Custom Homes
Contact Information:
{name} {phone}
Email Address: {email}
Contact Message:
{message}
Lastly, here's the form's index.php code: (Again, I have taken out my client's domain name for the post)
<?php
$script_root = './';
$referring_server = ''; // Example: $referring_server = 'xxxxxxx.com, www.xxxxxxx.com';
$language = 'en'; // (see folder 'languages')
$ip_banlist = '';
$ip_address_count = '0';
$ip_address_duration = '48';
$show_limit_errors = 'yes'; // (yes, no)
$log_messages = 'no'; // (yes, no) -- make folder "temp" writable with: chmod 777 temp
$text_wrap = '72';
$show_error_messages = 'yes';
$attachment = 'no'; // (yes, no) -- make folder "temp" writable with: chmod 777 temp
$attachment_files = 'jpg, gif,png, zip, txt, pdf, doc, ppt, tif, bmp, mdb, xls, txt';
$attachment_size = 9000000;
$captcha = 'no'; // (yes, no) -- make folder "temp" writable with: chmod 777 temp
$path['logfile'] = $script_root . 'logfile/logfile.txt';
$path['templates'] = $script_root . 'templates/';
$file['default_html'] = 'form.tpl.html';
$file['default_mail'] = 'mail.tpl.txt';
/*****************************************************
** Add further words, text, variables and stuff
** that you want to appear in the templates here.
** The values are displayed in the HTML output and
** the e-mail.
*****************************************************/
$add_text = array(
'txt_additional' => 'Additional', // {txt_additional}
'txt_more' => 'More' // {txt_more}
);
/*****************************************************
** Do not edit below this line - Ende der Einstellungen
*****************************************************/
/*****************************************************
** Send safety signal to included files
*****************************************************/
define('IN_SCRIPT', 'true');
/*****************************************************
** Load formmail script code
*****************************************************/
include($script_root . 'inc/formmail.inc.php');
echo $f6l_output;
?>
</code></pre>
| [
{
"answer_id": 1077429,
"author": "Basher",
"author_id": 132187,
"author_profile": "https://Stackoverflow.com/users/132187",
"pm_score": 1,
"selected": false,
"text": "From: \"{name}\" {phone} <{email}> <{message}> \n"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/306013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30043/"
] |
306,017 | <p>I realize that far is compiler specific, but my expectation is that the placement of the far specifier should make sense to those who really understand pointers.</p>
<p>So, I have two applications that share the processor's entire memory space.</p>
<p>App A needs to call function foo that exists in app B.</p>
<p>I know the memory location of function foo.</p>
<p>So this should work, in app A:</p>
<pre><code>typedef int (* __far MYFP)(int input);
void somefunc(void)
{
int returnvalue;
MYFP foo;
foo = (MYFP) 0xFFFFFA;
returnvalue = foo(39);
}
</code></pre>
<ul>
<li>Is the __far in the right spot in the typedef?</li>
<li>Do I need to add __far to the (MYFP) cast?</li>
<li>Some information suggests that the call to foo doesn't need to be dereferenced, what is your experience?</li>
<li><p>What else about this looks incorrect, or might I try to accomplish this?</p></li>
<li><p>Is there a better way to do this?</p></li>
</ul>
<p>Edit:</p>
<p>This is on an embedded device (Freescale S12XEQ device) using Code Warrior. It's a 16 bit device with 24 bit memory space, so yes, it is segmented/banked.</p>
<p>-Adam</p>
| [
{
"answer_id": 306067,
"author": "Skizz",
"author_id": 1898,
"author_profile": "https://Stackoverflow.com/users/1898",
"pm_score": 3,
"selected": false,
"text": "__far"
},
{
"answer_id": 306321,
"author": "Paul Nathan",
"author_id": 26227,
"author_profile": "https://S... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2915/"
] |
306,062 | <p>I need a CSS selector that can find the 2nd div of 2 that has the same class. I've looked at <code>nth-child()</code> but it's not what I want since I can't see a way to further clarify what class I want. These 2 divs will be siblings in the document if that helps.</p>
<p>My HTML looks something like this:</p>
<pre><code><div class="foo">...</div>
<div class="bar">...</div>
<div class="baz">...</div>
<div class="bar">...</div>
</code></pre>
<p>And I want the 2nd div.bar (or the last div.bar would work too).</p>
| [
{
"answer_id": 306087,
"author": "geocar",
"author_id": 37507,
"author_profile": "https://Stackoverflow.com/users/37507",
"pm_score": 6,
"selected": false,
"text": ".bar:nth-child(2)\n"
},
{
"answer_id": 306127,
"author": "Seamus",
"author_id": 30443,
"author_profile"... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12094/"
] |
306,065 | <p>Currently i have a NotInheritable class in App_Code that hold some variables that need to be access thur-out the application but i don't think it's a good way to manage global variables. </p>
| [
{
"answer_id": 306197,
"author": "Bruno Shine",
"author_id": 28294,
"author_profile": "https://Stackoverflow.com/users/28294",
"pm_score": 0,
"selected": false,
"text": "Settings.Default.PortalName"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/306065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28647/"
] |
306,075 | <p>Is there a cookie automatically placed on the user's machine? Or is it somehow associated with the requester's IP address? Or maybe in the ViewState? Elementary question, I know, but I've had a hard time finding an answer.</p>
| [
{
"answer_id": 306084,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "https://Stackoverflow.com/users/26479",
"pm_score": 1,
"selected": false,
"text": "ASP.NET_SessionId"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/306075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/767/"
] |
306,080 | <p>After following the advice in <a href="https://stackoverflow.com/questions/302560/wix-custom-actions-with-wixuiminimal">this question</a> successfully, I added a couple additional lines of code for another custom action. This one is intended to call regsvr32 on the copy of capicom which I've tried to put in the user's system folder. However, I'm getting error 2721, which seems to be a custom action not found error, from what I've seen. Any suggestions? I'm trying to maintain consistency with previous iterations of my installer by calling regsvr, rather than just adding the registry entries during install, which could be a good idea instead. :::shrug:::</p>
<pre><code><Directory Id="SystemFolder" Name="Sys">
...
<component ...>
...
<File Id="CapiCom.Dll" LongName="CapiCom.Dll" Name="CAPICOM.DLL" Source=... />
</component>
</directory>
...
<CustomAction Id="REGCAPICOM" ExeCommand='regsvr32.exe "[SystemFolder]capicom.dll"' Return = "ignore" Execute="deferred" />
...
<InstallExecuteSequence>
...
<Custom Action="REGCAPICOM" After="InstallFiles" />
</InstallExecuteSequence>
</code></pre>
<p>Edit: Yes, using regsvr32 as an installer is ugly. But when I downloaded the Capicom SDK, that is what MS said to do in order to install it. Searching around has found many people saying that this is a stupid way to do it...but it's also mechanism MS provided. I'll listen to suggestions for a better way. I don't consider it a big deal if Capicom being left behind when my application is uninstalled, considering that it's a standard windows component.</p>
<p>Edit: Hmmm. Apparently, one of the things running selfreg on the dll does is to create a random seed to add to the registry. Not sure what mechanism it uses to generate this seed but I suspect it would be considered in poor taste to just generate one myself, especially if I gave all the users the same seed. Not sure.... Apparently if I skip this Capicom does it on its own, so I'm fine.</p>
| [
{
"answer_id": 306409,
"author": "CheGueVerra",
"author_id": 17787,
"author_profile": "https://Stackoverflow.com/users/17787",
"pm_score": 0,
"selected": false,
"text": "heat file [Path\\Capicom.dll] -template:product -out capicom.wxs\n"
},
{
"answer_id": 447152,
"author": "B... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18192/"
] |
306,097 | <p>We determined in a <a href="https://stackoverflow.com/questions/303810/variable-dynamic-option-lists-in-html-select-using-ie">previous question</a> that many features of HTML SELECTs are not supported in IE. Is there an alternative widget that you would recommend from your experience that meets the following requirements?</p>
<ol>
<li>Respects the <code>contentEditable</code> property (does not allow selection changes if true)</li>
<li>Respects the <code>disabled</code> property of individual OPTIONs (shows them "grayed out" or with strike-through font, and makes them un-selectable)</li>
<li>Supports Option Groups (<code>OPTGROUP</code> elements)</li>
<li>Supports <code>style</code> options such as <code>border</code> and <code>margin</code> in the <code>SELECT</code> and all sub-elements</li>
<li>Supports dynamic add and delete of <code>OPTION</code> and <code>OPTGROUP</code> elements</li>
<li>Supports the above in IE version 6 and above</li>
</ol>
<p>EDIT: As noted by @Joel Coehoorn, items 3 and 5 above are currently supported in IE. They are included here to make sure they are not overlooked in a replacement widget.</p>
| [
{
"answer_id": 306125,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 3,
"selected": true,
"text": "<optgroup label=\"--\"></optgroup>\n"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/306097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26671/"
] |
306,130 | <p>I am trying to write a decorator to do logging:</p>
<pre><code>def logger(myFunc):
def new(*args, **keyargs):
print 'Entering %s.%s' % (myFunc.im_class.__name__, myFunc.__name__)
return myFunc(*args, **keyargs)
return new
class C(object):
@logger
def f():
pass
C().f()
</code></pre>
<p>I would like this to print:</p>
<pre><code>Entering C.f
</code></pre>
<p>but instead I get this error message:</p>
<pre><code>AttributeError: 'function' object has no attribute 'im_class'
</code></pre>
<p>Presumably this is something to do with the scope of 'myFunc' inside 'logger', but I've no idea what.</p>
| [
{
"answer_id": 306196,
"author": "Claudiu",
"author_id": 15055,
"author_profile": "https://Stackoverflow.com/users/15055",
"pm_score": 3,
"selected": false,
"text": "def logger(myFunc):\n def new(*args, **keyargs):\n print 'Entering %s.%s' % (myFunc.im_class.__name__, myFunc.__... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11677/"
] |
306,132 | <p>I have a site made with php which uses server side sessions throughout the site.<br>
In fact, it's a site with a user login which depends on session variables and if there were a problem with <em>all</em> session variables, no pages would load at all. </p>
<p>On the site, there's an iframe that holds a feed of little messages from other users.<br>
Those little messages have clickable photos next to them that open the user's profile.<br>
Now, each page requires some formatting to open the user's profile on that specific page...there's really only a few <em>problem</em> pages, but those pages have to have the onclick functions formatted a little differently or they break the page.<br>
So I set a session variable on each page (<code>$_SESSION["current_page"]</code>) that lets the feed know how to format the clickable photos. Now Firefox, Opera, Chrome, Safari all work as they are supposed to.<br>
But IE6 and IE7 are having problems on the pages that require special formatting.<br>
So after pulling my hair out a bit, I eventually got around to printing my session variables form the server.<br>
And lo and behold, on the special pages, (<code>$_SESSION["current_page"]</code>) is always set to "main" instead of "special1" or "special2". </p>
<p>I printed the same session variable in Firefox and all the other browsers I mentioned and they print out "special1" or "special2" as they're supposed to.<br>
Can anyone think of something - possibly related to the fact that the feed is in an iframe??? - that would cause IE to treat server side session variables differently or somehow launch page "main" silently in the background?<br>
I have checked the feed very carefully for any reference to page "main" - it doesn't seem like there's any ways it's loading that page. </p>
<p>this doesn't make sense to me. </p>
| [
{
"answer_id": 310288,
"author": "seans",
"author_id": 39385,
"author_profile": "https://Stackoverflow.com/users/39385",
"pm_score": 3,
"selected": true,
"text": "<img src= \"\" >"
},
{
"answer_id": 2146737,
"author": "dotcolor",
"author_id": 260047,
"author_profile"... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39385/"
] |
306,136 | <p>I know I could do this with closures (<code>var self = this</code>) if object was a function:</p>
<pre><code><a href="#" id="x">click here</a>
<script type="text/javascript">
var object = {
y : 1,
handle_click : function (e) {
alert('handling click');
//want to access y here
return false;
},
load : function () {
document.getElementById('x').onclick = this.handle_click;
}
};
object.load();
</script>
</code></pre>
| [
{
"answer_id": 306151,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 2,
"selected": false,
"text": "var object = { \n y : 1, \n handle_click : function (e) {\n alert('handling click');\n\n //want to access y he... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
306,139 | <p>I have a groovy script that needs a library in a jar. How do I add that to the classpath? I want the script to be executable so I'm using <code>#!/usr/bin/env groovy</code> at the top of my script. </p>
| [
{
"answer_id": 306168,
"author": "Eric Wendelin",
"author_id": 25066,
"author_profile": "https://Stackoverflow.com/users/25066",
"pm_score": 6,
"selected": true,
"text": "this.getClass().classLoader.rootLoader.addURL(new File(\"file.jar\").toURL())\n"
},
{
"answer_id": 8945888,
... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14481/"
] |
306,144 | <p>I am having trouble deleting orphan nodes using JPA with the following mapping</p>
<pre><code>@OneToMany (cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "owner")
private List<Bikes> bikes;
</code></pre>
<p>I am having the issue of the orphaned roles hanging around the database.</p>
<p>I can use the annotation <code>org.hibernate.annotations.Cascade</code> Hibernate specific tag but obviously I don't want to tie my solution into a Hibernate implementation.</p>
<p><strong>EDIT</strong>: It seems JPA 2.0 will include support for this.</p>
| [
{
"answer_id": 307203,
"author": "Varun Mehta",
"author_id": 31537,
"author_profile": "https://Stackoverflow.com/users/31537",
"pm_score": 8,
"selected": true,
"text": "CascadeType.DELETE_ORPHAN"
},
{
"answer_id": 2928481,
"author": "Kango_V",
"author_id": 174884,
"au... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3050/"
] |
306,169 | <p>In our web applications, we seperate our Data Access Layers out into their own projects.</p>
<p>This creates some problems related to settings. </p>
<p>Because the DAL will eventually need to be consumed from perhaps more than one application, web.config does not seem like a good place to keep the connection strings and some of the other DAL-related settings.</p>
<p>To solve this, on some of our recent projects we introduced a third project just for settings. We put the setting in a system of .Setting files... With a simple wrapper, the ability to have different settings for various enviroments (Dev, QA, Staging, Production, etc) was easy to achieve.</p>
<p>The only problem there is that the settings project (including the .Settings class) compiles into an assembly, so you can't change it without doing a build/deployment, and some of our customers want to be able to configure their projects without Visual Studio.</p>
<p>So, is there a best practice for this? I have that sense that I'm reinventing the wheel.</p>
<p>Some solutions such as storing settings in a fixed directory on the server in, say, our own XML format occurred to us. But again, I would rather avoid having to re-create encryption for sensitive values and so on. And I would rather keep the solution self-contained if possible.</p>
<p><strong>EDIT:</strong> The original question did not contain the really penetrating reason that we can't (I think) use web.config ... That puts a few (very good) answers out of context, my bad.</p>
| [
{
"answer_id": 306309,
"author": "Chris",
"author_id": 34942,
"author_profile": "https://Stackoverflow.com/users/34942",
"pm_score": 2,
"selected": false,
"text": "string connString = ConfigurationManager\n .ConnectionStrings[\"myConnString\"]\n .ConnectionString;\n"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/306169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16082/"
] |
306,176 | <p>I am following a VB tutorial to do some <a href="http://blogs.msdn.com/bethmassi/archive/2008/04/25/querying-html-with-linq-to-xml.aspx" rel="nofollow noreferrer">HTML manipulation using LINQ</a> </p>
<p>It has the following construct</p>
<pre><code>Imports <xmlns="http://www.w3.org/1999/xhtml">
</code></pre>
<p>How do I do the same in C#?</p>
<p>There appears to be something called an XMLNamespaceManager that may hold the solution, but I am too foolish to understand how to work it, and I am not sure it is the correct tree to bark up.</p>
<p>Got any advice?</p>
| [
{
"answer_id": 306216,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 3,
"selected": true,
"text": "XML Literals"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/306176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5552/"
] |
306,191 | <p>I have a list of error codes I need to reference, kinda like this:</p>
<pre><code>Code / Error Message
A01 = whatever error
U01 = another error
U02 = yet another error type
</code></pre>
<p>I get the Code returned to me via a web service call and I need to display or get the readable error. So I need a function when passed a Code that returns the readable description. I was just going to do a select case but thought their might be a better way. What is the best way / most effieient way to do this?</p>
| [
{
"answer_id": 306201,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 4,
"selected": true,
"text": "// Initialize this once, and store it in the ASP.NET Cache.\nDictionary<String,String> errorCodes = new Dictionary<String,Str... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34548/"
] |
306,233 | <p>I have several deployment projects. In order to deploy an application, I need to do several tasks, one of them is to change each deployment project's product version and product code.</p>
<p>I can't find a way to programmatically change them.</p>
<p>Since it's a Deployment project (which finally produces an executable installer), I'm not able to work with MSBuild, instead I'm using the Devenv from the command prompt.</p>
| [
{
"answer_id": 398093,
"author": "TheCodeMonk",
"author_id": 28956,
"author_profile": "https://Stackoverflow.com/users/28956",
"pm_score": 5,
"selected": true,
"text": "static void Main(string[] args) \n{\n string setupFileName = @\"<Replace the path to vdproj file>\"; \n StreamRea... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30339/"
] |
306,252 | <p>This is one of the minor CSS problems that plague me constantly.</p>
<p>How do folks around Stack Overflow vertically align <em><strong><code>checkboxes</code></strong></em> and their <em><strong><code>labels</code></strong></em> consistently <strong>cross-browser</strong>?</p>
<p>Whenever I align them correctly in Safari (usually using <code>vertical-align: baseline</code> on the <code>input</code>), they're completely off in Firefox and IE.</p>
<p>Fix it in Firefox, and Safari and IE are inevitably messed up. I waste time on this every time I code a form.</p>
<p>Here's the standard code that I work with:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><form>
<div>
<label><input type="checkbox" /> Label text</label>
</div>
</form></code></pre>
</div>
</div>
</p>
<p>I usually use Eric Meyer's reset, so form elements are relatively clean of overrides. Looking forward to any tips or tricks that you have to offer!</p>
| [
{
"answer_id": 306266,
"author": "digitalsanctum",
"author_id": 22436,
"author_profile": "https://Stackoverflow.com/users/22436",
"pm_score": 7,
"selected": false,
"text": "vertical-align: middle"
},
{
"answer_id": 306593,
"author": "One Crayon",
"author_id": 38666,
"... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38666/"
] |
306,271 | <p>I'd like some advice on designing a REST API which will allow clients to add/remove large numbers of objects to a collection efficiently.</p>
<p>Via the API, clients need to be able to add items to the collection and remove items from it, as well as manipulating existing items. In many cases the client will want to make bulk updates to the collection, e.g. adding 1000 items and deleting 500 different items. It feels like the client should be able to do this in a single transaction with the server, rather than requiring 1000 separate POST requests and 500 DELETEs. </p>
<p>Does anyone have any info on the best practices or conventions for achieving this?</p>
<p>My current thinking is that one should be able to PUT an object representing the change to the collection URI, but this seems at odds with the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6" rel="noreferrer">HTTP 1.1 RFC</a>, which seems to suggest that the data sent in a PUT request should be interpreted independently from the data already present at the URI. This implies that the client would have to send a complete description of the new state of the collection in one go, which may well be very much larger than the change, or even be more than the client would know when they make the request.</p>
<p>Obviously, I'd be happy to deviate from the RFC if necessary but would prefer to do this in a conventional way if such a convention exists.</p>
| [
{
"answer_id": 340161,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 0,
"selected": false,
"text": "If-Unmodified-Since"
},
{
"answer_id": 59979381,
"author": "Shyam",
"author_id": 4527664,
"autho... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20011/"
] |
306,272 | <p>Say I have a class with a private dispatch table. </p>
<pre><code>$this->dispatch = array(
1 => $this->someFunction,
2 => $this->anotherFunction
);
</code></pre>
<p>If I then call </p>
<pre><code>$this->dispatch[1]();
</code></pre>
<p>I get an error that the method is not a string. When I make it a string like this: </p>
<pre><code>$this->dispatch = array(
1 => '$this->someFunction'
);
</code></pre>
<p>This produces
<strong>Fatal error: Call to undefined function $this->someFunction()</strong></p>
<p>I have also tried using:</p>
<pre><code>call_user_func(array(SomeClass,$this->dispatch[1]));
</code></pre>
<p>Resulting in <strong>Message: call_user_func(SomeClass::$this->someFunction) [function.call-user-func]: First argument is expected to be a valid callback</strong>.</p>
<p><strong>Edit:</strong> I realized that this didn't really make sense since it is calling SomeClass::$this when $this is SomeClass. I have tried this a few ways, with the array containing </p>
<pre><code>array($this, $disptach[1])
</code></pre>
<p>This still does not accomplish what I need.</p>
<p><strong>End edit</strong></p>
<p>This works if I do not have a class and just have a dispatch file with some functions. For example, this works:</p>
<pre><code>$dispatch = array(
1 => someFunction,
2 => anotherFunction
);
</code></pre>
<p>I'm wondering if there is a way that I can still keep these as private methods in the class yet still use them with the dispatch table.</p>
| [
{
"answer_id": 306302,
"author": "Allain Lalonde",
"author_id": 2443,
"author_profile": "https://Stackoverflow.com/users/2443",
"pm_score": 4,
"selected": true,
"text": "$this->dispatch = array('somemethod', 'anothermethod');\n"
},
{
"answer_id": 306358,
"author": "Waquo",
... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1797/"
] |
306,284 | <p>So, I have a pair of typeclasses that I'll be using a lot together, and I want to avoid specifying both each time. Basically, instead of putting</p>
<pre><code>:: (Ord a, Fractional a, Ord b, Fractional b, ... Ord z, Fractional z) =>
</code></pre>
<p>at the beginning of all my type specifications, I'd rather put</p>
<pre><code>:: (OrdFractional a, OrdFractional b, ... OrdFractional z)
</code></pre>
<p>So, my initial idea on how to do this was to just declare a new typeclass</p>
<pre><code>module Example where
class (Fractional a, Ord a) => OrdFractional a
example :: (OrdFractional a, OrdFractional b) => (a,b) -> (a,b) -> (a,b) -> Bool
example (x1,y1) (x2,y2) (x3,y3) = (x1/x2 < x2/x3) && (y1/y2 < y2/y3)
</code></pre>
<p>But this didn't work as automagically as I wished it would:</p>
<pre><code>% ghci
Prelude> :l Example.hs
Ok, modules loaded: Example.
Prelude Example> example (1::Float,3::Float) (2,2) (3,1)
<interactive>:1:0:
No instance for (OrdFractional Float)
arising from a use of `example' at <interactive>:1:0-39
Possible fix:
add an instance declaration for (OrdFractional Float)
In the expression: example (1 :: Float, 3 :: Float) (2, 2) (3, 1)
In the definition of `it':
it = example (1 :: Float, 3 :: Float) (2, 2) (3, 1)
</code></pre>
<p>Manually creating instances seems like a drag so, next, I thought I might try to automatically create instances:</p>
<pre><code>module Example where
class OrdFractional a
instance (Fractional a, Ord a) => OrdFractional a
example :: (OrdFractional a, OrdFractional b) => (a,b) -> (a,b) -> (a,b) -> Bool
example (x1,y1) (x2,y2) (x3,y3) = (x1/x2 < x2/x3) && (y1/y2 < y2/y3)
</code></pre>
<p>But the compiler didn't like that:</p>
<pre><code>ghc -c Example.hs
Example.hs:4:0:
Illegal instance declaration for `OrdFractional a'
(All instance types must be of the form (T a1 ... an)
where a1 ... an are type *variables*,
and each type variable appears at most once in the instance head.
Use -XFlexibleInstances if you want to disable this.)
In the instance declaration for `OrdFractional a'
</code></pre>
<p>So is there a way I can do this?</p>
| [
{
"answer_id": 1077908,
"author": "ephemient",
"author_id": 20713,
"author_profile": "https://Stackoverflow.com/users/20713",
"pm_score": 3,
"selected": false,
"text": "Use -XFlexibleInstances"
},
{
"answer_id": 13621000,
"author": "javawizard",
"author_id": 992720,
"... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9859/"
] |
306,288 | <p>I've been trying to create a custom control that works exactly like the Panel control except surrounded by a few divs and such to create a rounded box look. I haven't been able to find a decent example of how to do this. </p>
<p>I need to be able to place text and controls inside the control and access it directly without referencing the panel (exactly the way the Panel control works).</p>
<p>Does anyone have any examples of this?</p>
| [
{
"answer_id": 306299,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 5,
"selected": true,
"text": "INamingContainer"
},
{
"answer_id": 306310,
"author": "baretta",
"author_id": 30052,
"author_profile": "h... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18234/"
] |
306,291 | <p>Is there a 4 byte unsigned int data type in MS SQL Server?</p>
<p>Am I forced to use a bigint?</p>
| [
{
"answer_id": 306300,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 4,
"selected": true,
"text": "int"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/306291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] |
306,305 | <p>I am trying to do positioning in JavaScript. I am using a cumulative position function based on the <a href="http://www.quirksmode.org/js/findpos.html" rel="noreferrer" title="Find position">classic quirksmode function</a> that sums <code>offsetTop</code> and <code>offsetLeft</code> for each <code>offsetParent</code> until the top node.</p>
<p>However, I am running into an issue where the element I'm interested in has no <code>offsetParent</code> in Firefox. In IE <code>offsetParent</code> exists, but <code>offsetTop</code> and <code>offsetLeft</code> all sum up to 0, so it has the same problem in effect as in Firefox.</p>
<p>What would cause an element that is clearly visible and usable on the screen to not have an <code>offsetParent</code>? Or, more practically, how can I find the position of this element in order to place a drop-down beneath it?</p>
<p><strong>Edit</strong>: Here's how to reproduce one particular instance of this (not solved by the currently-accepted answer):</p>
<ol>
<li>Open the <a href="http://stackoverflow.com">home page of Stack Overflow</a>.</li>
<li><p>Run the following code in the Console of the web browser (e.g. Chromev21):</p>
<pre class="lang-js prettyprint-override"><code>var e = document.querySelector('div');
console.log(e);
// <div id="notify-container"></div>
do{
var s = getComputedStyle(e);
console.log(e.tagName,s.display,s.visibility,s.position,e.offsetParent);
} while(e=e.parentElement)
// DIV block visible fixed null
// BODY block visible static null
// HTML block visible static null
</code></pre></li>
</ol>
<p><strong>Why is the <code>offsetParent</code> of that element <code>null</code>?</strong></p>
| [
{
"answer_id": 3313095,
"author": "Norman",
"author_id": 302971,
"author_profile": "https://Stackoverflow.com/users/302971",
"pm_score": 0,
"selected": false,
"text": "<div id=\"parent\">\n <div id=\"element1\">some stuff</div>\n <div id=\"element2\" style=\"display: none\">some hidden... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3078/"
] |
306,313 | <p>Why does the following behave unexpectedly in Python?</p>
<pre><code>>>> a = 256
>>> b = 256
>>> a is b
True # This is an expected result
>>> a = 257
>>> b = 257
>>> a is b
False # What happened here? Why is this False?
>>> 257 is 257
True # Yet the literal numbers compare properly
</code></pre>
<p>I am using Python 2.5.2. Trying some different versions of Python, it appears that Python 2.3.3 shows the above behaviour between 99 and 100.</p>
<p>Based on the above, I can hypothesize that Python is internally implemented such that "small" integers are stored in a different way than larger integers and the <code>is</code> operator can tell the difference. Why the leaky abstraction? What is a better way of comparing two arbitrary objects to see whether they are the same when I don't know in advance whether they are numbers or not?</p>
| [
{
"answer_id": 306347,
"author": "Amit",
"author_id": 29120,
"author_profile": "https://Stackoverflow.com/users/29120",
"pm_score": 4,
"selected": false,
"text": "id"
},
{
"answer_id": 306353,
"author": "Cybis",
"author_id": 32998,
"author_profile": "https://Stackover... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/893/"
] |
306,316 | <p>I am trying to write a C++ program that takes the following inputs from the user to construct rectangles (between 2 and 5): height, width, x-pos, y-pos. All of these rectangles will exist parallel to the x and the y axis, that is all of their edges will have slopes of 0 or infinity.</p>
<p>I've tried to implement what is mentioned in <a href="https://stackoverflow.com/questions/115426">this</a> question but I am not having very much luck.</p>
<p>My current implementation does the following:</p>
<pre><code>// Gets all the vertices for Rectangle 1 and stores them in an array -> arrRect1
// point 1 x: arrRect1[0], point 1 y: arrRect1[1] and so on...
// Gets all the vertices for Rectangle 2 and stores them in an array -> arrRect2
// rotated edge of point a, rect 1
int rot_x, rot_y;
rot_x = -arrRect1[3];
rot_y = arrRect1[2];
// point on rotated edge
int pnt_x, pnt_y;
pnt_x = arrRect1[2];
pnt_y = arrRect1[3];
// test point, a from rect 2
int tst_x, tst_y;
tst_x = arrRect2[0];
tst_y = arrRect2[1];
int value;
value = (rot_x * (tst_x - pnt_x)) + (rot_y * (tst_y - pnt_y));
cout << "Value: " << value;
</code></pre>
<p>However I'm not quite sure if (a) I've implemented the algorithm I linked to correctly, or if I did exactly how to interpret this?</p>
<p>Any suggestions?</p>
| [
{
"answer_id": 306332,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": 11,
"selected": true,
"text": "if (RectA.Left < RectB.Right && RectA.Right > RectB.Left &&\n RectA.Top > RectB.Bottom && RectA.Bottom < RectB... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/135/"
] |
306,381 | <p>How do you create a custom control (not an ASCX control) and, more importantly, use it in your project? I'd prefer not to create a separate project for it or compile it as a DLL</p>
| [
{
"answer_id": 306388,
"author": "Bruno Shine",
"author_id": 28294,
"author_profile": "https://Stackoverflow.com/users/28294",
"pm_score": 1,
"selected": false,
"text": "<%@ Register Assembly=\"NAME_OF_THE_ASSEMBLY\" Namespace=\"NAMESPACE_OF_THE_CUSTOM_CONTROL\" TagPrefix=\"cc1\" %>\n"
... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18234/"
] |
306,387 | <p>Delegates look like such a powerful language feature, but I've yet to find an opportunity to use them in anger (apart from in DALs I must say).</p>
<p>How often do you use them, and under what circumstances do you find them most useful? </p>
| [
{
"answer_id": 306394,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": 3,
"selected": false,
"text": "public delegate void MyDelegate(object sender, EventArgs e, string otherParameterIWant);\n//...Inside the class... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38522/"
] |
306,400 | <p>How do I retrieve an item at random from the following list?</p>
<pre><code>foo = ['a', 'b', 'c', 'd', 'e']
</code></pre>
| [
{
"answer_id": 306417,
"author": "Pēteris Caune",
"author_id": 5821,
"author_profile": "https://Stackoverflow.com/users/5821",
"pm_score": 13,
"selected": true,
"text": "random.choice()"
},
{
"answer_id": 12373205,
"author": "Juan Pablo Rinaldi",
"author_id": 540477,
... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] |
306,410 | <p>I have a following object model:</p>
<pre>
- Book
-- Chapter 1
--- Page 1
---- Image 1
---- Image 2
---- Text 1
--- Page 2
...
</pre>
<p>Resources are way down at the page level. But, I need to know the full path to resources, from the resources' point of view. </p>
<p>One way, is to have resources be aware of their parents. </p>
<p>So my Image object could have a "parentPage" property, which in turn could have a "parentChapter" property. This way, I could access the complete path via currentImage.parentPage.parentChapter. Is there a better way?</p>
<p>A couple of words on why I'd need to know the full path from a resource's point of view. I have an object model that gets walked and rendered on screen. The renderer descends from chapter level all the way down into the element/resource level (this is where the rendering occurs). However to display the resources, I need to know where they live (ie the actual path on disk) and this information is typically specified at the Chapter level.</p>
<p>Thanks!</p>
<p>-- Edit --
Just to clarify, is this parent.parent approach the best? It forces child objects to know about the parents, which makes me uncomfortable. Coupling?</p>
| [
{
"answer_id": 306448,
"author": "Zachary Yates",
"author_id": 8360,
"author_profile": "https://Stackoverflow.com/users/8360",
"pm_score": 3,
"selected": false,
"text": "class TreeNode {\n public TreeNode Parent { get; set; }\n public List<TreeNode> Children { get; set; }\n}\n\nclass Boo... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38753/"
] |
306,433 | <p>I have a fairly huge database with a master table with a single column GUID (custom GUID like algorithm) as primary key and 8 child tables that have foreign key relationships with this GUID column. All the tables have approximately 3-8 million records. None of these tables have any BLOB/CLOB/TEXT or any other fancy data types just normal numbers, varchars, dates, and timestamps (about 15-45 columns in each table). No partitions or other indexes other than the primary and foreign keys.</p>
<p>Now, the custom GUID algorithm has changed and though there are no collisions I would like to migrate all the old data to use GUIDs generated using the new algorithm. No other columns need to be changed. Number one priority is data integrity and performance is secondary.</p>
<p>Some of the possible solutions that I could think of were (as you will probably notice they all revolve around one idea only)</p>
<ol>
<li>add new column ngu_id and populate with new gu_id; disable constraints; update child tables with ngu_id as gu_id; renaname ngu_id->gu_id; re-enable constraints</li>
<li>read one master record and its dependent child records from child tables; insert into the same table with new gu_id; remove all records with old gu_ids</li>
<li>drop constraints; add a trigger to the master table such that all the child tables are updated; start updating old gu_id's with new new gu_ids; re-enable constraints</li>
<li>add a trigger to the master table such that all the child tables are updated; start updating old gu_id's with new new gu_ids</li>
<li>create new column ngu_ids on all master and child tables; create foreign key constraints on ngu_id columns; add update trigger to the master table to cascade values to child tables; insert new gu_id values into ngu_id column; remove old foreign key constraints based on gu_id; remove gu_id column and rename ngu_id to gu_id; recreate constraints if necessary;</li>
<li>use <code>on update cascade</code> if available?</li>
</ol>
<p>My questions are:</p>
<ol>
<li>Is there a better way? (Can't burrow my head in the sand, gotta do this)</li>
<li>What is the most suitable way to do this? (I've to do this in Oracle, SQL server and mysql4 so, vendor-specific hacks are welcome)</li>
<li>What are the typical points of failure for such an exercise and how to minimize them?</li>
</ol>
<p>If you are with me so far, thank you and hope you can help :)</p>
| [
{
"answer_id": 310611,
"author": "George Eadon",
"author_id": 30530,
"author_profile": "https://Stackoverflow.com/users/30530",
"pm_score": 0,
"selected": false,
"text": "CREATE TABLE AS SELECT"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/306433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7616/"
] |
306,439 | <p>I have this Trigger in Postgresql that I can't just get to work (does nothing). For understanding, there's how I defined it:</p>
<pre><code>CREATE TABLE documents (
...
modification_time timestamp with time zone DEFAULT now()
);
CREATE FUNCTION documents_update_mod_time() RETURNS trigger
AS $$
begin
new.modification_time := now();
return new;
end
$$
LANGUAGE plpgsql;
CREATE TRIGGER documents_modification_time
BEFORE INSERT OR UPDATE ON documents
FOR EACH ROW
EXECUTE PROCEDURE documents_update_mod_time();
</code></pre>
<p>Now to make it a bit more interesting.. How do you debug triggers?</p>
| [
{
"answer_id": 306509,
"author": "Kev",
"author_id": 16777,
"author_profile": "https://Stackoverflow.com/users/16777",
"pm_score": 2,
"selected": false,
"text": "ALTER TABLE documents\n ALTER COLUMN modification_time SET DEFAULT clock_timestamp();\n"
},
{
"answer_id": 312866,
... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35189/"
] |
306,443 | <p>In designing a fluid layout, how do you use borders without ruining the layout.</p>
<p>More specifically, I have a HTML widget which consists of five divs. I would like the five divs to take up all the room in the containing element. I would also like to have a 1px border around each.</p>
<p>I tried:
.box { float: left; height: 100%; width: 100%; border: 1px solid red; }
This doesn't work: there will be an extra 10px in width causing the boxes to wrap. Reducing the width percentage doesn't work as it will not take up the correct amount of space and for certain page sizes, will still wrap.</p>
<p>Whats the proper way to manage the interaction between these elements?</p>
| [
{
"answer_id": 306472,
"author": "One Crayon",
"author_id": 38666,
"author_profile": "https://Stackoverflow.com/users/38666",
"pm_score": 2,
"selected": false,
"text": "width: 100%"
},
{
"answer_id": 306947,
"author": "Ola Tuvesson",
"author_id": 6903,
"author_profile... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
306,452 | <p>Let's say I need to implement domain model for StackOverflow. </p>
<p>If I am doing ORM, how can I define (and map) property for fetching "last comments" and other "last" things?
It looks to me like this should be reflected in the domain model.</p>
<p>Sometimes I might need "all comments" though...</p>
| [
{
"answer_id": 306472,
"author": "One Crayon",
"author_id": 38666,
"author_profile": "https://Stackoverflow.com/users/38666",
"pm_score": 2,
"selected": false,
"text": "width: 100%"
},
{
"answer_id": 306947,
"author": "Ola Tuvesson",
"author_id": 6903,
"author_profile... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38325/"
] |
306,459 | <p>Is there a clever way to determine which field is causing 'string or binary data would be truncated' with LINQ.</p>
<p>I've always ended up doing it manually by stepping through a debugger, but with a batch using 'SubmitChanges' I have to change my code to inserting a single row to find the culprit in a batch of rows. </p>
<p>Am I missing something or in this day and age do I really have to still use a brute force method to find the problem.</p>
<p>Please dont give me advice on avoiding this error in future (unless its something much cleverer than 'validate your data'). The source data is coming from a different system where I dont have full control anyway - plus I want to be lazy.</p>
<p>PS. Does SQL Server 2008 actually tell me the field name. Please tell me it does! I'll upgrade!</p>
| [
{
"answer_id": 306540,
"author": "DJ.",
"author_id": 10492,
"author_profile": "https://Stackoverflow.com/users/10492",
"pm_score": -1,
"selected": false,
"text": "Record # 9999\nCaused \"string or binary data would be truncated\" error\nField1: \"Data\" Length: 55\nField2: 9999\netc.\n"
... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] |
306,462 | <p>I'm using <a href="http://www.codeproject.com/KB/cs/lotusnoteintegrator.aspx" rel="nofollow noreferrer">Interop.Domino.dll</a> to retrieve E-mails from a Lotus "Database" (Term used loosely). I'm having some difficulty in retrieving certain fields and wonder how to do this properly. I've been using <code>NotesDocument.GetFirstItem</code> to retrieve Subject, From and Body. </p>
<p>My issues in this regard are thus:</p>
<ol>
<li>How do I retrieve Reply-To address? Is there a list of "Items" to get somewhere? I can't find it.</li>
<li>How do I retrieve friendly names for From and Reply-To addresses?</li>
<li>When I retrieve Body this way, it's formatted wierdly with square bracket sets ([]) interspersed randomly across the message body, and parts of the text aren't where I expect them. </li>
</ol>
<p>Related code:</p>
<pre><code>string
ActualSubject = nDoc.GetFirstItem("Subject").Text,
ActualFrom = nDoc.GetFirstItem("From").Text,
ActualBody = nDoc.GetFirstItem("Body").Text;
</code></pre>
| [
{
"answer_id": 306624,
"author": "tsilb",
"author_id": 11112,
"author_profile": "https://Stackoverflow.com/users/11112",
"pm_score": 3,
"selected": true,
"text": "Object[] ni = (Object[])nDoc.Items;\nstring names_values = \"\";\nfor (int x = 0; x < ni.Length; x++)\n{\nNotesItem item = (N... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11112/"
] |
306,463 | <p>Is there any performance gain using a CTE over a derived table?</p>
| [
{
"answer_id": 306624,
"author": "tsilb",
"author_id": 11112,
"author_profile": "https://Stackoverflow.com/users/11112",
"pm_score": 3,
"selected": true,
"text": "Object[] ni = (Object[])nDoc.Items;\nstring names_values = \"\";\nfor (int x = 0; x < ni.Length; x++)\n{\nNotesItem item = (N... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343291/"
] |
306,466 | <p>I'm writing a script to display the 10 most recently "active" WordPress blog posts (i.e. those with the most recent comments). Problem is, the list has a lot of duplicates. I'd like to weed out the duplicates. Is there an easy way to do this by changing the MySQL query (like IGNORE, WHERE) or some other means? Here's what I have so far:</p>
<pre><code><?php
function cd_recently_active() {
global $wpdb, $comments, $comment;
$number = 10; //how many recently active posts to display? enter here
if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) {
$comments = $wpdb->get_results("SELECT comment_date, comment_author, comment_author_url, comment_ID, comment_post_ID, comment_content FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number");
wp_cache_add( 'recent_comments', $comments, 'widget' );
}
?>
</code></pre>
| [
{
"answer_id": 307002,
"author": "55skidoo",
"author_id": 34964,
"author_profile": "https://Stackoverflow.com/users/34964",
"pm_score": 0,
"selected": false,
"text": " if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) {\n $comments = $wpdb->get_results(\"SELECT commen... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34964/"
] |
306,475 | <p>In SharePoint MOSS 2007, I have created a custom content type that I will be applying to a document library. One of the required fields is "Incoming Date" and another is the "Due Date". </p>
<p>The Due Date is always 10 working days from the Incoming Date. The Incoming Date is when the mail room received the letter, not necessarily when the document is posted to the library.</p>
<p>From here: <a href="http://msdn.microsoft.com/en-us/library/bb862071.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb862071.aspx</a></p>
<pre><code>=DATE(YEAR([Incoming Date]),MONTH([Incoming Date]),DAY([Incoming Date])+10)
</code></pre>
<p>adds 10 days, but how can I add 10 working days? I don't have the luxury of VS.NET either per the governance plan of our sharepoint rollout.</p>
<p>Assume a human is responsible for the data entry, but I would like to make it easier for them.</p>
| [
{
"answer_id": 620739,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "C_Wknd =IF(TEXT(WEEKDAY([Complaint Created On]),\"ddd\")=\"Mon\",11,13)\n\nC_NYDay =IF(AND([Complaint Created On]<=DATE(2009,... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24229/"
] |
306,477 | <p>I am using the MFC class <code>CSocket</code>. Nothing complicated - open a connection to a server and send a short message. The code works fine when I link with MFC in a DLL. However, the call to <code>CSocket::Create()</code> crashes when I link to MFC in a static library.</p>
<p>I would like to use MFC in a static library since it simplifies distribution.</p>
| [
{
"answer_id": 14278279,
"author": "user1969975",
"author_id": 1969975,
"author_profile": "https://Stackoverflow.com/users/1969975",
"pm_score": 2,
"selected": false,
"text": " void SocketThreadInit()\n {\n #ifndef _AFXDLL\n #define _AFX_SOCK_THREAD_STATE AFX_MODULE_THREAD_STATE\... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16582/"
] |
306,482 | <p>I have the following command which will loop over all the subdirectories in a specific location and output the full path:</p>
<pre><code>for /d %i in ("E:\Test\*") do echo %i
</code></pre>
<p>Will give me:</p>
<pre><code>E:\Test\One
E:\Test\Two
</code></pre>
<p>But how do I get both the full path, and just the directory name, so the do command might be something like:</p>
<pre><code>echo %i - %j
</code></pre>
<p>And the output might be something like:</p>
<pre><code>E:\Test\One - One
E:\Test\Two - Two
</code></pre>
<p>Thanks in advance!</p>
| [
{
"answer_id": 306507,
"author": "Craig Lebakken",
"author_id": 33130,
"author_profile": "https://Stackoverflow.com/users/33130",
"pm_score": 3,
"selected": true,
"text": "%~fI - expands %I to a fully qualified path name\n%~nI - expands %I to a file name only\n"
},
{
... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39428/"
] |
306,497 | <p>I would like to be a PHP/MySQL programmer </p>
<p>What are the technologies that I must know?</p>
<p>Like:</p>
<ol>
<li>Frameworks</li>
<li>IDEs</li>
<li>Template Engines</li>
<li>Ajax and CSS Frameworks</li>
</ol>
<p>Please tell me the minimum requirements that I must know, and tell me your favourite things in the previous list?</p>
<p>Thanks</p>
| [
{
"answer_id": 306657,
"author": "Kornel",
"author_id": 27009,
"author_profile": "https://Stackoverflow.com/users/27009",
"pm_score": 2,
"selected": false,
"text": "echo $some_variable_that_seems_innocent"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/306497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22634/"
] |
306,504 | <p>I'm creating a multi-part web form in ASP.NET that uses Panels for the different steps, making only the Panel for the current step visible. On Step 1, I have a drop-down list that uses a Javascript function to reconfigure some of the fields in the same Panel via "onchange". Obviously, since the client-side script is only affecting the DOM, when I go to Step 2 and then back up to Step 1, the fields in Step 1 are back to their orignal configuration even though the same drop-down choice is selected.</p>
<p>What is a good method for storing the visual state of the Panels between steps? I considered calling the drop-down's onchange function on page load, but that seemed clunky. Thanks!</p>
<p>--</p>
<p>Thanks for the quick answers - I think I'll try out the Wizard, but the AJAX solution also sounds like fun.</p>
| [
{
"answer_id": 306657,
"author": "Kornel",
"author_id": 27009,
"author_profile": "https://Stackoverflow.com/users/27009",
"pm_score": 2,
"selected": false,
"text": "echo $some_variable_that_seems_innocent"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/306504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22761/"
] |
306,527 | <p>I have a bit of code that looks like this:</p>
<pre><code>text = reg.Replace(text, new MatchEvaluator(MatchEvalStuff));
</code></pre>
<p>I need to pass in a 2nd parameter like this:</p>
<pre><code>text = reg.Replace(text, new MatchEvaluator(MatchEvalStuff, otherData));
</code></pre>
<p>Is this possible, and what would be the best way to do this?</p>
| [
{
"answer_id": 306564,
"author": "Daniel Plaisted",
"author_id": 1509,
"author_profile": "https://Stackoverflow.com/users/1509",
"pm_score": 5,
"selected": false,
"text": "text = reg.Replace(text, match => MatchEvalStuff(match, otherData));\n"
},
{
"answer_id": 306629,
"autho... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343/"
] |
306,531 | <p>I have written a KornShell (ksh) script that sets an array the following way:</p>
<pre><code>set -A fruits Apple Orange Banana Strawberry
</code></pre>
<p>but when I am trying to run it from within cron, it raises the following error:</p>
<pre><code>Your "cron" job on myhost
/myScript.sh
produced the following output:
myScript.sh: -A: bad option(s)
</code></pre>
<p>I have tried many crontab syntax variants, such as:</p>
<p>Attempt 1:</p>
<pre><code>0,5,10,15,20,25,30,35,40,45,50,55 * * * * /path/to/script/myScript.sh
</code></pre>
<p>Attempt 2:</p>
<pre><code>0,5,10,15,20,25,30,35,40,45,50,55 * * * * /path/to/script/./myScript.sh
</code></pre>
<p>Attempt 3:</p>
<pre><code>0,5,10,15,20,25,30,35,40,45,50,55 * * * * cd /path/to/script && ./myScript.sh
</code></pre>
<p>Any workaround would be sincerely appreciated. Thanks much in advance!</p>
| [
{
"answer_id": 306673,
"author": "Nano Taboada",
"author_id": 6992,
"author_profile": "https://Stackoverflow.com/users/6992",
"pm_score": 2,
"selected": true,
"text": "0,5,10,15,20,25,30,35,40,45,50,55 * * * * cd /path/to/script && ksh ./myScript.sh\n"
},
{
"answer_id": 306879,
... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6992/"
] |
306,533 | <p>How do you get a list of files within a directory so each can be processed?</p>
| [
{
"answer_id": 306542,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 6,
"selected": true,
"text": "boost::filesystem"
},
{
"answer_id": 306917,
"author": "Chris Kloberdanz",
"author_id": 2871... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/370/"
] |
306,541 | <p>I've had this problem many times before, and I've never had a solution I felt good about. </p>
<p>Let's say I have a Transaction base class and two derived classes AdjustmentTransaction and IssueTransaction.</p>
<p>I have a list of transactions in the UI, and each transaction is of the concrete type AdjustmentTransaction or IssueTransaction.</p>
<p>When I select a transaction, and click an "Edit" button, I need to decide whether to show an AdjustmentTransactionEditorForm or an IssueTransactionEditorForm.</p>
<p>The question is how do I go about doing this in an OO fashion without having to use a switch statement on the type of the selected transaction? The switch statement works but feels kludgy. I feel like I should be able to somehow exploit the parallel inheritance hierarchy between Transactions and TransactionEditors.</p>
<p>I could have an EditorForm property on my Transaction, but that is a horrible mixing of my UI peanut butter with my Model chocolate.</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 306565,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 2,
"selected": true,
"text": "Dictionary <Type,Type> typeMapper = new Dictionary<Type,Type>();\ntypeMapper.Add(typeof(AdjustTransaction), typeof(AdjustTran... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3285/"
] |
306,545 | <p>With WinForms, I can use <code>Control.Scale</code> to scale a control larger. When I do that, all child controls are repositioned and scaled correctly, but font size remains the same.</p>
<p>Is there an easy way to force font to scale up/down, or is the only way to manually update font for all controls when control is being scaled?</p>
<p>Background: I'm working on a program in which I need to support zoom in/out to make labels, textboxs, etc. more readable for users with poor eyesight.</p>
| [
{
"answer_id": 306768,
"author": "Hans Passant",
"author_id": 17034,
"author_profile": "https://Stackoverflow.com/users/17034",
"pm_score": 2,
"selected": false,
"text": " public partial class Form1 : Form {\n float mDesignSize;\n int mIncrement;\n public Form1() {\n Initi... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19124/"
] |
306,551 | <p>I am in a Windows Desktop application and I have a data stream and a mime type in the database. Is there a better way than writing it to a temp folder and launching the default editor for it?</p>
<p>If I have to use the temp folder how can I get the file extension from the MIME type in a C# Windows Desktop application? </p>
| [
{
"answer_id": 306597,
"author": "activout.se",
"author_id": 20444,
"author_profile": "https://Stackoverflow.com/users/20444",
"pm_score": 3,
"selected": true,
"text": "HKEY_CLASSES_ROOT\\MIME\\Database\\Content Type"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/306551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30099/"
] |
306,559 | <p>I'm trying to figure out how to write this function:</p>
<pre><code>template <typename Bound>
Bound::result_type callFromAnyList(Bound b, list<any> p)
{
}
</code></pre>
<p>Then, if I had some function:</p>
<pre><code>double myFunc(string s, int i)
{
return -3.0;
}
</code></pre>
<p>I could call it by doing something like this:</p>
<pre><code>list<any> p;
p.push_back((string)"Hello");
p.push_back(7);
double result = callFromAnyList(bind(myFunc, _1, _2), p);
</code></pre>
<p>Is it possible to write something like my <code>callFromAnyList</code> function? Can you inspect the result type and the parameter types from the type returned from <code>bind</code>? And then call <code>any_cast<P1>(*p.begin())</code>, etc? I've tried to understand the bind code, but it's a little hard to follow, and it doesn't appear as though they wrote it with inspection in mind.</p>
| [
{
"answer_id": 306691,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 2,
"selected": true,
"text": "template<typename>\nstruct return_of;\n\ntemplate<typename R>\nstruct return_of<R(*)()> {\n typedef R typ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8643/"
] |
306,572 | <p>I recently started building a console version of a web application. I copied my custom sections from my web.config. to my app.config. When I go to get config information i get this error:</p>
<p>An error occurred creating the configuration section handler for x/y: Could not load type 'x' from assembly 'System.Configuration</p>
<p>The line that it is not liking is:</p>
<p>return ConfigurationManager.GetSection("X/Y") as Z;</p>
<p>Anyone run into something like this?</p>
<p>I was able to add </p>
<pre><code><add key="IsReadable" value="0"/>
</code></pre>
<p>in the appSettings and read it.</p>
<p>Addition:</p>
<p>I do actually have this defined about the custom section:</p>
<pre><code> <configSections>
<sectionGroup name="x">
<section name="y" type="zzzzz"/>
</sectionGroup>
</configSections>
</code></pre>
| [
{
"answer_id": 306575,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 3,
"selected": true,
"text": "<configSection>\n <section\n name=\"YOUR_CLASS_NAME_HERE\"\n type=\"YOUR.NAMESPACE.CLASSNAME,... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] |
306,573 | <p>Is it possible to have a file belong to multiple subpackages? For example:</p>
<pre><code>/**
* Name
*
* Desc
*
* @package Core
* @subpackage Sub1
* @subpackage Sub2
*/
</code></pre>
<p>Thanks!</p>
| [
{
"answer_id": 11404615,
"author": "E Brent Nelson",
"author_id": 1513307,
"author_profile": "https://Stackoverflow.com/users/1513307",
"pm_score": 2,
"selected": false,
"text": "* @package popcap\\system\\cache\n"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/306573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/538/"
] |
306,579 | <p>I would like to be able to Serialize a DateTime with a specific Time Zone that is not the server, nor is it client time. Basically, any time zone.
Is it possible to override the DateTime serialization, in .Net2.0 webservices?</p>
<p>I compile an xmlschema using xsd.exe, so I made an attempt using XmlSchemaImporter.</p>
<p>The OnSerialize examples show value changes, but not changes to the output format.</p>
<p>XmlSchemaImporter, loaded it into the gac, ran xsd.exe, and generated code that has the class I want... but that class is an attribute, which end up not being able to be reflected.</p>
<blockquote>
<p>[InvalidOperationException: Cannot
serialize member 'metadataDateTime' of
type Cuahsi.XmlOverrides.W3CDateTime.
XmlAttribute/XmlText cannot be used to
encode complex types.]</p>
</blockquote>
<p>Generated code</p>
<pre><code>[System.Xml.Serialization.XmlAttributeAttribute()]
public Cuahsi.XmlOverrides.W3CDateTime dateTime {
get {
return this.dateTimeField;
}
set {
this.dateTimeField = value;
}
}
</code></pre>
<p>XmlSchemaImporter</p>
<pre><code>public class ImportW3CTime :
System.Xml.Serialization.Advanced.SchemaImporterExtension
{
public override string ImportSchemaType(string name, string ns,
XmlSchemaObject context, XmlSchemas schemas,
XmlSchemaImporter importer, CodeCompileUnit compileUnit,
CodeNamespace mainNamespace, CodeGenerationOptions options,
CodeDomProvider codeProvider)
{
if (XmlSchema.Namespace == ns)
{
switch (name)
{
case "dateTime":
string codeTypeName = typeof(W3CDateTime).FullName;
CodeTypeDeclaration cls =
new CodeTypeDeclaration("W3CDateTime");
cls.IsStruct = true;
cls.Attributes = MemberAttributes.Public;
cls.BaseTypes.Add("dateTime");
mainNamespace.Types.Add(cls);
return codeTypeName;
default: return null;
}
}
else { return null; }
}
}
</code></pre>
<p><strong>Addendum 1:</strong>
I just tired DateTimeoffset, and that still causes an error when the class is tagged like:</p>
<pre><code>[System.Xml.Serialization.XmlAttributeAttribute(DataType = "dateTime")]
public System.DateTimeOffset metadataDateTime {
get {
return this.metadataDateTimeField;
}
set {
this.metadataDateTimeField = value;
}
}
</code></pre>
| [
{
"answer_id": 7140219,
"author": "Thomas Levesque",
"author_id": 98713,
"author_profile": "https://Stackoverflow.com/users/98713",
"pm_score": 2,
"selected": false,
"text": "DateTimeOffset"
}
] | 2008/11/20 | [
"https://Stackoverflow.com/questions/306579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36627/"
] |
306,583 | <p>I have a layout similar to this:</p>
<pre><code><div id="..."><img src="..."></div>
</code></pre>
<p>and would like to use a jQuery selector to select the child <code>img</code> inside the <code>div</code> on click.</p>
<p>To get the <code>div</code>, I've got this selector:</p>
<pre><code>$(this)
</code></pre>
<p>How can I get the child <code>img</code> using a selector?</p>
| [
{
"answer_id": 306608,
"author": "Maxam",
"author_id": 15310,
"author_profile": "https://Stackoverflow.com/users/15310",
"pm_score": 5,
"selected": false,
"text": "$(this).children()[0]\n"
},
{
"answer_id": 306632,
"author": "Adam",
"author_id": 36324,
"author_profile... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306583",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16974/"
] |
306,591 | <p>I'm trying to get the contents from another file with <code>file_get_contents</code> (don't ask why).<br />
I have two files: <em>test1.php</em> and <em>test2.php</em>. <em>test1.php</em> returns a string, bases on the user that is logged in.</p>
<p><em>test2.php</em> tries to get the contents of <em>test1.php</em> and is being executed by the browser, thus getting the cookies.</p>
<p>To send the cookies with <code>file_get_contents</code>, I create a streaming context:</p>
<pre><code>$opts = array('http' => array('header'=> 'Cookie: ' . $_SERVER['HTTP_COOKIE']."\r\n"))`;
</code></pre>
<p>I'm retrieving the contents with:</p>
<pre><code>$contents = file_get_contents("http://www.example.com/test1.php", false, $opts);
</code></pre>
<p>But now I get the error:</p>
<blockquote>
<p>Warning: file_get_contents(<a href="http://www.example.com/test1.php" rel="nofollow noreferrer">http://www.example.com/test1.php</a>) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found</p>
</blockquote>
<p>Does somebody knows what I'm doing wrong here?</p>
<p>edit:<br />
forgot to mention: Without the <em>streaming_context</em>, the page just loads. But without the cookies I don't get the info I need.</p>
| [
{
"answer_id": 308060,
"author": "Alan Storm",
"author_id": 4668,
"author_profile": "https://Stackoverflow.com/users/4668",
"pm_score": 6,
"selected": true,
"text": "$opts = array('http' => array('header'=> 'Cookie: ' . $_SERVER['HTTP_COOKIE'].\"\\r\\n\"));\n$context = stream_context_cre... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20261/"
] |
306,596 | <p>I am trying to deserialize a stream but I always get this error "End of Stream encountered before parsing was completed"?</p>
<p>Here is the code:</p>
<pre><code> //Some code here
BinaryFormatter b = new BinaryFormatter();
return (myObject)b.Deserialize(s);//s---> is a Stream object that has been fill up with data some line over here
</code></pre>
<p>Any one have ideas?</p>
| [
{
"answer_id": 306598,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": 7,
"selected": true,
"text": " BinaryFormatter b = new BinaryFormatter();\n s.Position = 0;\n return (YourObjectType)b.De... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14441/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.