qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
400,849
<p>Say I have two script controls and one control has the other as a child control:</p> <pre><code>ParentControl : ScriptControl { ChildControl childControl; } </code></pre> <p>The script for the Child Control:</p> <pre><code>ChildControl = function(element) { ChildControl.initializeBase(this, [element]); } ChildControl.prototype = { callMethod: function() { return 'hi'; }, initialize: function() { ChildControl.callBaseMethod(this, 'initialize'); }, dispose: function() { ChildControl.callBaseMethod(this, 'dispose'); } } </code></pre> <p>And on script side I want to call a method on the child control:</p> <pre><code>ParentControl.prototype = { initialize: function() { this._childControl = $get(this._childControlID); this._childControl.CallMethod(); ParentControl.callBaseMethod(this, 'initialize'); }, dispose: function() { ParentControl.callBaseMethod(this, 'dispose'); } } </code></pre> <p>Problem is, everytime I try this is says this method isn't found or supported. Shouldn't all methods on the ChildControl be accessible by the ParentControl?</p> <p>Is there some way I have to make the method public so that the ParentControl can see it?</p> <p><strong>Update</strong> Would it be possible to "type" the this._childControl? </p> <p>Here's the reason I ask... When I use Watch, the system knows what the ChildControl class is, and I can call methods off the class itself, however, I can't call the same methods off the this._childControl object. You would think that if the class design (?) in memory recognizes the method existing, and object instantiated from that class would too.</p>
[ { "answer_id": 2834504, "author": "Wallace Breza", "author_id": 233845, "author_profile": "https://Stackoverflow.com/users/233845", "pm_score": 0, "selected": false, "text": "this._childControl = $find(this._childControlID);\nthis._childControl.CallMethod();\n public class CustomControl ...
2008/12/30
[ "https://Stackoverflow.com/questions/400849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21691/" ]
400,861
<p>I have to write a program that read from a file that contains the folowing:</p> <pre><code>toto, M, 50 fifi, F, 60 soso, F, 70 lolo, M, 60 fifi, F, 60 </code></pre> <hr /> <p>And then find the following:</p> <p>Which mark is most repeated, and how many times is it repeated?</p> <ul> <li>average all students</li> <li>average all male</li> <li>average all female</li> </ul> <p>How many are below average mark?</p> <p>How many more than average mark?</p> <p>And reverse.</p> <p>How many students' names start with T and end with T in a file?</p> <p>(all results should be placed in an out file)</p> <hr /> <p>I've done it all with no errors but its not writing on the file can any one tell me why and please I don't want to use any new methods as (LINQ and other advance stuff).</p> <pre><code> using System; using System.Collections.Generic; using System.Text; using System.IO; namespace Exam_Ex { class Program { public static int[] ReadFile(string FileName, out string[] Name, out char[] Gender) { Name = new string[1]; int[] Mark = new int[1]; Gender = new char[1]; if (File.Exists(FileName)) { FileStream Input = new FileStream(FileName, FileMode.Open, FileAccess.Read); StreamReader SR = new StreamReader(Input); string[] Current; int Counter = 0; string Str = SR.ReadLine(); while (Str != null) { Current = Str.Split(','); Name[Counter] = Current[0]; Mark[Counter] = int.Parse(Current[2]); Gender[Counter] = char.Parse(Current[1].ToUpper()); Counter++; Array.Resize(ref Name, Counter + 1); Array.Resize(ref Mark, Counter + 1); Array.Resize(ref Gender, Counter + 1); Str = SR.ReadLine(); } } return Mark; } public static int MostFreq(int[] M, out int Frequency) { int Counter = 0; int Frequent = 0; Frequency = 0; for (int i = 0; i &lt; M.Length; i++) { Counter = 0; for (int j = 0; j &lt; M.Length; j++) if (M[i] == M[j]) Counter++; if (Counter &gt; Frequency) { Frequency = Counter; Frequent = M[i]; } } return Frequent; } public static int Avg(int[] M) { int total = 0; for (int i = 0; i &lt; M.Length; i++) total += M[i]; return total / M.Length; } public static int AvgCond(char[] G, int[] M, char S) { int total = 0; int counter = 0; for (int i = 0; i &lt; G.Length; i++) if (G[i] == S) { total += M[i]; counter++; } return total / counter; } public static int BelowAvg(int[] M, out int AboveAvg) { int Bcounter = 0; AboveAvg = 0; for (int i = 0; i &lt; M.Length; i++) { if (M[i] &lt; Avg(M)) Bcounter++; else AboveAvg++; } return Bcounter; } public static int CheckNames(string[] Name, char C) { C = char.Parse(C.ToString().ToLower()); int counter = 0; string Str; for (int i = 0; i &lt; Name.Length - 1; i++) { Str = Name[i].ToLower(); if (Str[0] == C || Str[Str.Length - 1] == C) counter++; } return counter; } public static void WriteFile(string FileName, string[] Output) { FileStream FS = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.Write); StreamWriter SW = new StreamWriter(FS); for (int i = 0; i &lt; Output.Length; i++) SW.WriteLine(Output[i]); } static void Main(string[] args) { int[] Mark; char[] Gender; string[] Name; string[] Output = new string[8]; int Frequent, Frequency, AvgAll, MaleAvg, FemaleAvg, BelowAverage, AboveAverage, NamesCheck; Mark = ReadFile(&quot;c:\\IUST1.txt&quot;, out Name, out Gender); Frequent = MostFreq(Mark, out Frequency); AvgAll = Avg(Mark); MaleAvg = AvgCond(Gender, Mark, 'M'); FemaleAvg = AvgCond(Gender, Mark, 'F'); BelowAverage = BelowAvg(Mark, out AboveAverage); NamesCheck = CheckNames(Name, 'T'); Output[0] = &quot;Frequent Mark = &quot; + Frequent.ToString(); Output[1] = &quot;Frequency = &quot; + Frequency.ToString(); Output[2] = &quot;Average Of All = &quot; + AvgAll.ToString(); Output[3] = &quot;Average Of Males = &quot; + MaleAvg.ToString(); Output[4] = &quot;Average Of Females = &quot; + FemaleAvg.ToString(); Output[5] = &quot;Below Average = &quot; + BelowAverage.ToString(); Output[6] = &quot;Above Average = &quot; + AboveAverage.ToString(); Output[7] = &quot;Names With \&quot;T\&quot; = &quot; + NamesCheck.ToString(); WriteFile(&quot;d:\\output.txt&quot;, Output); } } } </code></pre>
[ { "answer_id": 400871, "author": "Gant", "author_id": 12460, "author_profile": "https://Stackoverflow.com/users/12460", "pm_score": 3, "selected": true, "text": "SW.close()" }, { "answer_id": 400899, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https:...
2008/12/30
[ "https://Stackoverflow.com/questions/400861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
400,872
<p>I'm using the following code on Windows Vista Ultimate SP1 to query our active directory server to check the user name and password of a user on a domain.</p> <pre><code>public Object IsAuthenticated() { String domainAndUsername = strDomain + "\\" + strUser; DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, strPass); SearchResult result; try { //Bind to the native AdsObject to force authentication. DirectorySearcher search = new DirectorySearcher(entry) { Filter = ("(SAMAccountName=" + strUser + ")") }; search.PropertiesToLoad.Add("givenName"); // First Name search.PropertiesToLoad.Add("sn"); // Last Name search.PropertiesToLoad.Add("cn"); // Last Name result = search.FindOne(); if (null == result) { return null; } //Update the new path to the user in the directory. _path = result.Path; _filterAttribute = (String)result.Properties["cn"][0]; } catch (Exception ex) { return new Exception("Error authenticating user. " + ex.Message); } return user; } </code></pre> <p>the target is using .NET 3.5, and compiled with VS 2008 standard</p> <p>I'm logged in under a domain account that is a domain admin where the application is running.</p> <p>The code works perfectly on windows XP; but i get the following exception when running it on Vista: </p> <pre><code>System.DirectoryServices.DirectoryServicesCOMException (0x8007052E): Logon failure: unknown user name or bad password. at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_AdsObject() at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne) at System.DirectoryServices.DirectorySearcher.FindOne() at Chain_Of_Custody.Classes.Authentication.LdapAuthentication.IsAuthenticated() at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_AdsObject() at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne) at System.DirectoryServices.DirectorySearcher.FindOne() at Chain_Of_Custody.Classes.Authentication.LdapAuthentication.IsAuthenticated() </code></pre> <p>I've tried changing the authentication types, I'm not sure what's going on.</p> <hr> <p><b>See also</b>: <a href="https://stackoverflow.com/questions/290548/c-validate-a-username-and-password-against-active-directory"><a href="https://stackoverflow.com/questions/290548/c-validate-a-username-and-password-against-active-directory">Validate a username and password against Active Directory?</a></a></p>
[ { "answer_id": 405254, "author": "Steve Evans", "author_id": 46420, "author_profile": "https://Stackoverflow.com/users/46420", "pm_score": 7, "selected": true, "text": "PrincipalContext adContext = new PrincipalContext(ContextType.Domain);\n\nusing (adContext)\n{\n return adContext.V...
2008/12/30
[ "https://Stackoverflow.com/questions/400872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33082/" ]
400,895
<p>A simple expression like</p> <pre><code>(x) - y </code></pre> <p>is interpreted differently depending on whether <code>x</code> is a type name or not. If <code>x</code> is not a type name, <code>(x) - y</code> just subtracts <code>y</code> from <code>x</code>. But if <code>x</code> is a type name, <code>(x) - y</code> computes the negative of <code>y</code> and casts the resulting value to type <code>x</code>.</p> <p>In a typical C or C++ compiler, the question of whether <code>x</code> is a type or not is answerable because the parser communicates such information to the lexer as soon as it processes a typedef or struct declaration. (I think that such required violation of levels was the nastiest part of the design of C.)</p> <p>But in Java, <code>x</code> may not be defined until later in the source code. How does a Java compiler disambiguate such an expression? </p> <p>It's clear that a Java compiler needs multiple passes, since Java doesn't require declaration-before-use. But that seems to imply that the first pass has to do a very sloppy job on parsing expressions, and then in a later pass do another, more accurate, parse of expressions. That seems wasteful.</p> <p>Is there a better way? </p>
[ { "answer_id": 400934, "author": "Michael Myers", "author_id": 13531, "author_profile": "https://Stackoverflow.com/users/13531", "pm_score": 2, "selected": false, "text": "Double y = new Double(0.1);\nSystem.out.println((Double)-y);\n operator - cannot be applied to Double, java.lang.Dou...
2008/12/30
[ "https://Stackoverflow.com/questions/400895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19725/" ]
400,900
<p>I'm trying to deserialize an array of an type unknown at compile time. At runtime I've discovered the type, but I don't know how to create an instance.</p> <p>Something like:</p> <pre><code>Object o = Activator.CreateInstance(type); </code></pre> <p>which doesn't work because there is no parameterless constructor, Array doesn't seem to have any constructor.</p>
[ { "answer_id": 400912, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 4, "selected": false, "text": "object o = Array.CreateInstance(type, 10);\n" }, { "answer_id": 34487680, "author": "Arghya C", "aut...
2008/12/30
[ "https://Stackoverflow.com/questions/400900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16260/" ]
400,909
<p>I need to be able to check what the "current" value of a variable is inside a redeclaration of that same variable in a different xslt that includes the other.</p> <p>main.xslt:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:import href="other.xslt"/&gt; &lt;xsl:variable name="email"&gt; &lt;xsl:if test="string-length($email) = 0"&gt; bar@foo.com &lt;/xsl:if&gt; &lt;/xsl:variable&gt; &lt;xsl:template match="/"&gt; &lt;Email&gt; &lt;xsl:value-of select="$email"/&gt; &lt;/Email&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>other.xslt:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:variable name="email"&gt;foo@bar.com&lt;/xsl:variable&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>What I would like to do is be able to check what the value of the lower-precedence variable will be to see if I need to overwrite it in the variable in the current xslt. (disclaimer - the current code crashes viciously) </p>
[ { "answer_id": 402383, "author": "Dimitre Novatchev", "author_id": 36305, "author_profile": "https://Stackoverflow.com/users/36305", "pm_score": 3, "selected": true, "text": "<xsl:stylesheet version=\"1.0\"\n xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n<!-- ...
2008/12/30
[ "https://Stackoverflow.com/questions/400909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34211/" ]
400,911
<p>I'm working on a web application which uses Lucene.net(version 2.0.0.4) for store search. Though my web application user can search for stores in the US which are located within 50 miles from a given location. I'm using a third party API to find all the cities within a radius.For a city say Edison,NJ, it gives me around 450 cities within 40 miles(API returns a .Net hashtable containing 450 cities). By iterating over this hashtable, am using BooleanQuery/Query classes to build lucene query.</p> <p>In this scenario,i find that it is taking a lot of time to build,execute and return the search results through lucene. Is there any way I can optimize this code??</p> <p>Thanks!</p>
[ { "answer_id": 490855, "author": "itsadok", "author_id": 7581, "author_profile": "https://Stackoverflow.com/users/7581", "pm_score": 0, "selected": false, "text": "nearyby_city nearby_city:\"Edison, NJ\"" } ]
2008/12/30
[ "https://Stackoverflow.com/questions/400911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41625/" ]
400,916
<p>Is there any way to check if a particular plugin is available?</p> <p>Imagine that you are developing a plugin that depends on another plugin being loaded.</p> <p>For example I want the jQuery Validation plugin to use the dateJS library to check if a given date is valid. What would be the best way to detect, in the jQuery Valdation plugin if the dateJS was available?</p>
[ { "answer_id": 400940, "author": "ceejayoz", "author_id": 1902010, "author_profile": "https://Stackoverflow.com/users/1902010", "pm_score": -1, "selected": false, "text": "var plugin_exists = true;\n\ntry {\n // some code that requires that plugin here\n} catch(err) {\n plugin_exists =...
2008/12/30
[ "https://Stackoverflow.com/questions/400916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1842864/" ]
400,926
<p>I have a web application that pulls a datatable and displays results. Due to the nature of the business all of the business rules are incorporated in dlls that the web app must pull from. Because there are multiple site and we don't want to include the core dll's in all of the many apps that are deployed we consolidate any calls to the core dll's into a webservice. This helps when the core dll's are updated that only one new app (i.e. the web service) needs to be pushed. </p> <p>With this architecutre I have found that anyone logging into any web app is causing multiple calls to the database in order to get a datatable that is then parsed. The datatable in question changes slowly and I only need to refresh it maybe once every 4-6 hours. </p> <p>I am familiar with storing things like this in session when a user wants to see different views of the same datatable. However with the webservice session doesn't really apply. What is a good method for caching a datatable in the webservice so that we are not making repeated expensive trips to the database. </p> <p>The webservice and the apps are all in C# and ASP.NET 2.0, and we are using VS2005.</p>
[ { "answer_id": 400967, "author": "jro", "author_id": 49888, "author_profile": "https://Stackoverflow.com/users/49888", "pm_score": 1, "selected": false, "text": "//pseudo-code\n\nclass MyWebMethods {\n\n private static DataTable localDataTable;\n static MyWebMethods() {\n localDataT...
2008/12/30
[ "https://Stackoverflow.com/questions/400926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35585/" ]
400,935
<p>I have several web pages on several different sites that I want to mirror completely. This means that I will need images, CSS, etc, and the links need to be converted. This functionality would be similar to using Firefox to "Save Page As" and selecting "Web Page, complete". I'd like to name the files and corresponding directories as something sensible (e.g. myfavpage1.html,myfavpage1.dir).</p> <p>I do not have access to the servers, and they are not my pages. Here is one sample link: <a href="http://ww13.itau.com.br/PortalRI/Iframe.aspx?strURL=/PortalRI/PrincipaisIndicadores/principaisindicadores.aspx?idioma=port" rel="nofollow noreferrer">Click Me!</a></p> <p>A little more clarification... I have about 100 pages that I want to mirror (many from slow servers), I will be cron'ing the job on Solaris 10 and dumping the results every hour to a samba mount for people to view. And, yes, I have obviously tried wget with several different flags but I haven't gotten the results for which I am looking. So, pointing to the GNU wget page is not really helpful. Let me start with where I am with a simple example. </p> <pre> wget --mirror -w 2 -p --html-extension --tries=3 -k -P stackperl.html "https://stackoverflow.com/tags/perl" </pre> <p>From this, I should see the <a href="https://stackoverflow.com/tags/perl">https://stackoverflow.com/tags/perl</a> page in the stackper.html file, if I had the flags correct.</p>
[ { "answer_id": 11514515, "author": "WisdomFusion", "author_id": 191071, "author_profile": "https://Stackoverflow.com/users/191071", "pm_score": 2, "selected": false, "text": "wget -r -p -np -k URL\n" } ]
2008/12/30
[ "https://Stackoverflow.com/questions/400935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
400,941
<p>I have written a VBA app that opens a folder in outlook and then iterates through the messages. I need to write the message bodies (with some tweaking) to a single flat file. My code is as follows...</p> <pre><code>Private Sub btnGo_Click() Dim objOutlook As New Outlook.Application Dim objNameSpace As Outlook.NameSpace Dim objInbox As MAPIFolder Dim objMail As mailItem Dim count As Integer Set objNameSpace = objOutlook.GetNamespace("MAPI") Set objInbox = objNameSpace.GetDefaultFolder(olFolderInbox) count = 0 For Each objMail In objInbox.Items lblStatus.Caption = "Count: " + CStr(count) ProcessMailItem (objMail) count = count + 1 Next objMail End If End Sub </code></pre> <p>The part in question is "ProcessMailItem". As I am not overly concerned with performance at this stage so the very inefficent "open, append, close" file methodology is fine for this example.</p> <p>I know I could spend some time looking up the answer with google but I checked here first and there was no good answers for this. Being a fan of Stackoverflow I hope that putting this up here will help future developers looking for answers. Thanks for your patience.</p>
[ { "answer_id": 400999, "author": "Eric Ness", "author_id": 18891, "author_profile": "https://Stackoverflow.com/users/18891", "pm_score": 2, "selected": false, "text": "Private Sub ProcessMailItem(objMail As MailItem)\n\n Dim fso As New FileSystemObject\n Dim ts As TextStream\n\n ...
2008/12/30
[ "https://Stackoverflow.com/questions/400941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2894/" ]
400,945
<p>First off, let’s agree that namespace should match folder structure and that each language artefact should be in its own file. </p> <p>(see <a href="https://stackoverflow.com/questions/4664/should-the-folders-in-a-solution-match-the-namespace">Should the folders in a solution match the namespace?</a> ). </p> <p>The next question is how the folders should actually be organised on disk.<br> Suppose I have ClassC in the A.B.C namespace and ClassD in the A.B.C.D namespace.<br> Let’s also assume that each namespace is built into its own assembly (project) and that namespaces have dependencies from right to left as per accepted best practice (A.B.C.D can depend on A.B.C which can depend on A.B which can depend on A). I appreciate that each namespace doesn’t have to be in a separate assembly but in the general case we will have some namespaces in separate assemblies and my example illustrates that.</p> <p>I can see (at least) two ways to create the folder tree – which I’ll call “nested folders” and “flat folders”: </p> <h2>1 - Nested folders:</h2> <p>A<br> --A.csproj<br> --B<br> ----A.B.csproj<br> ----C<br> ------A.B.C.csproj<br> ------classC.cs<br> ------D<br> --------A.B.C.D.csproj<br> --------classD.cs </p> <p>OR</p> <h2>2 – Flat folders:</h2> <p>A<br> --A.csproj<br> A.B<br> --A.B.csproj<br> A.B.C<br> --A.B.C.csproj<br> --classC.cs<br> A.B.C.D<br> --A.B.C.D.csproj<br> --classD.cs </p> <p>You will see I’ve made a few assumptions already: </p> <ul> <li>Each project file has a fully qualified name (FQN) based on the namespace.</li> <li>Each class file uses a non-FQN</li> </ul> <p>Nested folders seems more natural (we all like hierarchies), but may be a bit harder to navigate in large solutions:</p> <p>When you look at your solution in VS, it shows a flat list of projects rather than a nested view. This looks more like “flat folders” so there may be merit in organising the folders on disk to match the view in VS. </p> <p>If you look in each folder on disk you will see the folder artefacts for that project plus the sub folder for the namespace: taking C as an example: </p> <p>C<br> --bin<br> --D<br> --obj<br> --Properties<br> --A.B.C.csproj<br> --classC.cs </p> <p>Depending on D’s real name it may not be obvious that D is a namespace folder rather than an organisational folder in the C namespace.</p> <p>I know we’ve had folders and namespaces from day one in .NET (8 or 9 years ago) and Java before that, but, personally speaking, we don’t appear to have come to a consensus on best practice project organisation for large solutions. I’d be really interested to find out what you all think. </p> <p>Thanks<br> Michael</p>
[ { "answer_id": 401010, "author": "Ricardo Villamil", "author_id": 19314, "author_profile": "https://Stackoverflow.com/users/19314", "pm_score": 3, "selected": false, "text": "- DataHelpers\\\n---Factory\\\n---DataAccess\\\n---...\n- Components\\\n--- EmailProcessor\\\n--- ErrorLogger\\\n...
2008/12/30
[ "https://Stackoverflow.com/questions/400945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50241/" ]
400,951
<p>Almost all languages have a <a href="https://en.wikipedia.org/wiki/Foreach_loop" rel="noreferrer"><code>foreach</code> loop</a> or something similar. Does C have one? Can you post some example code?</p>
[ { "answer_id": 400958, "author": "Adam Peck", "author_id": 26658, "author_profile": "https://Stackoverflow.com/users/26658", "pm_score": 3, "selected": false, "text": "char* nullTerm;\nnullTerm = \"Loop through my characters\";\n\nfor(;nullTerm != NULL;nullTerm++)\n{\n //nullTerm will...
2008/12/30
[ "https://Stackoverflow.com/questions/400951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50216/" ]
400,965
<p>I would like to customize both the background and the border color of a grouped-style UITableView.</p> <p>I was able to customize the background color by using the following:</p> <pre><code>tableView.contentView.backgroundColor = [UIColor greenColor]; </code></pre> <p>But the border color is still something I don't know how to change.</p> <p>How do I customize these two aspects of the grouped-style table view?</p>
[ { "answer_id": 401271, "author": "Mike Akers", "author_id": 17188, "author_profile": "https://Stackoverflow.com/users/17188", "pm_score": 8, "selected": true, "text": "UITableViewCell backgroundColor [UIColor colorWithPatternImage:] //\n// CustomCellBackgroundView.h\n//\n// Created by ...
2008/12/30
[ "https://Stackoverflow.com/questions/400965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35478/" ]
400,968
<p>I want all buttons to perform an action before and after their normal onclick event. So I came up with the "brilliant" idea of looping through all those elements and creating a wrapper function.</p> <p>This appeared to work pretty well when I tested it, but when I integrated it into our app, it fell apart. I traced it down to the 'this' value was changed by my wrapper. The sample code illustrates this; before you wrap the event handlers, each button displays the button id when you click, but after wrapping it the displayed name is 'undefined' in this example, or 'Form1' if you run it from within a form.</p> <p>Does anybody know either a better way to do the same thing? Or a good way to maintain the originally intended 'this' values?</p> <p>As you can imagine, I don't want to modify any of the existing event handler code in the target buttons.</p> <p>Thanks in advance.</p> <p>PS-The target browser is IE6 &amp; up, crossbrowser functionality not required</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;script language="javascript" type="text/javascript"&gt; function btnWrap_onClick() { var btns = document.getElementsByTagName("button"); for( var i = 0; i &lt; btns.length; i++) { var btn = btns[i]; // handle wrap button differerntly if( "btnWrap" == btn.id) { btn.disabled = true; continue; // skip this button } // wrap it var originalEventHandler = btn.onclick; btn.onclick = function() { alert("Starting event handler"); originalEventHandler(); alert("Finished event handler"); } } alert("Buttons wrapped successfully"); } &lt;/script&gt; &lt;body&gt; &lt;p&gt; &lt;button id="TestButton1" onclick="alert(this.id);"&gt;TestButton1&lt;/button&gt; &lt;button id="TestButton2" onclick="alert(this.id);"&gt;TestButton2&lt;/button&gt; &lt;/p&gt; &lt;button id="btnWrap" onclick="btnWrap_onClick();"&gt;Wrap Event Handlers&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 400985, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 2, "selected": false, "text": "originalEventHandler.call(btn); var originalEventHandler = btn.onclick.bind(btn);" }, { "answer_id": 401669, ...
2008/12/30
[ "https://Stackoverflow.com/questions/400968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29043/" ]
400,976
<p>We have a SQL server database which, according to Microsoft SQL Server Management Studio has just 119Mb out of 6436Mb available.</p> <p>Yet the command: EXEC sp_msforeachtable 'sp_spaceused ''?'''<br> reveals a total reserved space that is less than 2Gb</p> <p>How can we find out where the rest of the space is being used?</p>
[ { "answer_id": 401062, "author": "nick_alot", "author_id": 46100, "author_profile": "https://Stackoverflow.com/users/46100", "pm_score": 2, "selected": false, "text": "CREATE TABLE #temp(\n rec_id int IDENTITY (1, 1),\n table_name varchar(128),\n nbr_of_rows int,\n data...
2008/12/30
[ "https://Stackoverflow.com/questions/400976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34685/" ]
400,989
<p>Here is my issue. I have an array containing the name of cities that I need to lookup the weather for. So I'm looping through each city and performing an AJAX request to retrieve the weather.</p> <pre><code>var LOCATION = 'http://www.google.com/ig/api?weather='; $( document ).ready( function() { for( var cityIdx = 0; cityIdx &lt; cities.length; cityIdx++ ) { $.ajax({ type: 'GET', url: LOCATION + cities[ cityIdx ], dataType: 'xml', success: function( xml ) { if( $( xml ).find( 'problem_cause' ) != 0 ) { // Do what I want with the data returned var weather = $( xml ).find( 'temp_c' ).attr( 'data' ); } } }); } }); </code></pre> <p>The issue I'm encountering is that in the success function, I can't access the city name (via cities[cityIdx]). I inserted an alert() in the for loop and the success function and it seems like the loop gets executed <em>cities.length</em> times, then I get the success function alerts. My goal is to simply loop through each city getting the weather and showing it on my page along with the associated city name.</p> <p>Also, what would you suggest I should do to separate content with presentation?</p> <p>Thank you. :)</p>
[ { "answer_id": 401022, "author": "nezroy", "author_id": 49968, "author_profile": "https://Stackoverflow.com/users/49968", "pm_score": 1, "selected": false, "text": "function city_success(xml, name) {\n // your success handling code here\n}\n success: function (xml) { city_success(xml, c...
2008/12/30
[ "https://Stackoverflow.com/questions/400989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25371/" ]
400,991
<p>In Silverlight 2 I have the following class declaration for a control:</p> <pre><code>public partial class ClassX : UserControl </code></pre> <p>I wish to replace UserControl with ClassXBase which derives from UserControl but I'm getting the reasonable error "Partial declarations of 'ClassX' must not specify different base classes"</p> <p>However, I'm unable to find the other partial class to replace its base class. Any idea where this other partial class is or how I do this?</p>
[ { "answer_id": 402657, "author": "Shawn Wildermuth", "author_id": 40125, "author_profile": "https://Stackoverflow.com/users/40125", "pm_score": 4, "selected": false, "text": "public abstract class MyBaseUserControl : UserControl\n{\n // ...\n} \n <!-- Page.xaml -->\n<my:BaseUserControl ...
2008/12/30
[ "https://Stackoverflow.com/questions/400991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
400,993
<p>I've been extensively using smart pointers (boost::shared_ptr to be exact) in my projects for the last two years. I understand and appreciate their benefits and I generally like them a lot. But the more I use them, the more I miss the deterministic behavior of C++ with regarding to memory management and RAII that I seem to like in a programming language. Smart pointers simplify the process of memory management and provide automatic garbage collection among other things, but the problem is that using automatic garbage collection in general and smart pointer specifically introduces some degree of indeterminisim in the order of (de)initializations. This indeterminism takes the control away from the programmers and, as I've come to realize lately, makes the job of designing and developing APIs, the usage of which is not completely known in advance at the time of development, annoyingly time-consuming because all usage patterns and corner cases must be well thought of.</p> <p>To elaborate more, I'm currently developing an API. Parts of this API requires certain objects to be initialized before or destroyed after other objects. Put another way, the order of (de)initialization is important at times. To give you a simple example, let's say we have a class called System. A System provides some basic functionality (logging in our example) and holds a number of Subsystems via smart pointers.</p> <pre><code>class System { public: boost::shared_ptr&lt; Subsystem &gt; GetSubsystem( unsigned int index ) { assert( index &lt; mSubsystems.size() ); return mSubsystems[ index ]; } void LogMessage( const std::string&amp; message ) { std::cout &lt;&lt; message &lt;&lt; std::endl; } private: typedef std::vector&lt; boost::shared_ptr&lt; Subsystem &gt; &gt; SubsystemList; SubsystemList mSubsystems; }; class Subsystem { public: Subsystem( System* pParentSystem ) : mpParentSystem( pParentSystem ) { } ~Subsystem() { pParentSubsystem-&gt;LogMessage( "Destroying..." ); // Destroy this subsystem: deallocate memory, release resource, etc. } /* Other stuff here */ private: System * pParentSystem; // raw pointer to avoid cycles - can also use weak_ptrs }; </code></pre> <p>As you can already tell, a Subsystem is only meaningful in the context of a System. But a Subsystem in such a design can easily outlive its parent System.</p> <pre><code>int main() { { boost::shared_ptr&lt; Subsystem &gt; pSomeSubsystem; { boost::shared_ptr&lt; System &gt; pSystem( new System ); pSomeSubsystem = pSystem-&gt;GetSubsystem( /* some index */ ); } // Our System would go out of scope and be destroyed here, but the Subsystem that pSomeSubsystem points to will not be destroyed. } // pSomeSubsystem would go out of scope here but wait a second, how are we going to log messages in Subsystem's destructor?! Its parent System is destroyed after all. BOOM! return 0; } </code></pre> <p>If we had used raw pointers to hold subsystems, we would have destroyed subsystems when our system had gone down, of course then, pSomeSubsystem would be a dangling pointer. </p> <p>Although, it's not the job of an API designer to protect the client programmers from themselves, it's a good idea to make the API easy to use correctly and hard to use incorrectly. So I'm asking you guys. What do you think? How should I alleviate this problem? How would you design such a system?</p> <p>Thanks in advance, Josh</p>
[ { "answer_id": 401019, "author": "Greg Rogers", "author_id": 5963, "author_profile": "https://Stackoverflow.com/users/5963", "pm_score": 1, "selected": false, "text": "vector<Subsystem> vector<shared_ptr<Subsystem> >" }, { "answer_id": 401092, "author": "Brian", "author_i...
2008/12/30
[ "https://Stackoverflow.com/questions/400993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50251/" ]
400,994
<p>What is the correct way to separate between <kbd>F1</kbd> and i.e. <kbd>CTRL</kbd>+<kbd>F1</kbd> respective <kbd>SHIFT</kbd>-<kbd>CTRL</kbd>+<kbd>F1</kbd> within an KeyListener registered behind i.e. a JButton?</p> <pre><code>public void keyPressed(KeyEvent event) { int key = event.getKeyCode(); logger.debug("KeyBoard pressed char(" + event.getKeyChar() + ") code (" + key + ")"); } </code></pre> <p>.. always gives me 112 for <kbd>F1</kbd>, 113 for <kbd>F2</kbd> and so on. I understand that I can handle it by taking care of the keyPressed() respective for keyReleased for <kbd>CTRL</kbd> / <kbd>SHIFT</kbd> / <kbd>ALT</kbd> / etc on my own, but I hope that there is a better way.</p> <p>Many many thanks!!!</p>
[ { "answer_id": 401205, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_profile": "https://Stackoverflow.com/users/4725", "pm_score": 1, "selected": false, "text": "KeyEvent InputMap ActionMap" } ]
2008/12/30
[ "https://Stackoverflow.com/questions/400994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33429/" ]
400,997
<p>Trying to redirect a URL on one webserver on my LAN to another webserver on my LAN. I assumed that all I needed was a .htaccess file in my /var/www directory whose contents are the following 3 lines only:</p> <p>Options +FollowSymLinks</p> <p>RewriteEngine on</p> <p>RewriteMatch newsite\.level2\.level1\.com <a href="http://192.168.0.250:8080" rel="nofollow noreferrer">http://192.168.0.250:8080</a></p> <p>Also I created a symbolic link in folder /etc/apache2/mods-enabled to /etc/apache2/mods-available/rewrite.load</p> <p>1st: When I enter "newsite.level2.level1.com" in browser I end up at "level2.level1.com" 2nd: Does RewriteMatch support ports appended to the new URL</p> <p>Should mention that level2.level1.com is thru DynDns.org as I have Comcast and the function to allow *.level2.level1.com is enabled</p> <p>Thanks for looking, Rich</p>
[ { "answer_id": 402271, "author": "genehack", "author_id": 39933, "author_profile": "https://Stackoverflow.com/users/39933", "pm_score": 1, "selected": false, "text": "<VirtualHost> RewriteEngine On\n RewriteMatch .* http://192.168.0.250:8080/\n" }, { "answer_id": 404382, "...
2008/12/30
[ "https://Stackoverflow.com/questions/400997", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
401,024
<p>Short of inserting a try/catch block in each worker thread method, is there a way to deal with unhandled, non-ui thread, exceptions in Windows Forms?</p> <p><code>Thread.GetDomain().UnhandledException</code> works great for catching the error, but by then it's too late to do anything about it (besides log it). After control passes out of your <code>UnhandledException</code> handler the application will terminate. The best you can hope for is a generic Windows error that looks this:</p> <p><img src="https://i.stack.imgur.com/8kxgl.jpg" alt="http://i40.tinypic.com/2be98i.jpg"></p> <p>All my research indicates that you <em>must</em> insert a try/catch block in the worker thread method, but I wanted to put this out there in case anyone had a different take.</p> <p>Thanks.</p>
[ { "answer_id": 401394, "author": "Craigger", "author_id": 18924, "author_profile": "https://Stackoverflow.com/users/18924", "pm_score": 0, "selected": false, "text": "try\n{\n // run this code\n\n}\ncatch (Exception ex)\n{\n // an exception happened in the above try statement inside MY...
2008/12/30
[ "https://Stackoverflow.com/questions/401024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20700/" ]
401,025
<p>Assume I have a form</p> <pre><code>class SampleClass(forms.Form): name = forms.CharField(max_length=30) age = forms.IntegerField() django_hacker = forms.BooleanField(required=False) </code></pre> <p>Is there a way for me to define css classes on each field such that I can then use jQuery based on class in my rendered page?</p> <p>I was hoping not to have to manually build the form.</p>
[ { "answer_id": 401057, "author": "ashchristopher", "author_id": 22306, "author_profile": "https://Stackoverflow.com/users/22306", "pm_score": 6, "selected": false, "text": "def __init__(self, *args, **kwargs):\n super(SampleClass, self).__init__(*args, **kwargs)\n self.fields['name...
2008/12/30
[ "https://Stackoverflow.com/questions/401025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22306/" ]
401,040
<p>I have a sublayer on a layer-backed view. The sublayer's contents are set to an Image Ref and is a 25x25 rect.<br> I perform a hit test on the super layer when the touchesBegan and touchesMoved methods are invoked. The hit test method does, in fact, return the sublayer if it is touched, BUT only if the bottom half of the image is touched. If the top half of the image is touched, it returns the superlayer instead.</p> <p>I do know the iPhone OS compensates for the tendancy of user touches to be lower than intended. Even if I resize the sublayer to a larger size, 50x50, it exhibits the same behavior.</p> <p>Any thoughts? </p>
[ { "answer_id": 412018, "author": "Corey Floyd", "author_id": 48311, "author_profile": "https://Stackoverflow.com/users/48311", "pm_score": 1, "selected": false, "text": "#import \"myView.h\"\n#import <QuartzCore/QuartzCore.h>\n\n\n@implementation myView\n\n\n- (void)touchesBegan:(NSSet *...
2008/12/30
[ "https://Stackoverflow.com/questions/401040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48311/" ]
401,051
<p>I'm thinking about making repeated calls (spinning) to QueryPerformanceCounter in two threads that will be active at the same time. I'm not sure if this is really an issue as I've not seen anything written about it but is QueryPerformanceCounter thread safe?</p> <p>Thanks</p>
[ { "answer_id": 412018, "author": "Corey Floyd", "author_id": 48311, "author_profile": "https://Stackoverflow.com/users/48311", "pm_score": 1, "selected": false, "text": "#import \"myView.h\"\n#import <QuartzCore/QuartzCore.h>\n\n\n@implementation myView\n\n\n- (void)touchesBegan:(NSSet *...
2008/12/30
[ "https://Stackoverflow.com/questions/401051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
401,056
<p>Preface: I have jQuery and jQuery UI included on a page.</p> <p>I have this function defined:</p> <pre><code> function swap(sel) { if (1 == 1) { $(sel).hide('drop',{direction:'left'}); } } </code></pre> <p>How do I fix the (1 == 1) part to test to see if the element is already hidden and then bring it back if it is. I'm sure this is easy, but I'm new to jQuery.</p>
[ { "answer_id": 401063, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 2, "selected": false, "text": "function swap(sel) {\n $(sel).toggle();\n} \n" }, { "answer_id": 401064, "author": "Andrew Hare", ...
2008/12/30
[ "https://Stackoverflow.com/questions/401056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36590/" ]
401,060
<p>Could someone point me to a list of controls that implement <code>IPostBackDataHandler</code>?</p> <p>I want to know what controls implement this interface and what properties the controls will set during the <code>Postback</code>.</p> <p>For example:</p> <blockquote> <p>Textbox : Text</p> <p>DropDownList : SelectedIndex</p> </blockquote> <p>I'm basically looking for a list of properties that will not be saved in <code>ViewState</code>.</p> <p>Thanks!</p>
[ { "answer_id": 401193, "author": "TheZenker", "author_id": 10552, "author_profile": "https://Stackoverflow.com/users/10552", "pm_score": 1, "selected": false, "text": "IPostBackDataHandler" } ]
2008/12/30
[ "https://Stackoverflow.com/questions/401060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8797/" ]
401,075
<p>I've come up with the call that gets the user's UI font preference (as opposed to Borland's hard-coded choice of "MS Sans Serif").</p> <p>Let's pretend the user's font preference is:</p> <pre><code>Segoe Print, 15pt </code></pre> <p>I set the font of all items, on all forms, in all applications to:</p> <pre><code>Segoe Print, 15pt </code></pre> <p>Problem is that things are now cut off. Buttons are too small - too narrow, too short. Text in labels is cut off, etc..</p> <p>The form has it's Scaled property, but that doesn't change depending on font sizes. The scaled property scaled the form when it is serialized in based on the height of the numeral "0".</p> <p>I can't find anything in the help for how Borland intended me to support the user's Windows application preferences.</p> <p>How do I handle user font preferences? </p> <p><strong>Note:</strong> I cross posted this from Embargadero's news group server, since Embargadero's news server seems to be dying, or censoring, or broken, or requiring a login.</p> <hr> <h2>Update 1</h2> <p>i'm talking about a user's font preference, not DPI settings. i.e.: imagine the following <strong>language neutral</strong> pseudo-code:</p> <pre><code>procedure TForm1.FormCreate(Sender: TObject); var FontFace: string; FontHeight: Integer; begin GetUserFontPreference(out FontFace, out FontHeight); Self.Font.Name := FontFace; Self.Font.Height := FontHeight; end; </code></pre> <p><strong>Note:</strong> This isn't my actual code (it is language neutral pseudo-code after all). But additionally, you need to recursivly go through every control on the form, changing the font when it needs to be changed. When a font has a different style applied than its parent (e.g. bold), and no longer inherits from its parent, it needs to be manually set.</p> <hr> <p>As per <a href="https://stackoverflow.com/users/30176/lkessler">lkessler</a>'s request, here's the code to retrieve the user's UI font preference from Windows:</p> <pre><code>procedure GetUserFontPreference(out FaceName: string; out PixelHeight: Integer); var lf: LOGFONT; begin ZeroMemory(@lf, SizeOf(lf)); //Yes IconTitleFont (not SPI_GETNONCLIENTMETRICS MessageFont) if SystemParametersInfo(SPI_GETICONTITLELOGFONT, SizeOf(lf), @lf, 0) then begin FaceName := PChar(Addr(lf.lfFaceName[0])); PixelHeight := lf.lfHeight; end else begin { If we can't get it, then assume the same non-user preferences that everyone else does. } FaceName := 'MS Shell Dlg 2'; PixelHeight := 8; end; end; </code></pre> <h2>Related questions</h2> <ul> <li><a href="https://stackoverflow.com/questions/196606/-net-2-0-winform-supporting-dpi-and-default-font-changes">.NET 2.0 WinForm: Supporting DPI and Default Font Changes</a></li> <li><a href="https://stackoverflow.com/questions/203577/-net-winforms-graphics-measurestring-returns-different-values-than-win32-gettext">.NET WinForms: Graphics.MeasureString returns different values than Win32 GetTextExtent</a></li> <li><a href="https://stackoverflow.com/questions/395195/wpf-how-to-layout-a-dialogs-in-xaml">WPF: How to layout a dialogs in XAML?</a></li> </ul>
[ { "answer_id": 448574, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "procedure SystemFont(Font: TFont);\nvar\n LogFont: TLogFont;\nbegin\n if SystemParametersInfo(SPI_GETICONTITLELOGFONT, SizeO...
2008/12/30
[ "https://Stackoverflow.com/questions/401075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
401,079
<p>I have a stored procedure in Oracle that returns a select statement cursor reference. I want to be able to pass column names and sort direction (example: 'CompanyName DESC') and be able to sort the results, or pass a filter such as 'CompanyID > 400' and be able to apply that to the select statement. what is the best way to accomplish this? This table is in an old database and has 90 columns, and I don't want to do logic for every possible combination. </p>
[ { "answer_id": 401225, "author": "Powerlord", "author_id": 15880, "author_profile": "https://Stackoverflow.com/users/15880", "pm_score": 3, "selected": true, "text": "OPEN-FOR USING CREATE OR REPLACE FUNCTION sort_table (\n p_sort VARCHAR2\n )\nIS\n TYPE cursor_type IS REF_CURSO...
2008/12/30
[ "https://Stackoverflow.com/questions/401079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18893/" ]
401,084
<p>I very often open a console window while doing my development. Usually <kbd>Win</kbd>+<kbd>R</kbd> -> cmd -> enter. However, Windows also lets you add a shortcut key to any shortcut ... but when I try to add <kbd>Win</kbd> + <kbd>C</kbd> to make the shortcut for my favorite-sized/shaped/buffered console appear, it uses <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>C</kbd> instead (already used in various editors and other apps...no go.)</p> <p>Is there any way to use the windows key as part of a shortcut key combo?</p> <p><em>(This would be with Windows XP)</em></p>
[ { "answer_id": 401159, "author": "BMK Media", "author_id": 50271, "author_profile": "https://Stackoverflow.com/users/50271", "pm_score": 1, "selected": false, "text": "___________\nDESCRIPTION:\n\nKana SendKey is a command line program which can be used\nto send a system wide hotkey.\n\n...
2008/12/30
[ "https://Stackoverflow.com/questions/401084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18097/" ]
401,090
<p>I've always been one to err on the side of preventing exception conditions by never taking an action unless I am certain that there will be no errors. I learned to program in C and this was the only way to really do things.</p> <p>Working with C# I frequently see more reactive programing - try to do something and handle exceptions. To me this seems like using exceptions as control statements. The first few times I saw this I dismissed it as bad practice. But over the past few months I've seen it all over the place and just have to wonder - is this accepted/efficient or just an epidemic?</p> <p>Update: For a bit of clarification most of the exception handling I am seeing is things like</p> <pre><code>try { //open file } catch { //message box for file not found } </code></pre> <p>or even worse</p> <pre><code>try { //open xml //modify xml (100+ lines of code) } catch { //message for 'unspecified error' } </code></pre> <p>I understand there are times when exception handling is very good to use (such as database connections) but I'm referring to the use of exceptions in place of more 'traditional' control. I asked this because I felt like this programming style was using exceptions as a crutch instead of as a recovery method and wanted to know if this was just something I'd have to learn to expect in the C# world.</p>
[ { "answer_id": 401291, "author": "JasonTrue", "author_id": 13433, "author_profile": "https://Stackoverflow.com/users/13433", "pm_score": 3, "selected": false, "text": "try\n{\n // do something that could throw\n // ...\n}\ncatch {} //swallow the exception\n catch { return null; }\n...
2008/12/30
[ "https://Stackoverflow.com/questions/401090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40284/" ]
401,114
<p>Right now I have a JSP page that allows to sort some items, when is ready and a link is clicked a JavaScript function converts all the info into XML (text in a variable), after this i need to send this XML to the JSP page again, i tried putting the info in a hidden input and submitting the form, sending with $.post and a few more jQuery functions but nothing worked. Any ideas?</p> <p>In my JSP I'm reading the post like this:</p> <pre><code>&lt;% out.println(request.getParameter("data")); %&gt; </code></pre> <p>This doesn't work:</p> <pre><code>xml = "&lt;xml&gt;&lt;/xml&gt;"; $("#form").submit(function(){ alert("JS: " + $("#data").text()); $("#data").text(xml); }); </code></pre> <p>This either:</p> <pre><code>xml = "&lt;xml&gt;&lt;/xml&gt;"; $("#data").text(xml); $("#form").submit(); </code></pre> <p>And replacing .text with .html doesn't work too. Any ideas are welcome, thx</p>
[ { "answer_id": 401595, "author": "inkredibl", "author_id": 22129, "author_profile": "https://Stackoverflow.com/users/22129", "pm_score": 3, "selected": true, "text": "<form method=\"POST\" id=\"form\">\n <input type=\"hidden\" id=\"data\" />\n</form>\n $(\"#data\").val(xml); text() ht...
2008/12/30
[ "https://Stackoverflow.com/questions/401114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43304/" ]
401,118
<p>I'm using Django to write a blog app, and I'm trying to implement a hierarchical category structure. Each category has a "parent" ForeignKey pointing back to the same Category model. I want to allow admins to add categories, and I want the interface to allow them to select a category's parent category. However, I want to avoid I'm-my-own-grandpa situations, so I want to limit the available choices of categories to those which do not have category in question as an ancestor.</p> <p>Right now, I'm controlling this from the view:</p> <pre><code>parent_candidates = list(Category.objects.all()) pruned_parent_list = [cat for cat in parent_candidates if instance.id not in cat.getHierarchy()] </code></pre> <p>where instance is the category being edited and getHierarchy() is a method to get a list of ancestor ids.</p> <p>There are a number of problems with this approach. In particular, it uses an extra database hit to get the list of all categories and it makes me write the selection mechanism into my template by looping through pruned_parent_list to get the options, when I'd really rather just specify a widget.</p> <p>Is there any better way to do this? I know I can add custom validation on the back-end to prevent this, but why give users the option?</p>
[ { "answer_id": 401256, "author": "David", "author_id": 49460, "author_profile": "https://Stackoverflow.com/users/49460", "pm_score": 1, "selected": true, "text": "parents = Category.objects.filter(parent_id=0)\n" }, { "answer_id": 402530, "author": "Gnudiff", "author_id":...
2008/12/30
[ "https://Stackoverflow.com/questions/401118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50272/" ]
401,135
<p>Is there a difference between "GO" and "BEGIN...END" in SQL Scripts/Stored Procedures? More specifically, does BEGIN...END specify batches just as GO does?</p>
[ { "answer_id": 401169, "author": "Eduardo Molteni", "author_id": 2385, "author_profile": "https://Stackoverflow.com/users/2385", "pm_score": 2, "selected": false, "text": "IF x\nBEGIN \n -- do y\n -- do w\nEND\n" } ]
2008/12/30
[ "https://Stackoverflow.com/questions/401135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47645/" ]
401,174
<p>Here's a simple syntax question (I hope), I know how to constrain one generic type using the where clause, but how to constrain two generic types?</p> <p>Maybe the easiest way is to write down what my best guess as to the syntax was.</p> <pre><code>public class GenericDaoGetByIdTests&lt;TDao, TComponent&gt; : BaseDaoTests where TDao : IDao&lt;TComponent&gt;, TComponent : EDC2ORMComponent { public void GetByIdTest(int id) { } } </code></pre> <p>This gives me an error. Anyone know what the proper syntax is?</p>
[ { "answer_id": 401190, "author": "ChrisW", "author_id": 49942, "author_profile": "https://Stackoverflow.com/users/49942", "pm_score": 6, "selected": true, "text": "public interface IParentNodeT<TChild, TSelf>\n where TChild : IChildNodeT<TSelf, TChild>, INodeT<TChild>\n where TSelf...
2008/12/30
[ "https://Stackoverflow.com/questions/401174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
401,178
<p>I want to split up the jQuery .js file into two, but I have noticed some of the features arent working when I split it up. Is it because I have two external scripts that start with:</p> <p>$(document).ready(function(){</p> <p>Is that not possible?</p>
[ { "answer_id": 401185, "author": "Ryan Morlok", "author_id": 1613178, "author_profile": "https://Stackoverflow.com/users/1613178", "pm_score": 3, "selected": true, "text": "$(document).ready(...)." } ]
2008/12/30
[ "https://Stackoverflow.com/questions/401178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28454/" ]
401,183
<p>I want to create a header file for C, C++ which is specific to help in randomization.</p>
[ { "answer_id": 401216, "author": "ChrisW", "author_id": 49942, "author_profile": "https://Stackoverflow.com/users/49942", "pm_score": 1, "selected": false, "text": "#include <stdlib.h> /* required for rand() and srand() */\n" }, { "answer_id": 401222, "author": "luiscubal", ...
2008/12/30
[ "https://Stackoverflow.com/questions/401183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20730/" ]
401,184
<p>What's the best method for handling a situation where you have an ASP.Net Dropdownlist that is used to link to another URL</p> <p><em>edited for clarity</em></p> <p>Here's the basic scenario:</p> <p>Dropdownlist with 5 cities bound to it</p> <p>Selecting one of the cities should send me to a URL based on the city</p> <p>Right now I am posting back using the "OnSelectedIndexChanged" event then handling the event and redirecting to the appropriate page.</p> <p>However this is causing 2 hits to the server per city selected, 1 to handle the postback and redirect, then another to render the actual page.</p> <p>Is using custom javascript to construct a URL my best option?</p>
[ { "answer_id": 401263, "author": "Robert C. Barth", "author_id": 9209, "author_profile": "https://Stackoverflow.com/users/9209", "pm_score": 2, "selected": false, "text": "window.navigate(this.options[this.selectedIndex].value);\n" }, { "answer_id": 401274, "author": "M4N", ...
2008/12/30
[ "https://Stackoverflow.com/questions/401184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32806/" ]
401,188
<p>How did you get rid of these annoying ASP.NET errors: Could not load file or assembly 'App_Web_z9w33txs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'</p> <p>This has only happened to me once before. It seems like it is related to ASP.NET caching some assembly dynamically, but not recompiling it for some reason. Thoughts? How do you fix this? What causes it?</p> <p><strong>More Info:</strong> This is happening to a WCF Service being called via Ajax from my Default.aspx page. The Default.aspx page loads fine.</p> <p><strong>removed stack trace</strong></p> <p><strong>Final Update:</strong><br> So this is happening to me at least 5 times a day now. I have to shutdown the app pool.<br> Go into C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files and deleted the files here Then restart the app pool. Anybody else run into something like this? Should I just break down and create a support case with Microsoft.</p>
[ { "answer_id": 401268, "author": "Gordon Bell", "author_id": 16473, "author_profile": "https://Stackoverflow.com/users/16473", "pm_score": 2, "selected": false, "text": "rd \"%TEMP%\\Temporary ASP.NET Files\\.\" /s /q\n gci \"$env:TEMP\\Temporary ASP.NET Files\" | % {ri $_.FullName -recu...
2008/12/30
[ "https://Stackoverflow.com/questions/401188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36590/" ]
401,191
<p>My design exposes two kinds of resources:</p> <ol> <li>Images</li> <li>Tags</li> </ol> <p>I would like clients to be able to request random images by their tag(s). For example: Give me random images that are tagged with "New York" and "Winter". What would a RESTful design look like in this case?</p>
[ { "answer_id": 401229, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 2, "selected": false, "text": "http://www.example.com/MyStuff/image/ / http://www.example.com/MyStuff/image/?tag= count=1 http://www.example.com/MyStuff/i...
2008/12/30
[ "https://Stackoverflow.com/questions/401191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14731/" ]
401,215
<p>I'm working on a Python library that interfaces with a web service API. Like many web services I've encountered, this one requests limiting the rate of requests. I would like to provide an optional parameter, <code>limit</code>, to the class instantiation that, if provided, will hold outgoing requests until the number of seconds specified passes.</p> <p>I understand that the general scenario is the following: an instance of the class makes a request via a method. When it does, the method emits some signal that sets a lock variable somewhere, and begins a countdown timer for the number of seconds in <code>limit</code>. (In all likelihood, the lock is the countdown timer itself.) If another request is made within this time frame, it must be queued until the countdown timer reaches zero and the lock is disengaged; at this point, the oldest request on the queue is sent, and the countdown timer is reset and the lock is re-engaged.</p> <p>Is this a case for threading? Is there another approach I'm not seeing?</p> <p>Should the countdown timer and lock be instance variables, or should they belong to the class, such that all instances of the class hold requests?</p> <p>Also, is this generally a bad idea to provide rate-limiting functionality within a library? I reason since, by default, the countdown is zero seconds, the library still allows developers to use the library and provide their own rate-limiting schemes. Given any developers using the service will need to rate-limit requests anyway, however, I figure that it would be a convenience for the library to provide a means of rate-limiting.</p> <p>Regardless of placing a rate-limiting scheme in the library or not, I'll want to write an application using the library, so suggested techniques will come in handy.</p>
[ { "answer_id": 401390, "author": "Brian", "author_id": 18192, "author_profile": "https://Stackoverflow.com/users/18192", "pm_score": 2, "selected": false, "text": "delay - Now + lastcalltime delay" }, { "answer_id": 401826, "author": "Community", "author_id": -1, "aut...
2008/12/30
[ "https://Stackoverflow.com/questions/401215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38140/" ]
401,231
<p>I have a set of data protected by 16bit checksums that I need to correct. The checksum locations are known, the exact areas they are calculated on and the exact algorithm used to calculate them are not. 16bit, LSB first. I suspect it's some sort of 16bit CRC, but I have not been able to find the code that's actually calculating the checksums. </p> <p>Example:</p> <pre><code>00 4E00FFFF26EC14091E00A01830393630 10 30313131313030393030363030313030 20 30303131313030393030363030313030 30 30303131313030393030363030313030 40 3030FFFF225E363436304D313037**0CE0** 50 64000000000000008080808080800000 60 00000000**BE6E**FC01E001EB0013010500 </code></pre> <p>Checksums are stored at 4E and 64. I don't know if they are calcuated starting from the offset in the first word at the beginning of each data section or starting after that, or on the whole range. I have tried a number of common CRC algorithms and polynomials with no luck. There are no references or specifications available for this application. </p> <p>Here is another data section with different CRCs for comparison's sake. </p> <pre><code>00 4E00FFFF26C014091600A01030393132 10 30313131313030393030313230313030 20 30303131313030393030313230313030 30 30303131313030393030313230313030 40 3030FFFF225E343231324F313044**8348** 50 64000000000000008080808080800000 60 00000000**72F8**E001EB00130105000E01 </code></pre> <p>My question is, can anyone identify the algorithm? Is there any way to calculate the CRC polynomial and other factors from the data and the CRC? </p> <p>Thanks!</p> <p>Edit: </p> <p>A search of my disassembly for the common CRC16 polynomial 0xA001 revealed this function:</p> <pre><code>34F86 ; =============== S U B R O U T I N E ======================================= 34F86 34F86 34F86 Possible_Checksum: ; CODE XREF: MEM_EXT_4:00034FEEP 34F86 ; MEM_EXT_4:0003503AP ... 34F86 mov [-r0], r9 ; Move Word 34F88 mov r4, r12 ; Move Word 34F8A mov r5, r13 ; Move Word 34F8C shr r4, #14 ; Shift Right 34F8E shl r5, #2 ; Shift Left 34F90 or r5, r4 ; Logical OR 34F92 mov r4, r12 ; Move Word 34F94 mov DPP0, r5 ; Move Word 34F98 and r4, #3FFFh ; Logical AND 34F9C movb rl3, [r4] ; Move Byte 34F9E mov DPP0, #4 ; Move Word 34FA2 movbz r9, rl3 ; Move Byte Zero Extend 34FA4 mov r15, #0 ; Move Word 34FA6 34FA6 loc_34FA6: ; CODE XREF: MEM_EXT_4:00034FC8j 34FA6 mov r4, [r14] ; Move Word 34FA8 xor r4, r9 ; Logical Exclusive OR 34FAA and r4, #1 ; Logical AND 34FAC jmpr cc_Z, loc_34FBA ; Relative Conditional Jump 34FAE mov r4, [r14] ; Move Word 34FB0 shr r4, #1 ; Shift Right 34FB2 xor r4, #0A001h ; Logical Exclusive OR 34FB6 mov [r14], r4 ; Move Word 34FB8 jmpr cc_UC, loc_34FC0 ; Relative Conditional Jump 34FBA ; --------------------------------------------------------------------------- 34FBA 34FBA loc_34FBA: ; CODE XREF: MEM_EXT_4:00034FACj 34FBA mov r4, [r14] ; Move Word 34FBC shr r4, #1 ; Shift Right 34FBE mov [r14], r4 ; Move Word 34FC0 34FC0 loc_34FC0: </code></pre>
[ { "answer_id": 401607, "author": "Judge Maygarden", "author_id": 1491, "author_profile": "https://Stackoverflow.com/users/1491", "pm_score": 3, "selected": true, "text": "unsigned short\ncrc16_update(unsigned short crc, unsigned char nextByte)\n{\n crc ^= nextByte;\n\n for (int i =...
2008/12/30
[ "https://Stackoverflow.com/questions/401231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50259/" ]
401,232
<p>Why are static indexers disallowed in C#? I see no reason why they should not be allowed and furthermore they could be very useful.</p> <p>For example:</p> <pre><code>public static class ConfigurationManager { public object this[string name] { get =&gt; ConfigurationManager.getProperty(name); set =&gt; ConfigurationManager.editProperty(name, value); } /// &lt;summary&gt; /// This will write the value to the property. Will overwrite if the property is already there /// &lt;/summary&gt; /// &lt;param name="name"&gt;Name of the property&lt;/param&gt; /// &lt;param name="value"&gt;Value to be wrote (calls ToString)&lt;/param&gt; public static void editProperty(string name, object value) { var ds = new DataSet(); var configFile = new FileStream("./config.xml", FileMode.OpenOrCreate); ds.ReadXml(configFile); if (ds.Tables["config"] == null) ds.Tables.Add("config"); var config = ds.Tables["config"]; if (config.Rows[0] == null) config.Rows.Add(config.NewRow()); if (config.Columns[name] == null) config.Columns.Add(name); config.Rows[0][name] = value.ToString(); ds.WriteXml(configFile); configFile.Close(); } public static void addProperty(string name, object value) =&gt; ConfigurationManager.editProperty(name, value); public static object getProperty(string name) { var ds = new DataSet(); var configFile = new FileStream("./config.xml", FileMode.OpenOrCreate); ds.ReadXml(configFile); configFile.Close(); if (ds.Tables["config"] == null) return null; var config = ds.Tables["config"]; if (config.Rows[0] == null) return null; if (config.Columns[name] == null) return null; return config.Rows[0][name]; } } </code></pre> <p>The above code would benefit greatly from a static indexer. However it won't compile because static indexers are not allowed. Why is this so?</p>
[ { "answer_id": 401255, "author": "ChrisW", "author_id": 49942, "author_profile": "https://Stackoverflow.com/users/49942", "pm_score": 3, "selected": false, "text": "class ConfigurationManager\n{\n //private constructor\n ConfigurationManager() {}\n //singleton instance\n public stati...
2008/12/30
[ "https://Stackoverflow.com/questions/401232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12243/" ]
401,234
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/1160/use-svn-revision-to-label-build-in-ccnet">Use SVN Revision to label build in CCNET</a> </p> </blockquote> <p>I'm working through the process of installing CruiseControl.net and converting an Msbuild script to work with it. I'd like our build number to reflect the Subversion revision number. It appears as though the LastChangeLabeller should work, but all I get is "unknown".</p> <p>My ultimate goal is to format the build number with both a build number (incrementing by 1) and the subversion revision. But for now I'd settle for the revision number.</p> <p><strong>Clarification:</strong> I'm trying to get the CruiseControl.Net build number updated. Not just the version numbers in the compiled results.</p>
[ { "answer_id": 401253, "author": "rmeador", "author_id": 10861, "author_profile": "https://Stackoverflow.com/users/10861", "pm_score": 0, "selected": false, "text": "make" } ]
2008/12/30
[ "https://Stackoverflow.com/questions/401234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1752/" ]
401,240
<p>I'm working on a Cocoa Mac app where I need to display a window/view on a secondary monitor, full-screen.</p> <p>I know how to create a window that could be dragged onto the secondary monitor, but I was wanting to programmatically create the window and make it full screen on the external monitor.</p>
[ { "answer_id": 401409, "author": "sbooth", "author_id": 31520, "author_profile": "https://Stackoverflow.com/users/31520", "pm_score": 5, "selected": true, "text": "[NSScreen screens] NSScreen *screen = /* from [NSScreen screens] */\nNSRect screenRect = [screen frame];\nNSWindow *window =...
2008/12/30
[ "https://Stackoverflow.com/questions/401240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32854/" ]
401,241
<p>I am new to Ruby on Rails, I have completed the <a href="http://guides.rubyonrails.org/getting_started_with_rails.html" rel="noreferrer">Blog Tutorial</a>.</p> <p>I am now trying to add an additional action to the controller, called 'start'.</p> <pre><code>def start end </code></pre> <p>I have added a view page "app/views/posts/start.html.erb" containing nothing but simple html.</p> <p>When I go to /posts/start i get the following error.</p> <pre><code>ActiveRecord::RecordNotFound in PostsController#show Couldn't find Post with ID=start </code></pre> <p>I understand the error, the show action is being executed and start is not a valid ID. Why doesn't the start action get executed, is there some part of the MVC architecture or configuration I am missing ?</p> <p>Below is my posts_controller.rb</p> <pre><code>class PostsController &lt; ApplicationController # GET /posts/start def start end # GET /posts # GET /posts.xml def index @posts = Post.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml =&gt; @posts } end end # GET /posts/1 # GET /posts/1.xml def show @post = Post.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml =&gt; @post } end end end </code></pre> <p>Yes I have restarted the server and tried it with Mongrel and webrick.</p>
[ { "answer_id": 401335, "author": "zenazn", "author_id": 46848, "author_profile": "https://Stackoverflow.com/users/46848", "pm_score": 6, "selected": true, "text": "map.resources :posts map.connect \"posts/:action\", :controller => 'posts', :action => /[a-z]+/i\n :action" }, { "an...
2008/12/30
[ "https://Stackoverflow.com/questions/401241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50262/" ]
401,277
<p>In Django, I've got loggers all over the place, currently with hard-coded names.</p> <p>For module-level logging (i.e., in a module of view functions) I have the urge to do this.</p> <pre><code>log = logging.getLogger(__name__) </code></pre> <p>For class-level logging (i.e., in a class <code>__init__</code> method) I have the urge to do this.</p> <pre><code>self.log = logging.getLogger("%s.%s" % ( self.__module__, self.__class__.__name__)) </code></pre> <p>I'm looking for second opinions before I tackle several dozen occurrences of <code>getLogger("hard.coded.name")</code>.</p> <p>Will this work? Anyone else naming their loggers with the same unimaginative ways? </p> <p>Further, should I break down and write a class decorator for this log definition?</p>
[ { "answer_id": 401352, "author": "Steve Losh", "author_id": 13498, "author_profile": "https://Stackoverflow.com/users/13498", "pm_score": 2, "selected": false, "text": "self __module__ self.log = logging.getLogger( \"%s.%s\" % ( self.__class__.__module__, self.__class__.__name__ ) )\n" ...
2008/12/30
[ "https://Stackoverflow.com/questions/401277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10661/" ]
401,284
<p>I've been working on a ASP.NET project that is going to save uploaded files to a network share. I figured I could just use a virtual directory and be fine, but I have been struggling with permissions for Directory.CreateDirectory.</p> <p>I was able to upload files so I decided to change my code to place everything in a single directory, however this requires me to make use of File.Exists to avoid overwriting duplicates.</p> <p>Now that I have all my code updated, I have discovered that no matter what I do, File.Exists always returns false (The file definitely exists) when I test against the network share.</p> <p>Any ideas? I'm coming to the very end of my rope with network shares.</p>
[ { "answer_id": 401325, "author": "Abram Simon", "author_id": 46204, "author_profile": "https://Stackoverflow.com/users/46204", "pm_score": 4, "selected": true, "text": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Runtime.InteropSer...
2008/12/30
[ "https://Stackoverflow.com/questions/401284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10420/" ]
401,303
<p>I'm having an issue with the 3.1 version of the logging application block...</p> <p>With 3.5 framework my application works fine on my desktop... once it's deployed out to our qa box... the logging ceases to function. The web.config is identical in both scenarios. Any ideas? Permissions issue?</p> <p>After a quick diagnosis... turns out it works while compiled in debug mode but not release... any one know of a setting to change to get this to work in release mode?</p>
[ { "answer_id": 413968, "author": "Charlie Salts", "author_id": 37971, "author_profile": "https://Stackoverflow.com/users/37971", "pm_score": 1, "selected": false, "text": "System.Diagnostics.Debug.Assert(conditionToTest, \"Message when assert fails\");\n" } ]
2008/12/30
[ "https://Stackoverflow.com/questions/401303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38734/" ]
401,304
<p>My path is <code>\\server\folderName1\another name\something\another folder\</code></p> <p>How do I extract each folder name into a string if I don't know how many folders there are in the path and I don't know the folder names?</p> <p>Many thanks</p>
[ { "answer_id": 401323, "author": "Matt Brunell", "author_id": 24970, "author_profile": "https://Stackoverflow.com/users/24970", "pm_score": 7, "selected": false, "text": "string mypath = @\"..\\folder1\\folder2\\folder2\";\nstring[] directories = mypath.Split(Path.DirectorySeparatorChar)...
2008/12/30
[ "https://Stackoverflow.com/questions/401304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
401,305
<p>I have a user control that behaves similar to a tab control. The tab headers are <code>UserControl</code> instances that override <code>Paint</code> events to make them look custom.</p> <p>In order to leverage the Validating events on various controls on our tab pages, when the user clicks on the tab headers, we set the Focus to the <code>TabHeader</code> user control.</p> <p>I've noticed that <code>Control.Focus()</code> returns false sometimes but the documentation does not say why <code>Control.Focus()</code> will ever return false other than that the control can't receive focus. But I don't know why.</p> <p>Here's what I see: If my <code>TabHeader</code> <code>UserControl</code> does not contain any sub-controls, and I call <code>myControl.Focus()</code> from the <code>MouseClick</code> event, focus returns true.</p> <p>If my <code>TabHeader</code> <code>UserControl</code> contains a sub-control and I call <code>myControl.Focus()</code> from the <code>MouseClick</code> event, focus returns false.</p> <p>If my <code>TabHeader</code> <code>UserControl</code> contains a sub-control, and I call <code>myControl.subControl.Focus()</code> from the <code>myControl.MouseClick</code> event, focus returns true.</p> <p>Can someone explain this?</p>
[ { "answer_id": 650878, "author": "Razzie", "author_id": 38889, "author_profile": "https://Stackoverflow.com/users/38889", "pm_score": 3, "selected": false, "text": "Focus() UserControl Select() Focus()" } ]
2008/12/30
[ "https://Stackoverflow.com/questions/401305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18924/" ]
401,306
<p>Is there any way to access the <code>&lt;compilation /&gt;</code> tag in a web.config file?</p> <p>I want to check if the "<em>debug</em>" attribute is set to "<em>true</em>" in the file, but I can't seem to figure out how to do it. I've tried using the <code>WebConfigurationManager</code>, but that doesn't seem to allow me to get to the <code>&lt;compilation /&gt;</code> section.</p> <p><strong>Update:</strong></p> <p>I know I could easily just load the file like an XML Document and use XPath, but I was hoping there was already something in the framework that would do this for me. It seems like there would be something since there are already ways to get App Settings and Connection Strings.</p> <p>I've also tried using the <code>WebConfigurationManager.GetSection()</code> method in a few ways: </p> <pre><code>WebConfigurationManager.GetSection("compilation")// Name of the tag in the file WebConfigurationManager.GetSection("CompilationSection") // Name of the class that I'd expect would be returned by this method WebConfigurationManager.GetSection("system.web") // Parent tag of the 'compilation' tag </code></pre> <p>All of the above methods return <code>null</code>. I'm assuming there is a way to get to this configuration section since there is a class that already exists ('<code>CompilationSection</code>'), I just can't figure out how to get it.</p>
[ { "answer_id": 401320, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 2, "selected": false, "text": "Web.config XmlDocument XPath XmlDocument doc = new XmlDocument();\ndoc.Load(Server.MapPath(\"~/Web.config\")); \ndoc.Selec...
2008/12/30
[ "https://Stackoverflow.com/questions/401306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/392/" ]
401,326
<p>I have lots of home directories under /ifshome on Linux. I want to see which users have not logged in for the past 6 months, and my solution is to parse the /ifshome/user/.lastlogin file. Each .lastlogin file has the same format, 1 line:</p> <pre><code>Last Login: Fri Mar 09 18:06:27 PST 2001 </code></pre> <p>I need to build a shell script that can parse the .lastlogin file in each user's home directory and output those directories whose owners haven't logged in for the last 6 months. </p>
[ { "answer_id": 401368, "author": "xtofl", "author_id": 6610, "author_profile": "https://Stackoverflow.com/users/6610", "pm_score": 1, "selected": false, "text": "find" }, { "answer_id": 401378, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https:/...
2008/12/30
[ "https://Stackoverflow.com/questions/401326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18406/" ]
401,331
<p>If I delete a file in Subversion, how can I look at it's history and contents? If I try to do <code>svn cat</code> or <code>svn log</code> on a nonexistent file, it complains that the file doesn't exist.</p> <p>Also, if I wanted to resurrect the file, should I just <code>svn add</code> it back?</p> <p>(I asked specifically about Subversion, but I'd also like to hear about how Bazaar, Mercurial, and Git handle this case, too.)</p>
[ { "answer_id": 401344, "author": "Jack M.", "author_id": 3421, "author_profile": "https://Stackoverflow.com/users/3421", "pm_score": 1, "selected": false, "text": "svn log -r <revision> <deleted file>\n" }, { "answer_id": 401353, "author": "Stefan", "author_id": 48003, ...
2008/12/30
[ "https://Stackoverflow.com/questions/401331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33795/" ]
401,338
<p>Is it possible to progmatically or dynamically create a project in VS2005 using c#? If so could someone provide some ideas or links on how to accomplish this?</p>
[ { "answer_id": 401547, "author": "rnwood", "author_id": 49419, "author_profile": "https://Stackoverflow.com/users/49419", "pm_score": 2, "selected": false, "text": "Engine engine=new Engine();\nengine.BinPath=RuntimeEnvironment.GetRuntimeDirectory();\nProject project=engine.CreateNewProj...
2008/12/30
[ "https://Stackoverflow.com/questions/401338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
401,339
<p>I am using the Microsoft.Practices.EnterpriseLibrary Database tools and I'm having trouble creating a new database using <em>just</em> the connection string information.</p> <p>Ideally I would like to do the following:</p> <pre><code>Database dbEngine = DatabaseFactory.CreateDatabase( "Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;"); </code></pre> <p>Is it possible to create a database using just the connection string?</p> <p>If so, how can it be achieved?</p>
[ { "answer_id": 412925, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "SqlDatabase dbEngine = new SqlDatabase(connectionString);\n" }, { "answer_id": 1195945, "author": "kiev", "aut...
2008/12/30
[ "https://Stackoverflow.com/questions/401339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
401,342
<p>Is there any recommended solutions when an embedding a script that will make a callback to the originating source but the js resides in a different domain. Sometimes other clients would be in a different domain and I can't rely on getting the document or window location.</p> <p>Currently, I've been using this but not too happy with this solution.</p> <pre><code>var host = window.location.hostname; if(host.indexOf('.devols.') &gt; -1){ return (('https:' == document.location.protocol) ? 'https://' : 'http://') + host; // return dev or localhost } else if(host.indexOf('.qaols.') &gt; -1){ return 'qa environment'; } else { return 'prod environment'; } </code></pre> <p>Update:</p> <p>So far I've been playing around with this:</p> <pre><code>var scriptLocation = ''; var SCRIPT_NAME = 'example.js'; var scripts = document.getElementsByTagName('script'); for(var i=0;i&lt;scripts.length;i++){ var src = scripts[i].getAttribute('src'); if(src){ var index = src.lastIndexOf(SCRIPT_NAME); if((index &gt; -1) &amp;&amp; (index + SCRIPT_NAME.length == src.length)) { scriptLocation=src.slice(0, src.indexOf('/my_script_location/')); break; } } } return scriptLocation; </code></pre> <p>So after the page loads the code cycles thru the script tag array and determines the location so the api can make a callback without having to figure out the urls and etc...</p>
[ { "answer_id": 401411, "author": "sammich", "author_id": 50276, "author_profile": "https://Stackoverflow.com/users/50276", "pm_score": 0, "selected": false, "text": "<script type=\"text/javascript\" src=\"http://foo/bar.js?caller=http://blah\"></script>\n" } ]
2008/12/30
[ "https://Stackoverflow.com/questions/401342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50261/" ]
401,348
<p>I have a common code of serializing a class object in my 3-4 methods ,So I am thinking to create a common function for that code and call function in all the methods </p> <p>I am doingn this from the following code </p> <pre><code>DataContractJsonSerializer ser = new DataContractJsonSerializer(this.GetType()); MemoryStream ms = new MemoryStream(); ser.WriteObject(ms, this); json = Encoding.Default.GetString(ms.ToArray()); ms.Close(); </code></pre> <p>I want to put this common code in seprate general function which returns Json string and which accept whole class as input parameter as I am converting whole class into a Json object , I tried creating function like </p> <p>public string GenerateJsonString(class C1)</p> <p>but this is giving me error on the keyword "class" saying that type is required </p> <p>Can anyone tell me how can I accept whole class object in seprate method or function</p>
[ { "answer_id": 401354, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": -1, "selected": false, "text": "public string GenerateJsonString(Type t1)\n" }, { "answer_id": 401356, "author": "TheSoftwareJedi", "aut...
2008/12/30
[ "https://Stackoverflow.com/questions/401348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14299/" ]
401,358
<p>I am digging around in a Linux application that supposedly uses DSNs to connet to SQL Server. The connection stopped working and I can't find the credentials that are being used (all I know is the DSN's name). </p> <p>I am familiar with DSNs in Windows, but how are they created and where are they stored in Linux?</p>
[ { "answer_id": 2849306, "author": "initzero", "author_id": 338713, "author_profile": "https://Stackoverflow.com/users/338713", "pm_score": 4, "selected": false, "text": "/usr/local/etc/odbc.ini /usr/local/etc/odbcinst.ini usr$ find . -iname 'odbc*.ini'\n" } ]
2008/12/30
[ "https://Stackoverflow.com/questions/401358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/556/" ]
401,376
<p>I'm just learning asp.net mvc and I'm trying to figure out how to move my controllers into a separate project. Typically when I have designed asp.net web apps before, I created one project for my models, another for my logic, and then there was the web. </p> <p>Now that I'm learning asp.net mvc I was hoping to follow a similar pattern and put the models and controllers each into their own separate projects, and just leave the views/scripts/css in the web. The models part was easy, but what I don't understand is how to make my controllers in a separate project be "found". Also, I would like to know if this is advisable. Thanks!</p>
[ { "answer_id": 401481, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 8, "selected": true, "text": "ControllerBuilder.Current.SetControllerFactory(new MyControllerFactory());\n ControllerBuilder.Current.DefaultNamespaces...
2008/12/30
[ "https://Stackoverflow.com/questions/401376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24908/" ]
401,389
<p>I'm using a UINavigationController and I'm having trouble releasing objects when I push a new view. I want to set an object on the new controller before pushing it. The way I'm currently doing this is:</p> <pre><code>OpenPageViewController *varOpenPageController = [[OpenPageViewController alloc] initWithNibName:@"OpenPageViewController" bundle:nil]; varOpenPageController.bookObj = bookObj; [[self navigationController] pushViewController:varOpenPageController animated:YES]; //[varOpenPageController release]; </code></pre> <p>If I uncomment that last line then the program crashes when I navigate back throughout my controller. I also have another question regarding when/how to release an object. In the bookObj I have a mutable array of Page objects and I want to change the text of the current page object. I do this by:</p> <pre><code>Page *pageObj = [[bookObj pagesArray] objectAtIndex:currentPage]; pageObj.page_Text = textView.text; [[bookObj pagesArray] replaceObjectAtIndex:currentPage withObject:pageObj]; //[pageObj release]; </code></pre> <p>The program crashes if I uncomment that last line as well. It will let me navigate forward but when I navigate back and try to go forward again it crashes. </p> <p>Autoreleasing the objects bring similar results. Please advise if you can. Thanks.</p> <p>EDIT: When I do release the first example varOpenPageController and run the simulator with Leaks then the program seems to function properly. However, if I don't run Leaks then it crashes. Does anyone have any ideas why this might happen? Thanks.</p>
[ { "answer_id": 401481, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 8, "selected": true, "text": "ControllerBuilder.Current.SetControllerFactory(new MyControllerFactory());\n ControllerBuilder.Current.DefaultNamespaces...
2008/12/30
[ "https://Stackoverflow.com/questions/401389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29941/" ]
401,415
<p>Hullo all,</p> <p>Wondering if there are any Java hackers who can clue me in at to why the following doesn't work:</p> <pre><code>public class Parent { public Parent copy() { Parent aCopy = new Parent(); ... return aCopy; } } public class ChildN extends Parent { ... } public class Driver { public static void main(String[] args) { ChildN orig = new ChildN(); ... ChildN copy = orig.getClass().cast(orig.copy()); } } </code></pre> <p>The code is quite happy to compile, but decides to throw a ClassCastException at runtime D= </p> <p><b>Edit:</b> Whoah, really quick replies. Thanks guys! So it seems I cannot downcast using this method... is there any other way to do downcasting in Java? I did think about having each <code>ChildN</code> class overwrite <code>copy()</code>, but wasn't enthusiastic about adding the extra boilerplate code.</p>
[ { "answer_id": 401419, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "ChildN copy = (ChildN) orig.copy();\n orig.getClass() ChildN.class orig.copy() Parent ChildN" }, { "answer_id": ...
2008/12/30
[ "https://Stackoverflow.com/questions/401415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50264/" ]
401,431
<p>I'm laying the groundwork for an automated build process and am trying to make sure I start down the right path. Our codebase is a mixture of Managed/Unmanaged C++. The managed part is in .NET 2.0 and all of the projects are part of a Visual Studio 2005 solution.</p> <p>Right now I'm looking at NAnt, but I can't figure out how to perform a build. When I try to build using the tag, it spits out an error: </p> <blockquote> <p>Microsoft Visual Studio.NET 2005 solutions are not supported.</p> </blockquote> <p>I feel like I'm just approaching this problem from the wrong direction. Can anyone point me in the right one?</p> <p>P.S. I also want to run doxygen as part of the build process, but I assume that whatever tool I choose will allow me to run it as a shell command at the very least.</p>
[ { "answer_id": 409493, "author": "Todd Smith", "author_id": 31624, "author_profile": "https://Stackoverflow.com/users/31624", "pm_score": 2, "selected": false, "text": "<?xml version=\"1.0\"?>\n<project name=\"Test Build\" default=\"build\" xmlns=\"http://nant.sf.net/release/0.85-rc4/nan...
2008/12/30
[ "https://Stackoverflow.com/questions/401431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2831/" ]
401,432
<p>I'm trying to figure out how to implement a function in a tree node which returns all its descendant leaves (whether direct or indirect). However, I don't want to pass a container in which the leaf nodes will be put recursively (the tree could be huge), instead I'd like to use a generator to iterate through the tree. I've tried a few approaches but none of them worked so far. This one is the closest I've come to a possible solution:</p> <pre><code> public interface ITreeNode { IEnumerable&lt;ITreeNode&gt; EnumerateLeaves(); } class Leaf : ITreeNode { public IEnumerable&lt;ITreeNode&gt; EnumerateLeaves() { throw new NotImplementedException(); } } class Branch : ITreeNode { private List&lt;ITreeNode&gt; m_treeNodes = new List&lt;ITreeNode&gt;(); public IEnumerable&lt;ITreeNode&gt; EnumerateLeaves() { foreach( var node in m_treeNodes ) { if( node is Leaf ) yield return node; else node.EnumerateLeaves(); } } } </code></pre> <p>But this is not working either. What am I doing wrong? Seems like calling .EnumerateLeaves recursively won't work if there's a yield statement in the same function.</p> <p>Any help would be very much appreciated. Thanks in advance.</p> <p>Edit: I forgot to mention that a branch can have either leaves or branches as children, hence the recursion.</p>
[ { "answer_id": 401435, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 4, "selected": true, "text": "public IEnumerable<ITreeNode> EnumerateLeaves()\n{\n foreach( var node in m_treeNodes )\n {\n if( node is...
2008/12/30
[ "https://Stackoverflow.com/questions/401432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7839/" ]
401,444
<p>I'm interested in cross-colo fail-over strategies for web applications, such that if the main site fails users seamlessly land at the fail-over site in another colo.</p> <p>The application side of things looks to be mostly figured out with a master-slave database setup between the colos and services designed to recover and be able to pick up mid-stream. I'm trying to figure out the strategy for moving traffic from the main site to the fail-over site. DNS failover, even with low TTLs, seems to carry a <a href="http://blog.pyromod.com/2007/09/viability-of-dns-failover.html" rel="noreferrer">fair bit of latency</a>.</p> <p>What strategies would you recommend for quickly moving traffic between colos, assuming the servers at the main colo are unreachable?</p> <p>If you have other interesting experience / words of wisdom about cross-colo failover I'd love to hear those as well.</p>
[ { "answer_id": 401471, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 3, "selected": true, "text": "gethostbyname()" } ]
2008/12/30
[ "https://Stackoverflow.com/questions/401444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13055/" ]
401,463
<p>I am trying to figure out the location of the script tag the current javascript is running in. What is really going on is that I need to determine from <em>inside</em> a src'd, dynamically inserted javascript file where it is located in the DOM. These are dynamically generated tags; code snippet: </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt; &lt;title&gt;where am i?&lt;/title&gt; &lt;script type="text/javascript" charset="utf-8"&gt; function byId(id) { return document.getElementById(id); } function create_script(el, code) { var script = document.createElement("script"); script.type = "text/javascript"; script.text = code; el.appendChild(script); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="find_me_please"&gt;&lt;/div&gt; &lt;script&gt; create_script(byId("find_me_please"), "alert('where is this code located?');"); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 401490, "author": "geocar", "author_id": 37507, "author_profile": "https://Stackoverflow.com/users/37507", "pm_score": 2, "selected": false, "text": "<script>\n(function(r) {\n document.write('<span id=\"'+r+'\"></span>');\n window.setTimeout(function() {\n var here_i...
2008/12/30
[ "https://Stackoverflow.com/questions/401463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50301/" ]
401,464
<p>Should Java Objects be reused as often as it can be reused ? Or should we reuse it only when they are "heavyweight", ie have OS resources associated with it ?</p> <p>All old articles on the internet talk about object reuse and object pooling as much as possible, but I have read recent articles that say <code>new Object()</code> is highly optimized now ( 10 instructions ) and Object reuse is not as big a deal as it used to be.</p> <p>What is the current best practice and how are you people doing it ?</p>
[ { "answer_id": 401498, "author": "Yuval Adam", "author_id": 24545, "author_profile": "https://Stackoverflow.com/users/24545", "pm_score": 2, "selected": false, "text": "String()" }, { "answer_id": 401502, "author": "billybob", "author_id": 49464, "author_profile": "ht...
2008/12/30
[ "https://Stackoverflow.com/questions/401464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18390/" ]
401,467
<p><em>edit: many thanks for all the answers. Here are the results after applying the optimisations so far:</em></p> <ul> <li><em>Switching to sorting the characters and run length encoding - new DB size 42M</em></li> <li><em>Dropping the indexes on the booleans - new DB size 33M</em></li> </ul> <p><em>The really nice part is this hasn't required any changes in the iphone code</em></p> <p>I have an iphone application with a large dictionary held in sqlite format (read only). I'm looking for ideas to reduce the size of the DB file, which is currently very large.</p> <p>Here is the number of entries and resulting size of the sqlite DB:</p> <pre><code>franks-macbook:DictionaryMaker frank$ ls -lh dictionary.db -rw-r--r-- 1 frank staff 59M 8 Oct 23:08 dictionary.db franks-macbook:DictionaryMaker frank$ wc -l dictionary.txt 453154 dictionary.txt </code></pre> <p>...an average of about 135 bytes per entry.</p> <p>Here is my DB schema:</p> <pre><code>create table words (word text primary key, sowpods boolean, twl boolean, signature text) create index sowpods_idx on words(sowpods) create index twl_idx on words(twl) create index signature_idx on words(signature) </code></pre> <p>Here is some sample data:</p> <pre><code>photoengrave|1|1|10002011000001210101010000 photoengraved|1|1|10012011000001210101010000 photoengraver|1|1|10002011000001210201010000 photoengravers|1|1|10002011000001210211010000 photoengraves|1|1|10002011000001210111010000 photoengraving|1|1|10001021100002210101010000 </code></pre> <p>The last field represents the letter frequencies for anagram retrieval (each position is in the range 0..9). The two booleans represent sub dictionaries.</p> <p>I need to do queries such as:</p> <pre><code>select signature from words where word = 'foo' select word from words where signature = '10001021100002210101010000' order by word asc select word from words where word like 'foo' order by word asc select word from words where word = 'foo' and (sowpods='1' or twl='1') </code></pre> <p>One idea I have is to encode the letter frequencies more efficiently, e.g. binary encode them as a blob (perhaps with RLE as there are many zeros?). Any ideas for how best to achieve this, or other ideas to reduce the size? I am building the DB in ruby, and reading it on the phone in objective C. </p> <p>Also is there any way to get stats on the DB so I can see what is using the most space?</p>
[ { "answer_id": 401533, "author": "Marc Novakowski", "author_id": 27020, "author_profile": "https://Stackoverflow.com/users/27020", "pm_score": 1, "selected": false, "text": "signature" } ]
2008/12/30
[ "https://Stackoverflow.com/questions/401467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42404/" ]
401,482
<p>I'm working with a code base where lists need to be frequently searched for a single element. </p> <p>Is it faster to use a Predicate and Find() than to manually do an enumeration on the List?</p> <p>for example:</p> <pre><code>string needle = "example"; FooObj result = _list.Find(delegate(FooObj foo) { return foo.Name == needle; }); </code></pre> <p>vs.</p> <pre><code>string needle = "example"; foreach (FooObj foo in _list) { if (foo.Name == needle) return foo; } </code></pre> <p>While they are equivalent in functionality, are they equivalent in performance as well?</p>
[ { "answer_id": 401549, "author": "Bevan", "author_id": 30280, "author_profile": "https://Stackoverflow.com/users/30280", "pm_score": 2, "selected": false, "text": "string needle = \"example\";\nforeach (FooObj foo in _list)\n{\n if (foo.Name == needle) \n return foo;\n}\...
2008/12/30
[ "https://Stackoverflow.com/questions/401482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50299/" ]
401,486
<p>I have a user model which has multiple addresses. Now for my application in rails, address is not mandatory. So, if someone wants to create a user and enter the address after the user has been created, my application should allow that. My problem is, for Address model I have validations for Address Line 1, City and Postal Code. These fields cannot be blank. When, editing a user, the following code fails:</p> <p>user.addresses &lt;&lt; Address.new</p> <p>Rails tries to create a new Address and fires an Insert command. This is going to fail because of the validations that is required in the model. The above code doesn't fail if the user is not present in the database. One solution to this problem is to create a separate form_for binding for the edit partial for user. I don't want to do that solution. Is there any solution that allows me to bind an empty Address object for an already existing User object in the database ?</p>
[ { "answer_id": 401549, "author": "Bevan", "author_id": 30280, "author_profile": "https://Stackoverflow.com/users/30280", "pm_score": 2, "selected": false, "text": "string needle = \"example\";\nforeach (FooObj foo in _list)\n{\n if (foo.Name == needle) \n return foo;\n}\...
2008/12/30
[ "https://Stackoverflow.com/questions/401486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49550/" ]
401,513
<p>Consider the following example structure</p> <pre><code>- Project - www - files + documents + html + images + scripts - WEB-INF * web.xml </code></pre> <p>The documents folder needs to be a symlink or in some other way external from the war file because users will add and remove documents (through a mapped network drive).</p> <p>I'd like to deploy the webapp as a war-file but I don't know how to do that and take the above into account. Could you give some pointers? /Adam</p>
[ { "answer_id": 402596, "author": "Marcel", "author_id": 2554, "author_profile": "https://Stackoverflow.com/users/2554", "pm_score": 0, "selected": false, "text": "$CATALINA_HOME/webapps" }, { "answer_id": 37633765, "author": "Gus", "author_id": 1172174, "author_profil...
2008/12/30
[ "https://Stackoverflow.com/questions/401513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31518/" ]
401,516
<p>I have test database and a production database. When developing I of course work against that test database then when deploying I have to semi-manually update the production database (by running a batch-sql-script). This usually works fine but there's a chance for mistakes where the deployed database isn't the same as the test database.</p> <p>For tables: Is there any way that I can automatically test all entities that I've mapped using linq2sql against a the production database so that all properties etc. exist?</p>
[ { "answer_id": 401527, "author": "Bramha Ghosh", "author_id": 3268, "author_profile": "https://Stackoverflow.com/users/3268", "pm_score": 2, "selected": false, "text": " if (address.City.Length > Utilities.LinqValidate.GetLengthLimit(address, \"City\"))\n throw new Argu...
2008/12/30
[ "https://Stackoverflow.com/questions/401516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40939/" ]
401,521
<p>In the ASP.NET ajax library, there is a line that makes me confused.</p> <pre><code>Type.prototype.registerClass = function Type$registerClass(typeName, baseType, interfaceTypes) { //.. this.prototype.constructor = this; //.. } </code></pre> <p>I know that <code>(this.prototype.constructor === this) == true</code>, so what is significance of this line? I remove the line, and test the library with some code. It seems it is okay. What is the purpose of this line?</p>
[ { "answer_id": 401527, "author": "Bramha Ghosh", "author_id": 3268, "author_profile": "https://Stackoverflow.com/users/3268", "pm_score": 2, "selected": false, "text": " if (address.City.Length > Utilities.LinqValidate.GetLengthLimit(address, \"City\"))\n throw new Argu...
2008/12/30
[ "https://Stackoverflow.com/questions/401521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33090/" ]
401,535
<p>Look at this situation:</p> <ol> <li><code>www.websitea.com</code> displays an <code>img</code> tag with a <code>src</code> attribute of <code>www.websiteb.com/image.aspx?id=5</code> and <code>style="display:none"</code></li> <li><code>www.websiteb.com</code> returns an clear image, in addition to a cookie with a name of <code>referrer</code> and value of <code>5</code> (created server-side from validated querystring.)</li> </ol> <p>Would the cookie be created on domain <code>www.websitea.com</code> or <code>www.websiteb.com</code>?</p> <p>Currently I'm sure a series of redirects with querystrings and to achieve cross-domain cookies, but I came up with this image idea a little ago. I guess I could also use an <code>iframe</code>.</p> <p>Thanks!</p>
[ { "answer_id": 401582, "author": "Shawn", "author_id": 26, "author_profile": "https://Stackoverflow.com/users/26", "pm_score": 0, "selected": false, "text": "<%@ Page Language=\"VB\" %>\n\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/...
2008/12/30
[ "https://Stackoverflow.com/questions/401535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26/" ]
401,538
<p>I remember there was a third party site that did all the sign up, quotas and key generation for API keys. I can not remember the name, so wondering if anyone knows about it?</p>
[ { "answer_id": 1501270, "author": "JonnyLitt", "author_id": 182176, "author_profile": "https://Stackoverflow.com/users/182176", "pm_score": 0, "selected": false, "text": "<?\n$customer = ' ';\n$customerid = ' ';\n$key = md5('Some salt here'.$customer).md5($customerid);\n// Then add s...
2008/12/30
[ "https://Stackoverflow.com/questions/401538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
401,556
<p>Is it a good idea to quote keys when using a hash in Perl?</p> <p>I am working on an extremely large legacy Perl code base and trying to adopt a lot of the best practices suggested by Damian Conway in <a href="http://oreilly.com/catalog/9780596001735/" rel="noreferrer">Perl Best Practices</a>. I know that best practices are <em>always</em> a touchy subject with programmers, but hopefully I can get some good answers on this one without starting a flame war. I also know that this is probably something that a lot of people wouldn't argue over due to it being a minor issue, but I'm trying to get a solid list of guidelines to follow as I work my way through this code base.</p> <p>In the <a href="http://oreilly.com/catalog/9780596001735/" rel="noreferrer">Perl Best Practices book by Damian Conway</a>, there is this example which shows how alignment helps legibility of a section of code, but it doesn't mention (anywhere in the book that I can find) anything about quoting the hash keys.</p> <pre><code>$ident{ name } = standardize_name($name); $ident{ age } = time - $birth_date; $ident{ status } = 'active'; </code></pre> <p>Wouldn't this be better written with quotes to emphasize that you are not using bare words?</p> <pre><code>$ident{ 'name' } = standardize_name($name); $ident{ 'age' } = time - $birth_date; $ident{ 'status' } = 'active'; </code></pre>
[ { "answer_id": 401895, "author": "Hynek -Pichi- Vychodil", "author_id": 49197, "author_profile": "https://Stackoverflow.com/users/49197", "pm_score": 2, "selected": false, "text": "$i{keys} = $a;\n$i{values} = [1,2];\n...\n" }, { "answer_id": 401964, "author": "Joe Casadonte"...
2008/12/30
[ "https://Stackoverflow.com/questions/401556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6406/" ]
401,561
<pre><code>Image.FromFile(@"path\filename.tif") </code></pre> <p>or</p> <pre><code>Image.FromStream(memoryStream) </code></pre> <p>both produce image objects with only one frame even though the source is a multi-frame TIFF file. <strong>How do you load an image file that retains these frames?</strong> The tiffs are saved using the Image.SaveAdd methods frame by frame. They work in other viewers but .NET Image methods will not load these frames, only the first. </p> <p><strong>Does this mean that there is no way to return a multi-frame TIFF from a method where I am passing in a collection of bitmaps to be used as frames?</strong></p>
[ { "answer_id": 401579, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 6, "selected": true, "text": "private List<Image> GetAllPages(string file)\n{\n List<Image> images = new List<Image>();\n Bitmap bitmap = (Bit...
2008/12/30
[ "https://Stackoverflow.com/questions/401561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35286/" ]
401,593
<p>I am working on an in-browser editor within a <code>textarea</code>. I have started looking for some information on dealing with <code>textarea</code> selection and found <a href="https://github.com/localhost/jquery-fieldselection" rel="noreferrer">this jQuery plugin, fieldSelection</a> that does some simple manipulation. </p> <p>However, it doesn't explain what's going on.</p> <p>I want to understand more on textarea selection in JavaScript, preferably with a description of both pre-DOM3 and post-DOM30 scenarios.</p>
[ { "answer_id": 403526, "author": "Borgar", "author_id": 27388, "author_profile": "https://Stackoverflow.com/users/27388", "pm_score": 4, "selected": true, "text": "textarea .selectionEnd .selectionStart .contentEditable" }, { "answer_id": 2966703, "author": "user357565", ...
2008/12/30
[ "https://Stackoverflow.com/questions/401593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/208/" ]
401,598
<p>JTextField has a keyTyped event but it seems that at the time it fires the contents of the cell have not yet changed.</p> <p>Because of that .length() is always wrong if read here.</p> <p>There must be a simple way of getting the length as it appears to the user after a key stroke?</p>
[ { "answer_id": 401613, "author": "Sean Bright", "author_id": 21926, "author_profile": "https://Stackoverflow.com/users/21926", "pm_score": 4, "selected": true, "text": "evt.getDocument().getLength()\n" }, { "answer_id": 401619, "author": "VonC", "author_id": 6309, "au...
2008/12/30
[ "https://Stackoverflow.com/questions/401598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
401,600
<p>I have a custom template for an expander that is close to the code below. I had to change some of the code to take out custom classes, brushes, etc..</p> <pre><code>&lt;Style TargetType="{x:Type Expander}"&gt; &lt;Setter Property="HorizontalContentAlignment" Value="Stretch" /&gt; &lt;Setter Property="VerticalContentAlignment" Value="Top" /&gt; &lt;Setter Property="BorderBrush" Value="Transparent" /&gt; &lt;Setter Property="FontFamily" Value="Tahoma" /&gt; &lt;Setter Property="FontSize" Value="12" /&gt; &lt;Setter Property="Foreground" Value="Black" /&gt; &lt;Setter Property="BorderThickness" Value="1" /&gt; &lt;Setter Property="Margin" Value="2,0,0,0" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type Expander}"&gt; &lt;Border x:Name="Border" SnapsToDevicePixels="true" Background="White" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Margin="0,0,0,10" Padding="0" CornerRadius="8"&gt; &lt;DockPanel&gt; &lt;Border x:Name="HeaderSite" Background="Blue" CornerRadius="8" Height="32" DockPanel.Dock="Top"&gt; &lt;DockPanel&gt; &lt;ToggleButton Foreground="White" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Margin="0" MinHeight="0" MinWidth="0" Padding="6,2,6,2" IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" DockPanel.Dock="Left"&gt; &lt;/ToggleButton&gt; &lt;ContentPresenter SnapsToDevicePixels="True" HorizontalAlignment="Left" Margin="4,0,0,0" ContentSource="Header" VerticalAlignment="Center" RecognizesAccessKey="True" /&gt; &lt;/DockPanel&gt; &lt;/Border&gt; &lt;Border x:Name="InnerBorder" Margin="0" &gt; &lt;ContentPresenter Focusable="false" Visibility="Collapsed" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" x:Name="ExpandSite" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" DockPanel.Dock="Bottom" /&gt; &lt;/Border&gt; &lt;/DockPanel&gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsExpanded" Value="true"&gt; &lt;Setter Property="Margin" TargetName="InnerBorder" Value="5" /&gt; &lt;Setter Property="Visibility" TargetName="ExpandSite" Value="Visible" /&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsEnabled" Value="false"&gt; &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" /&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>As you can see there are two ContentPresenters. I would like the first one to use Tahoma Bold as the font instead of the default Tahoma. How can I do this?</p>
[ { "answer_id": 401612, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 7, "selected": true, "text": "<ContentPresenter TextBlock.FontFamily=\"Tahoma\"\n TextBlock.FontWeight=\"Bold\"\n Sna...
2008/12/30
[ "https://Stackoverflow.com/questions/401600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1514/" ]
401,602
<p>I am using <a href="http://spritegen.website-performance.org/" rel="nofollow noreferrer">CSS Sprite Generator</a> to create sprites for a web page I am working on, but it doesn't seem to work, and I don't know why...I guess it's something obvious but..!</p> <p>So, I picked up 3 images, zipped, generated the PNG file (I checked out the result it is seems fine) and I got the following css classes back:</p> <pre><code>.sprite-welcom1 { background-position: 0 -30px; } .sprite-welcom3 { background-position: 0 -109px; } .sprite-3 { background-position: 0 -188px; } </code></pre> <p>So here is the HTML I am testing on, and for some reason all I get is a nice blank page:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style&gt; .sprite-welcom1 { background-position: 0 -30px; } .sprite-welcom3 { background-position: 0 -109px; } .sprite-3 { background-position: 0 -188px; } .sprite-bg { background: url(csg-495a902b04181.png) no-repeat top left; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="sprite-bg sprite-3"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Any tips?</p>
[ { "answer_id": 401615, "author": "Doug McClean", "author_id": 11173, "author_profile": "https://Stackoverflow.com/users/11173", "pm_score": 2, "selected": false, "text": ".sprite-bg background-position background top left background-position .sprite-3 .sprite-bg" }, { "answer_id"...
2008/12/30
[ "https://Stackoverflow.com/questions/401602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
401,604
<p>What's a good algorithm for "bouncing cards" like the ones you see in solitaire games?</p> <p>What's the coolest card animation you've seen?</p> <p><strong>Edit</strong> - Any besides the Windows game?</p>
[ { "answer_id": 401831, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 2, "selected": false, "text": "vel_x = # some value, units/sec\nvel_y = # some value, units/sec\nacc_x = # some value in units/sec^2\nacc_y = # so...
2008/12/30
[ "https://Stackoverflow.com/questions/401604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49908/" ]
401,616
<p>Just wondering which is faster:</p> <pre><code>DELETE FROM table_name WHERE X='1' DELETE FROM table_name WHERE X='2' DELETE FROM table_name WHERE X='3' </code></pre> <p>or</p> <pre><code>DELETE FROM table_name WHERE X IN ('1', '2', '3') </code></pre> <p>Any ideas, hints, or references where to read?</p> <p>Thank you all!</p>
[ { "answer_id": 401655, "author": "WOPR", "author_id": 46255, "author_profile": "https://Stackoverflow.com/users/46255", "pm_score": 2, "selected": false, "text": "DELETE FROM table_name WHERE X BETWEEN 1 AND 3\n" }, { "answer_id": 401839, "author": "sammich", "author_id":...
2008/12/30
[ "https://Stackoverflow.com/questions/401616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49881/" ]
401,621
<p>Suppose I have some per-class data: (AandB.h)</p> <pre><code>class A { public: static Persister* getPersister(); } class B { public: static Persister* getPersister(); } </code></pre> <p>... and lots and lots more classes. And I want to do something like:</p> <pre><code>persistenceSystem::registerPersistableType( A::getPersister() ); persistenceSystem::registerPersistableType( B::getPersister() ); ... persistenceSystem::registerPersistableType( Z::getPersister() ); </code></pre> <p>... for each class.</p> <p>My question is: is there a way to automate building a list of per-type data so that I don't have to enumerate each type in a big chunk (as in the above example)?</p> <p>For example, one way you might do this is: (AutoRegister.h)</p> <pre><code>struct AutoRegisterBase { virtual ~AutoRegisterBase() {} virtual void registerPersist() = 0; static AutoRegisterBase*&amp; getHead() { static AutoRegisterBase* head= NULL; return head; } AutoRegisterBase* next; }; template &lt;typename T&gt; struct AutoRegister : public AutoRegisterBase { AutoRegister() { next = getHead(); getHead() = this; } virtual void registerPersist() { persistenceSystem::registerPersistableType( T::getPersister() ); } }; </code></pre> <p>and use this as follows: (AandB.cxx: )</p> <pre><code>static AutoRegister&lt;A&gt; auto_a; static AutoRegister&lt;B&gt; auto_b; </code></pre> <p>Now, after my program starts, I can safely do: (main.cxx)</p> <pre><code>int main( int, char ** ) { AutoRegisterBase* p = getHead(); while ( p ) { p-&gt;registerPersist(); p = p-&gt;next; } ... } </code></pre> <p>to collect each piece of per-type data and register them all in a big list somewhere for devious later uses. </p> <p>The problem with this approach is that requires me to add an AutoRegister object somewhere per type. (i.e. its not very automatic and is easy to forget to do). And what about template classes? What I'd really like is for the instantiation of a template class to somehow cause that class to get automatically registered in the list. If I could do this I would avoid having to have the user of the class (rather than the author) to remember to create a:</p> <pre><code>static AutoRegister&lt; SomeClass&lt;X1&gt; &gt; auto_X1; static AutoRegister&lt; SomeClass&lt;X2&gt; &gt; auto_X2; ... etc.... </code></pre> <p>for each template class instantiation.</p> <p>For FIW, I suspect there's no solution to this.</p>
[ { "answer_id": 401761, "author": "Judge Maygarden", "author_id": 1491, "author_profile": "https://Stackoverflow.com/users/1491", "pm_score": 2, "selected": false, "text": "#include <iostream>\n#include <vector>\n\nusing namespace std;\n\nclass Registerable {\n static vector<Registerab...
2008/12/30
[ "https://Stackoverflow.com/questions/401621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48956/" ]
401,623
<p>I'm looking for any suggestion/rules/guides on making a decent print css for when a webpage is printed. Do you have any to offer?</p>
[ { "answer_id": 401648, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 2, "selected": false, "text": "<link rel=\"stylesheet\"\n type=\"text/css\"\n media=\"print\" href=\"print.css\" />\n\nbody {\n background: white;\n ...
2008/12/30
[ "https://Stackoverflow.com/questions/401623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/396/" ]
401,637
<p>The technique for adding a reference to the COM interop of Office in Visual Studio is to go to:</p> <ol> <li>References</li> <li>Add Reference</li> <li>Select the <strong>COM</strong> tab</li> <li>Select <strong>Microsoft Office 11.0 Object Library</strong></li> </ol> <p>And magically named reference appears:</p> <pre><code>Microsoft.Office.Core </code></pre> <p>The <code>Project.csproj</code> file shows the details of the reference:</p> <pre><code>&lt;COMReference Include="Microsoft.Office.Core"&gt; &lt;Guid&gt;{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}&lt;/Guid&gt; &lt;VersionMajor&gt;2&lt;/VersionMajor&gt; &lt;VersionMinor&gt;3&lt;/VersionMinor&gt; &lt;Lcid&gt;0&lt;/Lcid&gt; &lt;WrapperTool&gt;primary&lt;/WrapperTool&gt; &lt;Isolated&gt;False&lt;/Isolated&gt; &lt;/COMReference&gt; </code></pre> <p>And the project is checked into source control and all is well.</p> <hr> <p>Then a developer with <strong>Office 2007</strong> gets the project from source control, and cannot build it because such a reference doesn't exist.</p> <p>He (i.e. me) checks out the .csproj file, deletes the reference to</p> <pre><code>Microsoft Office 11.0 Object Library </code></pre> <p>and re-adds the COM reference as</p> <pre><code>Microsoft Office 12.0 Object Library </code></pre> <p>And magically a named reference appears:</p> <pre><code>Microsoft.Office.Core </code></pre> <p>The <code>Project.csproj</code> file shows the details of the reference:</p> <pre><code>&lt;COMReference Include="Microsoft.Office.Core"&gt; &lt;Guid&gt;{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}&lt;/Guid&gt; &lt;VersionMajor&gt;2&lt;/VersionMajor&gt; &lt;VersionMinor&gt;4&lt;/VersionMinor&gt; &lt;Lcid&gt;0&lt;/Lcid&gt; &lt;WrapperTool&gt;primary&lt;/WrapperTool&gt; &lt;Isolated&gt;False&lt;/Isolated&gt; &lt;/COMReference&gt; </code></pre> <p>And the project is checked into source control and all is well.</p> <hr> <p>Then a developer with <strong>Office 2003</strong> gets the project from source control, and cannot build it because such a reference doesn't exist.</p> <p>He (i.e. not me) checks out the .csproj file, deletes the reference to </p> <pre><code>Microsoft Office 12.0 Object Library </code></pre> <p>and re-adds the COM reference as</p> <pre><code>Microsoft Office 11.0 Object Library </code></pre> <p>And magically a named reference appears:</p> <pre><code>Microsoft.Office.Core </code></pre> <p>The <code>Project.csproj</code> file shows the details of the reference:</p> <pre><code>&lt;COMReference Include="Microsoft.Office.Core"&gt; &lt;Guid&gt;{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}&lt;/Guid&gt; &lt;VersionMajor&gt;2&lt;/VersionMajor&gt; &lt;VersionMinor&gt;3&lt;/VersionMinor&gt; &lt;Lcid&gt;0&lt;/Lcid&gt; &lt;WrapperTool&gt;primary&lt;/WrapperTool&gt; &lt;Isolated&gt;False&lt;/Isolated&gt; &lt;/COMReference&gt; </code></pre> <p>And the project is checked into source control and all is well.</p> <p>Then the project is built, pressed onto <strong>CDs</strong>, and sent to the customers who have <strong>Office 2007</strong>.</p> <p>And all is not well.</p> <hr> <p>In the olden days (i.e. before .NET dll hell), we would reference the Office objects using a <strong>version independant ProgID</strong>, i.e.: </p> <pre><code>"Excel.Application" </code></pre> <p>which resolves to a <strong>clsid</strong> of the installed Office, e.g.</p> <pre><code>{00024500-0000-0000-C000-000000000046} </code></pre> <p>of which a class is then constructed using a call to COM (language-netural pseudo-code):</p> <pre><code>public IUnknown CreateOleObject(string className) { IUnknown unk; Clsid classID = ProgIDToClassID(className); CoCreateInstance(classID, null, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IUnknown, out unk); return unk; } </code></pre> <hr> <h2>Questions</h2> <p>1) What is the approved technique to automate the installed Office applications?</p> <p>2) What are the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=3c9a983a-ac14-4125-8ba0-d36d67e0f4ad&amp;displaylang=en" rel="noreferrer">Office 2003 Primary Interop Assemblies</a> useful for?</p> <p>3) If i use the Office 2003 Primary Interop Assemblies, do i have to have office 2003 installed?</p> <p>4) If i build with the Office 2003 Primary Interop Assemblies, are my customers tied to Office 20003 forever?</p> <p>5) Are there any <strong><a href="http://www.microsoft.com/downloads/details.aspx?familyid=59DAEBAA-BED4-4282-A28C-B864D8BFA513&amp;displaylang=en" rel="noreferrer">Office 2007</strong> Primary Interop Assemblies</a>?</p> <p>6) If i install the Office 2007 Primary Interop Assemblies do i have to have Office 2007 installed?</p> <p>7) What is wrong with using standard COM interop to drive Excel, Word, or Outlook? e.g.:</p> <pre><code>[ComImport] [Guid("00024500-0000-0000-C000-000000000046")] public class Excel { } </code></pre> <p>8) What is one achieving when one adds a </p> <ul> <li><strong>Reference</strong> to items on the <strong>COM tab</strong>, </li> <li>as opposed to using [ComImport], </li> <li>as opposed to using the <em>Office 2007 Primary Interop Assemblies</em>?</li> </ul> <p>9) Is adding a reference using the <strong>COM tab</strong> identical to using <strong>COM interop</strong>, except that it needs a <strong>type library</strong> before you can see it?</p> <p>10) Are the Office 2003 Primary Interop Assemblies backwards and forwards compatible with: - Office 14 - Office 2007 - Office 2003 - Office XP - Office 2000 - Office 97 - Office 95</p> <p>If a customer, and a developer, installs a new version of Office, will it still work?</p> <p>11) Do we have to ship the Office 2003 Primary Interop Assemblies with our application?</p> <p>12) Does the customer have to install the Office 2003 Primary Interop Assemblies before they can use our application?</p> <p>13) If a customer installs the Office 2003 Primary Interop Assemblies do they have to have <strong>Office</strong> installed?</p> <p>14) If a customer installs the Office 2003 Primary Interop Assemblies do they have to have Office <strong>2003</strong> installed?</p> <p>15) Are the Office 2003 Primary Interop Assembles a free, lite, redistributable version of Office 2003?</p> <p>16) If my development machine has Office 2007, can i use the Office 2003 PIAs, and ship to a customer with Office XP installed?</p>
[ { "answer_id": 8572060, "author": "Jonno", "author_id": 620856, "author_profile": "https://Stackoverflow.com/users/620856", "pm_score": 1, "selected": false, "text": "<COMReference Include=\"Microsoft.Office.Core\">\n <Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid>\n <VersionMajo...
2008/12/30
[ "https://Stackoverflow.com/questions/401637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
401,656
<p>It is currently said that MD5 is partially unsafe. Taking this into consideration, I'd like to know which mechanism to use for password protection.</p> <p>This question, <a href="https://stackoverflow.com/questions/348109/is-double-hashing-a-password-less-secure-than-just-hashing-it-once">Is “double hashing” a password less secure than just hashing it once?</a> suggests that hashing multiple times may be a good idea, whereas <a href="https://stackoverflow.com/questions/55862/how-to-implement-password-protection-for-individual-files#55904">How to implement password protection for individual files?</a> suggests using salt.</p> <p>I'm using PHP. I want a safe and fast password encryption system. Hashing a password a million times may be safer, but also slower. How to achieve a good balance between speed and safety? Also, I'd prefer the result to have a constant number of characters.</p> <ol> <li>The hashing mechanism must be available in PHP</li> <li>It must be safe</li> <li>It can use salt (in this case, are all salts equally good? Is there any way to generate good salts?)</li> </ol> <p>Also, should I store two fields in the database (one using MD5 and another one using SHA, for example)? Would it make it safer or unsafer?</p> <p>In case I wasn't clear enough, I want to know which hashing function(s) to use and how to pick a good salt in order to have a safe and fast password protection mechanism.</p> <p><em>Related questions that don't quite cover my question:</em></p> <p><a href="https://stackoverflow.com/questions/157998/whats-the-difference-between-sha-and-md5-in-php">What's the difference between SHA and MD5 in PHP</a><br> <a href="https://stackoverflow.com/questions/30946/simple-password-encryption">Simple Password Encryption</a><br> <a href="https://stackoverflow.com/questions/198803/secure-methods-of-storing-keys-passwords-for-asp-net">Secure methods of storing keys, passwords for asp.net</a><br> <a href="https://stackoverflow.com/questions/205153/how-would-you-implement-salted-passwords-in-tomcat-5-5">How would you implement salted passwords in Tomcat 5.5</a></p>
[ { "answer_id": 401684, "author": "Robert K", "author_id": 24950, "author_profile": "https://Stackoverflow.com/users/24950", "pm_score": 11, "selected": true, "text": "password_hash password_verify \\0" }, { "answer_id": 401698, "author": "Henrik Paul", "author_id": 2238, ...
2008/12/30
[ "https://Stackoverflow.com/questions/401656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32775/" ]
401,659
<p>In .NET framework, is it possible to set some of the items in the <code>CheckedListBox</code> as "uncheckable" ? I don't want to allow user to check the same items again and add them to a another existing list. </p> <p>I hope I am clear. Thanks in advance.</p>
[ { "answer_id": 401678, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 4, "selected": true, "text": "public Form1()\n{\n InitializeComponent();\n checkedListBox1.Items.Add(\"Can't check me\", CheckState.Indeterminate...
2008/12/30
[ "https://Stackoverflow.com/questions/401659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49057/" ]
401,664
<p>I have created a local report on a datasource that has a field named "RelativePath". When my WinForms app renders the report, it exports files to the location specified in the RelativePath field. In the report builder, I set Navigation|Hyperlink action|Jump to URL to "=Fields!RelativePath.Value" and set the report's EnableHyperlink property to true. Whenever my app renders the report, however, the hyperlink is not active. If I hardcode the Jump to URL to an absolute path, however, it works just fine. Does the ReportViewer not render a hyperlink with a relative path?</p>
[ { "answer_id": 17602186, "author": "LawMan", "author_id": 2574087, "author_profile": "https://Stackoverflow.com/users/2574087", "pm_score": 1, "selected": false, "text": " string baseUrl = Request.Url.GetLeftPart(UriPartial.Authority);\n var param = new ReportParameter(\"AbsolutePa...
2008/12/30
[ "https://Stackoverflow.com/questions/401664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/470/" ]
401,668
<p>I am wondering how I can read CSS comments out of a linked stylesheet.</p> <p>I have this sample CSS loaded via:</p> <pre><code>&lt;link rel="stylesheet" type="text/css" media="all" href="test.css" /&gt; </code></pre> <p>&nbsp;</p> <pre><code>#test1{ border:1px solid #000; } #test2{ border:1px solid #000; } #test3{/* sample comment text I'm trying to read */} </code></pre> <p>I'm testing this in FF3. The following javascript reads the rules but doesn't read the comments in<code>#test3</code>.</p> <pre><code>window.onload = function(){ s=document.styleSheets; for(i=0;i &lt; s[0].cssRules.length;i++){ alert(s[0].cssRules[i].cssText); } } </code></pre>
[ { "answer_id": 401739, "author": "Cristian Libardo", "author_id": 16526, "author_profile": "https://Stackoverflow.com/users/16526", "pm_score": 4, "selected": true, "text": "jQuery.get(\"test.css\", null, function(data) {\n var comments = data.match(/\\/\\*.*\\*\\//g);\n for each (...
2008/12/30
[ "https://Stackoverflow.com/questions/401668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
401,681
<p>I am working on code generation and ran into a snag with generics. Here is a "simplified" version of what is causing me issues.</p> <pre><code>Dictionary&lt;string, DateTime&gt; dictionary = new Dictionary&lt;string, DateTime&gt;(); string text = dictionary.GetType().FullName; </code></pre> <p>With the above code snippet the value of <code>text</code> is as follows:</p> <pre class="lang-none prettyprint-override"><code> System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] </code></pre> <p>(Line breaks added for better readability.)</p> <p>Is there a way to get the type name (<code>type</code>) in a different format without parsing the above string? I desire the following result for <code>text</code>:</p> <pre class="lang-none prettyprint-override"><code>System.Collections.Generic.Dictionary&lt;System.String, System.DateTime&gt; </code></pre>
[ { "answer_id": 401703, "author": "jcollum", "author_id": 30946, "author_profile": "https://Stackoverflow.com/users/30946", "pm_score": 0, "selected": false, "text": "Type.Parse()" }, { "answer_id": 401803, "author": "Walt Gaber", "author_id": 50336, "author_profile": ...
2008/12/30
[ "https://Stackoverflow.com/questions/401681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30099/" ]
401,702
<p>Lets say I have a header banner on a webpage I'm about to print. Instead of wasting someone's ink printing the entire block of the image, is there a way via css to replace the image with text of H1 size?</p>
[ { "answer_id": 401708, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 4, "selected": true, "text": "h1 display:none h1 display:none" }, { "answer_id": 401713, "author": "Tim Knight", "author_id": 43043...
2008/12/30
[ "https://Stackoverflow.com/questions/401702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/396/" ]
401,720
<p>In a project that I've been involved with for many years, I've gradually evolved a design pattern that's proven to be extremely useful for me. I sometimes feel I should get a bit evangelical with it, but I'd be a bit embarrassed if I tried and found out that it was just my version of somebody's old hat. I've dug through <i>Design Patterns</i> looking for it in vain, and I haven't run across anyone else talking about it, but my search hasn't been exhaustive.</p> <p>The core idea is having a broker object that manages a set of definition objects, each definition object constituting a possible value of some complex property. As an example, you might have Car, Plane, and Generator classes that all have an EngineType. Car doesn't store its own EngineType object, it stores a reference key of some kind that states the kind of Engine it has (such as an integer or string ID). When we want to look at properties or behavior of an EngineType, say WankelEngine, we ask the EngineTypeBroker singleton object for WankelEngine's definition object, passing it the reference key. This object encapsulates whatever's interesting to know about EngineTypes, possibly simply being a property list but potentially having behavior loaded onto it as well.</p> <p>So what it's facilitating is a kind of shared, loosely-coupled aggregation, where many Cars may have a WankelEngine but there is only one WankelEngine definition object (and the EngineTypeBroker can replace that object, leveraging the loose coupling into enhanced runtime morphism).</p> <p>Some elements of this pattern as I use it (continuing to use EngineType as an example):</p> <ol> <li>There are always IsEngineType(x) and EngineType(x) functions, for determining whether a given value is a valid reference key for an EngineType and for retrieving the EngineType definition object corresponding to a reference key, respectively.</li> <li>I always allow multiple forms of reference key for a given EngineType, always at least a string name and the definition object itself, more often than not an integer ID, and sometimes object types that aggregate an EngineType. This helps with debugging, makes the code more flexible, and, in my particular situation, eases a lot of backward compatibility issues relative to older practices. (The usual way people used to do all this, in this project's context, was to define hashes for each property an EngineType might have and look up the properties by reference key.)</li> <li>Usually, each definition instance is a subclass of a general class for that definition type (i.e. WankelEngine inherits EngineType). Class files for definition objects are kept in a directory like /Def/EngineType (i.e. WankelEngine's class would be /Def/EngineType/WankelEngine). So related definitions are grouped together, and the class files resemble configuration files for the EngineType, but with the ability to define code (not typically found in configuration files).</li> </ol> <p>Some trivially illustrative sample pseudocode:</p> <pre><code>class Car { attribute Name; attribute EngineTypeCode; object GetEngineTypeDef() { return EngineTypeBroker-&gt;EngineType(this-&gt;GetEngineTypeCode()); } string GetDescription() { object def = this-&gt;GetEngineTypeDef(); return "I am a car called " . this-&gt;GetName() . ", whose " . def-&gt;GetEngineTypeName() . " engine can run at " . def-&gt;GetEngineTypeMaxRPM() . " RPM!"; } } </code></pre> <p>So, is there a name out there for this?</p>
[ { "answer_id": 401800, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 3, "selected": true, "text": "class DataFetcher {\n abstract Object getData( Object id );\n}\n\nclass CustomerNameDataFetcher extends DataFetcher {\n...
2008/12/30
[ "https://Stackoverflow.com/questions/401720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47529/" ]
401,740
<p>I'm currently using SMO and C# to traverse databases to create a tree of settings representing various aspects of the two databases, then comparing these trees to see where and how they are different.</p> <p>The problem is, for 2 reasonably sized database, it takes almost 10mins to crawl them locally and collect table/column/stored procedure information I wish to compare.</p> <p>Is there a better interface then SMO to access databases in such a fashion? I would like to not include any additional dependencies, but I'll take that pain for a 50% speed improvement. Below is a sample of how I'm enumerating tables and columns.</p> <pre><code> Microsoft.SqlServer.Management.Smo.Database db = db_in; foreach (Table t in db.Tables) { if (t.IsSystemObject == false) { foreach (Column c in t.Columns) { } } } </code></pre>
[ { "answer_id": 401782, "author": "devio", "author_id": 21336, "author_profile": "https://Stackoverflow.com/users/21336", "pm_score": 4, "selected": true, "text": "Server server = new Server();\n\n// Force IsSystemObject to be returned by default.\nserver.SetDefaultInitFields(typeof(Store...
2008/12/30
[ "https://Stackoverflow.com/questions/401740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5965/" ]
401,744
<p>I am using shared hosting with IIS7 and support for PHP. I am trying to run a wordpress blog with "pretty urls" (removing index.php). The hosting provider doesn't want to install the URLRewrite module, so that option isn't available to me. I found a plugin for wordpress that will remove the index.php from permalink URLs and changing the 404 page to index.php is supposed to do the trick... that isn't working either.</p> <p>I'm familiar with URL rewriting for an ASP.NET website, but I'm not sure how I would go about it for PHP. The hosting setup seems to support ASP.NET and PHP at the same time, so I'm thinking it would be possible to run the rewrite code through ASP.NET, but I'm not sure how to go about it.</p> <p>Does anybody have any experience with this or any ideas about the best approach to take. If anything leads me in the right direction or if I figure it out myself, I will be more than happy to share the code here for anybody else that may need it. </p>
[ { "answer_id": 404252, "author": "Rob Boek", "author_id": 27179, "author_profile": "https://Stackoverflow.com/users/27179", "pm_score": 3, "selected": false, "text": "# Managed Fusion Url Rewriter\n# http://managedfusion.com/products/url-rewriter/\n#\n# Developed by: Nick Berardi\n# ...
2008/12/30
[ "https://Stackoverflow.com/questions/401744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8087/" ]
401,747
<p>I got some legacy code that has this:</p> <pre><code>&lt;?PHP if(isset($_GET['pagina'])=="homepage") { ?&gt; HtmlCode1 &lt;?php } else { ?&gt; HtmlCode2 &lt;?php } ?&gt; </code></pre> <p>I don't know exactly why but this seems to be working. The htmlcode1 is loaded when I have ?pagina=homepage and the htmlcode2 is loaded when the pagina var doesn't exist or is something else (haven't really seen with something else, just not there). The website is using php4 (don't know the exact version). But really, how can this work? I looked at the manual and it says isset returns a bool..</p> <p>Anyone?</p>
[ { "answer_id": 401757, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "isset() \"homepage\" true if ( isset($_GET['pagina']) == true )\n ?pagina=somethingelse" }, { "answer_id": 401759, ...
2008/12/30
[ "https://Stackoverflow.com/questions/401747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8715/" ]
401,748
<p>This problem seems to happen inconsistently. We are using a java applet to download a file from our site, which we store temporarily on the client's machine. </p> <p>Here is the code that we are using to save the file:</p> <pre><code>URL targetUrl = new URL(urlForFile); InputStream content = (InputStream)targetUrl.getContent(); BufferedInputStream buffered = new BufferedInputStream(content); File savedFile = File.createTempFile("temp",".dat"); FileOutputStream fos = new FileOutputStream(savedFile); int letter; while((letter = buffered.read()) != -1) fos.write(letter); fos.close(); </code></pre> <p>Later, I try to access that file by using:</p> <pre><code>ObjectInputStream keyInStream = new ObjectInputStream(new FileInputStream(savedFile)); </code></pre> <p>Most of the time it works without a problem, but every once in a while we get the error:</p> <pre><code>java.io.StreamCorruptedException: invalid stream header: 0D0A0D0A </code></pre> <p>which makes me believe that it isn't saving the file correctly.</p>
[ { "answer_id": 402275, "author": "Ry4an Brase", "author_id": 8992, "author_profile": "https://Stackoverflow.com/users/8992", "pm_score": 1, "selected": false, "text": "URL targetUrl = new URL(urlForFile);\nInputStream is = targetUrl.getInputStream();\nFile savedFile = File.createTempFile...
2008/12/30
[ "https://Stackoverflow.com/questions/401748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
401,752
<p>I recently wrote some javascript code that filled a drop down list based on some XML, pretty simple stuff. The problem was I had to write similar code to do almost the same thing on a different page. </p> <p>Because the code was almost identical I named most of the functions the same, thinking that they would never be included in the same page. However, naming conflicts arose because both javascript files were eventually included in the same HTML page.</p> <p>When I had to go back and change the names I simply added first_ or second_ to the method's names. This was a pain and it doesn't seem very elegant to me. I was wondering if there is a better way to resolve name conflicts in javascript?</p>
[ { "answer_id": 401790, "author": "LarryF", "author_id": 18518, "author_profile": "https://Stackoverflow.com/users/18518", "pm_score": 1, "selected": false, "text": "function goBlank(image)\n{\n if(image) {\n var imgobj = document[image];\n imgobj.src=\"/images/blank.png\";\n }\n}...
2008/12/30
[ "https://Stackoverflow.com/questions/401752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48728/" ]
401,754
<p>Am building a "Book search" API using Lucene. I need to index Book Name,Author, and Book category fields in Lucene index.</p> <p>A single book can fall under multiple distinct book categories...for example: </p> <p>BookName1 --fiction,humour,philosophy. BookName1 --fiction,science. BookName1 --humour,business. BookName4-humour and so on.....</p> <p>User should be able to search all the books under a particular category say "homour".</p> <p>Given this situation, how do i index above fields and build the query in lucene?</p>
[ { "answer_id": 402045, "author": "James Brady", "author_id": 29903, "author_profile": "https://Stackoverflow.com/users/29903", "pm_score": 2, "selected": false, "text": "schema.xml <field name=\"book_id\" type=\"string\" indexed=\"true\" stored=\"true\" required=\"true\" multiValued='fal...
2008/12/30
[ "https://Stackoverflow.com/questions/401754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40907/" ]
401,756
<p>I'm trying to parse some JSON using the JSon.Net library. The documentation seems a little sparse and I'm confused as to how to accomplish what I need. Here is the format for the JSON I need to parse through.</p> <pre><code>{ "displayFieldName" : "OBJECT_NAME", "fieldAliases" : { "OBJECT_NAME" : "OBJECT_NAME", "OBJECT_TYPE" : "OBJECT_TYPE" }, "positionType" : "point", "reference" : { "id" : 1111 }, "objects" : [ { "attributes" : { "OBJECT_NAME" : "test name", "OBJECT_TYPE" : "test type" }, "position" : { "x" : 5, "y" : 7 } } ] } </code></pre> <p>The only data I really need from this is the stuff in the objects array. Is it possible for me to parse through that with something like the JSonTextReader and just pull out the things I want, like OBJECT_TYPE and the x and y position? I can't seem to get <code>JSonTextReader</code> to work the way I want it to and I find little to no examples of usage for it. </p> <p>It seems like serializing first then using LINQ with my object would be ideal and every example I find discusses serializing the JSON first, but I'm not sure how I would build an object for this structure. Particularly the objects array which would need to be something like a list of Pairs of attribute and position objects. I have no idea how I would code my object so JSon.Net would know how to serialize that.</p> <p>I thought I could write my own simple parser to just pull out everything I need into an attributes object that I created, but I'm having little luck. </p> <p>Hopefully this all makes sense, any ideas?</p>
[ { "answer_id": 401976, "author": "jarrodn", "author_id": 15273, "author_profile": "https://Stackoverflow.com/users/15273", "pm_score": 3, "selected": false, "text": "MyObject deserializedObject = JsonConvert.DeserializeObject<MyObject>(json);\n attributes position Point System.Drawing Sy...
2008/12/30
[ "https://Stackoverflow.com/questions/401756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49294/" ]