input
stringlengths
51
42.3k
output
stringlengths
18
55k
how to save the generated xml file using jsp? <p>i have generated xml file using jsp,but i want the generated xml file should be saved as a file. my code is</p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;%@ page contentType="text/xml;charset=ISO-8859-1" %&gt; &lt;playlist version="1" xmlns = "http://xspf.org/ns/0/"&gt; &lt;title&gt;My Band Rocks Your Socks&lt;/title&gt; &lt;trackList&gt; &lt;%! String[] sports; %&gt; &lt;% sports = request.getParameterValues("sports"); if (sports != null) { for (int i = 0; i &lt; sports.length; i++) { // out.println (sports[i]); String total=sports[i]; String[] sa=total.split("[,]"); // String[] sub=new String(); out.print("&lt;track&gt;"); for (int j=0;j&lt;sa.length;j++) { // out.println(sa[j]); // out.println("sa["+j+"]="+sa[j]); if( j == 0) { out.print("&lt;location&gt;" + sa[0] +"&lt;/location&gt;"); } else if (j == 1) { out.print("&lt;image&gt;" + sa[1] +"&lt;/image&gt;"); } else if( j==2) { out.print("&lt;title&gt;" + sa[2] +"&lt;/title&gt;"); } }// end of inner for loop() out.print("&lt;/track&gt;"); //out.println(); }// end of outer for() } //else out.println ("&lt;b&gt;none&lt;b&gt;"); %&gt; &lt;/trackList&gt; &lt;/playlist&gt; </code></pre>
<p>Yes, you can. The way to do it is basically to set an extra header - which you can do on the response object.</p> <p>The header to set is called Content-Disposition and the value should be something like "attachment; filename=\"foo.xml\"".</p>
What is the format accepted by System.Net.Mail.MailAddress' parser? <p>I'm working on an app that's using <a href="http://msdn.microsoft.com/en-us/library/system.net.mail.mailaddress.aspx" rel="nofollow">System.Net.Mail.MailAddress</a> and friends for sending emails. Does that parser implement the full <a href="http://www.ietf.org/rfc/rfc5322.txt" rel="nofollow">RFC5322</a> or a subset or what? The MSDN is not very forthcoming on this topic.</p> <p>Any hints appreciated.</p>
<p>I've wrote a little snippet to test the function:</p> <pre><code>foreach (int i in Enumerable.Range(32,128-32)) { char c = (char)i; string addr = String.Format("par.t1{0}pa.r{0}t2@example.com", c); try { var mailAddr = new MailAddress(addr); } catch { Console.WriteLine("MailAddress failed '{0}' ({1}): {2}", c, i, addr); } } </code></pre> <p>With the following results on 3.5 SP1:</p> <pre> MailAddress failed ' ' (32): par.t1 pa.r t2@example.com MailAddress failed '"' (34): par.t1"pa.r"t2@example.com MailAddress failed '(' (40): par.t1(pa.r(t2@example.com MailAddress failed ')' (41): par.t1)pa.r)t2@example.com MailAddress failed ',' (44): par.t1,pa.r,t2@example.com MailAddress failed ':' (58): par.t1:pa.r:t2@example.com MailAddress failed ';' (59): par.t1;pa.r;t2@example.com MailAddress failed '&lt;' (60): par.t1&lt;pa.r&lt;t2@example.com MailAddress failed '&gt;' (62): par.t1>pa.r>t2@example.com MailAddress failed '@' (64): par.t1@pa.r@t2@example.com MailAddress failed '[' (91): par.t1[pa.r[t2@example.com MailAddress failed '\' (92): par.t1\pa.r\t2@example.com MailAddress failed ']' (93): par.t1]pa.r]t2@example.com MailAddress failed '⌂' (127): par.t1⌂pa.r⌂t2@example.com </pre> <p>Also it doesn't seem to support "quoted-string" local-parts, like <code>"blah"@example.com</code>.</p> <p>I don't think a validator could accept any less before becoming unusable.</p>
How to format string in XAML Setter Value? <p>I have learned how to format strings in the content attribute of a label like this:</p> <pre><code>&lt;Label Content="{Binding ElementName=theSlider, Path=Value}" ContentStringFormat="The font size is {0}."/&gt; </code></pre> <p>I want to do the same thing in a Setter but "ValueStringFormat" doesn't exist, what is the correct syntax to do what I want to accomplish here:</p> <pre><code>&lt;DataTrigger Binding="{Binding Path=Kind}" Value="Task"&gt; &lt;Setter TargetName="TheTitle" Property="Text" Value="{Binding Title}" ValueStringFormat="Your title was: {0}"/&gt; &lt;/DataTrigger&gt; </code></pre>
<p>Can you simply use the StringFormat property of the Binding itself?</p> <pre><code>&lt;DataTrigger Binding="{Binding Path=Kind}" Value="Task"&gt; &lt;Setter TargetName="TheTitle" Property="Text" Value="{Binding Title,StringFormat='Your title was: {}{0}'}" /&gt; &lt;/DataTrigger&gt; </code></pre>
ASP.NET: Session state not updated when redirecting in explorer <p>I have an aspx page (page1.aspx) where I set a Session variable and then redirect to another page:</p> <pre><code>HttpContext.Current.Response.Redirect("page2.aspx"); </code></pre> <p>On page2.aspx I want to read the session variable, but it doesn't exist until I reload the page. I try to read the session variable in page_load. </p> <p>The weird thing is that it works in firefox, but not in explorer??</p> <p>(Note that I've simplied this a bit to explain the problem page1.aspx is accessed from my HttpModule that and is rewritepathed (my workaround to get access to Session). So the flow is HttpModule -pathrewrite-> page1.aspx (set session var) -redirect-> page.2.aspx.)</p>
<p>Try switching your Response Redirect to:</p> <pre><code>Response.Redirect("page2.aspx",false); HttpContext.Current.ApplicationInstance.CompleteRequest(); </code></pre> <p>The nominal <code>Redirect(url)</code> implicitly calls <code>Redirect("url", true)</code> which throws a <code>ThreadAbortException</code>. The ThreadAbortException raised is a special exception when it is done as such inside ASP.NET. This exception while it can be caught cannot be muted. It will continue to bubble up the ASP.NET call chain to cause the current worker thread to immediately terminate. </p> <p>It's possible that the abrupt termination could be impacting this.</p>
Subclassing a private (support) class in AVM2 <p>I am developing a dynamic mocking framework for Flex/AS3 and am having trouble with private/support types (ie. those declared outside the package {} in a class file).</p> <p>In my ABC "file", I am declaring the instance with the PROTECTED_NAMESPACE class flag and with a PRIVATE_NS multiname. I have also experimented with giving it the same namespace as the class it is subclassing (eg. PRIVATE_NS("ContainerClass.as$123")).</p> <p>No matter what I do, I always get the following error after loadBytes:</p> <blockquote> <p>VerifyError: Error #1014: Class ContainerClass.as$123::PrivateClass could not be found.</p> </blockquote> <p>I have experimented with loading the generated bytecode into the same ApplicationDomain as the private class (I use a child domain by default). I even tried registering a class alias before the load (though that was a bit of a stretch).</p> <p>Am I forgetting anything or is it simply a restriction of the AVM?</p> <p><strong>Please note that I am fully aware that this is illegal in ActionScript 3.0, I am looking for whether this is actually possible in the AVM.</strong></p> <p><strong>Edit:</strong> For those interested in the work so far, the project is <a href="http://asmock.sourceforge.net/" rel="nofollow">asmock</a> and is on sourceforge.</p>
<p>I'm no expert with ABC files but I just don't think this is possible in the AVM2. I did several tests a while ago with the <a href="http://eval.hurlant.com/" rel="nofollow">AS3 Eval lib</a> and they all failed.</p> <p>Related to dynamic mocking, I have filed an issue in Adobe bugbase, asking for a dynamic proxy mechanism: <a href="http://bugs.adobe.com/jira/browse/ASC-3136" rel="nofollow">http://bugs.adobe.com/jira/browse/ASC-3136</a></p>
Lambda "cannot be inferred from the usage" <p>I have the following dictionary declared:</p> <pre><code>private readonly Dictionary&lt;int, Image&gt; dictionary; </code></pre> <p>And I have a method, which is causing a compiler error:</p> <pre><code> public IQueryable&lt;Image&gt; Find(Func&lt;Image, bool&gt; exp) { return dictionary.Single(exp); } </code></pre> <p>The error i get is: </p> <pre><code>Error 1 The type arguments for method 'System.Linq.Enumerable.Single&lt;TSource&gt;(System.Collections.Generic.IEnumerable&lt;TSource&gt;, System.Func&lt;TSource,bool&gt;)' cannot be inferred from the usage. Try specifying the type arguments explicitly. C:\work\MSD-AIDS-Images\MSD-AIDS-Images-Test\TestImageRepository.cs 34 30 MSD-AIDS-Images-Test </code></pre> <p>I have tried googling around, I cant seem to find anything definitive as to what I am doing wrong</p> <p>Edit - This is monday morning at work.</p> <p>I meant to put "where", not single</p> <p><strong>Edit 2!</strong></p> <p>Ok, the code is now this:</p> <pre><code>public IQueryable&lt;Image&gt; Find(Func&lt;Image, bool&gt; exp) { return dictionary.Values.Where(exp); } </code></pre> <p>Now I get the following error:</p> <pre><code>Error 1 Cannot implicitly convert type 'System.Collections.Generic.IEnumerable&lt;MSD_AIDS_Images_Data.Image&gt;' to 'System.Linq.IQueryable&lt;MSD_AIDS_Images_Data.Image&gt;'. An explicit conversion exists (are you missing a cast?) C:\work\MSD-AIDS-Images\MSD-AIDS-Images-Test\TestImageRepository.cs 34 20 MSD-AIDS-Images-Test </code></pre> <p>As an FYI, the method there is for implementing an interface, the declaration for that is:</p> <pre><code>IQueryable&lt;T&gt; Find(Func&lt;T, bool&gt; exp); </code></pre> <p>This has got more complicated than it should be!</p>
<p>What is it you are trying to do? For example, <code>Single</code> will return an instance of <code>T</code>, not an <code>IQueryable&lt;T&gt;</code> (and for objects, you should probably be using <code>IEnumerable&lt;T&gt;</code> anyway)...</p> <p>It feels like you want:</p> <pre><code>public Image Find(Func&lt;Image, bool&gt; predicate) { return dictionary.Values.Single(predicate); } </code></pre> <p>Of course, you could do this globally as an extension method via something like:</p> <p>(<strong>edit</strong> includes <code>Where</code> from question edit)</p> <pre><code>static class DictionaryExtensions { public static TValue FindSingle&lt;TKey, TValue&gt;( this IDictionary&lt;TKey, TValue&gt; dictionary, Func&lt;TValue, bool&gt; predicate) { return dictionary.Values.Single(predicate); } public static IEnumerable&lt;TValue&gt; Find&lt;TKey, TValue&gt;( this IDictionary&lt;TKey, TValue&gt; dictionary, Func&lt;TValue, bool&gt; predicate) { return dictionary.Values.Where(predicate); } } </code></pre> <p>(I'm not sure it is much harder for the caller to do this themselves, though)</p>
.NET best practices? <p>I know it is a broad topic but I'm interested in any of .NET's so-called best practices, though I'm looking for less obvious ones, unlike "use as instead of casting".<br /> Let's see what interesting things I can learn from Stack Overflow users.</p>
<p>First, check out <a href="http://msdn.microsoft.com/en-us/practices/default.aspx" rel="nofollow">patterns &amp; practices</a> - "Use Microsoft's proven practices for software engineering.".</p> <p>Next check out IDesign: .NET Design and Process Solutions.</p> <p>After you dig through those to get some ideas make sure to enable code analysis/<a href="http://en.wikipedia.org/wiki/FxCop" rel="nofollow">FxCop</a> on your code base. Start thoroughly going through each warning.</p> <p>Last, but not least, go check out <a href="http://en.wikipedia.org/wiki/JetBrains" rel="nofollow">JetBrains</a>' software and GET <a href="http://www.jetbrains.com/dotnet/" rel="nofollow">ReSharper</a>. ReSharper (or similar tool, some are available out there) is a must have if you want to be 100% efficient and ensure you code to a high standard with a minimal amount of headache! :)</p> <p>That will get you 99% covered on standards and best practices.</p>
Dynamic Query in SQL Server <p>I have a table with 10 columns as col_1,col_2,.... col_10. I want to write a select statement that will select a value of one of the row and from one of these 10 columns. I have a variable that will decide which column to select from. Can such query be written where the column name is dynamically decided from a variable.</p>
<p>Yes, using a CASE statement:</p> <pre><code>SELECT CASE @MyVariable WHEN 1 THEN [Col_1] WHEN 2 THEN [Col_2] ... WHEN 10 THEN [Col_10] END </code></pre> <p>Whether this is a good idea is another question entirely. You should use better names than Col_1, Col_2, etc.</p> <p>You could also use a string substitution method, as suggested by others. However, that is an option of last resort because it can open up your code to sql injection attacks.</p>
What does the "New ... With" syntax do in VB Linq? <p>What (if any) is the difference between the results of the following two versions of this VB Linq query?</p> <p>' assume we have an XElement containing employee details defined somewhere else</p> <pre><code>Dim ee = From e In someXML.&lt;Employee&gt; _ Select New With {.Surname = e.&lt;Surname&gt;, .Forename = e.&lt;Forename&gt;} </code></pre> <p>and</p> <pre><code>Dim ee = From e In someXML.&lt;Employee&gt; _ Select Surname = .Surname = e.&lt;Surname&gt;, .Forename = e.&lt;Forename&gt; </code></pre> <p>ie what is the point of the New ... With syntax?</p> <p>I suspect that this has a simple answer, but I can't find it - any links to suitable tutorials or Microsoft documentation would be appreciated.</p>
<p>The difference is that the 1st explicitly creates an anonymous type. The 2nd is a query expression, and may use an existing type rather than creating an anonymous type. From the documentation linked by Cameron MacFarland:</p> <blockquote> <p>Query expressions do not always require the creation of anonymous types. When possible, they use an existing type to hold the column data. This occurs when the query returns either whole records from the data source, or only one field from each record.</p> </blockquote>
why windows allowed us to create a folder as "con"? <p>i tried a lot to create a folder names as "con" , but it says the desired device name is not known.. can you tell me why this is happening?? thanks in advance</p> <p><strong>Duplicate of <a href="http://stackoverflow.com/questions/448438/windows-and-renaming-folders-the-con-issue">Windows and renaming folders - the ‘con’ issue</a></strong></p>
<p><strong>con</strong> is a reserved word, from the old DOS days when con was a device name for console. Because of the potential ambiguity from having both a device and folder name the same, Windows does not allow a folder named con.</p>
Google App Engine Query (not filter) for children of an entity <p>Are the children of an entity available in a Query?</p> <p>Given:</p> <pre><code>class Factory(db.Model): """ Parent-kind """ name = db.StringProperty() class Product(db.Model): """ Child kind, use Product(parent=factory) to make """ @property def factory(self): return self.parent() serial = db.IntegerProperty() </code></pre> <p>Assume 500 factories have made 500 products for a total of 250,000 products. Is there a way to form a resource-efficient query that will return just the 500 products made by one particular factory? The ancestor method is a filter, so using e.g. Product.all().ancestor(factory_1) would require repeated calls to the datastore.</p>
<p>Although ancestor is described as a "filter", it actually just updates the query to add the ancestor condition. You don't send a request to the datastore until you iterate over the query, so what you have will work fine.</p> <p>One minor point though: 500 entities with the same parent can hurt scalability, since writes are serialized to members of an entity group. If you just want to track the factory that made a product, use a ReferenceProperty:</p> <pre><code>class Product(db.Model): factory = db.ReferenceProperty(Factory, collection_name="products") </code></pre> <p>You can then get all the products by using:</p> <pre><code>myFactory.products </code></pre>
Do Strongly Typed Datasets improve performance? <p>Where I work we're <em>finally</em> coming around to the idea of using strongly typed datasets to encapsulate some of our queries to sqlserver. One of the idea's I've been touting is the strength of the strongly typed column's, mainly for not needing to cast any data. Am I wrong in thinking that strongly-typed-datasets would improve performance in the following situation where there could be potentially thousands of rows?</p> <p>old way:</p> <pre><code>using(DataTable dt = sql.ExecuteSomeQuery()) { foreach (DataRow dr in dt.Rows) { var something = (string)dr["something"]; var somethingelse = (int)dr["somethingelse"]; } } </code></pre> <p>new way:</p> <pre><code>MyDataAdapter.Fill(MyDataset); foreach (DataRow dr in MyDataset.MyDT.Rows) { var something = dr.Something; var somethingelse = dr.SomethingElse; } </code></pre> <p>If the properties are really just doing the casting behind the scenes, I can see how there wouldn't be any speedup at all; perhaps it would take even longer then before with the overhead of the function call in the first place. </p> <p>Are there any other performance strengths / weaknesses of using DataSets we should know about?</p> <p>Thanks!</p>
<p>I'm not sure if there will be any performance improvements using the strongly typed datasets, however you get the added type safety, and with it compiler errors when you mistype a field name, for example.</p> <p>There's an article in <a href="http://msdn.microsoft.com/en-us/magazine/cc163877.aspx">MSDN magazine</a> about them, to quote a line in it:</p> <blockquote> <p>The speed in accessing a typed DataSet is comparable to the faster techniques in accessing an untyped DataSet (since a typed DataSet is just a layer over an untyped DataSet) and the readability of the typed DataSet is the best</p> </blockquote> <p>Also, as Stuart B pointed out, the Intellisense alone makes it worthwhile.</p>
Visual Studio detaches from application as soon as debugging starts <p>I have a web application that I've always been able to run in Visual Studio and it debugs just fine (breakpoints work, I can pause execution, etc). Recently, the behavior changed suddenly, and a few things happen:</p> <ul> <li>I start debugging, it lauches IE and loads the application, but after a few seconds (sometimes the page hasn't even displayed yet), Visual Studio acts as if debugging has stopped - I'm able to edit code in VS again, and the "Play" button on the toolbar is enabled. The application continues to run in the IE window just spawned, but I'm not attached to it</li> <li>During this few seconds that VS is "debugging", because it detaches, my breakpoints show as hollow - as if I'm set to "Release" mode and they won't be hit. In fact, I have a breakpoint set in Page_Load, and it skips right by. I've checked, and I'm set to debug mode, though the compile mode dropdown is missing from my toolbar (I checked in the build properties to ensure I was in debug mode).</li> </ul> <p>Can anybody shed some light here?</p>
<p>It turns out that this was actually a result of an upgrade to Windows Vista. VS wasn't being "Run as an Administrator", which caused it to lack the rights to attach to other processes for debugging. As a result, debugging would stop right after it started. Changing the VS shortcut to run as an administrator resolved this problem.</p>
What CSS properties can be applied to which HTML elements <p>I'm looking for a source/spec that can tell me what CSS properties can applied to which HTML elements. For instance, the css property; "overflow". I know I can apply this to div, p, textarea but what other elements can I apply this too? Is there a spec somewhere I can reference?</p>
<p>See <a href="http://www.w3.org/TR/CSS2/" rel="nofollow">http://www.w3.org/TR/CSS2/</a> and <a href="http://www.w3.org/TR/CSS/" rel="nofollow">http://www.w3.org/TR/CSS/</a>.</p> <p>For example, regarding your question about the <code>overflow</code> property, see:</p> <p><a href="http://www.w3.org/TR/CSS2/visufx.html#overflow-clipping" rel="nofollow">http://www.w3.org/TR/CSS2/visufx.html#overflow-clipping</a>, stating:</p> <pre><code>'overflow' Value: visible | hidden | scroll | auto | inherit Initial: visible Applies to: block-level and replaced elements Inherited: no Percentages: N/A Media: visual </code></pre>
SQL sort by version "number", a string of varying length <p>I'm trying to create an SQL query that will order the results by a version number (e.g. 1.1, 4.5.10, etc.)</p> <p>Here's what I tried:</p> <pre><code>SELECT * FROM Requirements WHERE Requirements.Release NOT LIKE '%Obsolete%' ORDER BY Requirements.ReqNum </code></pre> <p>Now, the ReqNum field is a string field and unfortunately I can't change it to a float or something like that because I have requirement numbers like <code>162.1.11</code>.</p> <p>When I get the results back, I'll get ordering like this:</p> <pre><code>1.1 1.10 1.11 1.3 </code></pre> <p><strong>How can I write a query that will sort by lexicographic order?</strong> </p> <p>... or,</p> <p><strong>How can I correctly sort the data?</strong></p> <p>Thanks for the input in advance!</p>
<p>For best results, refactor version number storage so that each section has it's own column: MajorVersion, MinorVersion, Revision, Build. Then the ordering problem suddenly becomes trivial. You can also build a computed column for easy retrieval of the full string.</p>
How do you set a directory to have persistent group permissions? <p>We have two users:</p> <ul> <li>user1</li> <li>user2</li> </ul> <p>They both belong to the group 'admin'.</p> <p>We have a directory that has been set to 775. The directory's group has been changed to 'admin'. Each user has full access to write into that directory, though when a user writes a new file to the directory, the group permissions of the folder are not persisted to the file that was written.</p> <p>How should we make it so that files inherit the directory's group permissions?</p> <p>Clarification: when a new file or directory is written, it uses the users' group as the group of the new file, rather than that of the directory, which makes sense - but how do I not make that happen?</p>
<p>You can propagate group permissions by setting the directory's setgid bit (<code>chmod g+s</code>). <strike>This may not be portable across all *nixes and all file systems.</strike></p> <p><a href="http://en.wikipedia.org/wiki/Setuid#setgid_on_directories">http://en.wikipedia.org/wiki/Setuid#setgid_on_directories</a></p> <p><a href="http://www.gnu.org/software/coreutils/manual/html_node/Directory-Setuid-and-Setgid.html">http://www.gnu.org/software/coreutils/manual/html_node/Directory-Setuid-and-Setgid.html</a></p>
What is the best way to embed Firebird Installation in the Installer for my app? <p>My app has its own installer but I have to guide my users to install Firebird on their own.</p> <p>I'd like to install it automatically.</p> <p>Thanks.</p>
<p>You can download Firebird source code. It contains <a href="http://www.jrsoftware.org/isinfo.php" rel="nofollow">InnoSetup</a> script that actually installs firebird on windows targets. You can then modify it to suit your needs. </p> <p>As a side advice, maybe you should consider Inno Setup yourself. </p>
Parameter Problem with Crystal Reports Export <p>I'm trying to export a crystal report to pdf and then email it, but every time I get to the export command, I get a ParameterFieldCurrentValue exception.</p> <p>I've traced the values of the Parameter collection in the ReportDocument and the values are being set there. Also, all four parameters are strings. The first one is set to allow more than one value and also either discrete or range values. The dialog I call sets values for the choosable selections for that parameter. There are no other parameter fields. There are formula fields, in the report however.</p> <p>My code is:</p> <pre><code>SelectionDialog sd = new SelectionDialog(null, null, @"\\er1\common\bfi_apps\ReportMasterTwo\eds\custno.csv", true, false); DialogResult dr = sd.ShowDialog(); string filename = @"c:\documents and settings\aap\desktop\salesanalysis.pdf"; if (dr == DialogResult.OK &amp;&amp; sd.selectedVals != null) { for (int i = 0; i &lt; sd.selectedVals.Count; i++) { ar100SalesABC_edcustom1.Parameter_Customer_Number.CurrentValues.AddValue (sd.selectedVals[i]); } ar100SalesABC_edcustom1.Parameter_Fiscal_period.CurrentValues.AddValue("1"); ar100SalesABC_edcustom1.Parameter_Fiscal_year.CurrentValues.AddValue("2007"); ar100SalesABC_edcustom1.Parameter_Product_Type.CurrentValues.AddValue("F"); ar100SalesABC_edcustom1.ExportToDisk (ExportFormatType.PortableDocFormat, filename); // ERROR HAPPENS HERE // .. emailing code and other stuff } </code></pre> <p>What am I doing wrong? Is there some other way of doing this that is better? I have tried export options, I have tried SetParameter, I keep getting that error.</p>
<p>I ended up using SetParameter instead of the current values method and using a values collection for the multi-valued parameter.</p> <p>Also instead of using the typed report, I used an untyped report document. </p> <p>I also copied over the sql from Crystal Reports and used it to make a dataset. I think the dataset was the part I was missing before.</p> <p>It works now, although it looks nothing like the code above.</p>
Change Properties.settings for a .net deployed application <p><strong>Hi All,</strong></p> <p>I have two .net applications, these applications want to talk to each other, I made a setting in the first project as follows</p> <pre><code>[CompilerGeneratedAttribute()] [GeneratedCodeAttribute("SettingsSingleFileGenerator", "9.0.0.0")] public sealed partial class Settings :ApplicationSettingsBase { [UserScopedSettingAttribute()] [DebuggerNonUserCodeAttribute()] [DefaultSettingValueAttribute("False")] public bool BeginWorking { get { return ((bool)(this["BeginWorking"])); } set { this["BeginWorking"] = value; } } [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("False")] public bool Result { get { return ((bool)(this["Result"])); } set { this["Result"] = value; } } [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("False")] public bool Completed{ get { return ((bool)(this["Completed"])); } set { this["Completed"] = value; } } } </code></pre> <p>the second project may set the BeginWorking setting for the first project in order to tell it to work, and waits for the Completed setting to be set and get the result from the Result setting.</p> <p><strong>Is that possible and how??</strong></p> <p>I feel it may be not easy to answer but excuse me I'm get unable to think more.</p> <p>Thanks All</p>
<p>User level app settings are isolated in a subdirectory of AppData. One app cannot find the settings of another app. Just use a plain file.</p>
What happened to types.ClassType in python 3? <p>I have a script where I do some magic stuff to dynamically load a module, and instantiate the first class found in the module. But I can't use <code>types.ClassType</code> anymore in Python 3. What is the correct way to do this now?</p>
<p>I figured it out. It seems that classes are of type "type". Here is an example of how to distinguish between classes and other objects at runtime.</p> <pre><code>&gt;&gt;&gt; class C: pass ... &gt;&gt;&gt; type(C) &lt;class 'type'&gt; &gt;&gt;&gt; isinstance(C, type) True &gt;&gt;&gt; isinstance('string', type) False </code></pre>
How would you force the System.Net.Socket.Connect() method to use a socks proxy (code injection vs external custom proxy) <p>I'm using WCF's netTcpBinding, which connects directly to an endpoint and doesn't seems to know anything about socks proxies.</p> <p>I need to use a proxy because most of my clients won't allow direct outbound connections, and enforce the use of socks proxies at all times.</p> <ul> <li><p>My first idea was to configure the .net framework to do that, so I edited the machine.config file as follows, but it seems it only works with http proxies (not socks)</p> <pre><code>&lt;system.net&gt; &lt;defaultProxy enabled="true"&gt; &lt;proxy usesystemdefault="False" proxyaddress="foo:1080" bypassonlocal="True"/&gt; &lt;module /&gt; &lt;/defaultProxy&gt; &lt;/system.net&gt; </code></pre></li> <li><p>My second option was to implement a custom binding inheriting from netTcpBinding, and only overriding the connection logic to add the proxy code.</p> <p>I've dissasembled the System.ServiceModel assembly, and unfortunately, a lot of classes are marked as internal (including SocketConnectionInitiator, ConnectionPoolHelper, ClientFramingDuplexSessionChannel and FramingDuplexSessionChannel, and probably others aswell)</p> <p>This makes creating a custom netTcpBinding a huge work, and moreover could cause some problems as new versions of the .net framework are delivered.</p></li> <li><p>Another idea is to inject some code directly into the Socket.Connect() method. This is quite easy to achieve, but I'm not very confident with modifying the inner code of the .net framework. Also, although the socket class isn't marked as sealed, I'm afraid of breaking something, especially in later relases of the framework.</p></li> <li><p>Last idea I've got for now: I could create a little proxy tool, running on the same computer as my software, which would automatically connect to the corporate's socks proxy, and issue the good "connect server" command to the real socks proxy. </p></li> </ul> <p>The latter option is in my opinion the better, but I'm curious to hear other people opinions.</p> <p>What do you think?</p>
<p>Use SocksCap, WideCap, or something, if you can install it to client machines</p> <p>Or implement/find some Socks->HTTP proxy and use that.</p>
Crystal Reports Subreport Using DataSets <p>I use Crystal Reports XI with C# Visual Studio 2005. I am trying to create a subreport from a summary dataset. A simple example would be Company listing with Employees. I load the Company dataset (with CompanyId). I want to create a subreport which is linked by CompanyId whereby the dataset is loaded (obviously) on demand. I can create this subreport if I load all the detail into one monster dataset, but in my real-world implementation this would involve loading millions of detail rows (not an option).</p> <p>Is there a way I can capture the SubReport event and load the dataset from my database connection? I basically want to intercept the subreport link call to build the dataset myself.</p>
<p>This is simply possible. Create 2 data tables in the xsd dataset you have. Get values for these 2 datatables based on a common ID/key value. Copy one dataset table to the other like </p> <pre><code>ds2.Tables.Add(ds1.Tables[0].Copy()); </code></pre> <p>then,</p> <pre><code>rpt.Load(path + @"Report\Report1.rpt"); rpt.SetDataSource(ds2); //datasource is single crystalReportViewer.ReportSource = FFrpt; </code></pre> <p>when ur adding subreport, get the second table as the datasource and its values. add those fields to your subreport, its done !</p> <p>Regards Shyam</p>
In NAnt, can I create a fileset of the files listed in a VS project? <p>I'm rewriting our <a href="http://nant.sourceforge.net/" rel="nofollow">NAnt</a> build scripts to make them cleaner and simpler, as well as more general purpose. </p> <p>One of the steps in our build process is to package certain files into a zip file. Before we had created a <a href="http://nant.sourceforge.net/release/latest/help/types/zipfileset.html" rel="nofollow"><code>fileset</code></a> with lots of included file types, trying to catch everything that might be in the project. This occasionally caused problems when we wanted to include a non-standard file type with the project.</p> <p>I was hoping that I could find a way to create a <a href="http://nant.sourceforge.net/release/latest/help/types/zipfileset.html" rel="nofollow"><code>fileset</code></a> based on the files (and, also, a <em>subset</em> of the files) listed in the Visual Studio project file (.csproj). I could then use this fileset in a <a href="http://nant.sourceforge.net/release/latest/help/tasks/zip.html" rel="nofollow"><code>zip</code></a> task. I haven't found anything that does this automatically (though the now-deprecated <a href="http://nantcontrib.sourceforge.net/release/latest/help/tasks/slingshot.html" rel="nofollow"><code>SLiNgshoT</code></a> task in <a href="http://nantcontrib.sourceforge.net/" rel="nofollow">NAntContrib</a> looked a little promising).</p> <p>I started down the path of trying to do this manually, but have gotten stuck. I have a target that gets the project from the solution (using <a href="http://nant.sourceforge.net/release/latest/help/tasks/regex.html" rel="nofollow"><code>regex</code></a>), then tries to get each Content file in the project using <a href="http://nant.sourceforge.net/release/latest/help/tasks/xmlpeek.html" rel="nofollow"><code>xmlpeek</code></a> (with the XPath query <code>/n:Project/n:ItemGroup/n:Content/@Include</code>). The problem here is that <a href="http://nant.sourceforge.net/release/latest/help/tasks/xmlpeek.html" rel="nofollow"><code>xmlpeek</code></a> doesn't return every value, just the first. And, even if it did return every value, I'm not sure how I'd get it into a <a href="http://nant.sourceforge.net/release/latest/help/types/zipfileset.html" rel="nofollow"><code>fileset</code></a> from here.</p> <p>Is there any way to salvage this track of thinking? Can I accomplish what I want with a custom NAnt task (I'd prefer not to have every project dependent on a custom task)? Is there some built-in way to do this that I'm not finding?</p> <p>Please feel free to ask questions in the comments if something about my goal or method isn't clear.</p> <p>Thanks!</p> <p><hr /></p> <p><strong>UPDATE:</strong> To clarify, my point in all of this is to make the whole process much more seamless. While I can easily add all .xml files to a package, this often gets .xml files that live in the same folder but aren't really part of the project. When I already have a list of the files that the project uses (separated out between Content and other types, even), it seems a shame not to use that information. Ultimately, no one should have to touch the build file to change what gets included in a package. It doesn't seem like too much of a pipe dream to me...</p>
<p>See <a href="http://stackoverflow.com/questions/441614/how-to-query-msbuild-file-for-list-of-supported-targets">this related question</a>. The microsoft.build.buildengine interface should let you get much better access to the information you need, but unfortunately I think you would have to build a custom task. </p> <p>But I think that parsing a project file to generate a fileset that is used elsewhere is ... a bit much to put all inside your build script. And since you seem to want to re-use this, I don't think that depending on a custom task is any worse than any other form of re-use (even if you can do it all in existing Nant tasks, you'd still need to have every project inherit that process somehow).</p>
How to get ctags to pick up functions in a .h file? <p>I am using Exuberant Ctags 5.7. I am trying to build a tag database for CGContext.h with:</p> <pre> tags /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Headers/CGContext.h </pre> <p>The resulting tags file has no functions included in it. It only has 75 lines for types, and enums.</p>
<p>You need to add --c-types=+p (now --c-kinds).</p>
Including a service reference from a class library <p>I have a C# class library and a startup project (a console app). The class library includes a service reference to a web service. When I try to run the project, I get an InvalidOperationException because the startup project isn't reading the class library's app.config, and it's ignoring the service reference. To get it working, I'm forced to add the same service reference to the startup project. Is there any way I can avoid this? Can I make the startup project recognize the class library's service reference and app.config without having to copy it to the startup project?</p> <p>I've tried adding a link to the app.config from the class library, but that doesn't work. The class library isn't very portable if it requires anyone who uses it to add that service reference to the startup project.</p>
<p>Think about what you are trying to do - you have two assemblies that you are building:</p> <pre><code>Library ConsoleApp </code></pre> <p>Both of these assemblies have configuration files - I would imagine they look something like this:</p> <pre><code>Library app.config ConsoleApp ConsoleApp.exe.config </code></pre> <p>When you run <code>ConsoleApp</code> it has no way of reading from or knowing aboout <code>app.config</code> from your <code>Library</code> assembly. The only configuration file that it knows or cares about is <code>ConsoleApp.exe.config</code>. Now it is possible to have configuration files reference each other but this is not the proper solution for what you are trying to do.</p> <p>Since your <code>Library</code> assembly has no entry point, it will never be loaded into an AppDomain. Since it will never be loaded into an AppDomain its application configuration file will never be used.</p> <p>What you ought to do is reference <code>Library</code> in <code>ConsoleApp</code> via a project reference. Then move all the relevant configuration data from <code>app.config</code> into <code>ConsoleApp.exe.config</code> as this is the configuration file that will be used by your application.</p> <p>This will allow you to have to two things you need to invoke methods on your web service</p> <ol> <li>The code in <code>Library</code> that can send and receive SOAP messages. </li> <li>The configuration metadata that is required by <code>Library</code> to function. </li> </ol>
Dead Center for JavaScript Output <p>I'm going to apologize in advance for how basic this question is, but this is my first time using javascript in html.. </p> <p>Basically, I have a javascript that produces a different bit of random text every time a user loads the page. I'd like to format that text in helvetica and then display it centered in the middle of the page. I'm attempting to do this with css as indicated below, but it is not working for me. Any suggestions much appreciated.</p> <p><strong>HTML</strong></p> <pre><code>&lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;title&gt;home&lt;/title&gt; &lt;link href="style.css" rel="stylesheet" type="text/css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="horizon"&gt; &lt;div id="content"&gt; &lt;script type="text/javascript" src="scripts.js"&gt;&lt;/script&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p><strong>CSS</strong></p> <pre><code>#horizon { color: white; background-color: #ffffff; text-align: center; position: absolute; top: 50%; left: 0px; width: 100%; height: 1px; overflow: visible; visibility: visible; display: block } #content { font-family: Helvetica, Geneva, Arial, sans-serif; font-color: black; background-color: white; margin-left: -410px; position: absolute; top: -237px; left: 50%; width: 825px; height: 475px; visibility: visible } </code></pre>
<p>Well for starters, your missing your HTML tags. You need to wrap your HTML code between HTML Tags.</p> <p>Second, you will need to set your text to a different color as the background color. In your CSS, you will need to change the #horizon color to black, or something else.</p> <p>Other than that, your code works.</p>
Parameter vs. Member variables <p>I've recently been working with someone else's code and I realized that this individual has a very different philosophy regarding private variables and method parameters than I do. I generally feel that private variables should only be used in a case when:</p> <ol> <li>The variable needs to be stored for recall later.</li> <li>The data stored in the variable is used globally in the class.</li> <li>When the variable needs to be globally manipulated (something decidedly different from the need to read the variable by every class method).</li> <li>When it will make programming substantially easier. (Admittedly vague, but one has to be in many circumstances to avoid painting oneself into a corner).</li> </ol> <p>(I admit, that many of the above are slightly repetative, but they each seem different enough to merit such treatment... )<br /><br /> It just seems that this is the most efficient means of preventing changing a variable by accident. It also seems like following these standards will allow for the eventual manipulation of external references (if the class is eventually modified), thus leaving you with further options in the future. Is this simply a style issue (like one true bracket or Hungarian naming conventions), or do I have justification in this belief? Is there actually a best practice in this case?</p> <p><strong>edit</strong><br /> I think this needs to be corrected. I used "globally" above where I actually meant, "globally by instance methods" not "globally accessible by anything, anywhere".<br /><br /> <strong>edit2</strong><br /> An example was asked for:</p> <pre><code>class foo { private $_my_private_variable; public function __constructor__() { } public function useFoo( $variable ) { // This is the line I am wondering about, // there does not seem to be a need for storing it. $this-&gt;_my_private_variable = $variable; $this-&gt;_doSometing(); } private function _doSomething() { /* do something with $this-&gt;_my_private_variable. */ // This is the only place _my_private_variable is used. echo $this-&gt;_my_private_variable; } } </code></pre> <p>This is the way I would have done it:</p> <pre><code>class foo { public function __constructor__() { } public function useFoo( $variable ) { $this-&gt;_doSometing( $variable ); } private function _doSomething( $passed_variable ) { /* do something with the parameter. */ echo $passed_variable; } } </code></pre>
<p>In general, class members should represent <em>state</em> of the class object.</p> <p>They are not temporary locations for method parameters (that's what method parameters are for).</p>
Do Python regexes support something like Perl's \G? <p>I have a Perl regular expression (shown <a href="http://stackoverflow.com/questions/529657/how-do-i-write-a-regex-that-performs-multiple-substitutions-on-each-line-except/529735#529735">here</a>, though understanding the whole thing isn't hopefully necessary to answering this question) that contains the \G metacharacter. I'd like to translate it into Python, but Python doesn't appear to support \G. What can I do?</p>
<p>Try these:</p> <pre><code>import re re.sub() re.findall() re.finditer() </code></pre> <p>for example:</p> <pre><code># Finds all words of length 3 or 4 s = "the quick brown fox jumped over the lazy dogs." print re.findall(r'\b\w{3,4}\b', s) # prints ['the','fox','over','the','lazy','dogs'] </code></pre>
MDX Calculating Time Between Events <p>I have a Cube which draws its data from 4 fact/dim tables. </p> <ol> <li><code>FactCaseEvents (EventID,CaseID,TimeID)</code> </li> <li><code>DimEvents (EventID, EventName)</code> </li> <li><code>DimCases (CaseID,StateID,ClientID)</code> </li> <li><code>DimTime (TimeID,FullDate)</code></li> </ol> <p>Events would be: <code>CaseReceived,CaseOpened,CaseClientContacted,CaseClosed</code></p> <p>DimTime holds an entry for every hour.</p> <p>I would like to write an MDX statement that will get me 2 columns: "<code>CaseRecievedToCaseOpenedOver5</code>" and "<code>CaseClientContactedToCaseClosedOver5</code>"</p> <p><code>CaseRecievedToCaseOpenedOver5</code> would hold the number of cases that had a time difference over 5 hours for the time between <code>CaseReceived</code> and <code>CaseOpened</code>.</p> <p>I'm guessing that "<code>CaseRecievedToCaseOpenedOver5</code>" and "<code>CaseClientContactedToCaseClosedOver5</code>" would be calculated members, but I need some help figuring out how to create them.</p> <p>Thanks in advance.</p>
<p>This looks like a good place to use an accumulating snapshot type fact table and calculate the time it takes to move from one stage of the pipeline to the next in the ETL process.</p>
SQL Images -> byte arrays <p>So I am importing some images stored in SQL image columns, and I need to change them to Byte arrays since I store my images as varbinary(max) and recreate them. I would LOVE it if there was a program to do this, or a really easy way since I don't have a ton of time. </p> <p>Any ideas out there?</p>
<p>The image data type in Sql Server is a varbinary field that is being discontinued in future versions.</p> <p>I would bet that a tool like <a href="http://msdn.microsoft.com/en-us/library/ms162802.aspx" rel="nofollow">bcp</a> handles the "conversion" automatically. I use quotes because its a type conversion and not a format conversion.</p>
Django - How to prepopulate admin form fields <p>I know that you can prepopulate admin form fields based on other fields. For example, I have a slug field that is automatically populated based on the title field.</p> <p>However, I would also like to make other automatic prepopulations based on the date. For example, I have an URL field, and I want it to automatically be set to <a href="http://example.com/20090209.mp3" rel="nofollow">http://example.com/20090209.mp3</a> where 20090209 is YYYYMMDD. </p> <p>I would also like to have a text field that automatically starts with something like "Hello my name is author" where author is the current user's name. Of course, I also want the person to be able to edit the field. The point is to just make it so the user can fill out the admin form more easily, and not just to have fields that are completely automatic.</p>
<p>I know that you can prepopulate some values via GET, it will be something like this</p> <pre><code>http://localhost:8000/admin/app/model/add/?model_field=hello </code></pre> <p>I got some problems with date fields but, maybe this could help you.</p>
ActionMailer problem- what is the correct syntax for sending PDF attachments <p>What is the correct syntax for sending an email with actionmailer that includes some PDF file attachments? I am using Gmail for SMTP, with the TLS plugin. Here is what I have so far (and have tried variations on this too):</p> <pre><code>**lead_mailer.rb:** def auto_response(lead) recipients lead.email subject "Information" body :recipient =&gt; lead.first_name from "me@mydomain.com" attachment "application/pdf" do |a| a.body = File.read(RAILS_ROOT + "/public/files/Datasheet.pdf") end attachment "application/pdf" do |a| a.body = File.read(RAILS_ROOT + "/public/files/OtherSheet.pdf") end end **lead_observer.rb:** class LeadObserver &lt; ActiveRecord::Observer def after_save(lead) mail = LeadMailer.create_auto_response(lead) LeadMailer.deliver(mail) end end </code></pre> <p>The problem is that it sends the attachments, but they show up as "no name", even though upon opening them they appear correctly. However, the body of the email does not appear at all. I am sure I am doing something simple, wrong. </p>
<p>Okay I stepped away for a moment and came back and googled a little more and got the answer!</p> <p>From the API:</p> <p>Implicit template rendering is not performed if any attachments or parts have been added to the email. This means that you‘ll have to manually add each part to the email and set the content type of the email to multipart/alternative. </p> <p>For the main mailer method I switched out body and added this explicit render. Note- I skipped the multipart/alternative and it worked, most likely because I am sending a plain text email.</p> <pre><code>part :body =&gt; render_message('auto_response', :recipient =&gt; lead.first_name) </code></pre> <p>For the attachment naming issue, this is what I did:</p> <pre><code>attachment "application/pdf" do |a| a.body = File.read(RAILS_ROOT + "/public/files/OtherSheet.pdf") a.filename = "Othersheet.pdf" end </code></pre>
Best Way to Transfer Large Files in Windows <p>I often have to transfer large files >50GBs sometimes >100GBs between drives both internal and external during backups of our networks email servers. What is the best method of transferring these files? Command Line such as XCOPY? Possibly something robust enough to continue the transfer if interrupted due to time limits or network issues.</p>
<p>Check out <a href="http://en.wikipedia.org/wiki/Robocopy">robocopy</a>. From Wikipedia:</p> <blockquote> <p>robocopy, or "Robust File Copy", is a command-line directory replication command. It was available as part of the Windows Resource Kit, and introduced as a standard feature of Windows Vista and Windows Server 2008.</p> </blockquote>
How to get rid of the "default" form-element from a .aspx-page? <p>As that web-standards geek I am, I dislike the default <code>&lt;form runat="server"&gt;</code> that surrounds my entire webpages. I've seen many ASP.NET based webpages that don't have these, so it seems like it can be removed without taking away any functionality. How?</p>
<p>There will have to be a <code>&lt;form runat="server"&gt;</code> if you wish to use controls 'n stuff. Otherwise postbacks are impossible, as is viewstate and the rest of the stuff that .NET depends upon.</p> <p>Are you sure you've seen what you've thought you've seen? Perhaps these pages only contained static content? Or perhaps they were user-controls? Or yet another common possibility - perhaps it was the Master Page that had the <code>&lt;form runat="server"&gt;</code>?</p>
Is it possible to display a message in an empty datagrid <p>I have a datagrid which is populated with CSV data when the user drag/drops a file onto it. Is it possible to display a message in the blank grid for example "Please drag a file here" or "This grid is currently empty". The grid currently displays as a dark grey box as I wait until the file is dragged to setup the columns etc.</p>
<p>We subclassed the DataGridView control and added this. We didnt need the drag/drop functionality - we just needed to tell the user when there was no data returned from their query.</p> <p>We have an emptyText property declared like this:</p> <pre><code> private string cvstrEmptyText = ""; [Category("Custom")] [Description("Displays a message in the DataGridView when no records are displayed in it.")] [DefaultValue(typeof(string), "")] public string EmptyText { get { return this.cvstrEmptyText; } set { this.cvstrEmptyText = value; } } </code></pre> <p>and overloaded the PaintBackground function:</p> <pre><code> protected override void PaintBackground(Graphics graphics, Rectangle clipBounds, Rectangle gridBounds) { RectangleF ef; base.PaintBackground(graphics, clipBounds, gridBounds); if ((this.Enabled &amp;&amp; (this.RowCount == 0)) &amp;&amp; (this.EmptyText.Length &gt; 0)) { string emptyText = this.EmptyText; ef = new RectangleF(4f, (float)(this.ColumnHeadersHeight + 4), (float)(this.Width - 8), (float)((this.Height - this.ColumnHeadersHeight) - 8)); graphics.DrawString(emptyText, this.Font, Brushes.LightGray, ef); } } </code></pre>
JDBC and Connection Pools in Glassfish App Server <p>I want to set up a connection pool and JDBC connection on EAR deployment so I do not have to set it up on each App Server I deploy to manually. What do I need to do? Is there an .xml file I can put this information into?</p>
<p>If you are using a single GlassFish administration console to manage multiple application servers throughout your environment, those application servers can share a common configuration. If each deployed application server has its own administration console, you can write a script to call the CLI (asadmin) to create and configure the connection pools. Actually, you can use the CLI to configure a distributed deployment in the 1st use case, but you'll have to specify which configuration you are modifying. The CLI is good for automation.</p> <p>Hopefully the following resources help:</p> <ul> <li><a href="http://docs.sun.com/app/docs/doc/820-4341/abdjl?a=view" rel="nofollow">http://docs.sun.com/app/docs/doc/820-4341/abdjl?a=view</a></li> <li><a href="http://wiki.glassfish.java.net/Wiki.jsp?page=GlassFishV2Architecture" rel="nofollow">http://wiki.glassfish.java.net/Wiki.jsp?page=GlassFishV2Architecture</a></li> <li><a href="http://docs.sun.com/app/docs/doc/820-4332/6nfq988or?a=expand" rel="nofollow">http://docs.sun.com/app/docs/doc/820-4332/6nfq988or?a=expand</a> (for asadmin CLI reference)</li> <li><a href="http://docs.sun.com/app/docs/doc/820-4332/create-jdbc-connection-pool-1?a=view" rel="nofollow">http://docs.sun.com/app/docs/doc/820-4332/create-jdbc-connection-pool-1?a=view</a> (see --target to specify the target in a multi-host deployment)</li> </ul> <p>John Clingan, GlassFish Group Product Manager</p>
What happened to clockless computer chips? <p>Several years ago, the 'next big thing' was clockless computers. The idea behind it was that without a clock, the processors would run significantly faster.</p> <p>That was then, this is now and I can't find any info on how it's been coming along or if the idea was a bust...</p> <p>Anyone know?</p> <p>For reference:</p> <p><a href="http://www1.cs.columbia.edu/async/misc/technologyreview_oct_01_2001.html">http://www1.cs.columbia.edu/async/misc/technologyreview_oct_01_2001.html</a></p>
<p>Here's <a href="http://www1.cs.columbia.edu/async/misc/technologyreview_oct_01_2001.html">an article from a few years ago</a> that's gung-ho on the technology, but I think the answer can be found in this quote:</p> <blockquote> <p>Why, for example, did Intel scrap its asynchronous chip? The answer is that although the chip ran three times as fast and used half the electrical power as clocked counterparts, that wasn't enough of an improvement to justify a shift to a radical technology. An asynchronous chip in the lab might be years ahead of any synchronous design, but the design, testing and manufacturing systems that support conventional microprocessor production still have about a 20-year head start on anything that supports asynchronous production. Anyone planning to develop a clockless chip will need to find a way to short-circuit that lead.</p> <p>"If you get three times the power going with an asynchronous design, but it takes you five times as long to get to the market—well, you lose," says Intel senior scientist Ken Stevens, who worked on the 1997 asynchronous project. "It's not enough to be a visionary, or to say how great this technology is. It all comes back to whether you can make it fast enough, and cheaply enough, and whether you can keep doing it year after year." </p> </blockquote>
Best Way to Modify/Format Database Data in the Controller? <p>Let's say that in the controller I get an array of objects from the database this way:</p> <pre><code>@statuses = TwitterStatus.find(:all, :order =&gt; "tweet_id DESC", :include =&gt; :twitter_user) </code></pre> <p>Also I have the following loop in the view:</p> <pre><code>&lt;% unless @statuses.nil? -%&gt; &lt;ol&gt; &lt;% for status in @statuses %&gt; &lt;li&gt;&lt;%= h(status.text -%&gt;/li&gt; &lt;% end -%&gt; &lt;/ol&gt; &lt;% end -%&gt; </code></pre> <p>I have a lot more data in my model class (user info, status_id, etc.) that I would like to put in the view.</p> <p>The problem is that much of this date needs to be change. I need to format the dates a certain way. I would like to insert 'target="_blank"' into any URLs in the "text" field.</p> <p>My first though would be to have something like this in the controller:</p> <pre><code>for status in @statuses status.date = status.date.formatDate status.url = status.date.insertTarget status.user = status.user.doUserstuff #Adding new attribute status.username = status.user.lookupUserName end </code></pre> <p>This just feels kinda lame to me. But, I can't think of anything better.</p>
<p>I want to agree with Aram. My Views were littered with formatting code until I started adding model methods that cleaned them up considerably. In my last app it was Names and Times (an employee scheduling application). </p> <pre><code>class Employee def full_name self.first_name + " " + self.last_name end end </code></pre> <p>And Time was always a pain, time was everywhere in my views(and vital to the app). So everywhere I wanted to display start time, instead of calling the attribute I had stored in the database, I called a custom method</p> <pre><code>class Schedule def formatted_start_time self.start_time.strftime('%I:%M%p') end end </code></pre> <p>Also as a final note, If you continue formatting time the same way everywhere in your views, you can extend the Time class and make your calls much more succinct. In my initializers folder I added a ''conversions.rb' file where I added this little line</p> <pre><code>Time::DATE_FORMATS.update(:shift =&gt; '%I:%M%p') </code></pre> <p>Now all I do is is call: </p> <pre><code>time_object.to_s(:shift) </code></pre> <p>to return my frequently used formatted string anywhere in the application. You can have a whole list of your favorite formats to clean up your views and make them more understandable. </p>
Going from VisualStudio generated Database stuff to Programmer Generated <p>I'd like to be able to better access the database so I can execute queries (primarily because I don't understand/know the API for it, but I do know SQL). I don't want to remove everything Visual Studio has done because a lot is already built upon it, but how can I get an object that I can use to execute SQL queries.</p> <p>This is Visual Studio 2008, C#, and MSSQL</p>
<p>Try something like <a href="http://blog.biztalk-info.com/archive/2008/06/19/Execute_SQL_Query_from_within_a_C_function.aspx" rel="nofollow">this</a>:</p> <pre><code>using (SqlConnection conn = new SqlConnection("Connection String Goes Here")) { conn.Open(); using (SqlCommand comm = new SqlCommand("SELECT * FROM TABLE", conn)) { return command.ExecuteScalar() as string; } } </code></pre> <p>Don't forget to add: </p> <pre><code>using System.Data; using System.Data.SqlClient; </code></pre>
iPhone UIWebview -- Saving an image already downloaded <p>I have an iPhone app with an embedded UIWebview (Safari) control. I'd like to be able to store the images from certain webpages locally. </p> <p>Can I programmatically access the path where UIWebview downloads images? Or do I need to parse the HTML and then go find the image resource out on the net and download it again?</p>
<p>I do not know if you can access the preloaded images from Safari's cache...</p> <p>However you can easily find the image URLs without parsing HTML, by running a bit of javascript instead:</p> <pre><code>NSString *script = @"var n = document.images.length; var names = [];" "for (var i = 0; i &lt; n; i++) {" " names.push(document.images[i].src);" "} String(names);"; NSString *urls = [webView stringByEvaluatingJavaScriptFromString:script]; // urls contains a comma-separated list of the image URLs. </code></pre>
Taking code and design from other Websites. Ripoff or Standard? <p>While designing my site I am constantly faced with the issue of whether its ok to TAKE ideas and designs from other sites. In some cases there is no distinction in certain aspects. Is there anything ethically wrong with this? Is this expected in the design programming community? </p>
<p><strong>Depends on how much you 'steal'.</strong></p> <p><em>Code</em></p> <p>If you're ripping off the whole design, then its a bit dodgy. If you like (for example) the Stack Overflow concept of voting up stuff, then steal the concept and use it in a different manner. If you want to know how say the orange highlighting of the up-voted items works, then look at the code. But don't do both and steal both the concept and the design, you'll just create a clone.</p> <p>Due to the way different web browsers treat CSS and the like, there are often only a very few limited ways to do a particular thing (3-column layouts, etc.). It seems fair enough to blatantly copy in these cases where there is a common way of doing things. Where its something unique, and there's many ways of doing it, it seems a bit more off to blatantly copy.</p> <p><em>Graphics</em></p> <p>Ripping off graphics - not so okay. Images have been around a lot longer than code so copyright law, etc. probably suits them better. If nothing else you have to contend with possible watermarks or other metadata to identify the original source. It's very easy to check for image stealing, less so for code within a larger block.</p> <p>I'm a coder, not a designer so what I tend to do is borrow graphics that I like just while mocking up my web-app for internal use. Does that seem fair? I'll change them for newly-designed or paid-for ones before going live. At least that's the idea, though it could be far too easy to forget and use them by accident.</p> <p>That's the way it works in the newspaper world (well it used to, not sure now with the advent of this there Internet thang): You download as many graphics as you can bother waiting to come over your 57.6k modem; you only pay for the ones you actually publish.</p>
How to execute sp_send_dbmail while limiting permissions <p>Is there a way to provide access to users in my database to execute <strong><code>msdb.dbo.sp_send_dbmail</code></strong> without needing to add them to the MSDB database and the DatabaseMailUserRole?</p> <p>I've tried this:</p> <pre><code>ALTER PROCEDURE [dbo].[_TestSendMail] ( @To NVARCHAR(1000), @Subject NVARCHAR(100), @Body NVARCHAR(MAX) ) WITH EXECUTE AS OWNER AS BEGIN EXEC msdb.dbo.sp_send_dbmail @profile_name = N'myProfile', @recipients = @To, @subject = @Subject, @body = @Body END </code></pre> <p>But I get this error:</p> <pre><code>The EXECUTE permission was denied on the object 'sp_send_dbmail', database 'msdb', schema 'dbo'. </code></pre> <p>Thanks!</p>
<p>Your approach is OK, but your wrapper proc must be in the msdb database. Then, you execute "EXEC msdb.dbo._TestSendMail"</p> <p>This still leave the issue of permissions on dbo._TestSendMail in msdb. But public/EXECUTE will be enough: it only exposes the 3 parameters you need.</p> <p>If in doubt, add WITH ENCRYPTION. This is good enough to stop anyone without sysadmin rights viewing the code</p> <pre><code>USE msdb GO CREATE PROCEDURE [dbo].[_TestSendMail] ( @To NVARCHAR(1000), @Subject NVARCHAR(100), @Body NVARCHAR(MAX) ) -- not needec WITH EXECUTE AS OWNER AS BEGIN EXEC dbo.sp_send_dbmail @profile_name = N'myProfile', @recipients = @To, @subject = @Subject, @body = @Body END </code></pre>
SFTP Libraries for .NET <p>Can anyone recommend a good SFTP library to use? Right now I'm looking at products such as SecureBlackbox, IPWorks SSH, WodSFTP, and Rebex SFTP. However, I have never used any SFTP library before so I'm not sure what I'm looking for.</p> <p>If anyone has used these before, is there any reason why I should go with product "X" over "Y"?</p> <p>Thanks!</p>
<p>I've searched around and found that <a href="https://bitbucket.org/mattgwagner/sharpssh" rel="nofollow">this fork of SharpSSH</a> and <a href="https://github.com/sshnet/SSH.NET" rel="nofollow">SSH.NET</a> are the most up to date and best maintained libraries for <a href="http://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol" rel="nofollow">SFTP</a> (not to be confused with <a href="http://en.wikipedia.org/wiki/FTPS" rel="nofollow">FTPS</a>) communication in .NET. SSH.NET is a clean .NET 4.0 implementation of the SFTP protocol, and I've used it in a couple of solutions with flying colors and great success.</p> <p>The original <a href="http://sourceforge.net/projects/sharpssh/" rel="nofollow">SharpSsh</a> seems to be dead and most other solutions either require installation of Windows executables or a bucketload of cash (or worse; both).</p>
Linking to a static lib that links to a static lib <p>I have a (managed/unmanaged C++) winforms app that links to a static library. That library links to another static library. When I do a Rebuild on the Winforms project, Visual Studio 2005 attempts to rebuild the references static library, but does not rebuild deeper than one level. This causes me to have to manually rebuild the leaf project and then rebuild up the chain to the Winforms project. Is there a way to force a deeper rebuild?</p>
<p>Should I just add all static libs as dependancies to the Winform app?</p>
RTF editor <p>I have a templates written in RTF(with some tags which are replaced by data from DB in app), but when I edit them in MS Word, Word put some invisible tags to the templates, which destruct my tags(I must open template in Notepad and edit code). Do you know some editor for RTF, which strict follows RTF specification?</p> <p>Thanks</p>
<p>On Windows, the included app Wordpad is pretty decent in my opinion.</p>
Why does a WPF BitmapImage object not download an image from a Uri Source in ASP.Net Web Forms? <p>I'm trying to accomplish the following in ASP.Net:</p> <ol> <li>Create a WPF Canvas control</li> <li>Spin up a WPF Image control and a BitmapImage object</li> <li>Set the BitmapImage source to a Uri for an image</li> <li>Add the image to the canvas</li> <li>When the image is downloaded render the canvas to a new bitmap</li> </ol> <p>My code works correctly in WPF itself, however when running in an ASP.Net page the image is not downloaded.</p> <p>It works totally fine for other WPF UI elements. In the case of Image, using the BitmapImage.StreamSource property to set the source works correctly. When I use the BitmapImage.UriSource property the BitmapImage.DownloadCompleted event isn't raised, which hints that the image never starts downloading in the first place.</p> <p>It's important to note that it works fine for most controls - ellipses, rectangles, ink presenters, and also the Image control so long as I use a stream source rather than a uri source.</p> <p>So, what am I missing here? Why does the BitmapImage class behave differently in a web application?</p> <p>I know I'll get asked so the purpose in doing this is that I have written a Silverlight client to create graphical content which is stored on a web server. I want the web server to render the content to bitmap files.</p> <p>Thanks in advance for any advice..</p> <p>Here's my code for the ASP.Net page:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Windows.Controls; using System.Windows.Media.Imaging; using System.Threading; using System.Windows; using System.Net; using System.IO; using System.Windows.Media; public partial class _Default : System.Web.UI.Page { private static Canvas c; protected void Page_Load(object sender, EventArgs e) { Thread t = new Thread(new ThreadStart( delegate { DownloadAndSave(); })); t.SetApartmentState(ApartmentState.STA); t.Start(); t.Join(); } [STAThread] void DownloadAndSave() { c = new Canvas(); BitmapImage bitmap = new BitmapImage(); System.Windows.Controls.Image image = new System.Windows.Controls.Image(); bitmap.DownloadCompleted += new EventHandler(bitmap_DownloadCompleted); bitmap.BeginInit(); bitmap.UriSource = new Uri("http://andrew.myhre.tanash.net/customassets/andrewmyhre/image/face.jpg"); bitmap.EndInit(); image.Source = bitmap; c.Children.Add(image); c.UpdateLayout(); c.Measure(new Size(400, 300)); c.Arrange(new Rect(new Size(400, 300))); } void bitmap_DownloadCompleted(object sender, EventArgs e) { // this never fires!! SaveImage(c); } void SaveImage(UIElement element) { RenderTargetBitmap bmp = new RenderTargetBitmap(400, 300, 96, 96, PixelFormats.Pbgra32); bmp.Render(element); BitmapEncoder encoder = new JpegBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bmp)); using (Stream stm = File.Create(Server.MapPath("~/file.jpg"))) encoder.Save(stm); } } </code></pre>
<p>Did you verify that adding the STAThread attribute to the DownloadAndSave method actually makes it run in a STA thread? </p> <p>According to the documentation of the STAThreadAttribute (<a href="http://msdn.microsoft.com/en-us/library/system.stathreadattribute.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.stathreadattribute.aspx</a>) does it not have any effect on other methods that the main entry method, e.g. Main in a WinForms application.</p> <p>I guess you should look in that direction - I have had similar problems with WPF image functions that required STA.</p>
Deploying bluechannel with fastcgi <p>I am trying to get a basic blue-channel website running through fcgi, I have a django.fcgi file. How do I do this. Thank you</p>
<p><a href="http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#apache-setup" rel="nofollow">Read The Fabulous Manual</a></p>
Webserver Location - How important is it for SEO? <p>I am based in the UK and have two webservers, one German based (1&amp;1) and the other is UK based (Easyspace).</p> <p>I recently signed up to the UK easyspace server because it was about the same price I paid for my 1&amp;1 server but also I wanted to see if my sites hosted on a UK server gave better results in terms of UK based traffic.</p> <p>Its seems my traffic is roughly the same for both servers... however 1&amp;1 server performance and customer service is much better than Easyspace so I was thinking about cancelling it and getting another 1&amp;1 server.</p> <p>I understand about latency issues where USA/Asia would be much slower for UK traffic but I am just wondering what your thoughts are traffic, SEO etc and if you think I should stick with a UK server or if it doesn't matter? </p> <p>Looking forward to your replies.</p>
<p>I have never heard of common search engines ranking sites by their response time as it is highly variable due to the nature of the internet. If a search engine would penalize you for the subnet you are on then you likely have bigger problems.</p>
Python 2.x gotcha's and landmines <p>The purpose of my question is to strengthen my knowledge base with Python and get a better picture of it, which includes knowing its faults and surprises. To keep things specific, I'm only interested in the CPython interpreter.</p> <p>I'm looking for something similar to what learned from my <a href="http://stackoverflow.com/questions/512120/php-landmines-in-general">PHP landmines</a> question where some of the answers were well known to me but a couple were borderline horrifying.</p> <p>Update: Apparently one maybe two people are upset that I asked a question that's already partially answered outside of Stack Overflow. As some sort of compromise here's the URL <a href="http://www.ferg.org/projects/python_gotchas.html">http://www.ferg.org/projects/python_gotchas.html</a></p> <p>Note that one or two answers here already are original from what was written on the site referenced above.</p>
<p><strong>Expressions in default arguments are calculated when the function is defined, <em>not</em> when it’s called.</strong> </p> <p><strong>Example:</strong> consider defaulting an argument to the current time:</p> <pre><code>&gt;&gt;&gt;import time &gt;&gt;&gt; def report(when=time.time()): ... print when ... &gt;&gt;&gt; report() 1210294387.19 &gt;&gt;&gt; time.sleep(5) &gt;&gt;&gt; report() 1210294387.19 </code></pre> <p>The <code>when</code> argument doesn't change. It is evaluated when you define the function. It won't change until the application is re-started.</p> <p><strong>Strategy:</strong> you won't trip over this if you default arguments to <code>None</code> and then do something useful when you see it:</p> <pre><code>&gt;&gt;&gt; def report(when=None): ... if when is None: ... when = time.time() ... print when ... &gt;&gt;&gt; report() 1210294762.29 &gt;&gt;&gt; time.sleep(5) &gt;&gt;&gt; report() 1210294772.23 </code></pre> <p><strong>Exercise:</strong> to make sure you've understood: why is this happening?</p> <pre><code>&gt;&gt;&gt; def spam(eggs=[]): ... eggs.append("spam") ... return eggs ... &gt;&gt;&gt; spam() ['spam'] &gt;&gt;&gt; spam() ['spam', 'spam'] &gt;&gt;&gt; spam() ['spam', 'spam', 'spam'] &gt;&gt;&gt; spam() ['spam', 'spam', 'spam', 'spam'] </code></pre>
Dojo - XHTML validation? <p>Is it possible to make Dojo (javascript) widgets validate for XHTML?</p> <p>If so, how?</p> <p>Can it be something as simple as using CDATA?</p>
<p>Yes, instead of using the dojoType="dojo.foo.bar" non-standard attribute, you instead need to have a document onload event that "takes over" standard HTML tags in your document and rewrites them into Dojo ones.</p>
-[NSURLRequest sendSynchronousRequest:returningResponse:error:] getting back HTTP headers <p>I'm trying to pull out HTTP Headers and an HTTP Response Code from a synchronous HTTP request on the iPhone. I generally don't have any issues doing this with asynchronous requests, although a bit of trouble here. The HTTP Response Headers are null and HTTP Status Code is 0. Web server is configured proper and I can retrieve the details I need in an asynchronous requests. Here's my code copied out to a command line program:</p> <p>Problem #1: [httpResponse allHeaderFields] returns nil.<br /> Problem #2: [httpResponse statusCode] returns 0.</p> <p>Am I wrong in understanding that if there is an error, which I'm now seeing as: Error Domain=NSURLErrorDomain Code=-1012 UserInfo=0x14b100 "Operation could not be completed. (NSURLErrorDomain error -1012.)", that I do not get access to http response headers/status code? </p> <pre><code>#import &lt;Foundation/Foundation.h&gt; int main (int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSString *urlStr = @"http://tmp/myscript.php"; NSString *postBody = @"foo=bar"; NSMutableURLRequest *request; NSData *postData = [postBody dataUsingEncoding:NSASCIIStringEncoding]; NSError *error; NSURLResponse *response; NSHTTPURLResponse *httpResponse; NSData *dataReply; id stringReply; request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:urlStr]]; [request setHTTPMethod: @"POST"]; [request setHTTPBody:postData]; [request setValue:@"text/xml" forHTTPHeaderField:@"Accept"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; dataReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error]; stringReply = (NSString *)[[NSString alloc] initWithData:dataReply encoding:NSUTF8StringEncoding]; // Some debug code, etc. NSLog(@"reply from server: %@", stringReply); httpResponse = (NSHTTPURLResponse *)response; int statusCode = [httpResponse statusCode]; NSLog(@"HTTP Response Headers %@", [httpResponse allHeaderFields]); NSLog(@"HTTP Status code: %d", statusCode); // End debug. [[NSRunLoop currentRunLoop] run]; [pool release]; return 0; } </code></pre>
<p>The error code you got is NSURLErrorUserCancelledAuthentication and is documented in <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSURLErrorUserCancelledAuthentication" rel="nofollow">Foundation Constants Reference</a>. You might be trying to load a password-protected page, in which case you may have to add a username and password to the URL.</p>
Best way to preserve user-generated HTML across a post request? <p>I am building a site that is an interface used to create XML files that are read as input by a server side program.</p> <p>The website allows users to dynamically create blocks of HTML. Each block can be thought of as an object and contains several input fields. When the user submits the form, the data is turned into an XML file. </p> <p>What is the best way to preserve/rebuild the user generated HTML across the post request? I am using JQuery, but not AJAX.</p>
<p>You're probably looking for XML's <a href="http://www.w3schools.com/XML/xml_cdata.asp" rel="nofollow">CDATA</a>.</p> <pre><code>&lt;post&gt; &lt;![CDATA[ &lt;p&gt;Hello, world! &lt;span style="color: green;"&gt;Green text&lt;/span&gt; &lt;!-- oops, didn't close the p! --&gt; &lt;ul&gt; &lt;li&gt;list &lt;li&gt;doesn't &lt;li&gt;have closing &lt;li&gt;&amp;lt;/li&gt; (note the lack of use of &amp;gt;) &lt;/ul&gt; ]]&gt; &lt;/post&gt; </code></pre> <p>Just be sure to escape the <code>]]&gt;</code> in the user's input, else they may exploit your use of <code>CDATA</code> and mangle your XML!</p>
A serious issue with jQuery and ActiveX security? <p>Has anyone not noticed that JQuery uses ActiveX controls?</p> <p>When a user has limited their activex security they will get script prompt popups and a yellow bar accross the top of their browser window. -This setting is by default on Windows Servers. -Internet Cafe's dont support Active X. -Company internal workstations dont support this.</p> <p>Considering this I don't see how people can use JQuery in a commercial application.</p> <p>Do you use JQuery in a commercial application? Does this concern you? Do you think I should be concerned with this?</p>
<p>Only spot where <code>ActiveX</code> is mentioned in the jQuery code is for the <code>ActiveXObject</code> which is used for XMLHttpRequests: </p> <pre><code>// Create the request object; Microsoft failed to properly // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available var xhr = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); </code></pre> <p>There's an open <a href="http://dev.jquery.com/ticket/3623" rel="nofollow">issue here</a> ... seems like jQuery doesn't fallback to use the native XMLHttpRequest on IE7 (this is probably what you're experiencing).</p> <p>Also this might help: <a href="http://www.mail-archive.com/discuss@jquery.com/msg06791.html" rel="nofollow">link</a></p>
.NET Optimized Int32 <p>While reading through the 70-536 training kit, it states: </p> <blockquote> <p>The runtime optimizes the performance of 32-bit integer types (Int32), so use those types for counters and other frequently accessed integral variables.</p> </blockquote> <p>Does this only apply in a 32 bit environment? Does Int64 take over in a 64 bit environment, or is Int32 still the better choice?</p>
<p>That's a funny way to put it. The runtime doesn't have much to do with it. The CPU is designed for processing 32-bit integers, which is why they're the most efficient to use.</p> <p>In a 64-bit environment, it again depends on the CPU. However, on x86 CPU's at least (which, to the best of my knowledge, is the only place .NET runs), 32-bit integers are still the default. The registers have simply been expanded so they can fit a 64-bit value. But 32 is still the default.</p> <p>So prefer 32-bit integers, even in 64-bit mode.</p> <p><em>Edit:</em> "default" is probably not the right word. The CPU just supports a number of instructions, which define which data types it can process, and which it can not. There is no "default" there. However, there is generally a data size that the CPU is designed to process efficiently. And on x86, in 32 and 64-bit mode, that is 32-bit integers. 64-bit values are generally not more expensive, but they do mean longer instructions. I also believe that at least the 64-bit capable Pentium 4's were significantly slower at 64-bit ops, although on recent CPU's, that part shouldn't be an issue. (But the instruction size may still be)</p> <p>Smaller than 32-bit values are somewhat more surprising. Yes, there is less data to transfer, which is good, but the CPU still grabs 32-byte at a time. Which means it has to mask out part of the value, so these become even slower.</p>
Seemingly random crashes with VB.NET and COM Interop <p>I'm thinking of rewriting a brand new VB.NET application in VB 6.</p> <p>The application runs under terminal services and makes heavy use of COM.</p> <p>For some reason, there is random weirdness with the application -</p> <ul> <li>Random Access Violation errors (WinDbg exception analysis points into dll's like comdlg32.dll, mscorwks)</li> <li>Random Buffer Overflow errors (same)</li> <li>Random errors in general - for example this line in Form.Load sometimes throws - Me.Icon = Resources.MyIcon</li> </ul> <p>I have followed all possible advice concerning resources, garbage collection, disposal patterns, etc... It just doesn't seem to do any good.</p> <p>I'm thinking there is hardware problems. This runs on a Win2k3 virtual machine under terminal services. The base server OS is Win2k3 with 64 GB RAM. The server has many virtual machines each running it's own "stuff" (Exchange, etc..).</p> <p>Either there's hardware problems, or the .NET environment is not as easy to program against as one may think.</p> <p>If the hardware were somehow verified (a entirely different story) and the application continued to behave as such would it be a feasible route to take (rewrite closer to the metal)?</p> <p>I'm not a big fan of virtual machines and doubt their integrity. (Especially on huge servers.)</p> <p><strong>Edit</strong> - Thanks to all for the responses. The issue turned out to be a single .NET .DLL in my application that was not being targeted to x86 code. The COM objects are all 32 bit, the OS is 64 bit, thus my .NET application needs to be targetted to 32 bit. (This explains why my sample VB6 apps always worked. Not that I <em>really</em> wanted to go that route anyway.)</p>
<p>Install PDB files and use <a href="http://www.microsoft.com/downloadS/details.aspx?FamilyID=28bd5941-c458-46f1-b24d-f60151d875a3&amp;displaylang=en" rel="nofollow">"Debug Diagnostics Tool 1.1"</a> for monitoring you app, for identify were leak occurs. <br></p> <p>View this too <a href="http://stackoverflow.com/questions/522580/good-tools-for-analysing-com-object-registry-interference/522670#522670">"Good tools for analysing COM object registry interference?"</a></p>
How to match a set using Linq-2-Sql <p>I'm trying to figure out how to do this, and I"m stumped. I'm sure it's something simple that I'm just missing.</p> <p>Say I have a table that is a collection of names, and I want to check if a subset of those names exist like this:</p> <pre><code>var names = new List{ "John", "Steven", "Mary"}; var dbNames = from n in Db.Names where n.FirstName == //names ???; </code></pre> <p>Is there anyway to do this?</p> <p>Thanks!</p>
<pre><code>where names.Contains(n.FirstName) </code></pre> <p>Although you have to watch the types you call this on -- some of the Contains methods won't get translated to LINQ-to-SQL. You might need to cast it to IEnumerable or IQueryable first, or something.</p>
Delphi TeeChart only showing one record from dataset <p>Using Delphi Steema TeeChart component, if I link a BarSeries to a dataset using the user interface, it shows up fine, but if I do it using code (which I need to), it's only showing one bar, even when I have several records in the database. What am I doing wrong?</p> <p>Code:</p> <pre><code>var i:Integer; Bar:TBarSeries; begin ADataSet.Close; ADataSet.LoadFromDataSet(mtbl); ADataSet.Active := true; ADataSet.First; ASource.DataSet := ADataSet; Bar := TBarSeries.Create(AChart); Bar.Assign(Series2); Bar.ParentChart := AChart; Bar.DataSource := ASource; Bar.XLabelsSource := 'Date'; Bar.YValues.ValueSource := 'Load'; for i := 0 to AChart.SeriesCount - 1 do begin AChart.Series[i].CheckDataSource; end; </code></pre> <p>ADataSet is a DevExpress MemData (TdxMemData). When I run the program, the X axis is only showing one bar, the first record in the dataset, even though I have 4 records in the dataset.</p>
<p>This code works for me (using an Access database with fields ID and Height, I dropped a TDBChart, TADODataSet, and a TButton on a form):</p> <pre><code>procedure TForm1.Button1Click(Sender: TObject); var Bar : TBarSeries; begin ADODataSet1.Close; ADODataSet1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;...'; Bar := TBarSeries.Create(DBChart1); DBChart1.AddSeries(Bar); Bar.ParentChart := DBChart1; Bar.DataSource := ADODataSet1; Bar.XLabelsSource := 'ID'; Bar.YValues.ValueSource := 'Height'; ADODataSet1.Active := true; end; </code></pre> <p>Note that the Datasource should be a TTable, TQuery, or TDataSet (not a TDataSource - go figure!).</p> <p>Hope this helps.</p>
Changing namespace of the WPF Project Template <p>When I modify the xaml's cs's I will have to go in and manually modify the corresponding *.g.cs file. And it seems to get overwritten every time I rebuild.</p> <p>So my question is, what is the proper way to change the namespace on a WPF application that has been generated by the WPF project template?</p>
<p>Since the .g.cs files are generated from the .xaml files, besides changing the namespace in the .xaml.cs files, you also have to change the namespace in the .xaml files.</p> <p>For example, the main window in one of my projects is declared like this in mainwindow.xaml:</p> <pre><code>&lt;Window x:Class="Penov.Playground.MainWindow"&gt; </code></pre> <p>The corresponding mainwindow.xaml.cs file contains:</p> <pre><code>namespace Penov.Playground { public class MainWindow } </code></pre> <p>If I want to change the namespace from Penov.Playground, I need to change it in both places. This would result in a .g.cs files generated on the next build with the new namespace.</p>
Design order: Firefox, IE, or both? <p>When coding new javascript heavy websites, which order or web browser do you code for?</p> <p>I can see these possible orders, but I am not sure which I like best:</p> <ol> <li>Code for one first and get it working well, then start testing with other and fix errors as I go. <ul> <li>This will allow for the most rapid development (with Firefox at least) but I've learned from experience that debugging IE with so much going on at once can be a pain!</li> </ul></li> <li>Code for both at the same time. In other words, for each new feature, ensure it works with both browsers before moving on. <ul> <li>This seems like it will actually take more time, so maybe do several features in Firefox then move to IE to patch them up.</li> </ul></li> </ol> <p>What do you all do?</p> <p><strong>Edit 1:</strong> To respond to a couple of answers here.: @JQuery usage: For some reason I was not expecting this kind of a response, however, now that this seems to be the overwhelming accepted answer, I guess I should tell everyone a few more things about the specifics of my app. This is actually the <a href="http://stackoverflow.com/questions/521723/reflective-web-application">DynWeb</a> that I started another question for, and as I'm developing, a lot of the important code seems to require that I use document.whatever() instead of any JQuery or Prototype functions that I could find. Specifically, when dynamically importing changing CSS, I have to use some similar to:</p> <pre><code>var cssid = document.all ? 'rules' : 'cssRules'; //found this to take care of IE and Firefox document.styleSheets[sheetIndex][cssid][cssRule].style[element] = value; </code></pre> <p>And I expect that I will have to continue to use this kind of raw coding currently unsupported by either JQuery or Prototype in the future. So while I would normally accept JQuery as an answer, I cannot as it is not a solution for this particular webapp.</p> <p>@Wedge and bigmattyh: As the webapp is supposed to build other webapps, part of the criteria is that anything it builds look and work functionally the same in whatever browsers I support (right now I'm thinking Firefox and IE7/8 atm, maybe more later on). So as this is a more interesting (and much more complicated) problem; are there any sites, references, or insights you may have for specific trouble areas (css entities, specific javascript pitfalls and differences, etc.) and how to avoid them? I'm almost certain that I am going to have to have some sort of <code>isIE</code> variable and simply perform different actions based on that, but I would like to avoid it as much as possible.</p> <p>Thanks for your input so far! I will keep this open for the rest of the day to see what others may have to say, and will accept an answer sometime tonight.</p>
<p>This is sort of a trick question. In my opinion you need to work in this order:</p> <p><strong>1: Conform to Standards</strong></p> <p>This gets you closest to working in every browser without having to test against every browser. Additionally, you gain the huge benefit that your site should work with any new browser that comes along (Chrome is a good example) so long as it's well made and standards compliant. It also makes it easier to tweak your site to work in specific browsers because the way that the popular browsers deviate from standards compliance is well known.</p> <p><strong>2: Support the Most Used Browsers <em>(For Your Site)</em></strong></p> <p>Note carefully the distinction between the breakdown of browser usage on the internet vs. browser usage <em>on your site</em>. On the internet as a whole IE is the most popular browser with Firefox a close second and Safari, Opera, and Chrome taking up most of the remainder. However, the demographics of your site's visitors can turn these numbers upside down. On sites that cater to a more technically savvy crowd it's common for firefox to be the dominant browser with IE in the distinct minority.</p> <p><strong>3: Support Other Browsers as Needed</strong> </p> <p>You need to be very explicit about the fact that browser compatibility is an operating cost for your site, and you need to decide where you draw the line. Depending on your site's purpose and business model it may be fine to support only the most popular browsers, or even a subset of them. On the other hand, it may be a vital business concern to support everything under the Sun, including IE5. It's ok to make a conscious decision to not fully support every browser if you think the cost/benefit ratio is too high to justify it. Indeed, many of the most popular sites on the internet do not work well in older and niche browsers. Though you should strive to make your site still functional in the least popular browsers, even if there are serious appearance or usability problems. </p>
Unregistering RemotingConfiguration unregister well known type <p>How to Unregister RemotingConfiguration unregister well known type</p>
<p>This might help you?</p> <p><a href="http://www.codeproject.com/KB/dotnet/Advanced%5FRemoting.aspx" rel="nofollow">http://www.codeproject.com/KB/dotnet/Advanced_Remoting.aspx</a></p>
Is the SMPP (binary SMS) protocol dead? <p>Has anyone dealt with the SMPP binary SMS protocol? I know this technology is still fairly widely used by the messaging aggregators and carriers, but it seems like the SMPP spec is not being updated, and support for SMPP libraries is slowly fading away. The "SMS Forum" (<a href="http://www.smsforum.net/">http://www.smsforum.net</a>) was shut down in 2007.</p> <p>To me, it feels like the protocol is dying in favor of web-service interfaces, but I was curious what other people think.</p>
<p>Since SMPP is used mainly by wireless operators, the answer to your question will depend a lot on what market/region/country you are dealing with. </p> <p>I have experience with Latin American wireless companies, and can tell you that although more and more companies are hiding their SMPP servers behing HTTP webservices (that provide them more flexibility) the SMPP protocol is still a requirement to connect to a lot of Wireless companies, so it's definitely not dead.</p> <p>And if you look inside those Wireless companies, the smpp protocol is very much alive in their internal networks and in the inter-connections with other carriers.</p> <p>It's true that the SMPP spec hasn't changed in a long time, but that's not a bad thing actually. The protocol has matured, and there seems to be no interest from the carriers in expanding it to include new functionality, specially because they have found the flexibility they need in custom HTTP APIs </p> <p>And regarding library implementations of SMPP, <a href="http://www.kannel.org/news.shtml">Kannel</a> is in active development, although I wouldn't recommend it's use. Unfortunately most of the successful long-term implementations that I have seen of SMPP clients have been home grown implementations</p>
Initialising an instance variable with a method from the class <p>Can I initialize an instance variable in Java, when I initialise it when I declare it, and initialise it with the return value of a method, which I define later in the class. </p> <p>Something like this:</p> <pre><code>public class MyClass { integers[] myArray = new integers[length()]; int length() { .... } } </code></pre> <p><code>length()</code> gives me some number, and I want this number to determine the number of elements in the array. It seems plausible to me, but I get <code>NullPointerException</code> (I don't know whether this mistake initialization is causing the exception, but I don't know what exactly, and because I have never done this initialization before, I am not sure it is correct).</p>
<p>Seems to work fine for me, with the method static or not static:</p> <pre><code>public class test { public int[] myarray = new int[this.length()]; public int length() { return 5; } public static void main(String[] args) { test foo = new test(); for (int element : foo.myarray) { System.out.println(element); } } } </code></pre> <p>Which produces:</p> <pre><code>0 0 0 0 0 </code></pre>
Any Static Code Analysis Tools for Stored Procedures? <p>Are there any <a href="http://en.wikipedia.org/wiki/Static_code_analysis">static code analysis</a> tools for <a href="http://en.wikipedia.org/wiki/Stored_procedure">stored procedures</a> written particularly in <a href="http://en.wikipedia.org/wiki/PL_SQL">PL/SQL</a> and <a href="http://en.wikipedia.org/wiki/Transact-SQL">T-SQL</a>?</p>
<p>For T-SQL, Microsoft has the database edition of VS Team Suite (although, I believe its now in the dev SKU). This link talks about writing your own static code analysis rule for T-SQL: <a href="http://blogs.msdn.com/gertd/archive/2009/01/01/creating-t-sql-static-code-analysis-rules.aspx">http://blogs.msdn.com/gertd/archive/2009/01/01/creating-t-sql-static-code-analysis-rules.aspx</a></p>
When do structs not live on the stack? <p>I'm reading through Jon Skeet's book reviews and he is going over the <a href="http://msmvps.com/blogs/jon_skeet/archive/2008/03/21/book-review-head-first-c.aspx" rel="nofollow">numerous inaccuracies</a> of <a href="http://rads.stackoverflow.com/amzn/click/0596514824" rel="nofollow">Head First C#</a>. </p> <p>One of them caught my eye:</p> <blockquote> <p>[Under Errors Section] Claiming that structs always live on the stack. </p> </blockquote> <p>In what situations would structs <em>not</em> live on the stack? This goes contrary to what I thought I knew about structs.</p>
<p>One common example is where the struct is a member of an object that is allocated in the heap. There is lots of additional detail in this question here. <a href="http://stackoverflow.com/questions/13049/whats-the-difference-between-struct-and-class-in-net">What’s the difference between struct and class in .Net?</a></p>
LINQ-to-SQL select filter <p>Is there a way to ensure a particular conditional clause is added to the expression tree on each select from a particular table? </p> <p>For example, a table with a field with the date a record was deleted should never come back or be included in any kind of statement. </p> <p>Rather than include a where clause each time, is there a way, without creating a view, to add a conditional to each select?</p> <p>--- Edit for clarity below ---</p> <p>I'm looking for a function I can partial, much like the Insert/Update/Delete functions, but for Selecting. I want to apply a blanket filter to all queries against a table. </p> <p>Furthermore, if I get a collection of items from a parent, I want that set to be filtered as well. </p> <p>Something like:</p> <pre><code>Private Function BaseItems() As IQueryable(Of Item) Return (From mi In dataContext.Items Where mi.DeletedAt Is Nothing Select mi) End Function Public Function GetItems() as list(of Item) Return (From mi in BaseItems() select mi).ToList() End Function </code></pre> <p>works for functions I write and call. ITEMS, can be a child of MASTER, for example. </p> <pre><code>'assume TheMaster is a LinqToSQL data class which has a one to many child of Items TheMaster.Items.Count '&lt;-- will bring back all Items. </code></pre> <p>How do I always filter what populates by data classes?</p>
<p>You should be able to do this my putting the items into a list and then use lambda expressions to filter the list?</p> <pre><code>MyListObject.Where(x =&gt; x == x.Date); </code></pre>
String manipulation without memory leaks? <p>I'd like to do a series of string substitutions to removed xml-escaped chars such as <code>'&amp;amp;'</code>. </p> <p>1) Is there an existing UIKit function that can do this?</p> <p>2) If not, what's the best way to do it without leaking memory? Here's the idea:</p> <pre><code>-(NSString*) unescape:(NSString*)string { string = [string stringByReplacingOccurrencesOfString:@"&amp;apos;" withString:@"'"]; string = [string stringByReplacingOccurrencesOfString:@"&amp;amp;" withString:@"&amp;"]; string = [string stringByReplacingOccurrencesOfString:@"&amp;quot;" withString:@"\""]; string = [string stringByReplacingOccurrencesOfString:@"&amp;gt;" withString:@"&gt;"]; string = [string stringByReplacingOccurrencesOfString:@"&amp;lt;" withString:@"&lt;"]; return string; } </code></pre> <p>But doesn't that leak memory with each assignment? Or does stringByReplacingOccurrencesOfString return autoreleased strings? How do we confirm that stringByReplacingOccurrencesOfString strings are autoreleased? Or should we wrap them with <code>[... autorelease]</code>?</p> <p>Even if they are autoreleased, it's preferable to avoid autorelease on the iPhone. (See <a href="http://kosmaczewski.net/2009/01/28/10-iphone-memory-management-tips/" rel="nofollow">here</a>). So then we would do:</p> <pre><code>-(NSString*) unescape:(NSString*)string { NSString* string2 = [string stringByReplacingOccurrencesOfString:@"&amp;apos;" withString:@"'"]; // don't release 'string' because we didn't allocate or retain it NSString* string3 = [string2 stringByReplacingOccurrencesOfString:@"&amp;apos;" withString:@"'"]; [string2 release]; NSString* string4 = [string3 stringByReplacingOccurrencesOfString:@"&amp;apos;" withString:@"'"]; [string3 release]; //...and so on } </code></pre> <p>But that's pretty ugly code. What's the best way to write this code to do multiple substitutions? How would you do it?</p>
<p>Any cocoa method which returns a new object via a method that does not start with <code>init</code> or contain the word <code>copy</code> will return an autoreleased object. So the above code should have noleaks.</p> <p>Although it may be easier to use a NSMutableString here. Then you just modify the string in place rather than creating a pile of autoreleased string objects, which should make things cleaner.</p> <p>Also, how about a dictionary of mappings that you iterate through, finding the <code>key</code> and replacing with the <code>value</code> of each item. Maybe even save this as a plist in your app for easy tweaking later.</p>
Post a KeyEvent to the focused component <p>What is the best way to post a Button Press to a component? I tried using the Robot class and it works, normally. However, this class has some problems under some Linux platforms, so I wonder what is the best Java-only way to post an event to a component.</p> <p>In this particular case, I want to post backspace events to a JTextField when I press a button.</p> <p><strong>EDIT: I've used the Robot class after all. I fixed the problem that prevented this class from working correctly under Linux</strong></p>
<p>You can find example of such key post event, like in <a href="http://www.koders.com/java/fid0A047C32296B5D1311C4B7D28D7A663F37068D02.aspx?s=backspace+dispatchEvent#L52" rel="nofollow">this class</a></p> <p>Those posts are using the <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Component.html#dispatchEvent%28java.awt.AWTEvent%29" rel="nofollow">dispatchEvent()</a> function</p> <pre><code>public void mousePressed(MouseEvent event) { KeyboardButton key = getKey(event.getX(), event.getY()); [...] KeyEvent ke; Component source = Component.getFocusComponent(); lastPressed = key; lastSource = source; key.setPressed(true); if(source != null) { if((key == k_accent || key == k_circle) &amp;&amp; (lastKey instanceof KeyboardButtonTextJapanese)) { int accent = ((KeyboardButtonTextJapanese)lastKey).getAccent(); if(accent &gt;= 1 &amp;&amp; key == k_accent) { /* ** First send a backspace to delete the previous character, then send the character with the accent. */ source.dispatchEvent(new KeyEvent(source, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), 0, k_backspace.getKeyEvent(), k_backspace.getKeyChar())); source.dispatchEvent(new KeyEvent(source, KeyEvent.KEY_TYPED, System.currentTimeMillis(), 0, k_backspace.getKeyEvent(), k_backspace.getKeyChar())); </code></pre>
CSS Specificity and normalising your stylesheets after a tight deadline <p>I have just finished building a heavyweight long sales page, with a lot of elements and varying styles on the page.The CSS has ended up being over specific with its selectors, and there are numerous rounded boxes, background images etc. In short, the CSS is a bit of a mess. (only myself to blame!)</p> <p>Can anyone suggest a method of going through this stylesheet methodically, in an effort to combine my duplicate properties etc? I doubt there are any tools to do this for me, but I'm wondering how others deal with this situation?</p> <p>Thanks. </p>
<ol> <li>Combine CSS to their shorthand properties if possible.</li> <li>Take advantage of unique dom ids to apply styles to the children of that element.</li> <li>You can use multiple CSS classes on the same element, for example class="somestyle some-other-style". Using this you can take duplicated CSS styles and define them in one.</li> <li>Use the * selector to apply styles to all the children.</li> <li>If its all in one big CSS file, split the code into sections where the styles are relevent to the pages across your site, i.e /* MEMBERS PAGE */</li> <li>Run the style through an online compressor to reduce code size. Some even combine elements automatically for you, further adding less complexity.</li> </ol> <p>That should get you started. It's hard to add further, it really depends on how your html code and structure is set out. If you could provide an idea we could assist further.</p>
WCF Memory Performance InstanceContextMode <p>I've been learning my way around WCF and I've got a question regarding the InstanceContextMode.</p> <p>Correct me if I'm wrong, but the WCF will instantiate your object, then call the service method on it per call by default.</p> <p>You can then set it to be PerSession or Single.</p> <p>It seems to me that it would make more sense to have something between session and call which could reuse your object. I.e if my service were reentrant, then I could open connections to databases etc. in the constructor, then leave the object in memory to answer calls concurrently.</p> <p>But in the current WCF implementation, it seems that it will always recreate the object no matter what.</p>
<p>The samples here</p> <p><a href="http://msdn.microsoft.com/en-us/library/aa967565.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa967565.aspx</a></p> <p>show how to use extensibility to exercise more fine-grained control over how instances are created and destroyed (e.g. pooling).</p>
A problem with batch file <p>I created a batch file, to uninstall my application. My problem is that as result, this uninstallation deleted some files but kept others. </p> <p>For example one, I created a folder in <code>C:\\Documents and settings\User-Name\myCompanyName\My Application name\</code> This folder contains all files for my application. Now when I uninstall, all these files are deleted. But I want to delete "myCompanyName" folder too from "C:\Documents and settings\User-Name"</p> <p>The other problem tied with the previous one is that I added a new folder to the start menu called <code>myComapny</code> It holds 4 files:</p> <ol> <li>exe file</li> <li>config file </li> <li>help file, and </li> <li>uninstall file </li> </ol> <p>When I click on the uninstall file, it removes everything but <strong>still keeps</strong> the folder in the start-menu containing the four files I just listed.</p> <p>How could I delete the unwanted folders through the <strong>batch file</strong>?</p> <p>Here is my batch file code:</p> <pre><code> @echo off msiexec /x {DD75996F-C279-420A-9A19-48EF9EFE70C2} RD /s "C:\Program Files\ASGATech" RD /s "C:\Documents and Settings\%userprofile%\start menu\programs\ASGATech" pause </code></pre> <p>NOTE: I tried to change the extension of the batch file from <code>bat</code> to <code>cmd</code> I also tried to get the current login user %userprofile% to go to his/her start menu. If this way is wrong, please inform me.</p>
<p>Remove the C:\Documents and Settings - this is already in the %userprofile% tag.</p> <p><code>RD /s "%userprofile%\start menu\programs\ASGATech"</code></p>
What are the best practices to speed up site development with CMS? <p>How can I speed up site development with a particular CMS if I need to build a lot of sites? Should I prepare a few different solutions based on barebone CMS but with pre-built components and deploy them if similar site is being requested for production? Or should I use some solution generator like <a href="http://Joomla-Builder.Com" rel="nofollow">Joomla-Builder</a>? Are there any tools for collaborative development of CMS-based sites?</p>
<p>Version control helps with collaboration. I use git. A good bug tracker keeps everyone in the picture. </p> <p>For tasks I perform over and over (like install and upgrade) I capture these tasks in a build file and run it with Apache Ant. </p> <p>Drupal has install profiles which don't have much documentation but are very helpful once you get the hang of them. This enables you to switch on various components as you see fit. I also run import scripts through them which grab content from CSV files.</p>
JYaml: dump object without including class name <p>I have an <code>ArrayList</code> of objects being dumped to a YAML string and have been comparing the performance of JYaml and SnakeYaml in handling this.</p> <pre><code> ArrayList&lt;HashMap&gt; testList = new ArrayList&lt;HashMap&gt;(); HashMap&lt;String, String&gt; testMap1 = new HashMap&lt;String, String&gt;(); HashMap&lt;String, String&gt; testMap2 = new HashMap&lt;String, String&gt;(); testMap1.put("1_1", "One"); testMap1.put("1_2", "Two"); testMap1.put("1_3", "Three"); testMap2.put("2_1", "One"); testMap2.put("2_2", "Two"); testMap2.put("2_3", "Three"); testList.add(testMap1); testList.add(testMap2); System.out.println(jYaml.dump(testList)); System.out.println(snakeYaml.dump(testList)); </code></pre> <p><br> The output from JYaml includes the serialised object's class name whereas the output from SnakeYaml does not:</p> <p>JYaml output:</p> <pre><code>- !java.util.HashMap 1_1: One 1_3: Three 1_2: Two - !java.util.HashMap 2_1: One 2_2: Two 2_3: Three </code></pre> <p>SnakeYaml output:</p> <pre><code>- {'1_1': One, '1_3': Three, '1_2': Two} - {'2_1': One, '2_2': Two, '2_3': Three} </code></pre> <p><br> I prefer the more 'clean' class name-less output of SnakeYaml as this would be more suitable for a language-neutral environment.</p> <p>I prefer the <em>speed</em> of JYaml. Serialisation/deserialisation times increase <em>linearly</em> with the amount of data being processed, as opposed to <em>exponentially</em> with SnakeYaml.</p> <p>I'd like to coerce JYaml into giving me class name-less output but am quite lost as to how this can be achieved.</p>
<p>How do you measure the speed ? What do you mean 'amount of data' ? Is it a size of a YAML document or an amount of documents ?</p> <p>JYaml output is <strong>incorrect</strong>. According to the specification underscores in numbers are ignored and 1_1 = 11 (at least for YAML 1.1). Because it is in fact a String and not an Integer the representation shall be:</p> <ul> <li>'1_1': One</li> </ul> <p>or canonically</p> <ul> <li>!!str "1_1": !!str "One"</li> </ul> <p>Otherwise when the document is parsed it will create Map&lt;<strong>Integer</strong>, String> instead of Map&lt;<strong>String</strong>, String></p> <p>JYaml has many open issues and does not implement complete YAML 1.1</p> <p>JYaml may indeed be faster but it is due to the simplified parsing and emitting.</p>
Finding patterns in source code <p>If I wanted to learn about pattern recognition in general what would be a good place to start (recommend a book)?</p> <p>Also, does anybody have any experience/knowledge on how to go about applying these algorithms to find abstraction patterns in programs? (repeated code, chunks of code that do the same thing, but in slightly different ways, etc.)</p> <p>Thanks</p> <p>Edit: I don't mind mathematically intensive books. In fact, that would be a good thing.</p>
<p>If you are reasonably mathematically confident then either of Chris Bishop's books "Pattern Recognition and Machine Learning" or "Neural Networks for Pattern Recognition" are very good for learning about pattern recognition.</p>
Debug code security .net framework to use caspol.exe <p>We have an application that is distribute to a varity of customers. Sometime it is installed on a network share. Usually we can give that application access with caspol.exe and grant the LocalIntranet Zone FullTrust. Sometimes the customers admins do not manage to grant that application access due to some network settings. When we launch the exe it opens for a short time and appears in the Client Task Manager and disappears silently... now the question is there a tool which gives me some debugging or tracing details on that. Is there a tool to debug security issues like that... I assueme that this happens before any of my code is executed... and I do not see anything in the event trace neither on the client nor on the server...</p> <p>Any ideas?</p>
<p>Can I recommend - perhaps look at ClickOnce - a click-once application can be hosted on a network share, but has much better security deployment factors. You just run the <code>.application</code> rather than the <code>.exe</code> (VS2005 and VS2008 have all the tools you need to publish a ClickOnce application trivially).</p> <p>Also - in one of the recent service packs (perhaps with 3.5 SP1), I believe that <em>mapped</em> shares get more priveleges - so <code>\\foo\bar\my.exe</code> would still error, but <code>f:\my.exe</code> (to the same location) should work.</p>
Retrieving Client Information from web service request <p>If i have an applicataion requesting a service, is it possible for the web service to determine the name of the application or does this have to be sent within the request?</p>
<p>You can use the UserAgent header of the HTTP request if the application sets it.</p>
Is there a built in URL class in .Net? <p>I'm spending time breaking up URLs into <code>protocol://domain:port/path/filename</code> but there must be a built in class, all I can find is <code>System.Security.Policy.Url</code></p>
<p>I bet <a href="http://msdn.microsoft.com/en-us/library/system.uri.aspx" rel="nofollow">System.Uri</a> is what you're looking for</p>
How can I make a Google Maps custom Overlay object behave like an InfoWindow? <p>My only problem with the InfoWindow is that I don't have a way to customize it's appearance (ie, the bubble, not it's contents). It seems that the only way to do that is to make my own Overlay and style that instead. But that gives me problems such as not being able to select text (dragging the mouse over this overlay just pans the map) or scroll (if the overlay has a div with overflowing text then scrolling causes the map to zoom in or out, clicking on the scroll bar will scroll but it will pan the map at the same time).</p> <p>I'm currently catching the mouseover and mouseout events to disable/enable dragging and zooming but I still can't highlight text and now scrolling the mouse wheel on an area of the overlay that doesn't have anything to scroll causes page elements outside of the map to move up the window.</p> <p>Has anyone else run into a situation like this? I haven't seen anything else that actually covers this and I'm trying not to tear out my hair trying to find a solution.</p>
<p>Great news. It looks like the problem I was experiencing in Firefox was due to my overlay being larger in height than the map container and assuming that Google Maps was setting <pre>overflow: hidden</pre> somewhere (I guess not). Setting it myself fixed that. The next step is to have your overlay container catch the click events and make sure that they aren't propagated as shown in the ExtInfoWindow code: <a href="http://gmaps-utility-library.googlecode.com/svn/trunk/extinfowindow/1.0/src/extinfowindow.js" rel="nofollow">http://gmaps-utility-library.googlecode.com/svn/trunk/extinfowindow/1.0/src/extinfowindow.js</a> (near the end of initialize).</p>
Threading in an Application Server <p>I have a Java program/thread that I want to deploy into an Application Server (GlassFish). The thread should run as a "service" that starts when the Application Server starts and stops when the Application Server closes. </p> <p>How would I go about doing this? It's not really a Session Bean or MDB. It's just a thread.</p>
<p>I've only done this with Tomcat, but it should work in Glassfish.</p> <p>Create a Listener class that implements <a href="http://docs.oracle.com/javaee/7/api/javax/servlet/ServletContextListener.html" rel="nofollow"><code>javax.servlet.ServletContextListener</code></a>, then put it in web.xml. It will be notified when your web app is started and destroyed.</p> <p>A simple Listener class:</p> <pre><code>public class Listener implements javax.servlet.ServletContextListener { MyThread myThread; public void contextInitialized(ServletContextEvent sce) { myThread = new MyThread(); myThread.start(); } public void contextDestroyed(ServletContextEvent sce) { if (myThread != null) { myThread.setStop(true); myThread.interrupt(); } } } </code></pre> <p>This goes in web.xml after your last 'context-param' and before your first 'servlet':</p> <pre><code>&lt;listener&gt; &lt;listener-class&gt;atis.Listener&lt;/listener-class&gt; &lt;/listener&gt; </code></pre> <p>Don't know whether this kind of thing is recommended or not, but it has worked fine for me in the past.</p>
How to add "help"-text to a mex-function? <p>I am writing a Matlab mex-file. However, mex-files seem to have a serious limitation: <code>help mexfilename</code> won't cause a help text to appear.</p> <p>I could circumvent this by writing a m-file, that ultimately calls the mex-file, but includes help, but there has to be a better way.</p> <p>On the other side, that way I could do all the error-checking in the m-file, where it is far more convenient to do so...</p>
<p>I believe PierreBdR is right; you would create an m-file version of your function with just the header call and comment block, but no body.</p> <p>It might not be a bad idea to put the error checking for the inputs in the m-file, then have the m-file invoke the mex-file (you may have to give them different names, though). It may be more straight-forward to check variables in MATLAB (using, for instance, built-ins like <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/nargchk.html">nargchk</a>) and put them into a standard format that you may always want the inputs to the mex function to have. Many of the Image Processing Toolbox functions that I've looked at seem to do this (formatting and checking data in the m-file then doing the expensive computations in a mex-file).</p>
Enhanced Flex textarea / text viewer components? <p>Is there any advanced textarea() component (AS3) for Flex available that could be used for both viewing/exiting text nicely? </p> <p>It would be good to have a text select feature, too. </p>
<p>Grant Skinner's <a href="http://www.gskinner.com/blog/archives/2009/01/editable_multif.html" rel="nofollow">TextFlowPro</a> seems very cool. Not sure what you mean by this question exactly, though.</p>
Problem with php function to catch error on saving image <p>I have a method to save an image, which is meant to deal gracefully with an error, setting $imageSrc to a particular image in the event of failure. My method works fine if the image is present, but no error conditions seems to be handled correctly.</p> <pre><code>$imageSrc = save_pic($PIC_URL, $pk); function save_pic($pic_url, $pk) { $imageDir = './'; if (!strlen($pic_url)) return "removed.jpg"; if (!is_dir($imageDir) || !is_writable($imageDir)) { return "removed.jpg"; } $image = file_get_contents($pic_url); if (empty($image)) { return "removed.jpg"; } $r = file_put_contents($imageDir.$pk.".jpg", $image); if ($r) { return "./$pk.jpg"; } else { return "removed.jpg"; } } </code></pre> <p>If the image does not exist, I get :</p> <pre><code>Warning: getimagesize(http://127.0.0.1/555.jpg) [function.getimagesize]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\Program Files\EasyPHP 2.0b1\www\get_auction.php on line 144 Array ( [type] =&gt; 2 [message] =&gt; getimagesize(http://127.0.0.1/555.jpg) function.getimagesize]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found [file] =&gt; C:\Program Files\EasyPHP 2.0b1\www\get_auction.php [line] =&gt; 144 ) 1 </code></pre> <p>returned.jpg is never returned in any event.</p> <p>edit: added imageResize code:</p> <pre><code>function imageResize($imageURL, $maxWidth, $maxHeight) { global $outputWidth, $outputHeight, $maxWidth, $maxHeight; $size = getimagesize($imageURL); if ($size) { $imageWidth = $size[0]; $imageHeight = $size[1]; $wRatio = $imageWidth / $maxWidth; $hRatio = $imageHeight / $maxHeight; $maxRatio = max($wRatio, $hRatio); if ($maxRatio &gt; 1) { $outputWidth = $imageWidth / $maxRatio; $outputHeight = $imageHeight / $maxRatio; } else { $outputWidth = $imageWidth; $outputHeight = $imageHeight; } } else { die(print_r(error_get_last())); } } </code></pre>
<p>Are you sure you're writing to the root folder? Because I can't see any problem with your code. <code>file_get_contents</code> and <code>file_put_contents</code> don't seem to be failing, so your image is being written somewhere.</p>
Tabs in HTML mode in Emacs <p>So I've started using emacs and I love it. However, I'm a tab person. Unless I'm working on a project that is already using spaces, I use tabs. I mostly do php and html work. I've got tabs in php working well. But I can't figure out how to have html mode use tabs instead of two spaces.</p> <p>Here is what I have so far:</p> <pre><code>(setq c-default-style "python") (setq-default c-basic-offset 4 tab-width 4 indent-tabs-mode t) </code></pre> <p>What can I set so that html mode will use tabs?</p> <p>Edit: Using Emacs 22.3.1</p>
<pre><code>(add-hook 'html-mode-hook (lambda() (setq sgml-basic-offset 4) (setq indent-tabs-mode t))) </code></pre>
Signing in Visual Studio 2005 - error using existing .pfx <ol> <li><p>Built my project.</p></li> <li><p>Created my .pfx using sn.exe -k (to create ShellTradingCCMPROD.pfx).</p></li> <li><p>Copied the file to the application folder.</p></li> <li><p>In VS 2005, I go to the Signing tab, 'Select From File' and browse to the .pfx file. </p></li> <li><p>I hit 'Open' and I get the following error:</p></li> </ol> <p>The file 'C:\2009.02.1.1\ShellTrading.CCM.WinUI\ShellTradingCCMPROD.pfx' could not be imported: Cannot find the requested object.</p> <p>Other .pfx files work - any clues?</p>
<p><code>sn.exe -k</code> does not create a file in the .pfx format. I don't have VS2005 around anymore, but it works in VS2010 when I name the file <code>ShellTradingCCMPROD.snk</code>. The key in this file is not password protected.</p> <p>As far as I know, you cannot use sn.exe to create password protected keys.</p>
How can I make a link in HTML turn a color when hovering and remove the underline using CSS? <p>How can I make a link in HTML turn a color when hovering and remove the underline using CSS?</p>
<p>You want to look at the <a href="http://www.w3.org/TR/CSS2/selector.html#dynamic-pseudo-classes" rel="nofollow">:hover pseudoselector</a>, the <a href="http://www.w3.org/TR/CSS2/colors.html#colors" rel="nofollow">color property</a>, and the <a href="http://www.w3.org/TR/CSS2/text.html#lining-striking-props" rel="nofollow">text-decoration</a> property.</p> <pre><code>a:hover { color: red; text-decoration: none; } </code></pre> <p>To assure your hyperlink is styled as you want (and does not conflict with other style rules), use <a href="http://www.w3.org/TR/CSS2/cascade.html#important-rules" rel="nofollow"><code>!important</code></a>:</p> <pre><code>a:hover { color: red !important; text-decoration: none !important; } </code></pre>
WPF: How to handle errors with a BackgroundWorker <p>I am a bit of a newbie when it comes to windows client programming. I have a background worker that has a DoWork event and a RunCompleted event wired up. If an exception gets thrown in DoWork, I want to make changes to my UI, however, I cant because it is in a different thread. I can communicate the error to RunCompleted, but that doesn't help me either.</p>
<p>call Dispatcher.BeginInvoke. Basically, you want code like this:</p> <pre><code>void UpdateState(WhatEverType someObject) { if (! Dispatcher.CheckAccess()) { Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(()=&gt;UpdateState(someObject)); } else { //make the UI changes here. } } </code></pre>
CATIA-CAA CATKeyboardEvent <p>I know there are only a few CAA Programmers in the world but I try it anyway...</p> <p>I can't get keyboard events to work. I found this code which looks reasonable but the Notification doesn't fire.</p> <pre><code>AddAnalyseNotificationCB(CATFrmLayout::GetCurrentLayout()-&gt;GetCurrentWindow()-&gt;GetViewer(), CATKeyboardEvent::ClassName(), (CATCommandMethod)&amp;PROTrvTreeView::OnKeyboardEvent, NULL); void PROTrvTreeView::OnKeyboardEvent(CATCommand * ipCmd, CATNotification * ipEvt, CATCommandClientData iobjData) { cout&lt;&lt; "KeyboardEvent" &lt;&lt;endl; } </code></pre> <p>Anyone any idea?</p>
<p>There is a much denser group of developers for CAA at:</p> <p><a href="http://www.3ds.com/alliances/c-java-developers/forum/" rel="nofollow">http://www.3ds.com/alliances/c-java-developers/forum/</a></p> <p>The same question came up, with several people mentioning that this API was unauthorized, and therefore you can't rely on it, even if it works. </p> <p>The other samples there are essentially the same code as yours, but the only one that purports to work doesn't use CATKeyboardEvent::ClassName, but instead uses "CATKeybdEvent". Might be worth a try.</p>
Dependency graph for Rails partials <p>In my current Ruby on Rails view we have many views and partials. So many in fact that it's not clear which view uses which partial (which itself may use other partials as well).</p> <p>The question is if there's a tool out there that generates a dependency graph of all views and partials (ideally generating a graph, but that's easy to do) or how you have solved this problem.</p>
<p>I've created a plugin (basically just a rake task) that generates a graph containing all the dependencies of the views and partials for you.</p> <p>Get it at <a href="http://github.com/msales/partial_dependencies/tree/master">http://github.com/msales/partial_dependencies/tree/master</a></p>
PHP Regex Question <p>Would it be possible to make a regex that reads {variable} like <code>&lt;?php echo $variable ?&gt;</code> in PHP files?</p> <p>Thanks</p> <p>Remy</p>
<p>The PHP manual already provides a <a href="http://docs.php.net/manual/en/language.variables.basics.php" rel="nofollow">regular expression for variable names</a>:</p> <pre><code>[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]* </code></pre> <p>You just have to alter it to this:</p> <pre><code>\{[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\} </code></pre> <p>And you’re done.</p> <hr> <p><strong>Edit</strong>   You should be aware that a simple sequential replacment of such occurrences <a href="http://stackoverflow.com/questions/532850/php-regex-question/532937#532937">as Ross proposed</a> can cause some unwanted behavior when for example a substitution also contains such variables.</p> <p>So you should better parse the code and replace those variables separately. An example:</p> <pre><code>$tokens = preg_split('/(\{[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\})/', $string, -1, PREG_SPLIT_DELIM_CAPTURE); for ($i=1, $n=count($tokens); $i&lt;$n; $i+=2) { $name = substr($tokens[$i], 1, -1); if (isset($variables[$name])) { $tokens[$i] = $variables[$name]; } else { // Error: variable missing } } $string = implode('', $tokens); </code></pre>
Change Local path, team explorer <p>Does any one know how to change the local path of the downloaded project in team explorer 2008. I downloaded a project to a wrong directory, now i deleted it and did get latest but i get a message "All files are up to date"</p> <p>Thanks -Mithil</p>
<p>In the source-control explorer click in the "workspaces..." option in the "Workspace:" Dropdown. And then edit your workspace or set a new one.</p> <p>When you recive the message that you mention, you can Get a specific->latest version with all the checkboxes checked.</p>
STOMP Protocol - Connect frame are login / passcode mandatory? <p>I have been using the STOMP protocol in various guises. I have experienced this phenomenon in the PHP, Python and Objective-C libraries for STOMP. The STOMP specification on <a href="http://stomp.codehaus.org/" rel="nofollow">the STOMP website</a> is not specific on this point.</p> <p>Basically, the CONNECT function in all three libraries (although the Python one has now fixed this, it was acknowledged as a bug. The function still sends a login and passcode parameter, even if none are specified. As so..</p> <pre><code>CONNECT login: passcode: </code></pre> <p>The specification is unclear, and I am wondering if anyone has any better idea about this. I am aware some people involved with STOMP and ActiveMQ browse these forums.</p>
<p>ActiveMQ does not require these headers to be sent. Take a look at this telnet session for example</p> <pre><code>$ telnet localhost 61613 Trying ::1... Connected to localhost. Escape character is '^]'. CONNECT ^@ CONNECTED session:ID:nc-example.com-51165-1234432649359-2:0 </code></pre> <p>It connects successfully to the broker without any headers.</p> <p>Cheers</p>
Recompiling a simple Win32 C++ app for x64 <p>I have a small C++ program for Win32, which has the following WinMain:</p> <pre><code>int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) </code></pre> <p>when trying to compile for x64, I get the following error:</p> <pre><code>error LNK2019: unresolved external symbol WinMain referenced in function __tmainCRTStartup </code></pre> <p>What steps must be taken to recompile a simple win32 app for x64?</p> <p>Thank you</p>
<p>Your linker is set to link the executable under the <code>CONSOLE</code> subsystem, thus it's looking for <code>main</code>, you'll need to set the subsystem to <code>WINDOWS</code>.</p>
What is the relationship between "late binding" and "inversion of control"? <p>In <a href="http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay_oop_en" rel="nofollow">his definition</a> of OOP, Alan Kay points out he supports "the extreme late-binding of all things". Does his interest in late-binding share the same motivation as people's interest in IoC?</p> <p>In particular, would it be correct to say that both are motivated by the concept "specify as little as possible, and leave implementation details to be filled in later"?</p>
<p>It depends what you mean by inversion of control - the term has been overloaded to include dependency injection, but they are really different concepts. IoC originally described a method of controlling program flow, whereas DI is specifically concerned with reducing coupling between types. </p> <p>That said, it could be argued that all these methods/patterns/philosophies share the same fundamental principle: to lower the cost of change.</p>
Make QA Drops of Only Selected Builds In CruiseControl.Net <p>CC.Net is creating many builds for us each day. Occasionally we do a bit of manual smoke testing and then a build becomes a QA drop (or release candidate if you prefer). QA drops are just copied to a remove server.</p> <p>I'd like to automate the execution of the qa-drop-copy nant script, against an existing successful build. How can I do that? To phrase my question in a broader way, how are folks automating the publishing to QA of a single selection from the set of successful builds?</p> <p>I envision something like an extra button with the label 'QA Drop' that can trigger the script. It might be next to the Force button (to publish that last build), or even available on each build report page (to publish any build).</p> <p>Thanks, Josh</p>
<p>This is exactly how we have things set up within AnthillPro. On a build record, you have an extra button called "Run secondary process" that can be wired to things like deployments and functional test suites. Click that, select your process, your target environment and off you go.</p> <p>How I've simulated this in other tools is to use the dependency widgets within the CI tool to have a QA deploy "project" that depends on the project I'd like to deploy. With most CI tools that support this, that approach mostly works when you are only deploying the most recent successful build.</p> <p>That approach can work as long as all you want is to get to a QA environment. As you start having several processes to string together some sort of living build or pipeline management strategy is probably required - which may start moving you out of the open source CI tool space.</p> <p>-- Eric</p>
Font Color not setting in Container on DOTNETNUKE <p>The header and body have the correct background color but the fonts look gray. I am running on DOTNETNUKE version 4.9.0 and 4.9.1 and Windows 2003. </p> <p>Thanks</p> <p>test.htm</p> <pre><code>&lt;body class="border"&gt; &lt;div class="PhilosophyHeader" runat="server"&gt;[ACTIONS][ICON]  [TITLE]&lt;/div&gt; &lt;div id="ContentPane" runat="server" class="PhilosophyBody"&gt;&lt;/div&gt; &lt;/body&gt; </code></pre> <p>container.css</p> <pre><code>.PhilosophyHeader { color: #FF0000; font: normal normal bold 100%/normal serif; border: thin #CC9900; background-color: #CC9900; } .PhilosophyBody { background-color: #800000; color: #CC9900; } .border { border: thin #FFFF00 solid; } </code></pre> <p>edit: Removed &lt; header >, it did not effect problem.</p> <p>Answer: The problem was a combination of tags not matched and use of the same name in two containters.</p>
<p>This could be caused by a variety of problems. Without having a website to view it's going to be difficult for anyone here to answer your question.</p> <p>One of the easiest ways to diagnose CSS problems like this is to use the Firefox extension <a href="http://getfirebug.com/" rel="nofollow">Firebug</a>. Inspect the text that is appearing gray and see exactly what styles are being applied to it. The styles are shown in a hierarchy from bottom to top.</p> <p>I don't know if you just formatted your example this way for Stack Overflow, but you should not be including the <code>&lt;head&gt;</code> or <code>&lt;body&gt;</code> tags in your container. DotNetNuke will automatically load the CSS file called <code>container.css</code> if it is in the same directory as your container HTML or ASCX file. It will additionally load any CSS file that has the same name as the container being loaded. For example, if you have a container called <code>MyContainer.ascx</code>, DotNetNuke will automatically load <code>container.css</code> and <code>MyContainer.css</code>, provided they exist.</p>
Joining fact tables in an MDX query <p>I am building and Anaysis Services project using VS 2005. The goal is to analyse advertising campaigns.</p> <p>I have a single cube with 2 fact tables</p> <p>factCampaign: which contains details of what people interviewed thought of an advertising campaign factDemographics: which contains demographic information of the people interviewed</p> <p>These fact tables have a common dimension dimRespodent which refers to the actual person interviewed</p> <p>I have 2 other dimensions (I’ve left non relevant dimensions)</p> <p>dimQuestion: which contains the list of questions asked dimAnswer: which contains the list of possible answers to each question</p> <p>dimQuestion and dimAnswer are linked to factDemogrpahics but not factCampaign</p> <p>I want to be able to run queries to return results of what people thought about campaign (from factCampaign) but using demographic criteria (using dimQuestion and dimAnswer)</p> <p>For example the how many Males, aged 18-25 recalled a particular campaign</p> <p>I am new to OLAP and Analysis Services (2005) so please excuse me if what I am asking is too basic.</p> <p>I have tried the following options</p> <ol> <li>Linking the to factTables in the datasource view using the common RespondentKey. Queries run and return results but the same result is returned regardless of the demographic criteria chosen, i.e. it is being ignored.</li> <li>Creating a dimension from factDemographics. I have tried to connect dimAnswer to factCampaign in Dimension Usage tabe of the Cube Structure but with out success. Either the project just stalls when I try to deploy it or I get the following error (note the attribute hierarchy enabled is set to true)</li> </ol> <p>Errors in the metadata manager. The 'Answer Key' intermediate granularity attribute of the 'Fact Demographics' measure group dimension does not have an attribute hierarchy enabled.</p> <p>I would appreciate any help that anyone can offer. Let me know if you require more info and again apologies if this is a basic question</p>
<p>What you probably need is a many-to-many relationship. There is a whitepaper <a href="http://www.sqlbi.eu/Projects/Manytomanydimensionalmodeling/tabid/80/language/en-US/Default.aspx" rel="nofollow">here</a> which goes through a number of scenarios for m2m relationships including one specifically around surveys and questionaires.</p>
allow .NET 2.0 runtime to run executables from network with full trust <p>Guys, this can't be for real</p> <p>I'm trying to make a .NET 2.0 executable run from a network drive and it turns out that since Microsoft .net 2.0 has no mscorcfg.msc installed on server 2003, in order to get one I have to install the full SDK. I simply want to run the dang thing without downloading 350Mb piece of crap!</p> <p>Sorry for rant... Anyone can think of an easy solution?</p> <p><strong>EDIT1</strong>: There seems to be a misunderstanding as to what is it that I want to achieve. This is for my test environment. I have many virtual machines and all I want is to just disable the dang security altogether. The task seems to be so trivial, yet it seems so far I have to deploy SDK, or 3.5 SP1, or some other multi-terabyte package to every machine in order to achieve it</p>
<p>You can try running the following command from the .NET command prompt -</p> <p><strong>caspol -cg All_Code FullTrust</strong></p> <p>This gives the code group 'All_Code' the full set of permissions.</p>
Ninject : Resolving an object by type _and_ registration name/identifier <p>I am looking for a way to do something like this with Ninject :</p> <pre><code>// Sample from the Unity application block IMyService result = myContainer.Resolve&lt;IMyService&gt;("Data"); </code></pre> <p>( from <a href="http://msdn.microsoft.com/en-us/library/cc440957.aspx">http://msdn.microsoft.com/en-us/library/cc440957.aspx</a> )</p> <p>Is it possible?</p>
<p>Ninject 2.0 has this capability:</p> <pre><code>Bind&lt;IMyService&gt;().To&lt;MyServiceA&gt;().Named("Data"); Bind&lt;IMyService&gt;().To&lt;MyServiceB&gt;().Named("SomethingElse"); kernel.Get&lt;IMyService&gt;("Data"); // will return MyServiceA </code></pre>
What does 'self' refer to in a @classmethod? <p>I thought I was starting to get a grip on "the Python way" of programming. Methods of a class accept self as the first parameter to refer to the instance of the class whose context the method is being called in. The @classmethod decorator refers to a method whose functionality is associated with the class, but which doesn't reference a specific instance.</p> <p>So, what does the first parameter of a @classmethod (canonically 'self') refer to if the method is meant to be called without an instance reference?</p>
<p><a href="http://docs.python.org/library/functions.html#classmethod">class itself</a>:</p> <blockquote> <p>A class method receives the class as implicit first argument, just like an instance method receives the instance.</p> </blockquote> <pre><code>class C: @classmethod def f(cls): print(cls.__name__, type(cls)) &gt;&gt;&gt; C.f() C &lt;class 'type'&gt; </code></pre> <p>and it's <code>cls</code> canonically, btw</p>
Viewing Rails model page works on first view but not subsequent views <p>This is using Rails 2.2.2</p> <p>I have a model that uses the acts_as_flaggable plugin, and on the page I use to display an instance of the model, I list any flags that the model has.</p> <p>When I start my Rails dev server(mongrel) using the standard script/server command, load the page holding the following code, it loads fine:</p> <pre><code>&lt;% @object.flags.each do |flag| %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= time_ago_in_words(flag.created_at) %&gt; ago&lt;/td&gt; &lt;td&gt;&lt;%= flag.flag %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= link_to flag.user.login, user_path(flag.user) %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;% end %&gt; </code></pre> <p>If I reload the page(and on any subsequent views), I get the following NoMethodError error:</p> <pre><code>You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.include? </code></pre> <p>If I restart the dev server, the page loads fine again one time then subsequent views yield the same strangeness.</p> <p>If I remove the line:</p> <pre><code>&lt;td&gt;&lt;%= link_to flag.user.login, user_path(flag.user) %&gt;&lt;/td&gt; </code></pre> <p>The page loads fine and will reload fine from then on.</p> <p>It seems as if the flaggable plugin is having trouble with the user model for some reason, but then why does it work on the first page load? I also can't seem to repeat the problem using script/console.</p> <p>--EDIT--</p> <p>Adding in the stack trace per request. Under normal circumstances I usually can handle this particular error, but the part that is confusing me is why it works the first time.</p> <p>Here is the error page/trace as it appears to me, I hope this proves to be helpful:</p> <pre><code>NoMethodError in Admin#list_flagged Showing app/views/admin/list_flagged.html.erb where line #65 raised: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.include? Extracted source (around line #65): 62: &lt;tr&gt; 63: &lt;td&gt;&lt;%= time_ago_in_words(flag.created_at) %&gt; ago&lt;/td&gt; 64: &lt;td&gt;&lt;%= flag.flag %&gt;&lt;/td&gt; 65: &lt;td&gt;&lt;%= link_to flag.user.login, user_path(flag.user) %&gt;&lt;/td&gt; 66: &lt;/tr&gt; 67: &lt;% end %&gt; RAILS_ROOT: /dev/trunk Application Trace | Framework Trace | Full Trace /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:142:in `create_time_zone_conversion_attribute?' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:75:in `define_attribute_methods' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:71:in `each' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:71:in `define_attribute_methods' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:350:in `respond_to?' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:209:in `method_missing' app/views/admin/list_flagged.html.erb:65 app/views/admin/list_flagged.html.erb:61 app/views/admin/list_flagged.html.erb:24:in `each' app/views/admin/list_flagged.html.erb:24 app/views/admin/list_flagged.html.erb:14 /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:142:in `create_time_zone_conversion_attribute?' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:75:in `define_attribute_methods' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:71:in `each' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:71:in `define_attribute_methods' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:350:in `respond_to?' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:209:in `method_missing' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:359:in `method_missing_without_paginate' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:212:in `method_missing' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:212:in `each' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:212:in `send' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:212:in `method_missing' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:359:in `method_missing_without_paginate' /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.6/lib/will_paginate/finder.rb:167:in `method_missing' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/form_helper.rb:313:in `fields_for' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/form_helper.rb:253:in `form_for' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in `send' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in `render' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/template.rb:73:in `render_template' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/base.rb:256:in `render' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/base.rb:367:in `_render_with_layout' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/base.rb:254:in `render' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1174:in `render_for_file' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:896:in `render_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in `render' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb:8:in `realtime' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in `render' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:868:in `render_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in `render' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb:8:in `realtime' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in `render' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1248:in `default_render' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1254:in `perform_action_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in `call_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in `perform_action_without_caching' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in `perform_action' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in `cache' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in `perform_action' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in `send' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in `process_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in `process_without_session_management_support' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in `process' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:392:in `process' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:183:in `handle_request' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:110:in `dispatch_unlocked' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:123:in `dispatch' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in `synchronize' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in `dispatch' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:132:in `dispatch_cgi' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:39:in `dispatch' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in `process' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `synchronize' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `process' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281 /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:142:in `load_without_new_constant_marking' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:142:in `load' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:142:in `load' /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/servers/mongrel.rb:64 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require' /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/server.rb:49 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' script/server:3 /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:142:in `create_time_zone_conversion_attribute?' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:75:in `define_attribute_methods' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:71:in `each' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:71:in `define_attribute_methods' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:350:in `respond_to?' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:209:in `method_missing' app/views/admin/list_flagged.html.erb:65 /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:359:in `method_missing_without_paginate' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:212:in `method_missing' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:212:in `each' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:212:in `send' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb:212:in `method_missing' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:359:in `method_missing_without_paginate' /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.6/lib/will_paginate/finder.rb:167:in `method_missing' app/views/admin/list_flagged.html.erb:61 app/views/admin/list_flagged.html.erb:24:in `each' app/views/admin/list_flagged.html.erb:24 /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/form_helper.rb:313:in `fields_for' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/form_helper.rb:253:in `form_for' app/views/admin/list_flagged.html.erb:14 /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in `send' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in `render' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/template.rb:73:in `render_template' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/base.rb:256:in `render' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/base.rb:367:in `_render_with_layout' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/base.rb:254:in `render' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1174:in `render_for_file' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:896:in `render_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in `render' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb:8:in `realtime' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in `render' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:868:in `render_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in `render' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb:8:in `realtime' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in `render' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1248:in `default_render' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1254:in `perform_action_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in `call_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in `perform_action_without_caching' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in `perform_action' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in `cache' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in `perform_action' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in `send' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in `process_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in `process_without_session_management_support' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in `process' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:392:in `process' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:183:in `handle_request' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:110:in `dispatch_unlocked' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:123:in `dispatch' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in `synchronize' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in `dispatch' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:132:in `dispatch_cgi' /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:39:in `dispatch' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in `process' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `synchronize' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `process' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281 /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:142:in `load_without_new_constant_marking' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:142:in `load' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:142:in `load' /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/servers/mongrel.rb:64 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require' /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/server.rb:49 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' script/server:3 Request Parameters: None Show session dump --- :user_id: 1 :last_page: http://localhost:3000/ flash: !map:ActionController::Flash::FlashHash {} Response Headers: {"cookie"=&gt;[], "Content-Type"=&gt;"text/html", "Cache-Control"=&gt;"no-cache"} </code></pre> <p>--EDIT #2--</p> <p>Well, I've "fixed" it. Despite the fact that there is a belongs_to relation in the Flag model, I added the following code to the Flag model from acts_as_flaggable:</p> <pre><code>def user User.find(self.user_id) end </code></pre> <p>This code does allow the page to load without error whether it is the first time on the page or the Nth.</p> <p>I would have added this as an answer, but I don't know that I am satisfied with this.</p>
<p>Having experience a similar problem, I'd check your <code>/config/initializers</code> directory. Does it declare some methods or include some modules into the models? If so, it will happen on first load, but the models will get reloaded on subsequent requests without the initializers running again.</p>
Dynamic dispatch and binding <p>Are dynamic dispatch and dynamic binding the same thing?</p> <p>Thanks</p> <p>Maciej</p>
<p>No. </p> <p>Dynamic Dispatch - The actual method group/signature/override chain is bound at compile time. The method called is dependent upon the actual runtime type of the object but no actual interpretation occurs. It will still be a version of the statically bound method. </p> <p>Here is an example in C#. </p> <pre><code>class Foo { public override string ToString() { return "foo's ToString"; } } void Example(object p1) { p1.ToString(); } </code></pre> <p>The call to p1.ToString is an example of dynamic dispatch. The code statically binds to the method ToString. However it is a virtual method so the actual .ToString() called won't be known until runtime but it is <strong>guaranteed</strong> to call a .ToString() method. It will be the ToString of the actual type of p1. So if p1 is actually an instance of Foo, Foo::ToString will be called. </p> <p>Dynamic Binding - The actual method is bound at runtime and is subject to interpretation based on the semantics of the language or reflection framework. This may fail due to an inability to bind.</p> <p>Example:</p> <pre><code>void CallBar(object o) { var method = o.GetType().GetMethod("Bar"); method.Invoke(new object[] {o}); } </code></pre> <p>In this case, we're attempting to invoke the method "Bar" on the object in question. The keyword is attempting. It's entirely possible that "Bar" will not exist on the object. But this is determined at runtime by dynamically binding to the method "Bar". </p> <p>The thing they have the most in common, is both operations (likely) depend on the runtime type of the object. </p> <p><strong>EDIT</strong></p> <p>Added some more examples at the request of the OP</p>