qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
397,692
<p>I'd like to display the binary (or hexadecimal) representation of a floating point number. I know how to convert by hand (using the method <a href="http://en.wikipedia.org/wiki/Floating_point#Implementation_in_actual_computers:_IEEE_floating-point" rel="noreferrer">here</a>), but I'm interested in seeing code samples that do the same.</p> <p>Although I'm particularly interested in the C++ and Java solutions, I wonder if any languages make it particularly easy so I'm making this <strong>language agnostic</strong>. I'd love to see some solutions in other languages.</p> <p><strong>EDIT:</strong> I've gotten good coverage of C, C++, C#, and Java. Are there any alternative-language gurus out there who want to add to the list?</p>
[ { "answer_id": 397700, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 6, "selected": true, "text": "union ufloat {\n float f;\n unsigned u;\n};\n\nufloat u1;\nu1.f = 0.3f;\n u1.u union udouble {\n double d;\n unsigned lo...
2008/12/29
[ "https://Stackoverflow.com/questions/397692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1288/" ]
397,708
<p>I am trying to write a MySQL query that retrieves one record from table "projects" that has a one-to-many relationship with table "tags". My application uses 4 tables to do this:</p> <pre><code>Projects - the projects table Entities - entity table; references several application resources Tags - tags table Tag_entity - links tags to entities </code></pre> <p>Is it possible to write the query in such a way that multiple values from table "Tags" are concatenated into one result column? I'd prefer doing this without using subqueries.</p> <p>Table clarification:</p> <pre><code> ------------- | Tag_Entity | ------------- ---------- | ----------- | ------- | Projects | | Entities | | - id | | Tags | | ----------- | | -------- | | - tag_id | | ----- | | - id | --&gt; | - id | --&gt; | - entity_id | --&gt; | id | | - entity_id | ---------- ------------- | name | ------------- ------- </code></pre> <p>Desired result:</p> <pre><code>Projects.id Entities.id Tags.name (concatenated) 1 5 'foo','bar','etc' </code></pre>
[ { "answer_id": 397716, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "DECLARE @csv varchar(max)\nSET @csv = ''\nSELECT @csv = @csv + ',' + foo.SomeColumn\nFROM [FOO] foo\nWHERE foo.Som...
2008/12/29
[ "https://Stackoverflow.com/questions/397708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11568/" ]
397,721
<p>Is it possible to add a jQuery function so that a click in a table cell will invoke a hidden &lt;a href="javascript: ..." /&gt; element (that is a descendant of the TD) ?</p> <p>I've tried with </p> <p>$('#table td').click(function() { $(this).find('a').click(); });</p> <p>An other variants, but to no luck.</p> <p>--larsw</p>
[ { "answer_id": 397742, "author": "Zach Langley", "author_id": 45230, "author_profile": "https://Stackoverflow.com/users/45230", "pm_score": 3, "selected": false, "text": "href $(document).ready(function() {\n $('table td').click(function(event) {\n alert($(this).html())\n })...
2008/12/29
[ "https://Stackoverflow.com/questions/397721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2732/" ]
397,723
<p>I have a collection of movies and TV shows in iTunes, and I'd like to rename them to an <a href="http://xbmc.org/wiki/?title=TV_Shows" rel="nofollow noreferrer">XBMC compatible naming convention</a> without breaking the links in iTunes.</p> <p>All the necessary metadata (season number, show name, episode number, etc) seems to be in an XML file that iTunes manages, and the episode name is the current file name. So programmatically renaming the files seems fairly straightforward but how do I keep the iTunes library straight at the same time? Is it enough to rewrite the XML file to point to the new file names?</p> <p>I'd rather not get into applescript if I can avoid it (life is too short), however if it is easier to do it that way I may look at it. Otherwise I'd ideally like to do this in ruby.</p>
[ { "answer_id": 397746, "author": "Dan Williams", "author_id": 4230, "author_profile": "https://Stackoverflow.com/users/4230", "pm_score": 2, "selected": false, "text": "var ITTrackKindFile = 1;\nvar iTunesApp = WScript.CreateObject(\"iTunes.Application\");\nvar deletedTracks = 0;\nva...
2008/12/29
[ "https://Stackoverflow.com/questions/397723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42404/" ]
397,736
<p>I want to globalize my application. I have created a small form which asks the user their language. I have a number of problems :</p> <p>Problem 1:</p> <p>In program.cs</p> <pre><code>new SplashScreen(_tempAL); new LangForm(_lang); Application.Run(new Form1(_tempAL, _lang)); </code></pre> <p>I want the application not to call Form1 until the user clicks on OK in LangForm . For more explaintion in LangForm :</p> <pre><code> public LangForm(char _langChar) { InitializeComponent(); _ch = _langChar; this.TopMost = true; this.Show(); } private void _btnOk_Click(object sender, EventArgs e) { string _langStr = _cbLang.SelectedText; switch (_langStr) { case "English": _ch = 'E'; this.Hide(); break; case "Arabic": _ch = 'A'; this.Hide(); break; case "Frensh": _ch ='F'; this.Hide(); break; } _pressedOk = true; } private void _btnCancel_Click(object sender, EventArgs e) { this.Close(); Application.Exit(); } </code></pre> <p>Now when I debug, the application calls LangForm and then Form1 so both forms are shown. I want Form1 to wait until the user clicks on Ok in LangForm.</p> <p>Problem 2:</p> <p>When should I check on the language? It's not allowed to check in "initializeComponent()" so should I check after this function and then set controls location according to the language.</p> <p>Problem 3:</p> <p>Within application process I displays some message so before each "MessageBox.Show("");" I should check for the language or there is another way where I may set the language once.</p> <p>Problem 4:</p> <p>I have searched for interfaces for MessageBox as actually I want to change its layout. How can I find templates for MessageBox?</p> <p>Thanks in-advance.</p>
[ { "answer_id": 397746, "author": "Dan Williams", "author_id": 4230, "author_profile": "https://Stackoverflow.com/users/4230", "pm_score": 2, "selected": false, "text": "var ITTrackKindFile = 1;\nvar iTunesApp = WScript.CreateObject(\"iTunes.Application\");\nvar deletedTracks = 0;\nva...
2008/12/29
[ "https://Stackoverflow.com/questions/397736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42782/" ]
397,738
<p>Last weekend I changed webhosts for my website. The host server I was on was a 32-bit OS and the one I moved to is 64-bit. Unexpectedly, some of my PHP scripts started giving incorrect results. </p> <p>In my case the &lt;&lt; and >> (bit shift) operations were the culprit. I ended up having to mask the result with 0xFFFFFFFF and then changing the result if negative for it to work as it did before.</p> <p>Are there any other possible problems in my PHP scripts I should look for?</p>
[ { "answer_id": 1175041, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": " 0010 >> 1 = 0001 [ 1 dec ]\n0000 0010 >> 1 = 0000 0001 [ 1 dec ]\n 0100 << 1 = 1000 [ -8 dec ]\n000...
2008/12/29
[ "https://Stackoverflow.com/questions/397738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30176/" ]
397,741
<p>My Microsoft SQL Server Management Studio is slow. And by slow I mean >1minute to render a context menu-slow. All other things work perfectly fine. The connection to the database itself is not slow (my app works just fine and context menus don't need connection to the DB anyway I guess)..</p> <p>Anybody has any idea what I should check to solve this?</p> <p><strong>--EDIT--</strong> </p> <ul> <li>Cpu is around 3% </li> <li>Gigs of free ram </li> <li>Only clicking right on a table in the object explorer, nothing else</li> <li>the database is remote</li> <li>It's the full version of SSMS</li> <li>No system logging errors</li> <li>Reinstall had no effect</li> </ul> <p><strong>UPDATE</strong> </p> <p>I installed Toad for SQL and everything works super smooth there. Actually, I find it way more productive then MSSql ever was for me. It's not really an answer to my question, but it certainly a solution. </p>
[ { "answer_id": 1175041, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": " 0010 >> 1 = 0001 [ 1 dec ]\n0000 0010 >> 1 = 0000 0001 [ 1 dec ]\n 0100 << 1 = 1000 [ -8 dec ]\n000...
2008/12/29
[ "https://Stackoverflow.com/questions/397741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
397,744
<p>I have a windows service written in c#. It has a timer inside, which fires some functions on a regular basis. So the skeleton of my service:</p> <pre><code>public partial class ArchiveService : ServiceBase { Timer tickTack; int interval = 10; ... protected override void OnStart(string[] args) { tickTack = new Timer(1000 * interval); tickTack.Elapsed += new ElapsedEventHandler(tickTack_Elapsed); tickTack.Start(); } protected override void OnStop() { tickTack.Stop(); } private void tickTack_Elapsed(object sender, ElapsedEventArgs e) { ... } } </code></pre> <p>It works for some time (like 10-15 days) then it stops. I mean the service shows as running, but it does not do anything. I make some logging and the problem can be the timer, because after the interval it does not call the tickTack_Elapsed function.</p> <p>I was thinking about rewrite it without a timer, using an endless loop, which stops the processing for the amount of time I set up. This is also not an elegant solution and I think it can have some side effects regarding memory.</p> <p>The Timer is used from the System.Timers namespace, the environment is Windows 2003. I used this approach in two different services on different servers, but both is producing this behavior (this is why I thought that it is somehow connected to my code or the framework itself).</p> <p>Does somebody experienced this behavior? What can be wrong?</p> <hr /> <h3>Edit:</h3> <p>I edited both services. One got a nice try-catch everywhere and more logging. The second got a timer-recreation on a regular basis. None of them stopped since them, so if this situation remains for another week, I will close this question. Thank you for everyone so far.</p> <hr /> <h3>Edit:</h3> <p>I close this question because nothing happened. I mean I made some changes, but those changes are not really relevant in this matter and both services are running without any problem since then. Please mark it as &quot;Closed for not relevant anymore&quot;.</p>
[ { "answer_id": 397770, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "private void tickTack_Elapsed(object sender, ElapsedEventArgs e)\n{\n CheckForRecycle();\n // ... actual code\n...
2008/12/29
[ "https://Stackoverflow.com/questions/397744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/968/" ]
397,753
<p>I've a need to add method that will calculate a weighted sum of worker salary and his superior salary. I would like something like this:</p> <pre><code>class CompanyFinanse { public decimal WeightedSumOfWorkerSalaryAndSuperior(Worker WorkerA, Worker Superior) { return WorkerA.Salary + Superior.Salary * 2; } } </code></pre> <p>Is this a good design or should I put this method somewhere else? I'm just staring designing project and think about a good, Object Oriented way of organize methods in classes. So I would like start from beginning with OOP on my mind. Best practice needed!</p>
[ { "answer_id": 397782, "author": "Shawn", "author_id": 26, "author_profile": "https://Stackoverflow.com/users/26", "pm_score": 3, "selected": false, "text": "public class Worker {\n public Worker Superior {get;set;}\n public readonly decimal WeightedSalary {\n get {\n ...
2008/12/29
[ "https://Stackoverflow.com/questions/397753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49836/" ]
397,754
<p>Is there a way to record the screen, either desktop or window, using .NET technologies.</p> <p>My goal is something free. I like the idea of small, low cpu usage, and simple, but would consider other options if they created a better final product.</p> <p>In a nutshell, I know how to take a screenshot in C#, but how would I record the screen, or area of the screen, as a video?</p> <p>Thanks a lot for your ideas and time!</p>
[ { "answer_id": 397812, "author": "driis", "author_id": 13627, "author_profile": "https://Stackoverflow.com/users/13627", "pm_score": 5, "selected": true, "text": " private Image CaptureScreen()\n {\n Rectangle screenSize = Screen.PrimaryScreen.Bounds;\n Bitmap target ...
2008/12/29
[ "https://Stackoverflow.com/questions/397754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23294/" ]
397,759
<p>I have two bitmaps, produced by different variations of an algorithm. I'd like to create a third bitmap by subtracting one from the other to show the differences.</p> <p>How can this be done in .NET? I've looked over the Graphics class and all its options, including the ImageAttributes class, and I have a hunch it involves the color matrix or remap tables functionality.</p> <p>Does anyone have a link to some example code, or can point me in the right direction? A google search doesn't reveal much, unless my google-fu is failing me today.</p>
[ { "answer_id": 397783, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "LockBits GetPixel" } ]
2008/12/29
[ "https://Stackoverflow.com/questions/397759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/267/" ]
397,760
<p>What does the <code>[string]</code> indexer of <code>Dictionary</code> return when the key doesn't exist in the Dictionary? I am new to C# and I can't seem to find a reference as good as the Javadocs.</p> <p>Do I get <code>null</code>, or do I get an exception?</p>
[ { "answer_id": 397772, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": false, "text": "Dictionary<TKey,TValue>" }, { "answer_id": 397776, "author": "Marc Gravell", "author_id": 23354, "au...
2008/12/29
[ "https://Stackoverflow.com/questions/397760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2598/" ]
397,788
<p>I'm trying to find URLs in some text, using javascript code. The problem is, the regular expression I'm using uses \w to match letters and digits inside the URL, but it doesn't match non-english characters (in my case - Hebrew letters). </p> <p>So what can I use instead of \w to match all letters in all languages?</p>
[ { "answer_id": 397801, "author": "David Koelle", "author_id": 2197, "author_profile": "https://Stackoverflow.com/users/2197", "pm_score": 5, "selected": true, "text": "\\w" }, { "answer_id": 400253, "author": "Jan Goyvaerts", "author_id": 33358, "author_profile": "htt...
2008/12/29
[ "https://Stackoverflow.com/questions/397788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3389/" ]
397,815
<p>I am attempting to manage an ajax connection by calling a button onclick method on a separate web part in order to force the partial postback on the consumer. </p> <p>Web part A (Provider) invokes the method on Web Part B (Consumer)</p> <p>Web Part A</p> <p>Type t = myButton.GetType(); object[] p = new object[1]; p[0] = EventArgs.Empty; MethodInfo m = t.GetMethod("OnClick", BindingFlags.NonPublic | BindingFlags.Instance); m.Invoke(myButton, p);</p> <p>Web Part B</p> <p>public void btnHidden_Click(object sender, EventArgs e) { Label1.Text = "Hidden Button: " + DateTime.Now.ToString(); }</p> <p>When I use reflection, I get the correct information on the HiddenButton. However, I cannot invoke the "OnClick" event. The btnHidden_Click does not execute. It works fine when I invoke from WebPart B to WebPart B, but not from a different webpart.</p> <p>There doesn't appear to be too much information regarding this behavior. Any suggestions?</p> <p>Thanks.</p> <p>Rob</p>
[ { "answer_id": 555544, "author": "Mike", "author_id": 62248, "author_profile": "https://Stackoverflow.com/users/62248", "pm_score": 0, "selected": false, "text": "document.getElementById('ElID').onclick();\n" } ]
2008/12/29
[ "https://Stackoverflow.com/questions/397815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
397,817
<p>I upgraded to Ubuntu Intrepid Ibex yesterday and suddenly some of the Perl modules that I installed (on the Hardy Heron) have all gone missing!</p> <p>I get the usual "Can't locate module in @INC" error. Has any of the CPAN repositories changed or something for Intrepid? Google doesn't help at all.</p> <p>Thanks in advance.</p>
[ { "answer_id": 398152, "author": "Trochee", "author_id": 49890, "author_profile": "https://Stackoverflow.com/users/49890", "pm_score": 3, "selected": false, "text": "cpan @INC $ cpan List::MoreUtils # installs latest from CPAN $ sudo apt-get install liblist-moreutils-perl # installs lat...
2008/12/29
[ "https://Stackoverflow.com/questions/397817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49847/" ]
397,837
<p>Im trying to sum an expression in visual studio and just keep getting an #error but not sure why as this si the first time i have tried to sum an expression, only ever done it on a single field before. Any Suggestions!!!</p> <pre><code> =IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = True, Fields!ORDERCOST.Value, "") </code></pre>
[ { "answer_id": 23648005, "author": "user3635498", "author_id": 3635498, "author_profile": "https://Stackoverflow.com/users/3635498", "pm_score": 0, "selected": false, "text": "=Sum(IIf(Fields!STATUS.value = \"Completed\" AND Fields!DONOTINVOICE.value = 1.0, Fields!ORDERCOST.Value, 0.0))\...
2008/12/29
[ "https://Stackoverflow.com/questions/397837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
397,839
<p>I'm working on Visual Studio Extensibility and I need to set the "shell" language from code. In other words, I'm looking for an API to do the same you can do "by hand" with the <em>Tools -> Options... -> Environment -> International Settings</em> property page.<br/> Up to now I didn't find any reference: hints and suggestions are welcome. ;-)<br/> Thanks in advance.<br/> <br/> EDIT: to clarify a bit the question, I need to set the current language of Visual Studio itself (actually of an Isolated Visual Studio Shell).</p>
[ { "answer_id": 23648005, "author": "user3635498", "author_id": 3635498, "author_profile": "https://Stackoverflow.com/users/3635498", "pm_score": 0, "selected": false, "text": "=Sum(IIf(Fields!STATUS.value = \"Completed\" AND Fields!DONOTINVOICE.value = 1.0, Fields!ORDERCOST.Value, 0.0))\...
2008/12/29
[ "https://Stackoverflow.com/questions/397839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49582/" ]
397,851
<p>I'm making a winform in C# using Visual Studio 2008.</p> <p>Currently, I have a tabcontrol, containing 2 tabs. In the first the, there is a button. When I click it, I must be taken to the second tab.</p> <p>Problem is, I don't know how. I've tried debugging, looking into al kinds of Properties and messing around with them, but I found nothing that helps.</p> <p>Does anybody here know how to pull this off?</p> <p>Extra info: my variables are named tabControl1, textTab and logTab.</p> <p>I'm in textTab, click on a button there and I want to be taken to logTab. That's it basically.</p>
[ { "answer_id": 397857, "author": "Matt Brunell", "author_id": 24970, "author_profile": "https://Stackoverflow.com/users/24970", "pm_score": 5, "selected": true, "text": "tabControl1.SelectedTab = logTab;\n" } ]
2008/12/29
[ "https://Stackoverflow.com/questions/397851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11795/" ]
397,864
<p>What are the different ways of communication between asp.net page and a popup page? Query strings etc. Which is most secure?</p>
[ { "answer_id": 397931, "author": "Mark Brittingham", "author_id": 15592, "author_profile": "https://Stackoverflow.com/users/15592", "pm_score": 2, "selected": true, "text": "<img style='cursor:hand;' alt=\"Open Note\" onclick=\"javascript:window.open('NoteEdit.aspx?T=3&UID=<%#NoteUID%>',...
2008/12/29
[ "https://Stackoverflow.com/questions/397864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1688440/" ]
397,867
<p>George Marsaglia has written an excellent random number generator that is extremely fast, simple, and has a much higher period than the Mersenne Twister. Here is the code with a description:</p> <p><a href="http://school.anhb.uwa.edu.au/personalpages/kwessen/shared/Marsaglia03.html" rel="noreferrer">good C random number generator</a></p> <p>I wanted to port the CMWC4096 code to Java, but it uses several unsigned datatypes so I am not sure how to do this properly. Here is the full C code:</p> <pre><code>/* choose random initial c&lt;809430660 and */ /* 4096 random 32-bit integers for Q[] */ static unsigned long Q[4096],c=362436; unsigned long CMWC4096(void) { unsigned long long t, a=18782LL; static unsigned long i=4095; unsigned long x,r=0xfffffffe; i = (i+1) &amp; 4095; t = a*Q[i] + c; c = (t&gt;&gt;32); x = t + c; if (x &lt; c) { x++; c++; } return (Q[i] = r - x); } </code></pre> <p>Can anyone port this to Java? How does this work when you only have signed numbers available?</p> <p><strong>EDIT:</strong> Thanks everybody for the quick answers! For the first 100 million numbers this java code seems to produce the same result as the C code. It is 3 times faster than Java's java.util.Random.</p> <pre><code>public class ComplimentaryMultiplyWithCarryRandom { /** * Choose 4096 random 32-bit integers */ private long[] Q; /** * choose random initial c&lt;809430660 */ private long c = 362436; private int i; public ComplimentaryMultiplyWithCarryRandom() { Random r = new Random(1); Q = new long[4096]; // TODO initialize with real random 32bit values for (int i = 0; i &lt; 4096; ++i) { long v = r.nextInt(); v -= Integer.MIN_VALUE; Q[i] = v; } i = 4095; } int next() { i = (i + 1) &amp; 4095; long t = 18782 * Q[i] + c; c = t &gt;&gt;&gt; 32; long x = (t + c) &amp; 0xffffffffL; if (x &lt; c) { ++x; ++c; } long v = 0xfffffffeL - x; Q[i] = v; return (int) v; } } </code></pre>
[ { "answer_id": 397960, "author": "Jason S", "author_id": 44330, "author_profile": "https://Stackoverflow.com/users/44330", "pm_score": 5, "selected": true, "text": "a=18782 t int t=a*Q[i]+c t=a*(((long)Q[i])&0xffffffffL)+c\n // marsaglia2003.cpp \n\n#include <stdio.h>\n#include <stdlib.h...
2008/12/29
[ "https://Stackoverflow.com/questions/397867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48181/" ]
397,895
<p>How can I create a list in C++? I need it to create a linked list. How would I go about doing that? Are there good tutorials or examples I could follow?</p>
[ { "answer_id": 397908, "author": "mepcotterell", "author_id": 43312, "author_profile": "https://Stackoverflow.com/users/43312", "pm_score": 3, "selected": false, "text": "#include <list>\n\n// in some function, you now do...\nstd::list<int> mylist; // integer list\n" }, { "answer...
2008/12/29
[ "https://Stackoverflow.com/questions/397895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49609/" ]
397,900
<p>I have a folder with subfolders of files. I would like to get the newest filename by modified time. Is there a more efficient way of finding this short of looping through each folder and file to find it? </p>
[ { "answer_id": 397961, "author": "jwmiller5", "author_id": 7824, "author_profile": "https://Stackoverflow.com/users/7824", "pm_score": 0, "selected": false, "text": "dir -r | select Name, LastWriteTime | sort LastWriteTime -DESC | select -first 1\n" }, { "answer_id": 397966, ...
2008/12/29
[ "https://Stackoverflow.com/questions/397900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49860/" ]
397,918
<p>Could someone tell me how the field "Task Group" is used in standard SharePoint Task Lists?</p>
[ { "answer_id": 4773764, "author": "Ahmed Said", "author_id": 586326, "author_profile": "https://Stackoverflow.com/users/586326", "pm_score": 1, "selected": false, "text": "<Where> <Membership Type=\"CurrentUserGroups\">\n<FieldRef Name=\"AssignedTo\"/>\n</Membership>\n" } ]
2008/12/29
[ "https://Stackoverflow.com/questions/397918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43506/" ]
397,926
<p>I would like to take a set of controls (INPUT, SELECT, TEXTAREA) which are contained within a DIV and send their values as JSON via Ajax to a server. This is easy enough with jQuery's <a href="http://docs.jquery.com/Ajax/serializeArray" rel="nofollow noreferrer">serializeArray</a>.</p> <p>However I then want the server to respond with the same structure of JSON that was sent and re-load the control values using the provided JSON. I can't find anything in the jQuery documentation that would make this a simple operation.</p> <p>Am I missing something or do I need to build this myself?</p>
[ { "answer_id": 398270, "author": "Pim Jager", "author_id": 35197, "author_profile": "https://Stackoverflow.com/users/35197", "pm_score": 2, "selected": false, "text": "$(\"*[name='\" + controlname + \"']\").val( value);\n $(\"#\" + controlID).val( value);\n" } ]
2008/12/29
[ "https://Stackoverflow.com/questions/397926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17516/" ]
397,927
<p>In openmoko (stable hybrid release, SHR), how do you programatically turn-off the screensaver (the dimmed/blank screen after a few seconds of inactivity) just while your app is running?</p>
[ { "answer_id": 398343, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": 1, "selected": false, "text": "xset s off\n" }, { "answer_id": 765344, "author": "Baruch Even", "author_id": 85036, "author_profile...
2008/12/29
[ "https://Stackoverflow.com/questions/397927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46478/" ]
397,933
<p>most of social networks does this. when you register one of them for example twitter it says why dont you invite your friends from hotmail or yahoo or gmail. and expect us to give our credentials and send those mails. I want to implement same feature in java.</p> <p>I tried <a href="http://code.google.com/p/contactlistimporter" rel="noreferrer">http://code.google.com/p/contactlistimporter</a> but it has a problem with hotmal.</p> <p>can you suggest me nice another library ?</p>
[ { "answer_id": 398386, "author": "Ole", "author_id": 49540, "author_profile": "https://Stackoverflow.com/users/49540", "pm_score": 1, "selected": false, "text": "http://mail.google.com/mail/contacts/data/export" } ]
2008/12/29
[ "https://Stackoverflow.com/questions/397933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
397,934
<p>How can I get an application to write debug text to the Event Log window in the Delphi IDE (Borland Developer Studio 2006)?</p> <p>How does one change the color of the text?</p>
[ { "answer_id": 397979, "author": "amo", "author_id": 49065, "author_profile": "https://Stackoverflow.com/users/49065", "pm_score": 3, "selected": false, "text": "OutputDebugString" }, { "answer_id": 400104, "author": "Jk.", "author_id": 50149, "author_profile": "https...
2008/12/29
[ "https://Stackoverflow.com/questions/397934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17560/" ]
397,944
<p>For the following code:</p> <pre><code>&lt;% foreach (Entities.Core.Location loc in locations){ %&gt; &lt;div class="place_meta"&gt; &lt;img src="~/static/images/stars/star_25_sml.gif" runat="server" class="star_rating"/&gt; &lt;/div&gt; &lt;% }; %&gt; </code></pre> <p>I would like to display the star rating image for each location object displayed. However, only the first location object's star rating is displayed. For the rest, the image tag becomes <code>&lt;img class="star_rating" /&gt;</code></p> <p>Am I missing anything in the syntax that allows the ability to have controls with runat=server within a foreach on the aspx page? This is with ASP.net 2.0.</p> <p>I could possibly call a function in the codebehind or a display class to absolute map the URL but I am very curious if there is a solution to this problem.</p> <p>Just for clarifications, the path to the image could possibly be different for each location object.</p>
[ { "answer_id": 397974, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 0, "selected": false, "text": "runat=\"server\"" }, { "answer_id": 397995, "author": "Fabrizio C.", "author_id": 49582, "author_pr...
2008/12/29
[ "https://Stackoverflow.com/questions/397944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32372/" ]
397,955
<p>I have an xml in which i have stored some html under comments like this</p> <pre><code> &lt;root&gt; &lt;node&gt; &lt;!-- &lt;a href="mailto:some@one.com"&gt; Mail me &lt;/a&gt; --&gt; &lt;/node&gt; &lt;/root&gt; </code></pre> <p>now in my Transform Xslt code of mine i am giving XPathNavigator which is pointing to node and in xslt i am passing the comment value of as a parameter.</p> <p>assuming $href to be <code>&lt;a href="mailto:some@one.com"&gt; Mail me &lt;/a&gt;</code></p> <p>in xslt i am doing <code>&lt;xsl:value-of select="$href" disable-output-escaping="yes"&gt;</code></p> <p>but $href is still escaped the result of xslt transformation comes up with &lt; &gt;</p> <p>Does any one know whats wrong with it any help in this regard would be highly appericiated.</p> <p>Thanks Regards Azeem</p>
[ { "answer_id": 399600, "author": "diciu", "author_id": 2811, "author_profile": "https://Stackoverflow.com/users/2811", "pm_score": 3, "selected": true, "text": "<xsl:template match=\"/\">\n<xsl:value-of select=\"/root/node/comment()\" disable-output-escaping=\"yes\"/>\n</xsl:template>\n ...
2008/12/29
[ "https://Stackoverflow.com/questions/397955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6351/" ]
397,998
<p>I have a table (T1) in t-sql with a column (C1) that contains almost 30,000 rows of data. Each column contains values like MSA123, MSA245, MSA299, etc. I need to run an update script so the MSA part of the string changes to CMA. How can I do this?</p>
[ { "answer_id": 398005, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "update t1\nset c1 = replace(c1,\"MSA\",\"CMA\")\nwhere c1 like \"MSA%\"\n" }, { "answer_id": 398011, "author...
2008/12/29
[ "https://Stackoverflow.com/questions/397998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
398,008
<p>We have a rails application in subversion that we deploy with Capistrano but have noticed that we can access the files in '/.svn', which presents a security concern. </p> <p>I wanted to know what the best way to do this. A few ideas:</p> <ul> <li>Global Apache configuration to deny access </li> <li>Adding .htaccess files in the public folder and all subfolders</li> <li>Cap task that changes the permissions</li> </ul> <p>I don't really like the idea of deleting the folders or using svn export, since I would like to keep the 'svn info' around.</p>
[ { "answer_id": 398249, "author": "csexton", "author_id": 19839, "author_profile": "https://Stackoverflow.com/users/19839", "pm_score": 5, "selected": false, "text": "RedirectMatch 404 /\\\\.svn(/|$)\n" }, { "answer_id": 3251448, "author": "Riccardo Galli", "author_id": 21...
2008/12/29
[ "https://Stackoverflow.com/questions/398008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19839/" ]
398,010
<p>I have a project in Xcode that contains multiple targets. One of these builds a sync schema bundle, and another one builds a Foundation command-line tool that initiates a sync session using the schema defined in the bundle.</p> <p>The schema bundle template creates <code>Schema-strings.h</code> and <code>Schema-strings.m</code> files, which contain constants for data class names, entity names, and attribute names, and I'd like to use these constants in my command-line tool's code.</p> <p>How do I configure the targets to make this possible?</p>
[ { "answer_id": 398249, "author": "csexton", "author_id": 19839, "author_profile": "https://Stackoverflow.com/users/19839", "pm_score": 5, "selected": false, "text": "RedirectMatch 404 /\\\\.svn(/|$)\n" }, { "answer_id": 3251448, "author": "Riccardo Galli", "author_id": 21...
2008/12/29
[ "https://Stackoverflow.com/questions/398010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2399475/" ]
398,021
<p>I want to change the text of a radio button (HTML element), not an ASP.NET component.</p> <p>How can I change it from ASP.NET?</p>
[ { "answer_id": 398026, "author": "Dillie-O", "author_id": 71, "author_profile": "https://Stackoverflow.com/users/71", "pm_score": 5, "selected": true, "text": "runat=\"server\"\n" }, { "answer_id": 398030, "author": "steve_c", "author_id": 769, "author_profile": "http...
2008/12/29
[ "https://Stackoverflow.com/questions/398021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44973/" ]
398,028
<p>I would like to know how to do performance testing for the old asp pages. Any tools out there that you've used?</p>
[ { "answer_id": 398077, "author": "TravisO", "author_id": 35116, "author_profile": "https://Stackoverflow.com/users/35116", "pm_score": 3, "selected": false, "text": "<%\n' Start the timer\nstarttime = timer()\n%>\n\n<!-- HTML and Code Here -->\n\n<%\n' End the timer\nendtime = timer()\n'...
2008/12/29
[ "https://Stackoverflow.com/questions/398028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49881/" ]
398,032
<p>What API or tools can I use to query the capabilities of the system and choose the most appropriate on for putting the PC to Sleep, Hibernate or shutdown mode?</p> <p>Thanks for any pointers.</p>
[ { "answer_id": 398062, "author": "Leon Tayson", "author_id": 18413, "author_profile": "https://Stackoverflow.com/users/18413", "pm_score": 4, "selected": true, "text": "Application.SetSuspendState(PowerState.Hibernate, true, true);\n" }, { "answer_id": 13329017, "author": "ds...
2008/12/29
[ "https://Stackoverflow.com/questions/398032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3811/" ]
398,037
<p>When I start a new ASP.NET project in Visual Studio, I can create an ASP.NET Web Application or I can create an ASP.NET Web Site.</p> <p>What is the difference between ASP.NET Web Application and ASP.NET Web Site? Why would I choose one over other?</p> <p>Is the answer different based on which version of Visual Studio I am using?</p>
[ { "answer_id": 398154, "author": "Daniel Auger", "author_id": 1644, "author_profile": "https://Stackoverflow.com/users/1644", "pm_score": 5, "selected": false, "text": "app_code app_code" }, { "answer_id": 12152820, "author": "Nagaraj P", "author_id": 1235202, "author...
2008/12/29
[ "https://Stackoverflow.com/questions/398037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7565/" ]
398,069
<p>My code is built to multiple .dll files, and I have a template class that has a static member variable.</p> <p>I want the same instance of this static member variable to be available in all dlls, but it doesn't work: I see different instance (different value) in each of them.</p> <p>When I don't use templates, there is no problem: initialize the static member in one of the source files, and use __declspec(dllexport) and __declspec(dllimport) directives on the class. But it doesn't work with templates. Is there any way to make it work?</p> <p>I saw some proposed solutions that use "extern", but I think I can't use it because my code is supposed to work with visual studio 2002 and 2005.</p> <p>Thank you.</p> <p>Clarification: I want to have a different instance of static variable per each different type of template instantiation. But if I instantiate the template with the same type in 2 different dlls, I want to have the same variable in the both of them.</p>
[ { "answer_id": 398132, "author": "Dominik Grabiec", "author_id": 3719, "author_profile": "https://Stackoverflow.com/users/3719", "pm_score": 1, "selected": false, "text": "template <class T> class Foo;\ntemplate<> class Foo<int> {};\n __declspec(dllexport) int Foo<int>::StaticMember = 0;...
2008/12/29
[ "https://Stackoverflow.com/questions/398069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44673/" ]
398,100
<p>It's quite possible a question like this has been asked before, but I can't think of the terms to search for.</p> <p>I'm working on a photo gallery application, and want to display 9 thumbnails showing the context of the current photo being shown (in a 3x3 grid with the current photo in the centre, unless the current photo is in the first 4 photos being shown, in which case if e.g. if the current photo is the 2nd I want to select photos 1 through 9). For example, given an album containing the list of photos with ids:</p> <p>1, 5, 9, 12, 13, 18, 19, 20, 21, 22, 23, 25, 26</p> <p>If the current photo is 19, I want to also view:</p> <p>9, 12, 13, 18, 19, 20, 21, 22, 23</p> <p>If the current photo is 5, I want to also view:</p> <p>1, 5, 9, 12, 13, 18, 19, 20, 21</p> <p>I've been thinking of something along the lines of:</p> <pre><code>SELECT * FROM photos WHERE ABS(id - currentphoto) &lt; 5 ORDER BY id ASC LIMIT 25 </code></pre> <p>but this doesn't work in the case where the ids are non-sequential (as in the example above), or for the case where there are insufficient photos before the currentphoto.</p> <p>Any thoughts?</p> <p>Thanks,</p> <p>Dom</p> <p>p.s. Please leave a comment if anything is unclear, and I'll clarify the question. If anyone can think of a more useful title to help other people find this question in future, then please comment too.</p>
[ { "answer_id": 398115, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 0, "selected": false, "text": " Select * From Photos P\n Where (Select Count(*) From Photos\n Where id <= P.Id)\n Between (Select Co...
2008/12/29
[ "https://Stackoverflow.com/questions/398100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20972/" ]
398,110
<p>How can you modify the URL for the current page that gets passed to Google Analytics? </p> <p>(I need to strip the extensions from certain pages because for different cases a page can be requested with or without it and GA sees this as two different pages.) </p> <p>For example, if the page URL is <code>http://mysite/cake/ilikecake.html</code>, how can I pass to google analytics <code>http://mysite/cake/ilikecake</code> instead?</p> <p>I can strip the extension fine, I just can't figure out how to pass the URL I want to Google Analytics. I've tried this, but the stats in the Google Analytics console don't show any page views:</p> <blockquote> <p>pageTracker._trackPageview('cake/ilikecake');</p> </blockquote> <p>Thanks, Mike</p>
[ { "answer_id": 398548, "author": "Athena", "author_id": 17846, "author_profile": "https://Stackoverflow.com/users/17846", "pm_score": 4, "selected": true, "text": "pageTracker._trackPageview('/cake/ilikecake');\n" }, { "answer_id": 492243, "author": "pelms", "author_id": ...
2008/12/29
[ "https://Stackoverflow.com/questions/398110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18228/" ]
398,111
<p>What's a surefire way of detecting whether a user has Firebug enabled?</p>
[ { "answer_id": 398120, "author": "Andreas Grech", "author_id": 44084, "author_profile": "https://Stackoverflow.com/users/44084", "pm_score": 7, "selected": true, "text": "console if (window.console && window.console.firebug) {\n //Firebug is enabled\n}\n window.console.firebug if (windo...
2008/12/29
[ "https://Stackoverflow.com/questions/398111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5123/" ]
398,117
<p>Given two shorts (<code>System.Int16</code>)</p> <pre><code>short left = short.MaxValue; short right = 1; </code></pre> <p>I want to get an <code>OverflowException</code> when adding them.</p> <pre><code>checked(left+right) </code></pre> <p>does not work, because the result of <code>left+right</code> is an <code>Int32</code>.</p> <pre><code>checked((short)(left+right)) </code></pre> <p>works as expected.</p> <p>My problem is that, using Expression Trees, the "trick" doesn't work:</p> <pre><code>var a = Expression.Constant(left); var b = Expression.Constant(right); var sum = Expression.ConvertChecked(Expression.Add(a, b), typeof(short)); var l = Expression.Lambda(sum); var f = (Func&lt;short&gt;)l.Compile(); </code></pre> <p>Calling <code>f()</code> does not throw an overflow exception but returns <code>-32768</code>. What's wrong?</p>
[ { "answer_id": 398155, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "using System;\nusing System.Linq.Expressions;\n\nclass Test\n{\n static void Main(string[] args)\n {\n short...
2008/12/29
[ "https://Stackoverflow.com/questions/398117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48722/" ]
398,137
<p>Hi What is the best way to do nested try &amp; finally statements in delphi?</p> <pre><code>var cds1 : TClientDataSet; cds2 : TClientDataSet; cds3 : TClientDataSet; cds4 : TClientDataSet; begin cds1 := TClientDataSet.Create(application ); try cds2 := TClientDataSet.Create(application ); try cds3 := TClientDataSet.Create(application ); try cds4 := TClientDataSet.Create(application ); try /////////////////////////////////////////////////////////////////////// /// DO WHAT NEEDS TO BE DONE /////////////////////////////////////////////////////////////////////// finally cds4.free; end; finally cds3.free; end; finally cds2.free; end; finally cds1.free; end; end; </code></pre> <p>Can you Suggest a better way of doing this?</p>
[ { "answer_id": 398161, "author": "skamradt", "author_id": 9217, "author_profile": "https://Stackoverflow.com/users/9217", "pm_score": 6, "selected": true, "text": "var cds1 : TClientDataSet;\n cds2 : TClientDataSet;\n cds3 : TClientDataSet;\n cds4 : TClientDataSet;\nbegin\n ...
2008/12/29
[ "https://Stackoverflow.com/questions/398137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17560/" ]
398,144
<p>I'm baffled how to do this.</p> <p>I need to take a datetime object and get the duration in hours, days, whatever, to the current time.</p> <p>Thank you.</p>
[ { "answer_id": 398165, "author": "Sören Kuklau", "author_id": 1600, "author_profile": "https://Stackoverflow.com/users/1600", "pm_score": 4, "selected": true, "text": ">> foo = Time.new\n=> Mon Dec 29 18:23:51 +0100 2008\n>> bar = Time.new\n=> Mon Dec 29 18:23:56 +0100 2008\n>> print bar...
2008/12/29
[ "https://Stackoverflow.com/questions/398144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33287/" ]
398,163
<p>Let's say I have my pizza application with Topping and Pizza classes and they show in Django Admin like this:</p> <pre><code>PizzaApp - Toppings &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Add / Change Pizzas &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Add / Change </code></pre> <p>But I want them like this:</p> <pre><code>PizzaApp - Pizzas &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Add / Change Toppings &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Add / Change </code></pre> <p>How do I configure that in my admin.py?</p>
[ { "answer_id": 5345760, "author": "Roberto", "author_id": 665167, "author_profile": "https://Stackoverflow.com/users/665167", "pm_score": 6, "selected": false, "text": "class Topping(models.Model):\n .\n .\n .\n class Meta:\n verbose_name_plural = \"2. Toppings\"\n\ncl...
2008/12/29
[ "https://Stackoverflow.com/questions/398163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49898/" ]
398,170
<p>Simple question... is there a way to change the Assembly Version of a compiled .NET assembly?</p> <p>I'd actually be fine with a way to change the Assembly File Version.</p>
[ { "answer_id": 34045871, "author": "Georgi Atanassov", "author_id": 5630761, "author_profile": "https://Stackoverflow.com/users/5630761", "pm_score": 4, "selected": false, "text": ".custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = ( 01 00 07 ...
2008/12/29
[ "https://Stackoverflow.com/questions/398170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2848/" ]
398,188
<p>We're having a small issue and could use some help - we have the need to combine multiple resultsets from one stored procedure into one resultset (the limitation of our Java reporting framework). We've looked at Union, etc. but the problem is that the stored procedure resultsets are multiple crosstab results and the (1) number of columns for each resultset are unknown and (2) the column names for each resultset are unknown.</p> <p>Basically, if the sp_ has 3 results like:</p> <p>ID Name</p> <p>1 Sam</p> <p>2 Time</p> <p>ID FName LName</p> <p>1 John Jacob </p> <p>2 Tim Test</p> <p>3 Sam Hopkins</p> <p>ID Amount</p> <p>1 1000</p> <p>2 5000</p> <p>The ideal result would basically return the above text as-is which our framework would print to the user. Also please note that these 3-4 resultsets are not related to each other.</p> <p>We're using SQL Server 2000 and Java 1.4.</p> <p>Any advice would be appreciated.</p> <p>Thanks, SP</p> <p>PS: An alternative explaination in case the one above is not very clear. In SQL Query Analyzer if we have 3 select statements:</p> <p>select * from countries; {returns id,countryname,countrycode}</p> <p>select * from people; {id,countryname,countrycode}</p> <p>select * from balance; {id,countryname,countrycode}</p> <p>Then the results are displayed in three separate resultset boxes. We need to these resultsets to be returned as one resultset by the stored procedure (while not knowing the number/name of the columns due to the crosstab-ing taking place). Thanks.</p>
[ { "answer_id": 398196, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 2, "selected": true, "text": " Select ID, Name as value1, null as value2\n From TableA \n Union\n Select ID, FName as value1, LName as valu...
2008/12/29
[ "https://Stackoverflow.com/questions/398188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35309/" ]
398,192
<p>"Title" field is sealed. Any attempts to update the default value resets the value back to "null"</p> <hr> <p>Thanks for your time.</p> <p>Your idea of doing "RemoveFieldRef and FieldRef it right back in" would be the same as setting the properties "Required" and "Default Value" through the interface for the "Document" or inherited content types though your idea would help if we are building custom content types.</p> <p>Setting "Title" to required does not work in all situations. One such situation is when you try to add a item through "New" (which in my case opens up a template based on office 2007).</p> <p>Since "Title" as required field was giving me hard time, I wanted to try the "DefaultValue" route but even this one does not seem to work. Any help?</p>
[ { "answer_id": 408045, "author": "stlawrence", "author_id": 48924, "author_profile": "https://Stackoverflow.com/users/48924", "pm_score": 2, "selected": false, "text": " <ContentType ...>\n <FieldRefs>\n <FieldRef ID=\"{fa564e0f-0c70-4ab9-b863-0177e6ddd247}\" Name=\"Title\" Disp...
2008/12/29
[ "https://Stackoverflow.com/questions/398192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35175/" ]
398,203
<p>One of my coworkers is having a problem pushing changes from git on his machine. If he logs into another machine, he can push just fine - but from his machine, when he tries to push he gets the following error</p> <pre> D:\Projects\test1\best-practices>git push Counting objects: 4, done. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 273 bytes, done. Total 3 (delta 1), reused 0 (delta 0) error: unable to create temporary sha1 filename ./objects/42: Permission denied fatal: failed to write object error: unpack failed: unpacker exited with error code To //civ3s012/gitrepos/best-practices/.git ! [remote rejected] master -> master (n/a (unpacker error)) error: failed to push some refs to '//civ3s012/gitrepos/best-practices/.git' </pre> <p>The server is a windows machine, as is the client. No one else is having this problem - it seems to be a server permissions issue, but we've ruled that out as far as we can tell. Also, the fact that he can log into a different machine and push, using the same username, makes it seem like it's not server permissions. Any ideas what could be going wrong here?</p>
[ { "answer_id": 398852, "author": "Pat Notz", "author_id": 825, "author_profile": "https://Stackoverflow.com/users/825", "pm_score": 4, "selected": true, "text": "git" }, { "answer_id": 399133, "author": "Paul", "author_id": 23356, "author_profile": "https://Stackoverf...
2008/12/29
[ "https://Stackoverflow.com/questions/398203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1322/" ]
398,212
<p>I normally use C# and I'm attempting to convert a qbasic programmer to the joys of object oriented programming by easing him into VB 2005.</p> <p>Below is a extremely simplified version of what I'm trying to accomplish. It successfully compiles, but all members in the array of card objects are set to "Nothing". The test line throws a NullReferenceException. What am I doing wrong? </p> <pre><code> Sub Main() Dim deck1 As New Deck Console.WriteLine("Test: " &amp; deck1.cards(2).face) End Sub Class Card Public face As String Sub New() face = "Blank" End Sub End Class Class Deck Public cards(51) As Card End Class </code></pre>
[ { "answer_id": 398217, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "Class Deck\n Public cards(51) As Card\n\n Public Sub New()\n For i As Integer = 0 To cards.Length-1\n ...
2008/12/29
[ "https://Stackoverflow.com/questions/398212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18043/" ]
398,215
<p>Our application uses Hibernate for ORM, and stores data in several schemas, accessing them with a user whose grants are customized for the application.</p> <p>The schema names are determined at runtime based on data; it's not feasible to include their names in the entity mapping documents. This means that I need a way to tell Hibernate to use a specific schema name when performing lookups. Is there a way to do this?</p>
[ { "answer_id": 550663, "author": "paulmurray", "author_id": 63189, "author_profile": "https://Stackoverflow.com/users/63189", "pm_score": 1, "selected": false, "text": "ALTER SESSION SET CURRENT_SCHEMA = 'someotherschema'\n" } ]
2008/12/29
[ "https://Stackoverflow.com/questions/398215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23309/" ]
398,221
<p>A <a href="https://stackoverflow.com/questions/397817/unable-to-find-perl-modules-in-intrepid-ibex-ubuntu">recent question</a> here on SO got me thinking.</p> <p>On most Linux distributions that I tried, some Perl modules would be available through the package manager. Others, of course, not. For quite a while I would use my package manager whenever I needed to install some CPAN module to find out whether a package was available or not and to install it when it was.</p> <p>The obvious advantage is that you get your modules updated whenever a new version of the package becomes available.</p> <p>However, you get in trouble when the module is not available in pre-packaged form and there are dependencies for that module that are. Firing up your package manager every time the cpan shell asks whether it should follow a dependency can be quite tiring.</p> <p>Often, another drawback is the version of the pre-packaged module. If you are running Debian or Ubuntu you will soon find out that you will not be able to live on the bleeding edge, like many CPAN module authors seem to do. </p> <p>How do other Perl people on Linux handle that problem? Do you just ignore what your package managers have to offer? Are there any tools that make apt (for example) and cpan better team mates? Or do you simply not install anything via the cpan shell?</p>
[ { "answer_id": 398397, "author": "brian d foy", "author_id": 2766176, "author_profile": "https://Stackoverflow.com/users/2766176", "pm_score": 5, "selected": false, "text": "$ perl5.10.0 program.pl\n cpan5.10.1 #!perl\n\nuse 5.010;\n\nuse strict;\nuse warnings;\n\nuse File::Basename;\nus...
2008/12/29
[ "https://Stackoverflow.com/questions/398221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7498/" ]
398,223
<p>How do I make my Apache 2 server force a browser to open a file transfer dialogue if the URL points to a file with a .pln or .psa extension?</p> <p>I have a simple LAMP server with CentOS 5, Apache 2, MYSQL 5, PHP 5, recently built CentOS 5.2 i386 installation CDs. My web application generates files to be downloaded and imported into a custom application. The file extensions are .psa and .pln. How do I make my server force the browser to open a file transfer dialogue? If I point my browser to a .psa or .pln file on the Apache 2 server, the file's content is displayed in a pop-up window as simple text. I want a file transfer dialogue.</p> <p>The web-app I am working on is deployed on another web-server and handles the .pln and .psa files as desired. I cannot compare server configuration files because I do not have administrator access to the working server.</p> <p>How do I change my server's behavior? Does this require code changes to my web-app code (such as sending explicit headers)? If so, why does it work against the other server? Can code changes be avoided by configuring the server's default behavior?</p> <p>Any help would be appreciated.</p>
[ { "answer_id": 398230, "author": "palehorse", "author_id": 312, "author_profile": "https://Stackoverflow.com/users/312", "pm_score": 3, "selected": false, "text": "<FilesMatch \"\\.(?i:pin)$\">\n Header set Content-Disposition attachment\n</FilesMatch>\n" } ]
2008/12/29
[ "https://Stackoverflow.com/questions/398223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
398,231
<p>I'm using an ObjectDataSource to bind data to a GridView; it works fine except that it always creates a new object to use as a data source. I can do all the setup just fine but I cannot use an instance of an existing object to specify as the "data source" for it. Is it possible to do this? If so, how? </p> <p>If it's not possible, why?</p> <p>EDIT: Here's the gist of what's going on (object types changed): On the first page you are editting the attributes for a dog. One of the attributes is "has puppies" and if it's true, the next page you specify the names of those puppies. What's happening in my case is that those puppies are not getting linked to the original dog but to a "new" dog. (The implication that my problem is a "female dog" was coincidental. ;-) )</p>
[ { "answer_id": 398261, "author": "George", "author_id": 8803, "author_profile": "https://Stackoverflow.com/users/8803", "pm_score": 4, "selected": true, "text": "protected void ObjectDataSource1_ObjectCreating(object sender, ObjectDataSourceEventArgs e)\n{\n e.ObjectInstance = myObjec...
2008/12/29
[ "https://Stackoverflow.com/questions/398231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4068/" ]
398,237
<p>In a web application I am working on, the user can click on a link to a CSV file. There is no header set for the mime-type, so the browser just renders it as text. I would like for this file to be sent as a .csv file, so the user can directly open it with calc, excel, gnumeric, etc. </p> <pre><code>header('Content-Type: text/csv'); echo "cell 1, cell 2"; </code></pre> <p>This code works as expected on my computer (Isn't that how it always is?) but does not work on another computer.</p> <p>My browser is a nightly build of FF 3.0.1 (on linux). The browsers it did not work in were IE 7 and FF 3.0 (on windows)</p> <p>Are there any quirks I am unaware of?</p>
[ { "answer_id": 398239, "author": "Sean Bright", "author_id": 21926, "author_profile": "https://Stackoverflow.com/users/21926", "pm_score": 9, "selected": true, "text": "header('Content-type: text/csv');\nheader('Content-disposition: attachment;filename=MyVerySpecial.csv');\necho \"cell 1...
2008/12/29
[ "https://Stackoverflow.com/questions/398237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
398,259
<p>I am trying to create a hyperlink using LaTeX. When I use the command pdflatex to compile the file, I get an error.</p> <p>The relevant lines of the document are:</p> <pre><code>\documentclass[12pt]{article} \usepackage{hyperref} \begin{document} ... \href{http://www.cs.utah.edu/dept/old/texinfo/as/gprof_toc.html}{gprof} </code></pre> <p>pdflatex created a file called missfont.log, which contains this:</p> <pre><code>mktextfm pzdr </code></pre> <p>What am I doing wrong?</p>
[ { "answer_id": 398283, "author": "dreeves", "author_id": 4234, "author_profile": "https://Stackoverflow.com/users/4234", "pm_score": 2, "selected": false, "text": "\\usepackage{url}\n \\url{http://foo.com}\n" } ]
2008/12/29
[ "https://Stackoverflow.com/questions/398259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
398,299
<p>A friend was in need of an algorithm that would let him loop through the elements of an NxM matrix (N and M are odd). I came up with a solution, but I wanted to see if my fellow SO'ers could come up with a better solution.</p> <p>I'm posting my solution as an answer to this question.</p> <p><strong>Example Output:</strong></p> <p>For a 3x3 matrix, the output should be:</p> <p>(0, 0) (1, 0) (1, 1) (0, 1) (-1, 1) (-1, 0) (-1, -1) (0, -1) (1, -1)</p> <p><img src="https://i.stack.imgur.com/kjR4H.png" alt="3x3 matrix"></p> <p>Furthermore, the algorithm should support non-square matrices, so for example for a 5x3 matrix, the output should be:</p> <p>(0, 0) (1, 0) (1, 1) (0, 1) (-1, 1) (-1, 0) (-1, -1) (0, -1) (1, -1) (2, -1) (2, 0) (2, 1) (-2, 1) (-2, 0) (-2, -1)</p> <p><img src="https://i.stack.imgur.com/NE82F.png" alt="5x3 matrix"></p>
[ { "answer_id": 398302, "author": "Can Berk Güder", "author_id": 2119, "author_profile": "https://Stackoverflow.com/users/2119", "pm_score": 7, "selected": true, "text": "def spiral(X, Y):\n x = y = 0\n dx = 0\n dy = -1\n for i in range(max(X, Y)**2):\n if (-X/2 < x <= ...
2008/12/29
[ "https://Stackoverflow.com/questions/398299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2119/" ]
398,316
<p>I have string that I want to chop to array of substrings of given length n. I am not interested in remainder (if length of string cannot be divided by n without remainder)</p> <pre><code>let ChopString (myString : string) n = let res = seq{ for i = 0 to myString.Length / n - 1 do yield( String.sub myString (i*n) n ) } |&gt; Seq.to_array res </code></pre> <p>This is the best I could do. It looks ugly to me. </p> <p>Is there nicer/shorter version of this, maybe without for loop?</p>
[ { "answer_id": 398417, "author": "Juliet", "author_id": 40516, "author_profile": "https://Stackoverflow.com/users/40516", "pm_score": 4, "selected": true, "text": "stringInstance.[start..end] String.sub \n let chop (input : string) len = \n seq { for start in 0 .. len .. input....
2008/12/29
[ "https://Stackoverflow.com/questions/398316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25732/" ]
398,325
<p>I have a custom type that I created, which should be persisted in a database (in this case, SQL server) as a guid (though this question is just as valid for an object that could be stored as a string, integer, etc). </p> <p>When I pass this type as a parameter to a DbCommand object, I get an exception:</p> <blockquote> <p>ArgumentException: No mapping exists from object type [...] to a known managed provider native type.</p> </blockquote> <p>I have CType operators on the class that allow implicit conversion to a string, or a guid, but .NET doesn't use these since it doesn't know it should convert the type.</p> <p>Is there a way to add a type to the internal mapping, or otherwise tell .NET how to store my custom type in the database?</p> <p>I obviously can convert the type myself when passing it to the .NET stuff, but I'd like this to happen automatically, like it does for most of the built-in types.</p> <hr> <p>I've tried to implement a TypeConverter class for my type (inherits from TypeConverter, overrides CanConvertFrom, CanConvertTo, ConvertFrom, ConvertTo, IsValid, and added the System.ComponentModel.TypeConverter attribute to my class), but this still doesn't work. </p> <p>I'm assuming it's missing a piece telling .NET what type to convert to when storing the value in the database. </p> <hr> <p>My workaround for this, for now, is that I intercept the list of parameters, before I pass them to SQL server, and have a method that changes my custom type into a guid. This is dirty, but it does work for now, but I still think this question is unanswered.</p>
[ { "answer_id": 10697710, "author": "S. Galiamov", "author_id": 1006517, "author_profile": "https://Stackoverflow.com/users/1006517", "pm_score": 1, "selected": false, "text": "\n public interface ICustomDbValue\n {\n object Value { get; }\n }\n\n \n ...\n IDbCommand...
2008/12/29
[ "https://Stackoverflow.com/questions/398325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7913/" ]
398,332
<p>Everyone uses source-code control to manage versions (right?) and this provides some level of backup. There are times, however, when your local copy is out of sync with the repository. Moreover, some sandbox-type projects may not have yet ;-) made it into SCC.</p> <p><strong>EDIT</strong>: I have multiple projects in my projects directories. Not all are in current development but anyone of which might need to be "fixed" whenever a bug is found. Restoring a single, active project from SCC seems perfectly reasonable. Restoring all of the couple of dozen projects that I support from SCC seems less reasonable than restoring from a backup and syncing as necessary from SCC.</p> <p>What backup strategies, other than source code control, do you use to keep your code safe?</p> <p>A similar question can be found at <a href="https://stackoverflow.com/questions/38388/organization-wide-backup-strategy">https://stackoverflow.com/questions/38388/organization-wide-backup-strategy</a>, but I'm more interested in hearing others' personal strategies if you happen to work in an organization that has no overal strategy. I'll provide my strategy in an answer.</p>
[ { "answer_id": 398355, "author": "rp.", "author_id": 2536, "author_profile": "https://Stackoverflow.com/users/2536", "pm_score": 3, "selected": false, "text": "@echo off\n\necho Stop and start SQL Server\necho -------------------------\n\nnet stop \"SQL Server (SQLEXPRESS)\"\nnet stop \"...
2008/12/29
[ "https://Stackoverflow.com/questions/398332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12950/" ]
398,333
<p>I am crash-learning PHP for a project, and I have a ton of stupid questions to make. The first is the following. I have a structure like this:</p> <ul> <li>index.php</li> <li>header.php</li> <li>images/</li> <li>data <ul> <li>data.php</li> </ul></li> </ul> <p>Now, the problem is that I want to include the header.php file in the data.php file. That is no problem.</p> <p>The problem I have is that header.php has a link to the images folder in a relative way. So, the images won't load.</p> <p>To make matters worse, this structure is under a specific alias, so I just can't append a / to the beginning of the link to the image.</p> <p>What I need, I guess, is a way to get the path to the application in the script. That way I can reference to the images without worrying where the include is made.</p> <p>How do you get this path in PHP?</p>
[ { "answer_id": 398341, "author": "Glenn", "author_id": 25191, "author_profile": "https://Stackoverflow.com/users/25191", "pm_score": 0, "selected": false, "text": "$_SERVER['PATH_TRANSLATED']" }, { "answer_id": 398370, "author": "Andreas Grech", "author_id": 44084, "a...
2008/12/29
[ "https://Stackoverflow.com/questions/398333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2309/" ]
398,344
<p>I'm looking for something that runs in a terminal and allows me to track time. I'd like it to be open source but that isn't necessary. </p> <p>Most time tracking apps I've found are either web or gui based and there for take longer to enter data then I'd like.</p>
[ { "answer_id": 398431, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 4, "selected": false, "text": "$ echo `date`\": what I'm doing now\" >> timelog.txt\n date +%s date +%F%T #!/usr/bin/bash -\necho `date +%s` $* >>...
2008/12/29
[ "https://Stackoverflow.com/questions/398344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14744/" ]
398,347
<p>I have some settings I need in a Javascript file -- servers to connect to -- that changes based on my environment. For <code>development</code>, <code>test</code>, and <code>staging</code>, I want to use the staging servers; for <code>production</code>, the production servers. I already have the settings in Ruby (configured in my <code>environment/xyz.rb</code> files). So far, I've been dynamically creating the JS files at request time with an <code>application.js.erb</code> file and a custom route. This is pretty slow, though, and it means creating an extra controller and views directory just for this file.</p> <p>I would prefer to have a template file and a rake task that generates the correct version from the template and places a static file in the <code>public/javascripts</code> directory. Has anyone tried something like this? What did you use for rendering? Where did you put the template file and the rendering code?</p> <p>Or is it better to just keep the dynamic version and cache it in production?</p>
[ { "answer_id": 398523, "author": "salt.racer", "author_id": 757, "author_profile": "https://Stackoverflow.com/users/757", "pm_score": 3, "selected": true, "text": "<% javascript_include_file \"#{RAILS_ENV}.js\" %>\n \"lib\" \"constants.rb\" if ENV['RAILS_ENV'] != \"production\" ## if the...
2008/12/29
[ "https://Stackoverflow.com/questions/398347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1190/" ]
398,351
<p>i want to call a server side method using __DoPostBack and generating the HTML, but i dont want a hidden ASP runat server control in my page its possible to call a server side method by its name not by the name of the control that trigger it ??</p>
[ { "answer_id": 7237931, "author": "rick schott", "author_id": 58856, "author_profile": "https://Stackoverflow.com/users/58856", "pm_score": 1, "selected": false, "text": "WebMethod public partial class _Default : Page \n{\n [WebMethod]\n public static string GetDate()\n {\n return ...
2008/12/29
[ "https://Stackoverflow.com/questions/398351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
398,353
<p>I know that WPF 3.5 SP1 supports a <code>StringFormat</code> in a binding, but can Silverlight do the same? I thought it could, but damned if I can make it work!</p> <p>Here's a snippet of my XAML:</p> <pre><code>&lt;TextBlock Text="{Binding StartTime, StringFormat=t}" /&gt; </code></pre> <p>It compiles OK, but I get a runtime error when it gets to the browser...</p>
[ { "answer_id": 1891904, "author": "Simon_Weaver", "author_id": 16940, "author_profile": "https://Stackoverflow.com/users/16940", "pm_score": 5, "selected": false, "text": " <data:DataGridTextColumn Header=\"Date\" \n Binding=\"{Binding CreateDt, StringFormat=\\{0:d\\}}\" />\n" } ...
2008/12/29
[ "https://Stackoverflow.com/questions/398353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14537/" ]
398,378
<p>What is the most efficient way to display the last 10 lines of a very large text file (this particular file is over 10GB). I was thinking of just writing a simple C# app but I'm not sure how to do this effectively.</p>
[ { "answer_id": 398432, "author": "biozinc", "author_id": 30698, "author_profile": "https://Stackoverflow.com/users/30698", "pm_score": 1, "selected": false, "text": "FileInfo.Length" }, { "answer_id": 398512, "author": "jason", "author_id": 45914, "author_profile": "h...
2008/12/29
[ "https://Stackoverflow.com/questions/398378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2849/" ]
398,388
<p>How can i convert an array of bitmaps into a brand new image of TIFF format, adding all the bitmaps as frames in this new tiff image?</p> <p>using .NET 2.0.</p>
[ { "answer_id": 398529, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 7, "selected": true, "text": "Bitmap bitmap = (Bitmap)Image.FromFile(file);\n MemoryStream byteStream = new MemoryStream();\nbitmap.Save(byteStream,...
2008/12/29
[ "https://Stackoverflow.com/questions/398388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35286/" ]
398,395
<p>Why do most C programmers name variables like this:</p> <pre><code>int *myVariable; </code></pre> <p>rather than like this:</p> <pre><code>int* myVariable; </code></pre> <p>Both are valid. It seems to me that the asterisk is a part of the type, not a part of the variable name. Can anyone explain this logic?</p>
[ { "answer_id": 398403, "author": "biozinc", "author_id": 30698, "author_profile": "https://Stackoverflow.com/users/30698", "pm_score": 7, "selected": false, "text": "*myVariable int" }, { "answer_id": 398409, "author": "Greg Rogers", "author_id": 5963, "author_profile...
2008/12/29
[ "https://Stackoverflow.com/questions/398395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26149/" ]
398,425
<p>Say I have at database table containing information about a news article in each row. The table has an integer "sort" column to dictate the order in which the articles are to be presented on a web site. How do I best implement and maintain this sort order.</p> <p>The problem I want to avoid is having the the articles numbered 1,2,3,4,..,100 and when article number 50 suddenly becomes interesting it gets its sort number set to 1 and then all articles between them must have their sort number increased by one.</p> <p>Sure, setting initial sort numbers to 100,200,300,400 etc. leaves some space for moving around but at some point it will break.</p> <p>Is there a correct way to do this, maybe a completely different approach?</p> <hr> <p><em>Added-1</em>:</p> <p>All article titles are shown in a list linking to the contents, so yes all sorted items are show at once.</p> <p><em>Added-2</em>:</p> <p>An item is not necessarily moved to the top of the list; any item can be placed anywhere in the ordered list.</p>
[ { "answer_id": 398709, "author": "Alkini", "author_id": 47522, "author_profile": "https://Stackoverflow.com/users/47522", "pm_score": 3, "selected": false, "text": "UPDATE Articles\nSET sort_number = sort_number + 1\nWHERE sort_number BETWEEN :new_sort_number and :current_sort_number - 1...
2008/12/29
[ "https://Stackoverflow.com/questions/398425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
398,441
<p>I'm playing around with Project Euler's <a href="http://projecteuler.net/index.php?section=problems&amp;id=220" rel="nofollow noreferrer">Problem 220</a>, and I'm a little confused about the Wikipedia article on the topic, <a href="http://en.wikipedia.org/wiki/Dragon_curve" rel="nofollow noreferrer">Dragon Curve</a>. On the topic of calculating the direction of the nth turn without having to draw the entire curve, it says:</p> <blockquote> <p>First, express n in the form k * 2^m where k is an odd number. The direction of the nth turn is determined by k mod 4 i.e. the remainder left when k is divided by 4. If k mod 4 is 1 then the nth turn is R; if k mod 4 is 3 then the nth turn is L.</p> <p>For example, to determine the direction of turn 76376:</p> <pre><code>76376 = 9547 x 8. 9547 = 2386x4 + 3 so 9547 mod 4 = 3 so turn 76376 is L </code></pre> </blockquote> <ul> <li>Is there a clever way to figure out if n <strong>can</strong> be expressed as k2^m, apart from checking divisibility by successive powers of 2?</li> <li>What does it mean if n cannot be expressed in such a way? </li> </ul> <p>(The problem involves calculating the position of a point on a Dragon curve with length 2^50, so actually drawing the curve is out of the question.)</p>
[ { "answer_id": 398526, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https://Stackoverflow.com/users/14343", "pm_score": 1, "selected": false, "text": "def k_and_m(n):\n k, m = n, 0\n while (k % 2) == 0:\n k >>= 1\n m += 1\n return k, m\n" } ...
2008/12/29
[ "https://Stackoverflow.com/questions/398441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13051/" ]
398,458
<p>I am trying to build a board game ... And looks like it has to be implemented using a state machine.. </p> <p>I know of the <a href="http://en.wikipedia.org/wiki/State_pattern" rel="nofollow noreferrer">State pattern</a> from GoF, but I am sure there must be other ways to implement state machine. Please let me know.. if you know of any articles or books that contains details about different implementation (trade off of each of them), please direct me.. thanks</p>
[ { "answer_id": 398527, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "public delegate void ProcessEvent<TEvent>(TEvent ev);\n\npublic abstract class StateMachine<TEvent>\n{\n private ProcessEve...
2008/12/29
[ "https://Stackoverflow.com/questions/398458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30917/" ]
398,468
<p>I've got a sql query (using Firebird as the RDBMS) in which I need to order the results by a field, EDITION. I need to order by the contents of the field, however. i.e. "NE" goes first, "OE" goes second, "OP" goes third, and blanks go last. Unfortunately, I don't have a clue how this could be accomplished. All I've ever done is ORDER BY [FIELD] ASC/DESC and nothing else. </p> <p>Any suggestions? </p> <p>Edit: I really should clarify: I was just hoping to learn more here. I have it now that I just have multiple select statements defining which to show first. The query is rather large and I was really hoping to learn possibly a more effecient way of doing this: example: </p> <pre><code>SELECT * FROM RETAIL WHERE MTITLE LIKE 'somethi%' AND EDITION='NE' UNION SELECT * FROM RETAIL WHERE MTITLE LIKE 'somethi%' AND EDITION='OE' UNION SELECT * FROM RETAIL WHERE MTITLE LIKE 'somethi%' AND EDITION='OP' UNION (etc...) </code></pre>
[ { "answer_id": 398484, "author": "Peter T. LaComb Jr.", "author_id": 8513, "author_profile": "https://Stackoverflow.com/users/8513", "pm_score": 3, "selected": false, "text": "Edition Rank\nNE 1\nOE 2\nOP 3\n" }, { "answer_id": 398486, "author": "Pulsehead"...
2008/12/29
[ "https://Stackoverflow.com/questions/398468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48957/" ]
398,476
<p>I'm trying to edit the output joomla main_menu module so I can make a custom dropdown menu. At the moment it currently outputs html like this:</p> <pre><code>&lt;ul class="menu"&gt; &lt;li class="active item1" id="current"&gt;&lt;a href="#"&gt;&lt;span&gt;First Level Item &lt;/span&lt;/a&gt;&lt;/li&gt; &lt;li class="parent item63"&gt;&lt;a href="#"&gt;&lt;span&gt;First Level Item Parent&lt;/span&gt;&lt;/a&gt; &lt;ul&gt; &lt;li class="item60"&gt;&lt;a href="#"&gt;&lt;span&gt;Second Level Item&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li class="item69"&gt;&lt;a href="#"&gt;&lt;span&gt;Second Level Item&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li class="item64"&gt;&lt;a href="#"&gt;&lt;span&gt;First Level Item&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li class="item66"&gt;&lt;a href="#"&gt;&lt;span&gt;First Level Item&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; </code></pre> <p></p> <p>What I would like to do is remove the span tags for the output.</p> <p>What I know so far is that if I want to edit the output; in my template folder I make a directory called 'html' and then inside that a new directory called 'mod___mainmenu' and then a make copy the default.php file from the existing mod_mainmenu folder from the modules directory. All the changes to I make to take file will change the output.</p> <p>The problem that I'm having is that I can't understand what is happening with the code that is written in the default.php file as it use some XML system that I'm unfamilar with and there are no comments.</p> <p>If anyone has any ideas that would be super helpful!</p> <p>Here is the code from the default.php file for the menu:</p> <pre><code>defined('_JEXEC') or die('Restricted access'); if ( ! defined('modMainMenuXMLCallbackDefined') ) { function modMainMenuXMLCallback(&amp;$node, $args) { $user = &amp;JFactory::getUser(); $menu = &amp;JSite::getMenu(); $active = $menu-&gt;getActive(); $path = isset($active) ? array_reverse($active-&gt;tree) : null; if (($args['end']) &amp;&amp; ($node-&gt;attributes('level') &gt;= $args['end'])) { $children = $node-&gt;children(); foreach ($node-&gt;children() as $child) { if ($child-&gt;name() == 'ul') { $node-&gt;removeChild($child); } } } if ($node-&gt;name() == 'ul') { foreach ($node-&gt;children() as $child) { if ($child-&gt;attributes('access') &gt; $user-&gt;get('aid', 0)) { $node-&gt;removeChild($child); } } } if (($node-&gt;name() == 'li') &amp;&amp; isset($node-&gt;ul)) { $node-&gt;addAttribute('class', 'parent'); } if (isset($path) &amp;&amp; in_array($node-&gt;attributes('id'), $path)) { if ($node-&gt;attributes('class')) { $node-&gt;addAttribute('class', $node-&gt;attributes('class').' active'); } else { $node-&gt;addAttribute('class', 'active'); } } else { if (isset($args['children']) &amp;&amp; !$args['children']) { $children = $node-&gt;children(); foreach ($node-&gt;children() as $child) { if ($child-&gt;name() == 'ul') { $node-&gt;removeChild($child); } } } } if (($node-&gt;name() == 'li') &amp;&amp; ($id = $node-&gt;attributes('id'))) { if ($node-&gt;attributes('class')) { $node-&gt;addAttribute('class', $node-&gt;attributes('class').' item'.$id); } else { $node-&gt;addAttribute('class', 'item'.$id); } } if (isset($path) &amp;&amp; $node-&gt;attributes('id') == $path[0]) { $node-&gt;addAttribute('id', 'current'); } else { $node-&gt;removeAttribute('id'); } $node-&gt;removeAttribute('level'); $node-&gt;removeAttribute('access'); } define('modMainMenuXMLCallbackDefined', true); } modMainMenuHelper::render($params, 'modMainMenuXMLCallback'); </code></pre>
[ { "answer_id": 477167, "author": "Jerph", "author_id": 1701, "author_profile": "https://Stackoverflow.com/users/1701", "pm_score": 3, "selected": false, "text": "ob_start();\nmodMainMenuHelper::render($params, 'modMainMenuXMLCallback');\n$mainMenuContent = ob_get_clean();\necho str_repla...
2008/12/29
[ "https://Stackoverflow.com/questions/398476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28672/" ]
398,491
<p>I've been tasked with fixing a dotnetnuke installation that was simply copied from one server to another and the first thing I need to do is figure out which version it is.</p> <p>What's the easiest way?</p>
[ { "answer_id": 398885, "author": "Ian Robinson", "author_id": 326, "author_profile": "https://Stackoverflow.com/users/326", "pm_score": 5, "selected": false, "text": "select top 1 * from version order by createddate desc\n" } ]
2008/12/29
[ "https://Stackoverflow.com/questions/398491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/335036/" ]
398,509
<p>What are the advantages of replacing <code>(int)reader[0]</code> with <code>reader.GetInt32(0)</code>? I'm sure such casting functions are there for a reason, but other than it feeling more aesthetically pleasing to avoid the cast myself, I'm not sure what those reasons are.</p>
[ { "answer_id": 398605, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 4, "selected": true, "text": " void OneWay()\n {\n System.Data.SqlClient.SqlDataReader reader = null;\n int i = re...
2008/12/29
[ "https://Stackoverflow.com/questions/398509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18192/" ]
398,518
<p>I don't know if it's legit at StackOverflow to post your own answer to a question, but I saw nobody had asked this already. I went looking for a C# Glob and didn't find one, so I wrote one that others might find useful.</p>
[ { "answer_id": 398522, "author": "Mark Maxham", "author_id": 49737, "author_profile": "https://Stackoverflow.com/users/49737", "pm_score": 4, "selected": false, "text": " /// <summary>\n /// return a list of files that matches some wildcard pattern, e.g. \n /// C:\\p4\\software\...
2008/12/29
[ "https://Stackoverflow.com/questions/398518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49737/" ]
398,538
<p>I'm looking at building some web user controls with an eye toward re-use, but I can't seem to add a Web User Control in my class library in VS2008. Is there a way to work around this problem, or is there a better approach to creating reusable controls?</p>
[ { "answer_id": 398598, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "[DefaultProperty(\"Text\")]\n[Category(\"...\")]\n[DefaultValue(\"\")]\n" } ]
2008/12/29
[ "https://Stackoverflow.com/questions/398538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23276/" ]
398,543
<p>While learning different languages, I've often seen objects allocated on the fly, most often in Java and C#, like this:</p> <pre><code>functionCall(new className(initializers)); </code></pre> <p>I understand that this is perfectly legal in memory-managed languages, but can this technique be used in C++ without causing a memory leak? </p>
[ { "answer_id": 398562, "author": "Harper Shelby", "author_id": 21196, "author_profile": "https://Stackoverflow.com/users/21196", "pm_score": 0, "selected": false, "text": "new T();\n" }, { "answer_id": 398637, "author": "JohnMcG", "author_id": 1674, "author_profile": ...
2008/12/29
[ "https://Stackoverflow.com/questions/398543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1256/" ]
398,547
<p>Assume a requirement of implementing a class "CAR".</p> <p>Now, this class contains various states like "un-ignited", "ignited", "broken-down", "punctured", etc.,</p> <p>The way I look at to implement this requirement is to have boolean flags aka "properties" in the class and 'check the state' using these boolean flags inside each member function. For example,</p> <pre> CAR.goRacing() { if(bIsPunctured) return ENUM_CANT_DRIVE; //Start the Engine... }</pre> <p>This implementation, trivial so it might look, starts to become very complicated when the number of states that the object exposes increases. I have also seen occurences where a single state renders the maintenance of the object a lot cumbersome (i am sure that in this case, I am to blame for my programming skills) <br> Is there a standard way of implementing such a <strong>state-driven</strong> object? </p> <p>I have seen Steve Yeggey's <a href="http://steve-yegge.blogspot.com/2008/10/universal-design-pattern.html" rel="nofollow noreferrer">Property Pattern</a>, but I am really falling short of a real world example!</p> <p>Thanks.</p>
[ { "answer_id": 398554, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 2, "selected": false, "text": "//These are the states of the \"Pet\" class\n//sleep -> wake up -> play -> dinner -> sleep -> wake up .. etc. \nclass Pe...
2008/12/29
[ "https://Stackoverflow.com/questions/398547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
398,560
<p>How can I split by word boundary in a regex engine that doesn't support it?</p> <p>python's re can match on \b but doesn't seem to support splitting on it. I seem to recall dealing with other regex engines that had the same limitation.</p> <p>example input:</p> <pre><code>"hello, foo" </code></pre> <p>expected output:</p> <pre><code>['hello', ', ', 'foo'] </code></pre> <p>actual python output:</p> <pre><code>&gt;&gt;&gt; re.compile(r'\b').split('hello, foo') ['hello, foo'] </code></pre>
[ { "answer_id": 398570, "author": "gnud", "author_id": 27204, "author_profile": "https://Stackoverflow.com/users/27204", "pm_score": 0, "selected": false, "text": ">>> re.compile(r'\\W\\b').split('hello, foo')\n['hello,', 'foo']\n" }, { "answer_id": 398584, "author": "Christia...
2008/12/29
[ "https://Stackoverflow.com/questions/398560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41613/" ]
398,571
<p>You know, what you normally get when typing ctrl-alt-del or ctrl-alt-end. Except in this scenario I can't press those keys, but I want to launch that box. Specifically I want to be able to pull up the change password dialog from the command line.</p> <p>Thanks</p>
[ { "answer_id": 7916160, "author": "Raymond Chen", "author_id": 902497, "author_profile": "https://Stackoverflow.com/users/902497", "pm_score": 2, "selected": false, "text": "Shell.WindowsSecurity" }, { "answer_id": 24028982, "author": "Ben Key", "author_id": 2532437, ...
2008/12/29
[ "https://Stackoverflow.com/questions/398571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/362693/" ]
398,621
<p>See subject, note that this question only applies to the .NET <strong>compact</strong> framework. This happens on the emulators that ship with Windows Mobile 6 Professional SDK as well as on my English HTC Touch Pro (all .NET CF 3.5). iso-8859-1 stands for Western European (ISO), which is probably the most important encoding besides us-ascii (at least when one goes by the number of usenet posts).</p> <p>I'm having a hard time to understand why this encoding is not supported, while the following ones are supported (again on both the emulators &amp; my HTC):</p> <ul> <li>iso-8859-2 (Central European (ISO))</li> <li>iso-8859-3 (Latin 3 (ISO))</li> <li>iso-8859-4 (Baltic (ISO))</li> <li>iso-8859-5 (Cyrillic (ISO))</li> <li>iso-8859-7 (Greek (ISO))</li> </ul> <p>So, is support for say Greek more important than support for German, French and Spanish? Can anyone shed some light on this?</p> <p>Thanks!</p> <p>Andreas</p>
[ { "answer_id": 398683, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 4, "selected": false, "text": "System.Text.Encoding.GetEncoding(1252)\n" }, { "answer_id": 24618827, "author": "hdkrus", "author_id": 1195...
2008/12/29
[ "https://Stackoverflow.com/questions/398621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
398,641
<p>I have a factory that builds the objects with longest lifetime in my application. These have types, lets say, <code>ClientA</code> and <code>ClientB</code>, which depend on <code>Provider</code> (an abstract class with many possible implementations), so both clients have a reference to Provider as member.</p> <p>According to the command-line arguments, the factory chooses one implementation of <code>Provider</code>, constructs it (with "<code>new</code>"), and passes it to the constructors of both clients.</p> <p>The factory returns an object that represents my entire app. My main function is basically this:</p> <pre><code>int main(int argc, char** argv) { AppFactory factory(argc, argv); App app = factory.buildApp(); return app.run(); } </code></pre> <p>And the <code>buildApp</code> method is basically this:</p> <pre><code>App AppFactory::buildApp() { Provider* provider = NULL; if (some condition) { provider = new ProviderX(); } else { provider = new ProviderY(); } ClientA clientA(*provider); ClientB clientB(*provider); App app(clientA, clientB); return app; } </code></pre> <p>So, when execution ends, destructors of all objects are called, except for the provider object (because it was constructed with "<code>new</code>").</p> <p>How can I improve this design to make sure that the destructor of the provider is called?</p> <p>EDIT: To clarify, my intention is that both clients, the provider and the App object to share the same lifetime. After all answers, I now think both clients and the provider should be allocated on the heap its references passed to the App object, which will be responsible for deleting them when it dies. What do you say?</p>
[ { "answer_id": 398652, "author": "Stefan", "author_id": 48003, "author_profile": "https://Stackoverflow.com/users/48003", "pm_score": 0, "selected": false, "text": "delete provider;\nprovider = NULL;\n" }, { "answer_id": 398829, "author": "Rasmus Faber", "author_id": 5542...
2008/12/29
[ "https://Stackoverflow.com/questions/398641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23477/" ]
398,648
<p>I want to make a table that simply has two integer columns to serve as a mapping table between two different data sets and I wish to put the correct constraints on it.</p> <p>I initially set the two columns as a compound primary key, but then realized that represents a many to many, only keeping duplicate many to many mappings from occurring.</p> <p>How do I specify I want both columns to be unique integers in all rows? I'm using MS SQL, but I suppose this is a general database design question.</p>
[ { "answer_id": 398659, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 2, "selected": true, "text": "CREATE TABLE [dbo].[test](\n [x] [int] NOT NULL,\n [y] [int] NOT NULL,\n CONSTRAINT [PK_test] PRIMARY KEY...
2008/12/29
[ "https://Stackoverflow.com/questions/398648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21367/" ]
398,664
<p>It seems vsize() and length() return the same results. Does anyone know of a practical example of when to use vsize instead of length?</p> <pre><code>select vsize(object_name), length(object_name) from user_objects </code></pre> <p>Result:</p> <pre><code>/468ba408_LDAPHelper 20 20 /de807749_LDAPHelper 20 20 A4201_A4201_UK 14 14 A4201_PGM_FK_I 14 14 A4201_PHC_FK_I 14 14 </code></pre>
[ { "answer_id": 400392, "author": "David Aldridge", "author_id": 6742, "author_profile": "https://Stackoverflow.com/users/6742", "pm_score": 4, "selected": true, "text": "drop table daa_test;\ncreate table daa_test as select sysdate dt from dual;\nalter session set nls_date_format = 'YYYY...
2008/12/29
[ "https://Stackoverflow.com/questions/398664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/700/" ]
398,665
<p>I'm working on a demo that makes use of Spring.NET IoC capability in ASP.NET MVC . It's kind of like the MyBlog application presented on pair programming video tutorial on www.asp.net site. I've completed the same demo using Microsoft's Unity framework and now want to try out the Spring container. To that end I've implemented a simple IControllerFactory that first creates the Spring object factory like that:</p> <pre><code>IObjectFactory factory; (....) factory = new XmlObjectFactory(new FileSystemResource(application.Server.MapPath("objects.xml"))) </code></pre> <p>and next it gets the controller from that factory like that:</p> <pre><code>public IController CreateController(System.Web.Routing.RequestContext requestContext, string controllerName) { IController result = context.GetObject(controllerName) as IController; return result; } </code></pre> <p>(error handling stripped for simplification purposes).</p> <p>Now somewhere in my HomeController I have this kind of action:</p> <pre><code>[AcceptVerbs(HttpVerbs.Post)] public ActionResult AddEntry([Bind] BlogEntry entry, int id) { entry.EntryDate = DateTime.Now; .... </code></pre> <p>And here's the part of AddEntry.aspx view that defines the editors for entry parameter (really basic stuff):</p> <pre><code>&lt;form method="post" action="/Home/AddEntry/&lt;%= ViewData["id"] %&gt;"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;label for="Title"&gt;Title&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input name="entry.Title" type="text"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label for="Text"&gt;Content&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input name="entry.Text" type="text"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;br /&gt; &lt;input type="submit" value="Add entry" /&gt; &lt;input type="button" value="Cancel" onclick="history.back(-1);" /&gt; &lt;/form&gt; </code></pre> <p>Now here's the deal: When I'm using the Unity IoC it works like a charm. "entry" parameter gets deserialized from my form like it should and the line</p> <pre><code>entry.EntryDate = DateTime.Now; </code></pre> <p>completes without problems.</p> <p>However when I switch to Spring.NET object factory (like described above) things begin to go nuts. First of all the parameter "entry" turns null so an exception is thrown. To track the possible problem on my end I've implemented a sort of custom IModelBinder that looks like that:</p> <pre><code>public class BlogEntryBinder : IModelBinder { public ModelBinderResult BindModel(ModelBindingContext bindingContext) { ModelBinderResult result = ModelBinders.DefaultBinder.BindModel(bindingContext); return result; } } </code></pre> <p>When I come here using the Unity framework and drill down from bindingContext to HttpRequest I see that the Request.HttpMethod is "POST" and Request.Form is properly filled. When I do the same using Spring.NET the method is "GET" and Request.Form is empty. When however I step to my controller action (AddEntry) and drill down to the Request in both situations I see that the Request.HttpMethod and Request.Form have their proper values.</p> <p>Now the question is how do I fix the version with Spring.NET so that it works just like the one that uses Unity framework?</p>
[ { "answer_id": 398749, "author": "Matthias Hryniszak", "author_id": 49970, "author_profile": "https://Stackoverflow.com/users/49970", "pm_score": 3, "selected": true, "text": "<!-- Controlers -->\n<object name=\"Home\" type=\"MyBlog.Controllers.HomeController\">\n <property name=\"Blo...
2008/12/29
[ "https://Stackoverflow.com/questions/398665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49970/" ]
398,682
<p>I have a macro that looks like this:</p> <pre><code>#define coutError if (VERBOSITY_SETTING &gt;= VERBOSITY_ERROR) ods() </code></pre> <p>where ods() is a class that behaves similarly to cout, and VERBOSITY_SETTING is a global variable. There are a few of these for different verbosity settings, and it allows the code to look something like this:</p> <pre><code>if (someErrorCondition) { // ... do things relating to the error condition ... coutError &lt;&lt; "Error condition occurred"; } </code></pre> <p>And there is functionality in this framework to set the verbosity, etc. However, the obvious pattern breaks when not using braces in something like this:</p> <pre><code>void LightSwitch::TurnOn() { if (!PowerToSwitch) coutError &lt;&lt; "No power!"; else SwitchOn = true; } </code></pre> <p>because of the macro, will turn into this:</p> <pre><code>void LightSwitch::TurnOn() { if (!PowerToSwitch) if (VERBOSITY_SETTING &gt;= VERBOSITY_ERROR) ods() &lt;&lt; "No power!"; else SwitchOn = true; } </code></pre> <p>Which is not the intended functionality of the if statement.</p> <p>Now, I understand a way to fix this macro properly so it doesn't cause this problem, but I'd like to run an audit on the code and find any place that has this pattern of "if (...) coutError &lt;&lt; ...; else" to find out if there are any other cases where this happens to make sure that when fixing the macro, it will indeed be correct functionality.</p> <p>I can use any language/tool to find this, I just want to know the best way of doing that.</p>
[ { "answer_id": 398742, "author": "Roddy", "author_id": 1737, "author_profile": "https://Stackoverflow.com/users/1737", "pm_score": 3, "selected": true, "text": "#define coutError {} if (VERBOSITY_SETTING >= VERBOSITY_ERROR) ods()\n" }, { "answer_id": 398789, "author": "Dougla...
2008/12/29
[ "https://Stackoverflow.com/questions/398682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28776/" ]
398,708
<p>I'm working on wrapping my head around the factory pattern by using it in a simple data storage project in my free time. The idea is to take simple data and save it to a database using a simple factory pattern in VB.NET. I think I have a basic understanding of the pattern itself, however, what I'm struggling with is how to fit the factory classes into the architecture cleanly. I have a standard 3 tier architecture for this project that looks essentially like this:</p> <p>Presentation</p> <pre><code> -Presentation.Common -Presentation.DataStorageWebAppName </code></pre> <p>Business</p> <pre><code> -BusinessLayer.Common -BusinessLayer.DataStorageAppName </code></pre> <p>Data</p> <pre><code> -DataLayer.Common -DataLayer.DataStorageAppName </code></pre> <p>Common</p> <pre><code> -Common -Common.DataStorageAppName </code></pre> <p>Interfaces</p> <pre><code> -Interfaces.Common -Interfaces.DataStorageAppName </code></pre> <p>To highlight a particular scenario where I'm having trouble architecting the application, let me give an example. Let's say that in the business layer I create a class in the BusinessLayer.DataStorageAppName DLL called Foo. It has an interface, IFoo, that lives in the Interfaces.DataStorageAppName DLL. To create an instance of the class Foo through it's interface IFoo using a simple factory pattern, right now, I create a Factory class in BusinessLayer.DataStorageAppName and write a shared/static method to do give me an instance through the IFoo interface. Later, as I understand it, I could decide to swap out the object this Factory class returns without having to do much else (in theory).</p> <p>To get to the point, this works, but what seems funky about it is that I'm now forced into creating several Factory classes: one per DLL essentially, so that I can avoid circular references. Is there a cleaner way to implement these factory classes without resorting to using a 3rd party solution like castle windsor, etc. etc. It seems as though I'm missing a fundamental concept here. It seems as though it should be possible to have a single "repository", if you will, in the architecture that is responsible for handing out object instances.</p> <p>Thank you in advance!</p>
[ { "answer_id": 400055, "author": "Giraffe", "author_id": 50136, "author_profile": "https://Stackoverflow.com/users/50136", "pm_score": 1, "selected": false, "text": "public class FooConsumer1\n{\n public void DoStuff()\n {\n IFoo myFoo = new Foo();\n myFoo.Bar();\n ...
2008/12/29
[ "https://Stackoverflow.com/questions/398708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13955/" ]
398,734
<p>How can I specify a <code>td</code> tag should span all columns (when the exact amount of columns in the table will be variable/difficult to determine when the HTML is being rendered)? <a href="http://www.w3schools.com/tags/att_td_colspan.asp" rel="noreferrer">w3schools</a> mentions you can use <code>colspan="0"</code>, but it doesn't say exactly what browsers support that value (IE 6 is in our list to support). </p> <p>It appears that setting <code>colspan</code> to a value greater than the theoretical amount of columns you may have will work, but it will not work if you have <code>table-layout</code> set to <code>fixed</code>. Are there any disadvantages to using an automatic layout with a large number for <code>colspan</code>? Is there a more correct way of doing this?</p>
[ { "answer_id": 398763, "author": "George Stocker", "author_id": 16587, "author_profile": "https://Stackoverflow.com/users/16587", "pm_score": 4, "selected": false, "text": "colspan=\"5\" colspan=0 colspan=1" }, { "answer_id": 1470950, "author": "Community", "author_id": -...
2008/12/29
[ "https://Stackoverflow.com/questions/398734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45/" ]
398,747
<p>We have a database (SQL Server 2005) which we would like to get under source control. As part of that we are going to have a version table to store the current version number of the database. Is there a way to limit that table to only holding one row? Or is storing the version number in a table a bad idea? </p> <p>Ended up using this approach:</p> <pre><code>CREATE TABLE [dbo].[DatabaseVersion] ( [MajorVersionNumber] [int] NOT NULL, [MinorVersionNumber] [int] NOT NULL, [RevisionNumber] [int] NOT NULL ) GO Insert DataBaseVersion (MajorVersionNumber, MinorVersionNumber, RevisionNumber) values (0, 0, 0) GO CREATE TRIGGER DataBaseVersion_Prevent_Delete ON DataBaseVersion INSTEAD OF DELETE AS BEGIN RAISERROR ('DatabaseVersion must always have one Row. (source = INSTEAD OF DELETE)', 16, 1) END GO CREATE TRIGGER DataBaseVersion_Prevent_Insert ON DataBaseVersion INSTEAD OF INSERT AS BEGIN RAISERROR ('DatabaseVersion must always have one Row. (source = INSTEAD OF INSERT)', 16, 1) END GO </code></pre>
[ { "answer_id": 398765, "author": "Ole", "author_id": 49540, "author_profile": "https://Stackoverflow.com/users/49540", "pm_score": 1, "selected": false, "text": "SELECT v.version FROM version v ORDER by v.date DESC LIMIT 1;\n" }, { "answer_id": 398769, "author": "WOPR", "...
2008/12/29
[ "https://Stackoverflow.com/questions/398747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1973027/" ]
398,748
<p>I've created a new J2SE project in NetBeans, and I can run it from the IDE, but when I try to run it using Ant on the command line, I get the following problem:</p> <p>&lt;snip&gt;</p> <pre><code>run: [java] Exception in thread "main" java.lang.NoClassDefFoundError: IndexBuilder [java] Java Result: 1 </code></pre> <p>&lt;snip&gt;</p> <p>Based on the snippet from <code>project.properties</code> below, the class should be found.</p> <pre><code>run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} </code></pre> <p>How do I go about fixing this?</p>
[ { "answer_id": 604861, "author": "Eddie", "author_id": 57752, "author_profile": "https://Stackoverflow.com/users/57752", "pm_score": 1, "selected": false, "text": "IndexBuilder IndexBuilder IndexBuilder IndexBuilder IndexBuilder IndexBuilder NoClassDefFoundError" }, { "answer_id"...
2008/12/29
[ "https://Stackoverflow.com/questions/398748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4203/" ]
398,760
<p>What's the difference between the following two pieces of HTML (apologies if there are any typos as I'm typing this freehand)?</p> <p>Using jQuery:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $("#clickme").click(function() { alert("clicked!"); }); }); &lt;/script&gt; &lt;a id="clickme" href="javascript:void(0);"&gt;click me&lt;/a&gt; </code></pre> <p>Not using jQuery:</p> <pre><code>&lt;a id="clickme" href="javascript:void(0);" onclick="alert('clicked!');"&gt;click me&lt;/a&gt; </code></pre>
[ { "answer_id": 398797, "author": "orip", "author_id": 37020, "author_profile": "https://Stackoverflow.com/users/37020", "pm_score": 3, "selected": false, "text": "click" }, { "answer_id": 398800, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https:...
2008/12/29
[ "https://Stackoverflow.com/questions/398760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
398,781
<p>I want to build a nice API (C#) to make it easier for people to consume, I think I've seen this before and want to know how to do this:</p> <pre><code>MyNamespace.Cars car = null; if(someTestCondition) car = new Honda(); else car = new Toyota(); car.Drive(40); </code></pre> <p>Is this possible? If so, what needs to be done? </p>
[ { "answer_id": 398792, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 4, "selected": true, "text": "Interface Car\n{\nvoid Drive(int miles);\n}\n\nclass Honda : Car\n{\n...\n}\nclass Toyota : Car\n{\n...\n}\n" }, {...
2008/12/29
[ "https://Stackoverflow.com/questions/398781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
398,801
<p>I was wondering what everyone thinks of this. Is the code easy to follow? Or is there a better way to do this? By the way, this is how I am currently doing validation at the moment with ASP.NET MVC. I can follow it, but I am the one who wrote it. For some reason SO is removing the line breaks between the validators. </p> <pre><code> public override Validation&lt;MemberCreate&gt; ValidationRules() { var validation = new Validation&lt;MemberCreate&gt;(); validation.Add(x =&gt; x.Name) .LengthBetween( Config.Member.NameMinLength, Config.Member.NameMaxLength, Resources.Errors.LengthBetweenNotValid.Fmt( Resources.Titles.Name, Config.Member.NameMinLength, Config.Member.NameMaxLength)) .Characters(Resources.Errors.CharactersNotValid.Fmt(Resources.Titles.Name)); validation.Add(x =&gt; x.EmailAddress).Email( Resources.Errors.EmailNotValid.Fmt( Resources.Titles.EmailAddress)); validation.Add(x =&gt; x.VerifyEmailAddress).Equal( x =&gt; x.EmailAddress, Resources.Errors.CompareNotValid.Fmt( Resources.Titles.VerifyEmailAddress, Resources.Titles.EmailAddress)); validation.Add(x =&gt; x.PassWord).LengthGreaterThan( Config.Member.PassWordMinLength, Resources.Errors.LengthGreaterThanNotValid.Fmt( Resources.Titles.PassWord, Config.Member.PassWordMinLength)); validation.Add(x =&gt; x.VerifyPassWord).Equal( x =&gt; x.PassWord, Resources.Errors.CompareNotValid.Fmt( Resources.Titles.VerifyPassWord, Resources.Titles.PassWord)); return validation; } </code></pre>
[ { "answer_id": 398877, "author": "thrashr888", "author_id": 46443, "author_profile": "https://Stackoverflow.com/users/46443", "pm_score": 0, "selected": false, "text": "email" } ]
2008/12/29
[ "https://Stackoverflow.com/questions/398801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43380/" ]
398,802
<p>Has anyone attempted to use SQL Server Database as a Subversion file system back end? So that all Subversion Repositories would be stored in a SQL Database instead of a flat file system? Make for easier backups and reporting?</p>
[ { "answer_id": 398877, "author": "thrashr888", "author_id": 46443, "author_profile": "https://Stackoverflow.com/users/46443", "pm_score": 0, "selected": false, "text": "email" } ]
2008/12/29
[ "https://Stackoverflow.com/questions/398802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7911/" ]
398,803
<p>I have two report parameters that were set up automatically when I created their associated datasets. They are ReportID and CompanyID. The user selects a Company Name from a list box and a Report Name from another list box. The standard SELECT ID, Name FROM TableName query was used to fill the respective list boxes. The report parameters work just fine and the report is displayed properly. My problem is this. I would like to place the selected Report Name and the Company Name in the report header (these are the Name values the user selected from the dropdown lists just before hitting the View Report button. I set up two new parameters, ReportName and CompanyName; marked them as hidden and set their default values to the appropriate datasets. The problem is that the header always shows the first name from the list, not the name the user selected. My question is, how do I place the selected information into the header?</p>
[ { "answer_id": 398832, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 6, "selected": true, "text": "=Parameters!Farm.Label\n" }, { "answer_id": 15030288, "author": "Darren Griffith", "author_id": 770065, ...
2008/12/29
[ "https://Stackoverflow.com/questions/398803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
398,804
<p>I've got an existing Access MDB. I'm adding a command button to an existing Form that runs an existing report. The change being made is that this button needs to pass in a parameter containing the ID of the record being reported on - currently the report runs on every record in the MDB.</p> <p>I've altered the Query that the report runs on to use a parameter for the ID value, so that now when the button is clicked Access prompts for the record ID to report on, and the report displays like it should.</p> <p>However, I can't for the life of me figure out how to pass a parameter into the report for the query to use. How can I do this?</p>
[ { "answer_id": 398854, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 6, "selected": true, "text": "DoCmd.OpenReport\"rptReport\", acViewPreview,,\"ID=\" & Me.ID\n expression.OpenReport(ReportName, View, FilterName, WhereCo...
2008/12/29
[ "https://Stackoverflow.com/questions/398804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19074/" ]
398,806
<p>I have a view that I want to add some custom drawing to.</p> <p>I know how to do this with a View that isn't connected to a Nib/Xib file </p> <ul> <li>you write the drawing code in the <code>-drawRect:</code> method.</li> </ul> <p>But if I <code>init</code> the view using</p> <pre><code>[[MyView alloc] initWithNibName:@"MyView" bundle:[NSBundle mainBundle]]; </code></pre> <p><code>-drawRect:</code> of course doesn't get called. I tried doing the below code in <code>-viewDidLoad</code> </p> <pre><code>CGRect rect = [[self view] bounds]; CGContextRef ref = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(ref, 2.0); CGContextSetRGBStrokeColor(ref, 1.0, 1.0, 1.0, 1.0); CGContextSetRGBFillColor(ref, 0, 0, 0, 0); CGContextAddRect(ref, CGRectMake(1, 1, rect.size.width - 10, rect.size.height - 10)); CGContextStrokePath(ref); CGContextDrawPath(ref, kCGPathFillStroke); </code></pre> <p>But nothing get drawn. Any ideas?</p>
[ { "answer_id": 399027, "author": "e.James", "author_id": 33686, "author_profile": "https://Stackoverflow.com/users/33686", "pm_score": 2, "selected": false, "text": "addSubView:" }, { "answer_id": 399236, "author": "Chris Hanson", "author_id": 714, "author_profile": "...
2008/12/29
[ "https://Stackoverflow.com/questions/398806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1075/" ]
398,811
<p>I naively imagined that I could build a suffix trie where I keep a visit-count for each node, and then the deepest nodes with counts greater than one are the result set I'm looking for.</p> <p>I have a really really long string (hundreds of megabytes). I have about 1 GB of RAM.</p> <p>This is why building a suffix trie with counting data is too inefficient space-wise to work for me. To quote <a href="http://en.wikipedia.org/wiki/Suffix_tree" rel="noreferrer">Wikipedia's Suffix tree</a>:</p> <blockquote> <p>storing a string's suffix tree typically requires significantly more space than storing the string itself.</p> <p>The large amount of information in each edge and node makes the suffix tree very expensive, consuming about ten to twenty times the memory size of the source text in good implementations. The suffix array reduces this requirement to a factor of four, and researchers have continued to find smaller indexing structures.</p> </blockquote> <p>And that was wikipedia's comments on the tree, not trie.</p> <p>How can I find long repeated sequences in such a large amount of data, and in a reasonable amount of time (e.g. less than an hour on a modern desktop machine)?</p> <p>(Some wikipedia links to avoid people posting them as the 'answer': <a href="http://en.wikipedia.org/wiki/Category:Algorithms_on_strings" rel="noreferrer">Algorithms on strings</a> and especially <a href="http://en.wikipedia.org/wiki/Longest_repeated_substring_problem" rel="noreferrer">Longest repeated substring problem</a> ;-) )</p>
[ { "answer_id": 398938, "author": "FryGuy", "author_id": 28776, "author_profile": "https://Stackoverflow.com/users/28776", "pm_score": 2, "selected": false, "text": "void LongSubstrings(string data, string prefix, IEnumerable<int> positions)\n{\n Dictionary<char, DiskBackedBuffer> buff...
2008/12/29
[ "https://Stackoverflow.com/questions/398811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15721/" ]
398,816
<p>I'm trying to write javascript to find page elements relative to a given element by using parentNode, firstChild, nextSibling, childNodes[], and so on. Firefox messes this up by inserting text nodes between each html element. I've read that I can defeat this by removing all whitespace between elements but I've tried that and it doesn't doesn't work. Is there a way to write code that works on all modern browsers?</p> <p>For example:</p> <pre><code>&lt;div id="parent"&gt;&lt;p id="child"&gt;Hello world&lt;/p&gt;&lt;/div&gt; </code></pre> <p>In IE parent.firstChild is child but in Firefix it's a phantom Text element.</p>
[ { "answer_id": 398842, "author": "Ady", "author_id": 31395, "author_profile": "https://Stackoverflow.com/users/31395", "pm_score": 0, "selected": false, "text": " function getFirstTag(node) {\n return ((node.firstChild.tagName) ? node.firstChild : node.firstChild.nextSibling);\n}\n" }...
2008/12/29
[ "https://Stackoverflow.com/questions/398816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44394/" ]
398,866
<p>I am running into a design disagreement with a co-worker and would like people's opinion on object constructor design. In brief, which object construction method would you prefer and why? </p> <pre><code> public class myClass { Application m_App; public myClass(ApplicationObject app) { m_App = app; } public method DoSomething { m_App.Method1(); m_App.Object.Method(); } } </code></pre> <p>Or</p> <pre><code> public class myClass { Object m_someObject; Object2 m_someOtherObject; public myClass(Object instance, Object2 instance2) { m_someObject = instance; m_someOtherObject = instance2; } public method DoSomething { m_someObject.Method(); m_someOtherObject.Method(); } } </code></pre> <p>The back story is that I ran into what appears to be a fundamentally different view on constructing objects today. Currently, objects are constructed using an Application class which contains all of the current settings for the application (Event log destination, database strings, etc...) So the constructor for every object looks like:</p> <pre><code>public Object(Application) </code></pre> <p>Many classes hold the reference to this Application class individually. Inside each class, the values of the application are referenced as needed. E.g.</p> <pre><code>Application.ConfigurationStrings.String1 or Application.ConfigSettings.EventLog.Destination </code></pre> <p>Initially I thought you could use both methods. The problem is that in the bottom of the call stack you call the parameterized constructor then, higher up the stack, when the new object expects a reference to the application object to be there, we ran into a lot of null reference errors and saw the design flaw.</p> <p>My feeling on using an application object to set every class is that it breaks encapsulation of each object and allows the Application class to become a god class which holds information for everything. I run into problems when thinking of the downsides to this method.</p> <p>I wanted to change the objects constructor to accept only the arguments it needs so that <code>public object(Application)</code> would change to <code>public object(classmember1, classmember2 etc...)</code>. I feel currently that this makes it more testable, isolates change, and doesn't obfuscate the necessary parameters to pass.</p> <p>Currently, another programmer does not see the difference and I am having trouble finding examples or good reasons to change the design, and saying it's my instinct and just goes against the OO principles I know is not a compelling argument. Am I off base in my design thoughts? Does anyone have any points to add in favor of one or the other?</p>
[ { "answer_id": 399010, "author": "Robert C. Barth", "author_id": 9209, "author_profile": "https://Stackoverflow.com/users/9209", "pm_score": 3, "selected": true, "text": "Do.It(universe)\n" } ]
2008/12/29
[ "https://Stackoverflow.com/questions/398866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2916/" ]