input
stringlengths
51
42.3k
output
stringlengths
18
55k
How to operate with multiple assembly versions in private folders using config? <p>I have a scenario where I have multiple versions of the same assembly that I need to store in the application private folders, in a structure like this:</p> <pre><code>.\My.dll // latest version, say 1.1.3.0 .\v1.1.1\My.dll // version 1.1.1.0 .\v1.1.2\My.dll // version 1.1.2.0 </code></pre> <p>My problem is that the .Net runtime, when asked for one of the older versions, always finds the latest version and then fails due to build number mismatch before trying to probe for a better match.</p> <p>The assemblies are strong named and I'm using this configuration in my app.config:</p> <pre><code>&lt;runtime&gt; &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt; &lt;dependentAssembly&gt; &lt;assemblyIdentity name="My" publicKeyToken="xxxxxxxx" culture="netural" /&gt; &lt;bindingRedirect oldVersion="1.0.0.0-1.1.1.0" newVersion="1.1.1.0" /&gt; &lt;bindingRedirect oldVersion="1.1.3.0-1.1.65535.65535" newVersion="1.1.3.0" /&gt; &lt;codeBase version="1.1.1.0" href="v1.1.1\My.dll" /&gt; &lt;codeBase version="1.1.2.0" href="v1.1.2\My.dll" /&gt; &lt;/dependentAssembly&gt; &lt;/assemblyBinding&gt; &lt;/runtime&gt; </code></pre> <p>Hopefully there is something I have missed here. I know this can be solved in code by listening for the <a href="http://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve.aspx" rel="nofollow">AppDomain.AssemblyResolve</a> event but I would love to see a pure config solution.</p> <p><strong>Update:</strong> So I found the bug, which is as Kent assumed, a typo. I will leave it up to the reader to spot it. That said, without typos resolving works great when using codeBase tags that points to each version. The probing tag does not seem to work in this scenario.</p>
<p>Without seeing the entire solution, I can only assume you have a typo somewhere. I just tried this for myself and - with the help of <a href="http://msdn.microsoft.com/en-us/library/e74a18c4%28vs.71%29.aspx" rel="nofollow">fuslogvw</a>, I was able to get it working.</p> <p>I have three versions of the assembly and the consuming application references an older version than that in its output directory. The CLR finds the redirects and codeBase entry and loads the correct (older) version.</p> <p>I can email you my solution if you provide an email address.</p> <p>Kent</p>
Python - How to calculate equal parts of two dictionaries? <p>I have a problem with combining or calculating common/equal part of these two dictionaries. In my dictionaries, values are lists: </p> <pre><code>d1 = {0:['11','18','25','38'], 1:['11','18','25','38'], 2:['11','18','25','38'], 3:['11','18','25','38']} d2 = {0:['05','08','11','13','16','25','34','38','40', '43'], 1:['05', '08', '09','13','15','20','32','36','38', '40','41'], 2:['02', '08', '11', '13', '18', '20', '22','33','36','39'], 3:['06', '11', '12', '25', '26', '27', '28', '30', '31', '37']} </code></pre> <p>I'd like to check "d2" and know if there are numbers from "d1". If there are some, I'd like to update one of them with new data or receive 3rd dictionary "d3" with only the values that are identical/equal in both "d1" and "d2" like:</p> <pre><code>d3 = {0:['11','25','38'], 1:['38'], 2:['11','18'], 3:['11','25']} </code></pre> <p>Can anyone help me with this?</p> <p>My fault I forgot to be more specific. I'm looking for a solution in Python.</p>
<p>Assuming this is Python, you want:</p> <pre><code>dict((x, set(y) &amp; set(d1.get(x, ()))) for (x, y) in d2.iteritems()) </code></pre> <p>to generate the resulting dictionary "d3".</p> <h3>Python 3.0+ version</h3> <pre><code>&gt;&gt;&gt; d3 = {k: list(set(d1.get(k,[])).intersection(v)) for k, v in d2.items()} {0: ['11', '25', '38'], 1: ['38'], 2: ['11', '18'], 3: ['11', '25']} </code></pre> <p>The above version (as well as Python 2.x version) allows empty intersections therefore additional filtering is required in general case:</p> <pre><code>&gt;&gt;&gt; d3 = {k: v for k, v in d3.items() if v} </code></pre> <p>Combining the above in one pass:</p> <pre><code>d3 = {} for k, v in d2.items(): # find common elements for d1 &amp; d2 v3 = set(d1.get(k,[])).intersection(v) if v3: # whether there are common elements d3[k] = list(v3) </code></pre> <p><hr /></p> <p>[Edit: I made this post community wiki so that people can improve it if desired. I concede it might be a little hard to read if you're not used to reading this sort of thing in Python.]</p>
SharePoint Table of Contents Web Part and export/import <p>After moving a SharePoint MOSS site using stsadm export/import I have found some problems with the Table of Contents Web Part.</p> <p>If I click the Heading of one of the sections in the Table of Contents web part, for example 'Documents' the page errors as it is still trying to look at a sub-site url from the site that I exported from.</p> <p>So in the export site, the site was at <a href="http://sharepoint/sites/dashboard/" rel="nofollow">http://sharepoint/sites/dashboard/</a></p> <p>It is now at the root <a href="http://sharepoint/" rel="nofollow">http://sharepoint/</a></p> <p>Is this a bug? All the sub-links in the web part work fine, it's just the headings.</p> <p>Thanks for any suggestions.</p>
<p>Might be one of the properties on the webpart that has a value from where it was exported from (Site?).</p> <p><a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.webcontrols.tableofcontentswebpart_properties.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.webcontrols.tableofcontentswebpart_properties.aspx</a></p>
Unit test constructor that uses My.Settings <p>I have a constructor that looks like this:</p> <p>Public Sub New() MyBase.New() ws.Url = My.Settings.WebServiceURL End Sub</p> <p>(ws is private)</p> <p>Is there any point in unit testing this?</p> <p>The class did not previously have this constructor.</p>
<p>Is this the only constructor for the class? If so, then you test it every time you test the class, and a separate test is unnecessary. If you had written a separate test, you would have refactored it into the others after the first success.</p>
Splitting html table in ASP.NET <p>I have a html file which has a huge table with 4 columns and multiple rows. I want to display it in an asp 2.0/3.5 page, such that it's first 2 columns appear in one area and other two appear in another area adjacent to it. Some thing like splitting the table in two and displaying. Is there any way i can achieve it?</p>
<p>How do you generate the table? That will determine how you split it.</p> <p>Also, I don't understand the benefit of just putting the two halves side by side. Did you intend to be able to hide one half?</p>
Setting up Visual SVN for real world use <p>I have just setup VisualSVN on my local machine and on our server that hosts our websites. I used the standard default settings when installing the software but I'm a bit confused how to use this with our setup.</p> <p>I have tested the installation and everything appears to be working ok. In Visual Studio 2008, I can connect to and commit the website files to the server successfully using "IP of server/svn/domainname folder". If I point my browser to the url "IP of server/svn/domainname folder" and enter my username and password I see a folder tree with all of the files I just uploaded. So that bits working fine.</p> <p>My question is how could we test the website I just uploaded? On our server all our websites are stored in "C:\sites\domainname" folders. In IIS we map that folder to the domain name so when someone types in domainname.com they get the right website. How do I config the Visual SVN server setup to allow me use the "C:\sites\domainname" setup we currently have?</p> <p>Any help would be greatly appreciated as I'm totally confused by this.</p>
<p>I think you're confused about what VisualSVN is:</p> <blockquote> <p>VisualSVN Server is a package that contains everything you need to install, configure and manage Subversion server for your team on Windows platform. It includes Subversion, Apache and a management console. </p> </blockquote> <p>It's a slick package that contains everything you need to run a Subversion source control server on a Windows machine. I love it. Normally you would not install this on a machine that also hosts websites, and I would definitely not do it on one that hosts public facing sites.</p> <p>Subversion is just a source control system. It doesn't change anything about how you deploy sites.</p>
Sourcesafe command line options <p>I am having an issue with the Microsoft Visual Sourcesafe command line options that I'm hoping someone has run across and can assist me with. </p> <p>I have the following line in a DOS batch file.</p> <pre><code>"c:\Program Files\Microsoft Visual SourceSafe\ss.exe" GET "$/Development Projects/Activity" -GL"C:\Compile\Activity" -R -Q -Yname,password </code></pre> <p>When this line is executed in the batch file the following prompt appears ...</p> <blockquote> <p>Set C:\Compile\Activity as the default folder for project $/Development Projects/Activity?(Y/N)</p> </blockquote> <p>I need to suppress this prompt in order to let the script run unattended. I thought the -Q option would allow silent running but it does not suppress this prompt. </p> <p>I've searched and can't seem to find an option that will remove this prompt. I don't want to set the default folder for the project so I would like to default the answer to "N" if possible.</p>
<p><code>-I-Y</code> Answers Yes to all Yes or No questions</p> <p><a href="http://msdn.microsoft.com/en-us/library/028cya07%28v=vs.80%29.aspx">http://msdn.microsoft.com/en-us/library/028cya07%28v=vs.80%29.aspx</a></p>
How do I make a marquee progress bar in WPF? <p>In Winforms I could set the ProgressBarStyle of a progress bar to Marqee, and that would have the progress bar incriment on its own without having to be set, for processes where I don't know how long its going to take, and no good way to report back to the UI.</p> <p>I would like to do the same in WPF, but I can't find a way to pull it off short of hosting a winform progress bar, which seems counter productive.</p> <p>How can I pull this off in WPF? Do I have to host a winform progress bar?</p>
<p>I think you simply want to set the <em>IsIndeterminate</em> property of the ProgressBar to <em>true</em>. (See <a href="http://sachabarbs.wordpress.com/2009/12/29/better-wpf-circular-progress-bar/">this</a> article, which also has a nice example of a fancy circular progress indicator.)</p>
How scaleable really is a web-services based architecture? <p>Whenever someone talks about a services-based architecture, they often mention scalability, often in the same breath. However, it seems that using services adds more overhead, rather than reducing it, since there is now a protocol, like SOAP or REST, involved. So, does a web services based architecture really add performance benefits as the number of users of, say, a web application, scales by perhaps an order of magnitude? Or are the scalability requirements simply offloaded onto the services, rather than the core application?</p>
<p>Scalability and performance are two separate things. Yes, a service based approach does add the overhead of a network protocol, but this is a minimal sacrifice for the benefits of being able to rapidly adopt well-tested services in any application on the domain.</p> <p>If the overhead of the network is a deal-breaker for the system you want to build then clearly SOA is the wrong choice for you. Remember that not ever service must be accessed over HTTP. I think you would be surprised how fast some protocols (like <code>net.tcp</code>) can be.</p>
C# Extension Methods Architecture Question <p>I recently asked this question: <a href="http://stackoverflow.com/questions/638463">http://stackoverflow.com/questions/638463</a></p> <p>Marc Gravell answer was perfect and it solved my problem. But it gave me something to think about...</p> <p>If and Extension method must be placed on a Static Class and the method itself must be static, why can't we create a static Extension method?</p> <p>I understand that the parameter marked as "this" will be used to allow access to an instance of the object we are extending. What I do not understand is why can't a method be created to be static... it just seems to me that this is a senseless limitation...</p> <p>My question is: Why can't we create an extension method that will work as a static Method?</p>
<p>I expect the real answer is simply: there wasn't a good use-case. For instances, the advantage is that it enables a fluent-API over existing types (that don't themselves provide the logic) - i.e.</p> <pre><code>var foo = data.Where(x=&gt;x.IsActive).OrderBy(x=&gt;x.Price).First(); </code></pre> <p>which enables LINQ:</p> <pre><code>var foo = (from x in data where x.IsActive order by x.Price select x).First(); </code></pre> <p>With static methods, this simply isn't an issue, so there is no justification; just use the static method on the second type.</p> <p>As it is, extension methods are not <em>properly</em> object orientated - they are a pragmatic abuse to make life easier at the expense of purity. There was no reason to dilute static methods in the same way.</p>
Subversion Merge Access Rights <p>I need to limit access to merge changes into the trunk to specific individuals. Is there any way to limit merge rights on specific folders in subversion? I don't want to block merging from branch to branch, only into the trunk.</p>
<p>Can't you make the trunk read-only for those specific people, using Subversion's access control mechanisms?</p> <p>In your <a href="http://svnbook.red-bean.com/en/1.5/svn.serverconfig.pathbasedauthz.html" rel="nofollow"><code>svnaccess</code></a> file:</p> <pre><code>[/MyProject/trunk] me = rw albert = r bernard = r chris = rw </code></pre> <p>would allow you and Chris to make changes (including merges) to the trunk of "MyProject", while only giving read permissions to Albert and Bernard.</p>
How can I compare a float to NaN if comparisons to NaN always return false? <p>I have a float value set to NaN (seen in the Watch Window), but I can't figure out how to detect that in code:</p> <pre><code>if (fValue == float.NaN) // returns false even though fValue is NaN { } </code></pre>
<p>You want <code>float.IsNaN(...)</code>. Comparisons to <code>NaN</code> always return false, no matter what the value of the float is. It's one of the quirks of floating points.</p> <p>That means you can do this:</p> <pre><code>if (f1 != f1) { // This conditional will be true if f1 is NaN. </code></pre> <p>In fact, that's exactly how IsNaN() works. </p>
SQL query to calculate correct leadtime in table (MS Access) <p>I have the following table: <code>log(productId, status, statusDate, department...)</code>, where productId, status and statusDate is the primary key. Example:<br><br> id1 01 01/01/2009<br> id1 02 02/01/2009<br> <strong>id1 03 03/01/2009</strong><br> id1 01 06/01/2009<br> id1 02 07/01/2009<br> <strong>id1 03 09/01/2009</strong><br> id2 01 02/01/2009<br> id2 02 03/01/2009<br> id2 01 04/01/2009<br> <strong>id2 03 06/01/2009</strong><br> id3 01 03/01/2009<br> id3 02 04/01/2009<br><br> I want to make a query that retrieves for each productId in status03, the time that has passed between the first time it reached status01 and status03.Result expected:<br><br> id1 2<br> id1 3<br> id2 4<br><br> Any idea? Thank you</p>
<p>How about:</p> <pre><code>SELECT t.ID, t.Status, t.SDateTime, (SELECT Top 1 SDateTime FROM t t1 WHERE t1.Status = 1 AND t1.ID=t.ID AND t1.SDateTime&lt;t.SDateTime AND t1.SDateTime&gt;= Nz((SELECT Top 1 SDateTime FROM t t2 WHERE t2.Status=3 AND t2.ID=t.ID AND t2.SDateTime&lt;t.SDateTime),0)) AS DateStart, [SDateTime]-[DateStart] AS Result FROM t WHERE t.Status=3 </code></pre>
Pointer to member functions - C++ std::list sort <p>How do i pass a pointer to a member function to std::list.sort()? </p> <p>Is this possible? Thanks</p> <pre><code>struct Node { uint32_t ID; char * Value; }; class myClass { private: uint32_t myValueLength; public: list&lt;queueNode *&gt; MyQueue; bool compare(Node * first, Node * second); bool doStuff(); } bool myClass::compare(Node * first, Node * second) { unsigned int ii =0; while (ii &lt; myValueLength) { if (first-&gt; Value[ii] &lt; second-&gt; Value[ii]) { return true; } else if (first-&gt; Value[ii] &gt; second-&gt; Value[ii]) { return false; } ++ii; } return false; } bool myClass::doStuff() { list.sort(compare); } </code></pre> <p>I want to use a length variable from within the class instead of doing strlen() within the compare function (The Value will always be the same length)</p> <p>Edit: The myValueLength was not the only variable i wanted to access from within the comparison function I just simplified it to make the example shorter. </p>
<p>It is possible. Did you consider using boost::function?</p> <pre><code>list.sort( boost::bind( &amp;myClass::compare, this, _1, _2 ) ); </code></pre> <p>Is your 'compare' function will rely on <strong>this</strong> data? If not - you may simpy make 'compare' function to be <strong>static</strong>. And then it will be</p> <pre><code>list.sort( &amp;myClass::compare ); </code></pre> <p>You can add helper struct to do your comparison and then</p> <pre><code>list.sort( Comparer( myValueLength ) ); struct Comparer { Comparer( uint32_t myValueLength ): length( myValueLength ) {} bool operator() (Node * first, Node * second) { unsigned int ii =0; while (ii &lt; length) { if (first-&gt; Value[ii] &lt; second-&gt; Value[ii]) { return true; } else if (first-&gt; Value[ii] &gt; second-&gt; Value[ii]) { return false; } ++ii; } return false; } uint32_t length; }; </code></pre>
How to zero fill a number inside of an Excel cell <p>How do you zero fill a number to 10 positions inside an excel spreadsheet?</p> <p>i.e. If cell A1 has 1234 how can cell A2 display 0000001234 (10 postions).</p>
<p>=TEXT(A1,"0000000000")</p>
Writing a Macro to Use the Transpose Function Repeatedly <p>I am trying move rows of values into a column in Excel. The transpose function works well, but will only move one row at a time. I would like to get a macro that will convert 173 rows of data across three columns into one column. Please see example below. Thanks in advance for any help.</p> <p>Rows:</p> <pre> 98,058 98,058 98,314 82,362 82,684 83,326 93,410 93,479 93,761 </pre> <p>Columns:</p> <pre> 98,058 98,058 98,314 82,362 82,684 83,326 93410 93479 93761 </pre>
<p>The following will load the data from the CurrentRegion of A1 into an array and paste into one column, beginning in A5.</p> <p>I'm assuming the data is numerical, contiguous and that this is a one-off, rather than an exercise that might have to be repeated on data sets of differing sizes. If your data is not contiguous, or not bound by empty cells, then you can hard code the range instead.</p> <pre><code>Private Sub transposeRows() Dim inputRange As Variant Dim myArray() As Long Dim x As Long Dim testCell As Range 'Get the range of data to copy' Set inputRange = Range("A1").CurrentRegion 'Resize array to fit' ReDim myArray(inputRange.Count - 1) 'Fill up array with data' For Each testCell In inputRange myArray(x) = testCell x = x + 1 Next testCell 'Fill destination range' Range("A5:A" &amp; UBound(myArray) + 5) = WorksheetFunction.Transpose(myArray) End Sub </code></pre>
Inline Code on Webform Property <p>Why doesn't this display the date/time when rendered?</p> <pre><code>&lt;asp:Label runat="server" ID="test" Text="&lt;%= DateTime.Now.ToString() %&gt;" &gt;&lt;/asp:Label&gt; </code></pre> <p>Is there anyway to make this work?</p>
<p>Asp.net server controls don't play well with the &lt;%=, instead you can do:</p> <pre><code>&lt;span&gt;&lt;%= DateTime.Now.ToString() %&gt;&lt;/span&gt; </code></pre> <p>Ps. you could alternatively set the label's text on the code-behind. It might work for your scenario to set it on the PreRenderComplete.</p>
Making LaTeX Beamer Black & White <p>Is there a way to make LaTeX Beamer output black &amp; white? I need it for paper printing purposes. I'm using the default color theme, and for contrast reasons I need the title and everything to be black. If there is a black&amp;white color scheme, I could use it, but otherwise I don't want other color schemes, with colored backgrounds. Maybe there are some commands which I can redefine?</p> <p>Thanks.</p>
<p>OK, found it after some more search. The answer is:</p> <pre><code>\setbeamercolor{frametitle}{fg=black} </code></pre>
What are the advantages of delegates? <p>What are the benefits/advantages of using delegates? Can anyone provide any simple examples?</p>
<p>They're a great way of encapsulating a piece of code. For instance, when you attach an event handler to the button, that handler is a delegate. The button doesn't need to know what it does, just how to call it at the right time.</p> <p>Another example is LINQ - filtering, projecting etc all require the same kind of template code; all that changes is the logic to represent the filter, the projection etc. With lambda expressions in C# 3 (which are converted into delegates or expression trees) this makes it really simple:</p> <pre><code>var namesOfAdults = people.Where(person =&gt; person.Age &gt;= 18) .Select(person =&gt; person.Name); </code></pre> <p>(That can also be represented as a query expression, but let's not stray too far from delegates.)</p> <p>Another way of thinking of a delegate is as a single-method interface type. For example, the <code>EventHandler</code> delegate type is a bit like:</p> <pre><code>public interface IEventHandler { void Invoke(object sender, EventArgs e) } </code></pre> <p>But the delegate support in the framework allows delegates to be chained together, invoked asynchronously, used as event handlers etc.</p> <p>For more on delegates and events, see <a href="http://pobox.com/~skeet/csharp/events.html">my article on the topic</a>. Its focus is events, but it covers delegates too.</p>
Change lookup rule for views <p>I have an application that gets rolled out in multiple countries. There will be a setting in the web.config file, that defines the country. The country will not be in the URL.</p> <p>Some of the the views change depending on the country. My first attempt is to use a folder inside the views folder that contains views, if they differ from the default view:</p> <p><strong>Default</strong></p> <p>/questions/ask.aspx</p> <p><strong>Spain</strong></p> <p>/questions/ESP/ask.aspx</p> <p>If there is no view in the country-folder the default view is used. Is there a way to extend the ViewEngine to lookup views in the country folder first? </p> <p>EDIT:</p> <p>This is a poc only. To see a full implementation have a look at </p> <p><a href="http://pietschsoft.com/?tag=/mvc" rel="nofollow">http://pietschsoft.com/?tag=/mvc</a></p> <pre><code> private static string[] LocalViewFormats = new string[] { "~/Views/{1}/ESP/{0}.aspx", "~/Views/{1}/{0}.aspx", "~/Views/{1}/{0}.ascx", "~/Views/Shared/{0}.aspx", "~/Views/Shared/{0}.ascx" }; public LocalizationWebFormViewEngine() { ViewLocationFormats = LocalViewFormats; } </code></pre>
<pre><code>public class MyViewEngine : WebFormViewEngine { private static string[] LocalViewFormats = new[] { "~/Views/ESP/{0}.aspx", "~/Views/ESP/{0}.ascx" }; public MyViewEngine() { ViewLocationFormats = LocalViewFormats.Union(ViewLocationFormats).ToArray(); } } </code></pre> <p>Obviously, you don't want to hardcode the location, but this should give you the general idea.</p>
How much memory can a 32 bit process access on a 64 bit operating system? <p>On Windows, under normal circumstances a 32 bit process can only access 2GB of RAM (or 3GB with a special switch in the boot.ini file). When running a 32 bit process on a 64 bit operating system, how much memory is available? Are there any special switches or settings that can change this?</p>
<p>2 GB by default. If the application is large address space aware (linked with /LARGEADDRESSAWARE), it gets 4 GB (not 3 GB, see <a href="http://msdn.microsoft.com/en-us/library/aa366778.aspx">http://msdn.microsoft.com/en-us/library/aa366778.aspx</a>)</p> <p>They're still limited to 2 GB since many application depends on the top bit of pointers to be zero.</p>
Nhibernate one-to-one mapping a class with itself <p>We have a situation where we want to define a relationship where a class (named Module) may or may not be related to a Module object that is a predecessor to it. There can be zero or none predecessors. The class looks like this:</p> <pre><code>public class Module { public int Id { get; set; } // other stuff here public Module Predecessor { get; set; } } </code></pre> <p>And we have defined our mapping so that Predecessor is a property of type Module like so:</p> <pre><code>&lt;class name="Module"&gt; &lt;Id name="Id"&gt; &lt;generator class="native/&gt; &lt;/Id &lt;property name="Predecessor" type="Module" "unique="true"/&gt; &lt;class&gt; </code></pre> <p>However we are getting complaints about the mapping not being able to compile because it cannot find the type "Module". We have tried the long name for the class </p> <pre><code>type="STC.EI.JobSubmissionSystem.Data.Domain" </code></pre> <p>and the fully-qualified name for the class</p> <pre><code>type="STC.EI.JobSubmissionSystem.Data.Domain, STC.EI.JobSubmissionSystem.Data" </code></pre> <p>to no avail. My question is:</p> <p>Are we mapping this properly, and if not then how do we map it properly?</p>
<p>You could use the <a href="http://www.hibernate.org/hib%5Fdocs/nhibernate/1.2/reference/en/html%5Fsingle/#mapping-declaration-manytoone" rel="nofollow">many-to-one</a> element:</p> <pre><code>&lt;class name="Module"&gt; &lt;Id name="Id"&gt; &lt;generator class="native"/&gt; &lt;/Id&gt; &lt;many-to-one name="Predecessor" class="Module" column="predecessor_id" /&gt; &lt;class&gt; </code></pre> <p>Note that you need a column in your table to define the relation.</p>
What's needed for PHP's mcrypt_decrypt()? <p>I have a script that uses mcrypt_decrypt() function, but I get the following error</p> <blockquote> <p>Fatal error: Call to undefined function mcrypt_decrypt()</p> </blockquote> <p>What modules/libraries do I need to include to use this function? Or is there another reason I'm getting the error?</p> <p>Thanks</p>
<p>sudo apt-get install php5-mcrypt </p> <p>works on ubuntu. </p>
Enumerated Values based on distinct ones XSLT 2.0 <p>I have a long list of values in XML with named identifiers. I need to make separate output files for each of the distinct identifiers grouped together and uniquely named.</p> <p>So, for example, let's say I have:</p> <pre><code>&lt;List&gt; &lt;Item group="::this_long_and_complicated_group_name_that_cannot_be_a_filename::"&gt; Hello World! &lt;/Item&gt; &lt;Item group="::this_other_long_and_complicated_group_name_that_cannot_be_a_filename::"&gt; Goodbye World! &lt;/Item&gt; &lt;Item group="::this_long_and_complicated_group_name_that_cannot_be_a_filename::"&gt; This example text should be in the first file &lt;/Item&gt; &lt;Item group="::this_other_long_and_complicated_group_name_that_cannot_be_a_filename::"&gt; This example text should be in the second file &lt;/Item&gt; &lt;Item group="::this_long_and_complicated_group_name_that_cannot_be_a_filename::"&gt; Hello World! &lt;/Item&gt; &lt;/List&gt; </code></pre> <p>How can I write a transformation (XSLT 2.0) to output these grouped into generated filenames and uniquely valued? For example: mapping the first <code>@group</code> to file1.xml and the second <code>@group</code> to file2.xml</p>
<p><strong>Here is a solution that uses some of the good new features in XSLT 2.0:</strong></p> <p><strong><em>This transformation</em></strong>:</p> <pre><code>&lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt; &lt;!-- --&gt; &lt;xsl:template match="/*"&gt; &lt;xsl:variable name="vTop" select="."/&gt; &lt;!-- --&gt; &lt;xsl:for-each-group select="Item" group-by="@group"&gt; &lt;xsl:result-document href="file:///C:/Temp/file{position()}.xml"&gt; &lt;xsl:element name="{name($vTop)}"&gt; &lt;xsl:copy-of select="current-group()"/&gt; &lt;/xsl:element&gt; &lt;/xsl:result-document&gt; &lt;/xsl:for-each-group&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>when applied on the OP-provided Xml document (corrected to be well-formed!):</strong></p> <pre><code>&lt;List&gt; &lt;Item group="::this_long_and_complicated_group_name_that_cannot_be_a_filename::"&gt; Hello World! &lt;/Item&gt; &lt;Item group="::this_other_long_and_complicated_group_name_that_cannot_be_a_filename::"&gt; Goodbye World! &lt;/Item&gt; &lt;Item group="::this_long_and_complicated_group_name_that_cannot_be_a_filename::"&gt; This example text should be in the first file &lt;/Item&gt; &lt;Item group="::this_other_long_and_complicated_group_name_that_cannot_be_a_filename::"&gt; This example text should be in the second file &lt;/Item&gt; &lt;Item group="::this_long_and_complicated_group_name_that_cannot_be_a_filename::"&gt; Hello World! &lt;/Item&gt; &lt;/List&gt; </code></pre> <p><strong>produces the wanted two files</strong>: <em>file1.xml and file2.xml</em></p>
Is it possible to restore a SQL 7 DB to SQL 2008? <p>I have an old SQL 7 DB .bak file I am trying to work with now. I tried to restore the backup in SQL 2008, but it said that it was unable to work with the file. Does anyone know how I could restore this DB?</p>
<p>You will need to install SQL Server 7, 2000, or 2005 and restore the backup to one of those first.</p> <ul> <li>SQL 2000/2005 - Restore the backup, export, and restore to 2008.</li> <li>SQL 7 - Restore the backup and use the SQL Server 2008 import functionality to import the data.</li> </ul>
Tile scrolling / preloading (Google Maps style) of HTML layers with Ajax <p>I am looking to replicate the panning (not necessarily the zooming) effect of the Google Maps API, but without the images. Essentially, I want to position HTML elements in a large coordinate system and be able to navigate around them, <a href="http://prezi.com/" rel="nofollow">Prezi</a> style (though without the rotation).</p> <p>Preferably, I'd like to preload the elements dynamically through jQuery/AJAX, but if I have to load everything initially, I will.</p> <p>Any libraries out there that will allow me to do this? I could just code the thing myself, but I can't imagine noone else has thought of something similar before.</p> <p>Can this be done with the Google Maps API, and if so, how? Implementing the GOverlay interface?</p>
<p>Oh, you will have so much fun doing this yourself, and sure will be no too much time consuming if you use jQuery, here is a brief of what you'll do...</p> <p>Build you container/containing layout (use overflow:hidden to show only the desired size)</p> <p>Then capture user actions with the mousedown and mouseup events.</p> <p>Act accordingly based on the containing div position properties (use the "dimensions" plugin)</p> <p>You might get your first working attempt within minutes.</p> <p>Greetings</p>
Crystal Reports: Subreport on more than one page <p>Hi I have a Crystal reports, report set up and I want to insert a sub report as the first page. I thought I can do this buy placing a subreport in the PageHeader of my other report. It works well but it does not display the rest of my sub report pages; it only displays the first page. Can someone help me configure this? Thank you.</p>
<p>If you put a subreport in the pageheader and the subreport is longer than a page, crystal might blow up!</p>
How to add extra newline with 'puts' without sticking newline character into string? <p>If I say</p> <pre><code>puts "Hello" </code></pre> <p>and decide to add an extra newline I need to do this:</p> <pre><code>puts "Hello\n" </code></pre> <p>Having this character in the string is ugly. Is there any way to do this without polluting my string?</p>
<p>Just make another call to <code>puts</code>:</p> <pre><code>puts "Hello" puts </code></pre>
Linq to SQL connections <p>I'm using Linq to SQL for a fairly complicated site, and after go live we've had a number of database timeouts. The first thing I noticed was there are a fairly large number of connections to the database.</p> <p>Coming from an ADO.net background we used to code it so that any site would only use one or two pooled connections, and this resulted in acceptable performance even with a fair few concurrent users.</p> <p>So my question is, was this old way of doing it flawed, OR is there a way to do it LINQ? It seems our performance issues are being caused by so many connections to the DB but if this was an issue I'd have thought it would be mentioned in all the tutorials for LINQ.</p> <p>Any suggestions?</p>
<p>I'm guessing that you are keeping DataContexts around and not calling Dispose on them when done (or leaving them around, at least).</p> <p>Rather, you should initialize your DataContext, perform your operation, and then dispose of it when done. You shouldn't hold a reference to it between operations.</p> <p>Preferably, you would use the using statement for handling the call to IDisposable.</p> <p>Regarding connection pooling, the SqlClient pools connections by default, so unless you explicitly turn it off, you should be taking advantage of it already. Of course, if you aren't releasing connections you are using, then pooling will only take you so far.</p>
Best practices for Active Record Pattern and using static methods for group operations <p>It is true what they say about design patterns that they are simply the embodiment of techniques already in general use. I have been using the Active Record Pattern since 1985.</p> <p>One of the attributes of this pattern is the use of static members in the implementation to perform searches that return collections of the underlying data. </p> <pre><code>class Customer { static Customer FindCustomerById( int Id ) { ... } static Customer[] FindActiveCustomers() { ... } } </code></pre> <p>In many cases where I need much more flexibility I break encapsulation and include a method such as </p> <pre><code>static Customer[] FindCustomers( string criteria ) { ... } </code></pre> <p>where one would call it as</p> <pre><code>Customer[] customers = Customer.FindCustomers( "LastName = 'Smith'" ); </code></pre> <p>Of course this is a hold over from when I used this pattern in C, is clearly not a best practice, and in the wrong hands can lead to SQL injection and other problems.</p> <p>Is there a suitable pattern or practice that could be applied that would allow the Customer class to become a "criteria" for such a search?</p> <p>For example suppose I want to find customers whose last name was Smith, I might consider writing an implementation such as:</p> <pre><code>static Customer[] FindCustomers( Customer customer ) { ... } </code></pre> <p>to be called as (with the appropriate constructor of course):</p> <pre><code>Customer[] customersnamedsmith = Customer.FindCustomer( new Customer( "Smith" ) ); </code></pre> <p>Or is it better to create a co-class that would define the criteria?</p>
<p>Just from working with LINQ, I like the idea of passing in an expression instead of a string. But, perhaps that is just me? I am also not fond of ActiveRecord, as it mixes state and behavior in the same object. Nice packaging, but not a clean separation of model and data access.</p> <p>I have seen cases where a customer class is passed to active record, but if you are going that route, a repository pattern is much cleaner and does separate the behavior from state. I see nothing wrong, however, with using the investment you already have in active record and passing an object.</p> <p>If you would like create a criteria class, you will end up with a bit of a strategy pattern, which can make your active record a bit more active than it is today. It is an applicable pattern, however, and will also solve any injection issues.</p>
VB/VBA: Fetch HTML string from clipboard (copied via web browser) <p>It seems that when you copy something from a web browser to the clipboard, at least 2 things are stored:</p> <ol> <li>Plain text </li> <li>HTML source code</li> </ol> <p>Then it is up to the software that you are pasting into can determine which one it wants. When pasting into <strong>MS Excel 2003</strong>, you have a paste special option to paste HTML, which will paste the formatted HTML (as it is displayed by the browser). </p> <p>What I want to do is paste the actual source code as plain text. Can this be fetched from the clipboard in VBA?</p> <p><strong>Edit</strong> I'm trying to access all the source-code of the copied HTML, including the tags.</p>
<p>This time I've read the question properly and realised <em>coonj</em> wants to get the HTML from the clipboard including tags. </p> <p>I believe this is reasonably difficult. You need to read the clipboard using Windows API calls. And then, parse the resulting CF_HTML string which has some wacky headers added on top of the HTML. </p> <ol> <li><a href="http://support.microsoft.com/kb/274326" rel="nofollow">Microsoft Knowledge Base article</a> with Windows API code to read the CF_HTML from the clipboard (function GetHTMLClipboard).</li> <li><p>You will then probably want to ignore the wacky headers. Microsoft documents the format <a href="http://msdn.microsoft.com/en-us/library/aa767917.aspx" rel="nofollow">here</a>. An example CF_HTML fragment is shown below. You could probably come up with some guesswork method of skipping the first few lines.</p> <pre><code>Version:0.9 StartHTML:71 EndHTML:170 StartFragment:140 EndFragment:160 StartSelection:140 EndSelection:160 &lt;!DOCTYPE&gt; &lt;HTML&gt; &lt;HEAD&gt; &lt;TITLE&gt;The HTML Clipboard&lt;/TITLE&gt; &lt;BASE HREF="http://sample/specs"&gt; &lt;/HEAD&gt; &lt;BODY&gt; &lt;!--StartFragment --&gt; &lt;P&gt;The Fragment&lt;/P&gt; &lt;!--EndFragment --&gt; &lt;/BODY&gt; &lt;/HTML&gt; </code></pre></li> </ol> <p>It might also be worth thinking whether there's any other way of solving your problem. E,g, Will the browser always be Internet Explorer? Can you get what you need by walking the HTML tree using the COM object model?</p> <p>EDIT: <em>coonj</em> has tried this now and says "the GetHTMLClipboard function seems to work with both Firefox and IE, and it doesn't look like it is throwing those headers in there"</p>
How to make a dropdownlist disabled on change event using JQUERY? <pre><code>$(document).ready(function() { $('#&lt;%=ddlContinents.ClientID %&gt;').change(function() { var element = $(this); var totalLength = element.children().length; if ($(this).disabled == false) { $(this).disabled = true; } }); }); </code></pre> <p>What I am trying to do is fire off the change event of the <code>dropdownlist</code> and on change making this <code>dropdownlist</code> disabled. The code is firing and everything, but it does not disable the <code>dropdownlist</code>.</p> <p>This portion of the code is not working:</p> <pre><code>if ($(this).disabled == false) { $(this).disabled = true; } }); </code></pre>
<p>You should use <a href="http://api.jquery.com/prop/" rel="nofollow"><code>.prop()</code></a> for jQuery 1.6+ or <a href="http://api.jquery.com/attr/" rel="nofollow"><code>.attr()</code></a> for earlier versions of jQuery:</p> <p>> jQuery 1.6:</p> <pre><code>$(document).ready(function() { $('#&lt;%=ddlContinents.ClientID %&gt;').change(function() { var element = $(this); var totalLength = element.children().length; if (!$(this).prop("disabled")) { $(this).prop("disabled", true); } }); }); </code></pre> <p>&lt; jQuery 1.6:</p> <pre><code>$(document).ready(function() { $('#&lt;%=ddlContinents.ClientID %&gt;').change(function() { var element = $(this); var totalLength = element.children().length; if (!$(this).attr("disabled")) { $(this).attr("disabled", "disabled"); } }); }); </code></pre>
SQL 2005 instance won't work with DNS <p>Basically I have a sql 2005 standard server with a named instance installed (server/instance1). I also have created a DNS entry (dnsDBServer) that points to the ip address of the sql server. A web application we have can connect using the following methods (ipaddress/instance1, server/instance1) but cannot connect using the dnsDBServer/instance1. Of course this sort of defeats the purpose of the dns entry. Was wondering if sql aliases would help fix this problem or if anyone has a solution. Thanks.</p>
<p>Most likely your DNS resolution isn't working exactly like you thought it would.</p> <p>Do a tracert from the machine that is trying to talk to your sql server and see where it's going to.</p> <p>You should also look at the firewall settings between the requesting machine and the server to see if there is anything else affecting it.</p>
Unable to put TERM to .bashrc in Mac <p><a href="http://stevey-home.blogspot.com/" rel="nofollow">Stevey</a> recommends to set the following command to .bashrc</p> <pre><code>TERM=xterm-256color </code></pre> <p>I put the code to the top of my .bashrc and I have now a flashing black green terminal. The font color in my terminal switches from black to green and vice versa periodically.</p> <p><strong>What did I do wrong?</strong></p>
<p>Simply put, the Mac's terminal app doesn't support 256 color. See here: <a href="http://news.ycombinator.com/item?id=443769" rel="nofollow">http://news.ycombinator.com/item?id=443769</a></p> <p>From the same link, it looks like there may be other terminals that do. Good luck!</p>
Is there a way to get notified when a child is added/removed from a WPF Panel? <p>I can't find the event that would get fired when a child is added or removed from a WPF panel. Does such an event exist and I am just missing it?</p>
<p>I couldn't find an event, but you might try the <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.panel.onvisualchildrenchanged%28VS.85%29.aspx"><code>Panel.OnVisualChildrenChanged</code></a> method.</p>
read iphone sms messages? <p>is there a possibility to read received SMS messages ?</p>
<p>Yes, you can. The sms messages are stored in a Sqlite db file.</p> <p>Here's some information on howto read and get those files.</p> <p><a href="http://menoob.com/2008/12/04/how-to-save-and-read-your-iphone-text-messages-on-your-computer/">read and save sms</a></p> <p><a href="http://www.tuaw.com/2007/08/22/more-on-iphone-backups/">iphone backups</a></p>
HyperLinkField not showing as link <p>I have the following column in a <code>GridView</code>, and my problem is that it only renders the text "Download", not a URL.</p> <pre><code>&lt;asp:HyperLinkField DataNavigateUrlFields="ArchiveLocation" Text="Download" DataNavigateUrlFormatString="{0}" /&gt; </code></pre> <p>When I bind a <code>DataTable</code> with one row to the grid, the <code>ArchiveLocation</code> in that row contains the value:</p> <blockquote> <p>"~/Common/Forms/ExportStream.aspx?path=C:\Development\Chase\Exports\ChaseExport-090312073930.zip".</p> </blockquote>
<p>A work around would be to use a template field and encode the colon to its hexadecimal representation, which would be %3A.</p> <pre><code>&lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='&lt;%# Eval("ArchiveLocation","{0}").Replace(":", Server.UrlEncode(":")) %&gt;' Text="Download"&gt;&lt;/asp:HyperLink&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; </code></pre> <p>When retrieving the value from the query string variable collection it will be automatically decoded.</p> <pre><code>string path = Request.QueryString["path"]; </code></pre>
Is JasperReports the appropriate solution to display reports in a web application? <p>We want to generate Reports either embedded as html pages in a web app or downloadable as a <em>pdf</em>. Hence I came across <em>JasperReports</em> because it thought it would fullfill these requirements. </p> <p>Currently we assume our report will have about 50-100 pages, consisting of nearly only histograms and some tables. The data is retrieved by some expensive queries from our DB.</p> <p>After evaluating it the whole day i have several doubts regarding web app aspects.</p> <p>1) Pagination: Of course I don't want to display all pages in a single web page. We need something like pagination. But <em>JasperReports</em> seems not to support this approach. The wepp demo, which comes with <em>JasperReports</em>, sketches the way to go: I have to create a <strong><em>JasperPrint</em></strong>, which is already the full report, allocating unrequired memory and which has performed the expensive queries. Then I could display a single page. But doing this again and again for each page does not appear as a proper solution to me.</p> <p>2) As mentioned above, our report will mostly consist of diagrams. Images are generated during Exporting the <strong><em>JasperPrint</em></strong> to its output format. If I understand everything correct, the <strong><em>ImageServlet</em></strong>, which comes with <em>JR</em>, is capable but retrieve these images be</p> <p>i) Reading the generated images from the file system<br/> ii) the exporter has stored them in the session (therefore in memory). </p> <p>Since I think we will have a lot of images ii) is not an option, if we want to keep the memory footprint of the webapp low. But on the other hand flooding the file system with files is also not the best idea i could imagine. Does it delete the files somewhen? </p> <p>Did I got something wrong? Is my understanding Correct?</p>
<p><strong>Pagination</strong></p> <p>It's kind of your service design how your pageing ist implemented! PDF is an standalone output format for printing issues. It can't read more data from the server (without Web-Services and Reader Extensions). So you can define, that JasperReports should only a subset of your data for paging. </p> <p>If you define datasets in JasperReports, you can reuse them without allocating unrequired memory.</p> <p><strong>Images</strong></p> <p>If you want images in your reports and keep your memory footprint low, write a balancing algorithm which generates the images when the server load is under a specified value (may be a dynamic value from the avg of the last day load).</p> <p>Do you need real time creation of the images? If the images were created by a servlet, they'll be load to Memory. A Java App. can pass the images to the ReportGenerator. </p> <blockquote> <p>images can be loaded from memory, from disk, or from a URL see; <a href="http://www.infoap.utcluj.ro/bdate/jreports.pdf" rel="nofollow">Jasper Reports Book</a> P:170</p> </blockquote> <p>The images should never be saved in the HTTP_SESSION! This is a total antipattern which causes memory bloating. </p>
Image width/height as an attribute or in CSS? <p>What's the "correct" semantic way to specify image height and width? In CSS...</p> <pre><code>width:15px; </code></pre> <p>or inline...</p> <pre><code>&lt;img width="15" </code></pre> <p>?</p> <p>CSS seems like the right place to put visual information. On the other hand, few would argue that image "src" should not be specified as an attribute and the height/width seem as tied to the binary image data as the "src" is.</p> <p>(Yes, I realize from a technical, end-user perspective this really doesn't matter.)</p>
<p>It should be defined inline. If you are using the img tag, that image should have semantic value to the content, which is why the alt attribute is required for validation. </p> <p>If the image is to be part of the layout or template, you should use a tag other than the img tag and assign the image as a CSS background to the element. In this case, the image has no semantic meaning and therefore doesn't require the alt attribute. I'm fairly certain that most screen readers would not even know that a CSS image exists.</p>
System.UnauthorizedAccessException in mscorwks.dll causing app pool crashes <p>My app pools keep randomly crashing in IIS 6.0 MS Debug Diag points to kernel32.dll every time.</p> <p>The entry point is always mscorwks!CreateApplicationContext+bbef and the result is always a System.UnauthorizedAccessException.</p> <p>Stack Trace:</p> <pre><code>Function Arg 1 Arg 2 Arg 3 kernel32!RaiseException+3c e0434f4d 00000001 00000001 mscorwks!GetMetaDataInternalInterface+84a9 18316b3c 00000000 00000000 mscorwks!GetAddrOfContractShutoffFlag+ac01 18316b3c 00000000 023cfbd8 mscorwks!GetAddrOfContractShutoffFlag+ac73 00000000 000e8c88 8038b2d0 mscorwks!GetAddrOfContractShutoffFlag+aca4 18316b3c 00000000 023cfbe4 mscorwks!GetAddrOfContractShutoffFlag+acb2 18316b3c acc05c33 7a399bf0 mscorwks!CoUninitializeCor+67be 00000000 023cfc1c 023cfc8c mscorwks!CoUninitializeCor+87a1 001056e8 79fd87f6 023cfeb0 mscorwks!CorExitProcess+4ad3 023cfeb0 023cfd20 79f40574 mscorwks!CorExitProcess+4abf 001056e8 79f405a6 023cfd04 mscorwks!CorExitProcess+4b3e 000e8c88 00000000 023cfda7 mscorwks!StrongNameErrorInfo+1ddab 00000000 00000000 023cfeb0 mscorwks!StrongNameErrorInfo+1e07c 023cfeb0 00000000 00000000 mscorwks!CoUninitializeEE+4e0b 023cfeb0 023cfe5c 79f7762b mscorwks!CoUninitializeEE+4da7 023cfeb0 acc05973 00000000 mscorwks!CoUninitializeEE+4ccd 023cfeb0 00000000 001056e8 mscorwks!GetPrivateContextsPerfCounters+f1cd 79fc24f9 00000008 023cff14 mscorwks!GetPrivateContextsPerfCounters+f1de 79fc24f9 acc058c3 00000000 mscorwks!CorExeMain+1374 00000000 00000003 00000002 mscorwks!CreateApplicationContext+bc35 000e9458 00000000 00000000 kernel32!GetModuleHandleA+df 79f9205f 000e9458 00000000 </code></pre> <p>Does anybody know what this means and how to fix it?</p> <p><strong>Edit:</strong> The above stack trace turned out to be a symptom and not the cause. The above stack trace only shows the unmanaged stack but the problem happened in managed code. I used the steps in my answer below to dig into the crash dump and extract the managed exception.</p>
<p>The reference to mscorwks.dll was only a symptom of the problem. mscorwks.dll is the dll that contains the common language runtime.</p> <p>To diagnose the root cause of the problem, I followed the following steps:</p> <ol> <li>Use <a href="http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=28bd5941-c458-46f1-b24d-f60151d875a3&amp;displaylang=en">DebugDiag</a> to capture a crash dump when IIS recycled the app pool. </li> <li>Open the crash dump in <a href="http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx">windbg</a>.</li> <li>Type ".loadby sos mscorwks" (no quotes) at the windbg command line to load the CLR debug tools</li> <li>Use the !PrintException command to print out the last exception recorded in the crash dump. This is most likely the one that caused the IIS app pool recycle</li> <li>Use the !clrstack command to view the stack on the current thread that threw the exception</li> <li>More command references for windbg can be found <a href="http://windbg.info/doc/1-common-cmds.html#15%5Fcall%5Fstack">here</a> and <a href="http://geekswithblogs.net/.NETonMyMind/archive/2006/03/14/72262.aspx">here</a>. Lastly, <a href="http://blogs.msdn.com/tess/">this MSDN blog</a> has great tutorials on using windbg.</li> </ol> <p>Good luck on your debuging adventure!</p>
Can server-side viewstates fix one of the biggest problems with ASP.NET? <p>I've read a few SO articles about whether or not ASP.NET MVC is worth the migration from "regular" ASP.NET. One of the biggest reasons for using MVC I've seen quoted was not having to use Viewstates. </p> <p>However, it is possible to eliminate viewstates by storing the viewstate information on the server as <a href="http://www.codeguru.com/columns/vb/article.php/c13931" rel="nofollow">this article</a> shows. I've tried it in a sample project, it works great, is fully transparent as far as I noticed it and was very easy to implement. </p> <p>So, where's the catch? I expect it does put a slightly higher load on the server, but can it really be that bad? If not, why aren't more people using this approach instead of complaining about viewstates?</p>
<p>The only issue with viewstate is abusing the use of it. This easily happens as the default is to have it all on. You can't even turn it all off by default on a page, and selectively turn on specific controls (they will add support for this on the 4.0). You will see few code with the viewstate=false on it, and with lists of info it can get big fast. </p> <p>There are even some third party controls that abuse it awfully. I had to help finding out why a page was awfully slow (as in it doesn't even works), and it turned out the amount of info downloaded was huge, the cause was the viewstate was 10+ times the size of the content (really) and it was a third party control that liked storing everything you handed to it (which got really ugly because it was handed a hierarchy of objects).</p> <p>So the real problem isn't the viewstate, it is its size. If you already have the problem of big viewstates (normal big, not the extreme of the above), then moving it to session on the server means you will be storing a huge amount of info. This is moving the problem from one place to other, perhaps mitigating some of its effects, but it doesn't address the real issue, storing too much unneeded state (because either the developers did or some third party stuff misbehaved).</p> <p>That said, I don't think I would call it the single main problem with the regular asp.net approach. Don't take this as a "don't develop with it", but more like a "if you will develop on it, get to know it really well". I work a lot with regular asp.net, it Can work and very well. If I were to begin on it at this point, I think I would go with asp.net mvc though, as I think regular asp.net needs a whole lot more from the developer to get it right.</p>
How do I upload a file with mod_python? <p>I want to create a simple file upload form and I must be completely incapable. I've read docs and tutorials,but for some reason, I'm not getting the submitted form data. I wrote the smallest amount of code I could to test and it still isn't working. Any ideas what's wrong?</p> <pre><code>def index(): html = ''' &lt;html&gt; &lt;body&gt; &lt;form id="fileUpload" action="./result" method="post"&gt; &lt;input type="file" id="file"/&gt; &lt;input type="submit" value="Upload"/&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; ''' return html def result(req): try: tmpfile = req.form['file'] except: return "no file!" </code></pre>
<p>try putting enctype="multipart/form-data" in your form tag. Your mistake is not really mod_python related.</p>
Doubly connected ordered tree mapping using NHibernate <p>We need to map simple class using NHibernate:</p> <pre><code>public class CatalogItem { private IList&lt;CatalogItem&gt; children = new List&lt;CatalogItem&gt;(); public Guid Id { get; set; } public string Name { get; set; } public CatalogItem Parent { get; set; } public IList&lt;CatalogItem&gt; Children { get { return children; } } public bool IsRoot { get { return Parent == null; } } public bool IsLeaf { get { return Children.Count == 0; } } } </code></pre> <p>There are a batch of tutorials in the internet on this subject, but none of them cover little nasty detail: we need order to be preserved in Children collection. We've tried following mapping, but it led to strange exeptions thrown by NHibernate ("Non-static method requires a target.").</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Domain.Model" assembly="Domain"&gt; &lt;class name="CatalogItem" lazy="false"&gt; &lt;id name="Id" type="guid"&gt; &lt;generator class="guid" /&gt; &lt;/id&gt; &lt;property name="Name" /&gt; &lt;many-to-one name="Parent" class="CatalogItem" lazy="false" /&gt; &lt;list name="Children" cascade="all"&gt; &lt;key property-ref="Parent"/&gt; &lt;index column="weight" type="Int32" /&gt; &lt;one-to-many not-found="exception" class="CatalogItem"/&gt; &lt;/list&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>Does anyone have any thoughts?</p>
<p>I'm no expert, but <code>&lt;key property-ref=...&gt;</code> looks strange to me in this usage. You should be able to do <code>&lt;key column="ParentID"/&gt;</code>, and NHibernate will automatically use the primary key of the associated class -- itself, in this case.</p> <p>You may also need to set the list to <code>inverse="true"</code>, since the relationship is bidirectional. [See section 6.8 in the docs.]</p>
How To Check for an Index in Oracle <p>I am writing a schema upgrade script for a product that depends on an Oracle database. In one area, I need to create an index on a table - if that index does not already exist. Is there an easy way to check for the existence of an index that I know the name of in an Oracle script?</p> <p>It would be similar to this in SQL Server: IF NOT EXISTS (SELECT * FROM SYSINDEXES WHERE NAME = 'myIndex') // Then create my myIndex</p>
<p>select count(*) from user_indexes where index_name = 'myIndex'</p> <p>sqlplus won't support IF..., though, so you'll have to use anonymous PL/SQL blocks, which means EXECUTE IMMEDIATE to do DDL.</p> <pre><code>DECLARE i INTEGER; BEGIN SELECT COUNT(*) INTO i FROM user_indexes WHERE index_name = 'MYINDEX'; IF i = 0 THEN EXECUTE IMMEDIATE 'CREATE INDEX myIndex ...'; END IF; END; / </code></pre> <p>Edit: as pointed out, Oracle stores unquoted object names in all uppercase.</p>
IndexOutOfRangeException on accessing attributes through String array? <p>I have a treeView displayed on a winform.Now when i click on an xmlnode in the treeview its attributes get displayed in the listbox.Now i have divided the whole logic in UI and back end part. Now what i want that my back end class contains the method to display atrributes(name and value) of the xml node clicked and these are stored in an array and it is returned as a string to my front end class in the treev_AfterSelect event. How can i do it?I need to store attributes of the node i click on winform in a string array and display in listbox.Here is the code what i have for my Backhand class <code>enter code here</code></p> <pre><code>public string[] selectedNode(XmlNode eventNode) { XmlAttributeCollection attCol = eventNode.Attributes; string[] strArray = new string[attCol.Count]; if (attCol != null) for( int i = 0; i &lt;= attCol.Count;i++) { strArray[i] = "Attribute name: " + attCol[i].Name+","+" Attribute value: " + attCol[i].Value;//IndexOutOfRange Exception } return strArray; } </code></pre> <p>Here i am getting an exception of IndexOutOfRangeException : The index being passed in is out of range. on this line</p> <pre><code>strArray[i] = "Attribute name: " + attCol[i].Name+","+" Attribute value: " + attCol[i].Value; </code></pre> <p>My Front end ( UI ) class contains this code to retrieve the Attribute and values, display it on Listbox.</p> <pre><code>private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { classObj = new MytreeNodeClass(); listBox1.Items.Clear(); XmlNode xNode = e.Node.Tag as XmlNode; string[] arrStr = classObj.selectedNode(xNode); listBox1.Items.Add(arrStr); //Is this the correct syntax to retrieve the data in listbox?? } </code></pre> <p>Can you please help out where i m going wrong?? What and where to put exactly to remove the exception and run the code successfully??i dont want Treenode to be used in backhand. Thanks....</p>
<p>You're going too far in your loop.</p> <pre><code>for( int i = 0; i &lt;= attCol.Count;i++) </code></pre> <p>should be</p> <pre><code>for( int i = 0; i &lt; attCol.Count;i++) </code></pre>
Functors in Ocaml <p>I am having a bit of a problem with a functor (and it's resultant type). Below, I have a Set functor that uses an Ordered type. I actually used the <code>set.ml</code> that comes with ocaml for some guidance, but I seem to be doing everything <em>ahhem</em> right. I created an Ordered module with integers and applied it to the Set functor to get the last module on this code sample, IntSet.</p> <p>The next line fails, when I try to insert an integer. I get the following type error:</p> <pre><code>Error: This expression has type int but is here used with type SetInt.elt = Set(OrdInt).elt </code></pre> <p>Don't get me wrong, the type system is correct here. The top level reports that the type of the <code>SetInt.elt</code> is <code>Set(OrdInt).elt</code>, but when I do the same operations to set up a Set using the one provided by ocaml the 'same' line is, <code>SetInt.elt = OrderedInt.t</code>. Seems like I should be getting <code>SetInt.elt = Ordered.t</code>.</p> <p>This is so simple, I'm probably just missing some stupid detail! argh!</p> <p>Please Note: I have simplified the member/insert functions here since this issue has to do with types.</p> <pre><code>module type Ordered = sig type t val lt : t -&gt; t -&gt; bool val eq : t -&gt; t -&gt; bool val leq : t -&gt; t -&gt; bool end module type S = sig type elt type t exception Already_Exists val empty : t val insert : elt -&gt; t -&gt; t val member : elt -&gt; t -&gt; bool end module Set (Elt:Ordered) : S = struct type elt = Elt.t type t = Leaf | Node of t * elt * t exception Already_Exists let empty = Leaf let insert e t = t let member e t = false end module OrdInt : Ordered = struct type t = int let lt a b = a &lt; b let eq a b = a = b let leq a b = a &lt;= b end module IntSet = Set (OrdInt) (* line that fails *) let one_elm = IntSet.insert 1 IntSet.empty </code></pre>
<p>You need to change these two lines</p> <pre><code>module Set (Elt:Ordered) : S = module OrdInt : Ordered = </code></pre> <p>to</p> <pre><code>module Set (Elt:Ordered) : S with type elt = Elt.t = module OrdInt : Ordered with type t = int = </code></pre> <p>Without these, the modules will not have signatures that expose the types elt and t as int.</p> <p>[Edit]: The set.ml doesn't have the 'with' bit, because there's a sml.mli, which declares the signature for the functor and it does have the 'with'. Also, OrdInt doesn't need 'with' if you don't explicitly specify a signature for it, like this:</p> <pre><code>module OrdInt = </code></pre> <p>You can also construct the set by defining the module in place:</p> <pre><code>module IntSet = Set (struct type t = int let lt a b = a &lt; b let eq a b = a = b let leq a b = a &lt;= b end) </code></pre>
How do I fire an ASP.NET custom validator from JavaScript? <p>I want to code a function in javascript that every time I call it in the webform it fires up an specific validator in that same webform.</p>
<pre><code>&lt;asp:RequiredFieldValidator ID="passwordRequiredFieldValidator" runat="server" ErrorMessage="* Password Required!" EnableClientScript="true" CssClass="errorText" ControlToValidate="passwordTextBox"&gt; &lt;/asp:RequiredFieldValidator&gt; </code></pre> <p>To fire this validator use:</p> <pre><code>window.ValidatorValidate(window.passwordRequiredFieldValidator); </code></pre> <p>Further example: </p> <pre><code>function ValidatePassword() { window.ValidatorValidate(window.passwordRequiredFieldValidator); var valid = window.passwordRequiredFieldValidator.isvalid; alert(valid); } </code></pre>
Web Services for Remote Portlets in C# / .NET -- Options? <p>I recently had my mind expanded by a new concept: <a href="http://en.wikipedia.org/wiki/Web%5FServices%5Ffor%5FRemote%5FPortlets" rel="nofollow">Web Services for Remote Portlets</a>, or WSRP. I learned of it during a presentation on a Java-based web portal we are considering purchasing at work; we are a .NET shop and WSRP would be the means by which we would extend this portal. </p> <p>Although I cannot control the end decision as to whether or not we purchase the product, I can provide input as to how difficult it would be to build WSRP-compliant portlets. Unfortunately, my recent queries into the subject have turned up almost nill. </p> <p>So I ask you, the SO community, the following: what libraries or frameworks are out there for building WSRP-compliant portlets in C#/.NET? What are some of the pros and cons of using WSRP in general? </p> <p>Because there is no correct answer here, I will make this a community wiki post.</p> <p>So far, I have only found the following:</p> <ul> <li><a href="http://blogs.msdn.com/sharepoint/archive/2008/12/05/announcing-the-wsrp-toolkit-for-sharepoint.aspx" rel="nofollow">WSRP Toolkit for Sharepoint</a> by Microsoft (but requiring Sharepoint).</li> <li><a href="http://www.netunitysoftware.com/" rel="nofollow">WSRP Portal and WSRP .NET Framework</a> By NetUnity.</li> </ul> <p>Given that WSRP is on top of SOAP, this seems like a perfect candidate for a WCF binding and channel, and yet I see nothing on the subject, anywhere. </p>
<p>WSRP is very contrarian. By now the world has seen that tight coupling between the data model and the presentation model is suboptimal. The success of RSS, REST, MVC, and web services in general shows this. Despite the WS in the name, WSRP stands against the core principles of Web services. The WSRP spec ignores the sound advice to keep data and presentation separate, and couples them tightly. </p> <p>WSRP promises integration, at the UI level. This seems like the wrong problem to be solving. </p> <p>It baffles me that this thing has lived as long as it has.<br /> The problem it attempts to solve is often not the problem that <em>should be</em> solved.</p>
SVN Export with revision history problem <p>I need to provide our clients with a dump of a single sub directory in our SVN repository along with the revision history if possible. I know that you can do a dump but I don't believe you can tell it to isolate a single sub directory in the repo. If I export i'll only get the head or a single revision, this is not what I need. Is there anyway to achieve this, or is this just not supported?</p> <p>Edit:</p> <p>What I need is all the revision history and the changes to every file.</p> <p>Edit:</p> <p>It looks like rmeador's solution worked with one caveat. I was getting a cryptic error about a revision or file doesn't exist when executing the load command into a blank repo. svnadmin load seemed to get confused because creation of the "trunk" directory got filtered out by svndumpfilter. Therefore creating "trunk/MySubDirecory" fails. Doing a svn add/commit manually for "trunk" on the target empty repo and then doing a "svnadmin load" solved this problem. </p>
<p>It is possible to filter a dump file to only contain one subdirectory using <a href="http://svnbook.red-bean.com/en/1.5/svn.ref.svndumpfilter.html" rel="nofollow">svndumpfilter</a>. Such a dump file can then be loaded into a new repository and it will work perfectly fine, as if the repo had always been that directory.</p>
What is the easiest and lightest way to make a client-server in Perl? <p>It will be better if this solution is based on HTTP protocol.</p>
<p>Checkout <a href="http://search.cpan.org/~gaas/libwww-perl-5.825/lib/HTTP/Daemon.pm" rel="nofollow">HTTP::Daemon</a> in CPAN. It will give you the basics of a server. You can then over-ride methods to handle your HTTP.</p> <p>Alternatively, try <a href="http://search.cpan.org/~jesse/HTTP-Server-Simple-0.38/lib/HTTP/Server/Simple.pm" rel="nofollow">HTTP::Server::Simple</a> although that module doesn't seem as mature as the first one.</p> <p>Finally, you could take a look at <a href="http://search.cpan.org/~rhandom/Net-Server-0.97/lib/Net/Server.pod" rel="nofollow">Net::Server</a>, which is a more general approach.</p>
How do I properly format this json object in PHP <p>I need to be able to create a data structure in PHP which creates for instance, an array of car vendors. Each of those array elements contains a child array which holds types of cars for that vendor.</p> <p>So you'd have something like</p> <pre><code>$cars['toyota'] = array("camry", "etc"); </code></pre> <p>I need to be able to create this data structure in PHP so that on the JavaScript side of things I can do something like</p> <pre><code>alert(cars.vendor[0].type[1]) </code></pre> <p>How do I encode that data structure on the PHP end of things?</p>
<p>If you have PHP >5.2.0, try <a href="http://www.php.net/json%5Fencode" rel="nofollow"><code>json_encode($cars)</code></a>.</p> <p>This will make an array in an array, but it won't give you what you have in your javascript sample:</p> <pre><code>$vendors = array( 'toyota' =&gt; array('camry', 'etc.'), 'honda' =&gt; array('civic', 'fit', 'etc.'), ); </code></pre> <p>You probably don't need all the embedded levels of <code>vendors[0].types[1]</code> to get your information organized.</p>
Coming out of the habit of writing ifs/elseifs for every possible condition <p>When parsing an xml document for its nodes or attributes, if the document is large, I would have a bunch of ifs and else statements.</p> <p>Obviously, 100+ ifs does not make up maintainable code in the long run.</p> <p>Rather than doing this, is there another better way? I read on Hanselman's blog about a friend of his who had the same situation and wrote loads of ifs/else if and generally poor code. Hanselman provided some snippets of a more maintainable way but the entire code isn't available so it's a little hard to understand exactly what (the whole picture) is going on. <a href="http://www.hanselman.com/blog/BackToBasicsLifeAfterIfForAndSwitchLikeADataStructuresReminder.aspx" rel="nofollow">Life after if, else</a></p> <p>I am using .NET 3.5 SO I have the full power of extension methods and LINQ available to me. However, I use .NET 2.0 a work so would also appreciate any solutions in v2.0. :)</p> <p>My code looks very similar to the problem on Hanselman's site:</p> <p>if (xmlNode.Attributes["a"].Value == "abc" { </p> <p>}<br /> else if (xmlNode.Attributes["b"].Value == "xyz"<br /> {<br /> wt = MyEnum.Haze;<br /> } </p> <p>I could just have a dictionary storing the values I am looking for as keys and perhaps a delegate in the value (or whatever I want to happen on finding a required value), so I could say if (containskey) get delegate and execute it, in pseudocode.</p> <p>This sort of thing goes on and on. Obviously very naive way of coding. I have the same problem with parsing a text document for values, etc.</p> <p>Thanks</p>
<p>If you need to map <code>&lt;condition on xml node</code>> to <code>&lt;change of state</code>> there's no way to avoid defining that mapping <em>somewhere</em>. It all depends on how many assumptions you can make about the conditions and what you do under those conditions. I think the dictionary idea is a good one. To offer as much flexibility as possible, I'd start like this:</p> <pre><code>Dictionary&lt;Predicate&lt;XmlNode&gt;, Action&gt; mappings; </code></pre> <p>Then start simplifying where you can. For example, are you often just setting wt to a value of MyEnum like in the example? If so, you want something like this:</p> <pre><code>Func&lt;MyEnum, Action&gt; setWt = val =&gt; () =&gt; wt = val; </code></pre> <p>And for the presumably common case that you simply check if an attribute has a specific value, you'd want some convenience there too:</p> <pre><code>Func&lt;string, string, Predicate&lt;XmlNode&gt;&gt; checkAttr = (attr, val) =&gt; node =&gt; node.Attributes[attr] == val; </code></pre> <p>Now your dictionary can contain items like:</p> <pre><code> ... {checkAttr("a", "abc"), setWt(MyEnum.Haze)}, ... </code></pre> <p>Which is nice and terse, but also isn't restricted to the simple <code>&lt;attribute, value</code>> to <code>&lt;enum</code>> mapping. OK, so now you have a big dictionary of these condition-action pairs, and you just say:</p> <pre><code>foreach(DictionaryEntry&lt;Predicate&lt;XmlNode&gt;, Action&gt; mapping in mappings) { if (mapping.Key(xmlNode)) { mapping.Value(); break; } } </code></pre> <p>If you avoid the lambda syntax and the dictionary initializers, you should be able to do that in 2.0.</p>
Email integration <p>I was wondering if someone could help me out. In some web application, the app will send out emails, say when a new message has been posted. Then instead of signing into the application to post a reply you can just simply reply to the email and it will automatically update the web app with your response.</p> <p>My question is, how is this done and what is it called?</p> <p>Thanks</p>
<p><strong>Generally:</strong></p> <p>1) Set up a dedicated email account for the purpose.</p> <p>2) Have a programm monitor the mailbox (let's say fetchmail, since that's what I do).</p> <p>3) When an email arrives at the account, fetchmail downloads the email, writes it to disk, and calls script or program you have written with the email file as an argument.</p> <p>4) Your script or program parses the email and takes an appropriate action.</p> <p>The part that's usually mysterious to people is the fetchmail part (#2).</p> <p><strong>Specifically on Mail Servers</strong> <em>(iff you control the mailserver enough to redirect emails to scripts)</em>:</p> <p>1-3) Configure an address to be piped to a script you have written.</p> <p>4) Same as above.</p>
Unable to set iPython to use 2.6.1 Python <p>I have installed the newest iPython in Mac. However, it uses the Python verion 2.5.1.</p> <p>I installed the Python 2.6.1 by MacPython package at <a href="http://www.python.org/download/" rel="nofollow">here</a>. </p> <p><strong>How can I make my iPython to use Python 2.6.1?</strong></p> <p>I am not sure where the MacPython package exactly installed the newest Python. The <strong>newest Python should somehow put the PATH</strong> so that iPyhon can use it. </p> <p><strong>[edit]</strong> after the first answer</p> <p>I run the following command</p> <pre><code>$ln -s python python2.6 </code></pre> <p>I cannot open python2.6 by </p> <pre><code>python </code></pre>
<p>A good way to get it to work is <a href="http://www.jamesmurty.com/2009/06/05/ipython-with-python-2_6-osx-leopard/" rel="nofollow">here.</a> I needed to restart my terminal before ipython pointed to python2.6. Note the latest ipython distribution is 0.10, not 0.9.</p>
What tools exist for comparing C++ code to coding guidelines? <p>There exist tools for comparing code against a custom specified set of coding guidelines/standards for a variety of languages (rather than pure static analysis for common defects). Examples include <a href="http://msdn.microsoft.com/en-us/library/bb429476%28VS.80%29.aspx">FxCop</a> for .Net code and <a href="http://checkstyle.sourceforge.net/">CheckStyle</a> for Java, but I was wondering what examples people know of in the C++ world.</p> <p><a href="http://stackoverflow.com/questions/93260/a-free-tool-to-check-c-c-source-code-against-a-set-of-coding-standards">An existing question was asked regarding free tools</a> which provided examples like <a href="http://www.inspirel.com/vera/">Vera</a> but I was also wondering about commercial tools that may be available.</p>
<p>A tool used by us was CodeWizard from Parasoft. But I think the new version is called "Parasoft C++ Test". From the homepage:</p> <ul> <li>Static analysis of code for compliance with user-selected coding standards </li> <li>Graphical RuleWizard editor for creating custom coding rules </li> <li>Static code path simulation for identifying potential runtime errors </li> <li>Automated code review with a graphical interface and progress tracking </li> <li>Automated generation and execution of unit and component-level tests </li> <li>Flexible stub framework </li> <li>Full support for regression testing </li> <li>Code coverage analysis with code highlighting </li> <li>Runtime memory error checking during unit test execution </li> <li>Full team deployment infrastructure for desktop and command line usage</li> </ul>
What does "exec sp_reset_connection" mean in Sql Server Profiler? <p>Trying to understand what Sql Profiler means by emitting "sp_reset_connection".</p> <p>I have the following, "exec sp_reset_connection" line followed by BatchStarting and Completed,</p> <pre><code>RPC:Completed exec sp_reset_connection SQL:BatchStarting SELECT [c].[TestID] AS [TestID], [c].[Description] AS [Description] FROM [dbo].[Test] AS [c] SQL:BatchCompleted SELECT [c].[TestID] AS [TestID], [c].[Description] AS [Description] FROM [dbo].[Test] AS [c] </code></pre> <p>Basically does first line "exec sp_reset_connection" mean the whole process (my connection was opened, the select stmt is run, then the connection is closed and released back to pool) just take place? Or my connection is still in open stage.</p> <p>And, why does the sp_reset_connection executed before my own select statement, shouldn't it the reset come after user's sql?</p> <p>I'm trying to know is there a way to know in more detail when a connection is opened and closed?</p> <p>By seeing "exec sp_reset_connection", does that mean my connection is closed?</p>
<p>Like the other answers said, <code>sp_reset_connection</code> indicates that connection pool is being reused. Be aware of one particular consequence!</p> <blockquote> <p><strong><a href="http://blogs.msdn.com/b/jimmymay/archive/2009/02/02/sp-reset-connection-does-not-reset-transaction-isolation-level-unexpected-behavior-by-design.aspx" rel="nofollow">Jimmy Mays' MSDN Blog</a></strong> said:</p> <p>sp_reset_connection does NOT reset the transaction isolation level to the server default from the previous connection's setting.</p> </blockquote> <p><strong>UPDATE</strong>: Starting with SQL 2014, for client drivers with TDS version 7.3 or higher, the transaction isolation levels will be reset back to the default. </p> <p>ref: <a href="http://stackoverflow.com/questions/9851415/sql-server-isolation-level-leaks-across-pooled-connections">SQL Server: Isolation level leaks across pooled connections</a></p> <p>Here is some additional information:</p> <blockquote> <p><strong><a href="http://web.archive.org/web/20100730003952/http://sqldev.net/articles/sp_reset_connection/default.html" rel="nofollow">What does sp_reset_connection do?</a></strong></p> <p>Data access API's layers like ODBC, OLE-DB and System.Data.SqlClient all call the (internal) stored procedure sp_reset_connection when re-using a connection from a connection pool. It does this to reset the state of the connection before it gets re-used, however nowhere is documented what things get reset. This article tries to document the parts of the connection that get reset.</p> <p>sp_reset_connection resets the following aspects of a connection:</p> <ul> <li><p>All error states and numbers (like @@error)</p></li> <li><p>Stops all EC's (execution contexts) that are child threads of a parent EC executing a parallel query</p></li> <li><p>Waits for any outstanding I/O operations that is outstanding</p></li> <li><p>Frees any held buffers on the server by the connection</p></li> <li><p>Unlocks any buffer resources that are used by the connection</p></li> <li><p>Releases all allocated memory owned by the connection</p></li> <li><p>Clears any work or temporary tables that are created by the connection</p></li> <li><p>Kills all global cursors owned by the connection</p></li> <li><p>Closes any open SQL-XML handles that are open</p></li> <li><p>Deletes any open SQL-XML related work tables</p></li> <li><p>Closes all system tables</p></li> <li><p>Closes all user tables</p></li> <li><p>Drops all temporary objects</p></li> <li><p>Aborts open transactions</p></li> <li><p>Defects from a distributed transaction when enlisted</p></li> <li><p>Decrements the reference count for users in current database which releases shared database locks</p></li> <li><p>Frees acquired locks</p></li> <li><p>Releases any acquired handles</p></li> <li><p>Resets all SET options to the default values</p></li> <li><p>Resets the @@rowcount value</p></li> <li><p>Resets the @@identity value</p></li> <li><p>Resets any session level trace options using dbcc traceon()</p></li> <li><p>Resets CONTEXT_INFO to <code>NULL</code> in SQL Server 2005 and newer <sub>[ not part of the original article ]</sub></p></li> </ul> <p><strong>sp_reset_connection will NOT reset:</strong></p> <ul> <li><p>Security context, which is why connection pooling matches connections based on the exact connection string</p></li> <li><p>Application roles entered using sp_setapprole, since application roles can not be reverted</p></li> </ul> </blockquote> <p><em>Note: I am including the list here as I do not want it to be lost in the ever transient web.</em></p>
Best way to convert Delphi code to C++? <p>I have an application written in Delphi that compiles in Delphi 2007. I think it was originally written in Delphi 7.</p> <p>Anyway, I need to convert all the core non-GUI code into C++ because I want to release a Mac version of the software.</p> <p>What is the best way to do this? Any shortcuts I can take to speed up the process?</p> <p>EDIT: The code compiles to native code, not .NET.</p>
<p>Why not just use an OS X Delphi compiler? <a href="http://www.freepascal.org/">Free Pascal</a> claims to support Delphi on OS X (though not being a Pascal coder I haven't tried it).</p>
Changing the Log4Net Root Level When App is built as Release <p>I have a project I am working on using log4net, and it works great, but I want to know if i can override the XML configuration for the root "level" attribute for the logging when in debug and release.</p> <p>Currently my root configuration looks like:</p> <pre><code>&lt;root&gt; &lt;level value="WARN"/&gt; &lt;appender-ref ref="LogFileAppender"/&gt; &lt;appender-ref ref="DebugAppender"/&gt; &lt;/root&gt; </code></pre> <p>And in my web applications Global.asax class, I was thinking I could wrap something in a </p> <pre><code>protected override void Application_Start(object sender, EventArgs e) { base.Application_Start(sender, e); XmlConfigurator.Configure(); #if DEBUG //Change logging level to DEBUG #endif } </code></pre> <p>To change the root logging level to debug when the solution is built in debug.</p> <p>Is this possible, is my idea a best-practises type soltuion to what I want, and how would I do it (or how would you do it better)? </p>
<p>I do the oposite, in debug mode I use the developer configurations which is better for filtering the relevant messages for me; and in release mode, I lock the level to WARN to prevent a user wants to hack my code (he could use tons of other ways, but this is a 5 seconds trick): </p> <pre><code>public static void Initialize() { #if DEBUG ConfigureAndWatch(); #else ConfigureAndLockChanges(); #endif } #if DEBUG private static void ConfigureAndWatch() { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); } #else private static void ConfigureAndLockChanges() { // Disable using DEBUG mode in Release mode (to make harder to hack) XmlConfigurator.Configure(new FileInfo("log4net.config")); foreach (ILoggerRepository repository in LogManager.GetAllRepositories()) { repository.Threshold = Level.Warn; } } #endif </code></pre>
Reference ASP.NET control by ID in JavaScript? <p>When ASP.NET controls are rendered their ids sometimes change, like if they are in a naming container. <code>Button1</code> may actually have an id of <code>ctl00_ContentMain_Button1</code> when it is rendered, for example.</p> <p>I know that you can write your JavaScript as strings in your .cs file, get the control's clientID and inject the script into your page using clientscript, but is there a way that you can reference a control directly from JavaScript using ASP.NET Ajax?</p> <p>I have found that writing a function to parse the dom recursively and find a control that CONTAINS the id that I want is unreliable, so I was looking for a best practice rather than a work-around. </p>
<p>This post by Dave Ward might have what you're looking for:</p> <p><a href="http://encosia.com/2007/08/08/robust-aspnet-control-referencing-in-javascript/">http://encosia.com/2007/08/08/robust-aspnet-control-referencing-in-javascript/</a></p> <p>Excerpt from article:</p> <blockquote> <p>Indeed there is. The better solution is to use inline ASP.NET code to inject the control’s ClientID property:</p> <pre><code>$get('&lt;%= TextBox1.ClientID %&gt;') </code></pre> <p>Now the correct client element ID is referenced, regardless of the structure of the page and the nesting level of the control. In my opinion, the very slight performance cost of this method is well worth it to make your client scripting more resilient to change.</p> </blockquote> <p>And some sample code by Dave from the comment thread of that post:</p> <pre><code>&lt;script&gt; alert('TextBox1 has a value of: ' + $get('&lt;%= TextBox1.ClientID %&gt;').value); &lt;/script&gt; </code></pre> <p>The comment thread to the article I linked above has some good discussion as well.</p>
Rewrite urls from user submitted HTML <p>I use one WYSIWYG editor in a small cms. It allows users to upload files, images, etc. If I add image named dog.jpg, in source I'll get:</p> <pre><code>&lt;img src="/myweb/userfiles/images/dog.jpg" /&gt; </code></pre> <p>I can save this to a database and use it later on any page, until I move my site to a live domain.</p> <p>myweb is virtual directory in IIS. "/" points to root, in this case localhost, so I have to use "/myweb". However when I upload site to server and copy database there, all links will be broken, because there is no "myweb" folder on server.</p> <p>My idea was to replace "/myweb" on save with empty string. I also have to replace full url, which editor creates for some files. On display I would have to add correct Application dir. I would probably save both versions in database, and only on server change force display version to update.</p> <p>By now I've come up with:</p> <pre><code>p = p.Replace("href=\"" + fullUrl, "href=\"").Replace("src=\"" + fullUrl, "src=\"").Replace("href=\"" + partialUrl, "href=\"").Replace("src=\"" + partialUrl, "src=\""); </code></pre> <p>Which is ugly, hard to maintain and inefficient. I guess better approach would be to use regex, but I don't know how to do it.</p> <p>My question is, can anyone recommend good article, blog/forum post on this? If you have other solution, great.</p>
<p>I am unsure the regex version has any of the characteristics you mention in this case.</p> <p>That said, you can do:</p> <pre><code> string ReplaceUrlPaths(string html, string partialPath, string fullPath) { var pattern = string.Format("((href|src)=\")({0}|{1})", partialPath, fullPath); var regex = new Regex(pattern); return regex.Replace(html, m =&gt; m.Groups[1].Value); } [TestMethod] public void TestMethod10() { var input = @"&lt;img src=""/myweb/userfiles/images/dog.jpg"" /&gt;"; //carefull with any special regex char in the paths var replaced = ReplaceUrlPaths(input, "/myweb", "/some/full/path"); Assert.AreEqual( @"&lt;img src=""/userfiles/images/dog.jpg"" /&gt;", replaced); } </code></pre> <p>If you are proceeding with that, refactor it to instantiate the regex once with the compile option(as the partialPath and fullPath won't be changing).</p> <p>Also consider avoiding it all, by defining a web site with an alternate port to just have it as a root Url.</p>
What are some utilities to search for code throughout many files or folders? <p>What is an utility to find code throughout many files or folders. Something akin to PowerGrep but freeware.</p>
<p>On Windows, there's a "find" command that is similar to grep.</p> <p>You could also download cygwin or some other Unix emulator and get grep from that.</p> <p>On Windows, you can also get a standalone version of grep with "unxutils" pack: <a href="http://unxutils.sourceforge.net/" rel="nofollow">http://unxutils.sourceforge.net/</a></p>
Delphi - Problem With Set String and PAnsiChar and Other Strings not Displaying <p>I was getting <a href="http://stackoverflow.com/questions/628965/delphi-accessing-data-from-dynamic-array-that-is-populated-from-an-untyped-poin/629213#629213">advice from Rob Kennedy</a> and one of his suggestions that greatly increased the speed of an app I was working on was to use <code>SetString</code> and then load it into the VCL component that displayed it.</p> <p>I'm using Delphi 2009 so now that PChar is Unicode,</p> <pre><code>SetString(OutputString, PChar(Output), OutputLength.Value); edtString.Text := edtString.Text + OutputString; </code></pre> <p>Works and I changed it to PChar myself but since the data being moved isn't always Unicode in fact its usually ShortString Data.... so onto what he actually gave me to use:</p> <pre><code>SetString(OutputString, PAnsiChar(Output), OutputLength.Value); edtString.Text := edtString.Text + OutputString; </code></pre> <p>Nothing shows up but I check in the debugger and the text that normally appeared the way I did it building 1 char at a time in the past was in the variable.</p> <p>Oddly enough this is not the first time I ran into this tonight. Because I was trying to come up with another way, I took part of his advice and instead of building into a VCL's TCaption I built it into a string variable and then copied it, but when I send it over nothing's displayed. Once again in the debugger the variable that the data is built in... has the data.</p> <pre><code>for I := 0 to OutputLength.Value - 1 do begin OutputString := OutputString + Char(OutputData^[I]); end; edtString.Text := OutputString; </code></pre> <p>The above does not work but the old slow way of doing it worked just fine....</p> <pre><code>for I := 0 to OutputLength.Value - 1 do begin edtString.Text := edtString.Text + Char(OutputData^[I]); end; </code></pre> <p>I tried making the variable a ShortString, String and TCaption and nothing is displayed. What I also find interesting is while I build my hex data from the same array into a richedit it's very fast while doing it inside an edit for the text data is very very slow. Which is why I haven't bothered trying to change the code for the richedit as it works superfast as it is.</p> <p>Edit to add - I think I sorta found the problem but I have no solution. If I edit the value in the debugger to remove anything that can't be displayed (which by the old method used to just not display... not fail) then what I have left is displayed. So if it's just a matter of getting rid of bytes that were turned to characters that are garbage how can I fix that?</p> <p>I basically have incoming raw data from a SCSI device that's being displayed hex-editor style. My original slow style of adding one char at a time successfully displayed strings and Unicode strings that did not have Unicode-specific characters in them. The faster methods even if working won't display ShortStrings one way and the other way wont display UnicodeStrings that aren't using non 0-255 characters. I really like and could use the speed boost but if it means sacrificing the ability to read the string... then what's the point in the app?</p> <p>EDIT3 - Alright now that I've figured out that 0-31 is control char and 32 and up is valid I think I'm gonna make an attempt to filter char and replace those not valid with a . which is something I was planning on doing later to emulate hex editor style.</p> <p>If there are any other suggestions I'd be glad to hear about them but otherwise I think I can craft a solution that's faster than the original and does what I need it to at the same time.</p>
<p>Some comments:</p> <ol> <li>Your question is very unclear. What exactly do you want to do?</li> <li>Your question reads terrible, please check your text with a spelling checker. </li> <li>The question you are referring to is this one: <a href="http://stackoverflow.com/questions/628965/delphi-accessing-data-from-dynamic-array-that-is-populated-from-an-untyped-poin">Delphi accessing data from dynamic array that is populated from an untyped pointer</a></li> <li>Please give a complete code sample of your function like you did in your previous question, I want to know if you implemented Rob Kennedy's suggestion or the code you gave yourself in a following answer (let's hope not :) )</li> <li>As far a I understand your question: You're sending a query to your SCSI device and you get an array of bytes back which you store in the variable OutputData. After that you want to show your data to the user. So your real question is: <strong>How to show an array of bytes to the user?</strong></li> <li>Login as the same user and don't create an account for every new question. That way we can track your question history an can find out what you mean by 'getting advice'.</li> </ol> <p>Some assumptions and suggestions if I'm right about the true meaning of your question:</p> <ol> <li>Showing your data as a hex string won't give any problems</li> <li>Showing your data in a normal Memo field gives you problems, although a Delphi string can contain any character, including 0 bytes, displaying them will give you problems. A TMemo for example will show your data till the first 0 byte. What you have to do (and you gave the answer yourself), is replacing non viewable characters with a dummy. After that you can show your data in a TMemo. Actually all hex viewers do the same, characters that cannot be printed will be shown as a dot.</li> </ol>
How should I log while using multiprocessing in Python? <p>Right now I have a central module in a framework that spawns multiple processes using the Python 2.6 <a href="http://docs.python.org/library/multiprocessing.html?#module-multiprocessing"><code>multiprocessing</code> module</a>. Because it uses <code>multiprocessing</code>, there is module-level multiprocessing-aware log, <code>LOG = multiprocessing.get_logger()</code>. Per <a href="http://docs.python.org/library/multiprocessing.html#logging">the docs</a>, this logger has process-shared locks so that you don't garble things up in <code>sys.stderr</code> (or whatever filehandle) by having multiple processes writing to it simultaneously.</p> <p>The issue I have now is that the other modules in the framework are not multiprocessing-aware. The way I see it, I need to make all dependencies on this central module use multiprocessing-aware logging. That's annoying <em>within</em> the framework, let alone for all clients of the framework. Are there alternatives I'm not thinking of?</p>
<p>I just now wrote a log handler of my own that just feeds everything to the parent process via a pipe. I've only been testing it for ten minutes but it seems to work pretty well. </p> <p>(<strong>Note:</strong> This is hardcoded to <code>RotatingFileHandler</code>, which is my own use case.)</p> <hr> <h2>Update: Implementation!</h2> <p>This now uses a queue for correct handling of concurrency, and also recovers from errors correctly. I've now been using this in production for several months, and the current version below works without issue.</p> <pre><code>from logging.handlers import RotatingFileHandler import multiprocessing, threading, logging, sys, traceback class MultiProcessingLog(logging.Handler): def __init__(self, name, mode, maxsize, rotate): logging.Handler.__init__(self) self._handler = RotatingFileHandler(name, mode, maxsize, rotate) self.queue = multiprocessing.Queue(-1) t = threading.Thread(target=self.receive) t.daemon = True t.start() def setFormatter(self, fmt): logging.Handler.setFormatter(self, fmt) self._handler.setFormatter(fmt) def receive(self): while True: try: record = self.queue.get() self._handler.emit(record) except (KeyboardInterrupt, SystemExit): raise except EOFError: break except: traceback.print_exc(file=sys.stderr) def send(self, s): self.queue.put_nowait(s) def _format_record(self, record): # ensure that exc_info and args # have been stringified. Removes any chance of # unpickleable things inside and possibly reduces # message size sent over the pipe if record.args: record.msg = record.msg % record.args record.args = None if record.exc_info: dummy = self.format(record) record.exc_info = None return record def emit(self, record): try: s = self._format_record(record) self.send(s) except (KeyboardInterrupt, SystemExit): raise except: self.handleError(record) def close(self): self._handler.close() logging.Handler.close(self) </code></pre>
Asp.Net MVC Can't get .html files or .xml files 404 error? <p>How do I return .html files or .xml files that are in folders in the view? I'm using jquery which request a static Html file via ajax and insert the results into a div and it keeps giving a 404 error any idea?</p> <p>Thanks</p>
<p>If you need to ignore routing for a given path, use:</p> <pre><code>routes.IgnoreRoute("path/to/static/content"); </code></pre> <p>Also, I may be reading your question wrong, but it's a bad idea to put static content in your View folders. Make a folder like "Content" or "public" at the document root.</p> <p>If you're actually needing to <em>process</em> a request and spit it out as .html or .xml, make a route that looks like "{controller}/{action}/{id}.xml" or something.</p>
Strange 5 second pause with PHP command line interface (related to mysql/mysqli extension) <p>I'm getting a strange 5 to 7 second pause when executing PHP scripts from the command-line PHP client (PHP 5.2 on Windows).</p> <p>During this pause the PHP script just appears to 'freeze' for a while before returning to the command prompt. It is not using any significant CPU time, it's like it is waiting for some delay.</p> <p>After experimenting with PHP.ini, I've narrowed this down to the fact that the mysql or mysqli extension is enabled. If these extensions are both disabled, no annoying pause and the PHP script terminates in mere milliseconds.</p> <p>The command I'm using is:</p> <pre><code>"C:\Program Files\PHP\php.exe" -f %1 </code></pre> <p>Where %1 is the PHP script.</p> <p>The pause still occurs even if the PHP script being executed is essentially empty:</p> <pre><code>&lt;?php ?&gt; </code></pre> <p>Do you know what is causing this pause and how I can remove it while still allowing mysql or mysqli support for PHP on the command line?</p>
<p>it's a <a href="http://bugs.mysql.com/bug.php?id=37226">bug in mysql</a>. you can solve it by getting the latest libmysql.dll (5.1.31 or higher. some older versions also work - see second link). make sure that's the libmysql.dll actually used and there are no other libmysql.dlls in your path. see the related <a href="http://bugs.php.net/bug.php?id=41350">php issue</a> for details.</p>
Silverlight 2.0 loading issue <p>I have developed a SL2 application for a client (whose computers are under pretty heavy lockdown via group policies). The SL2 application has worked fine for everyone except the client.</p> <p>The client is using WinXP + IE7 and has the SL2 runtime installed.</p> <p>On the client's machine the following error pops up:</p> <pre><code>Error: Unhandled Error in Silverlight 2 Application Code: 2103 Category: InitializeError Message: 2103 An error has occurred Code: 0 </code></pre> <p>The client can load SLv1 websites like <a href="http://silverlight.net" rel="nofollow">http://silverlight.net</a></p> <p>The client can't load SLv2 websites like:</p> <ul> <li><a href="http://memorabilia.hardrock.com" rel="nofollow">http://memorabilia.hardrock.com/</a></li> <li><a href="http://demos.telerik.com/silverlight/default.aspx" rel="nofollow">http://demos.telerik.com/silverlight/default.aspx</a></li> <li><a href="http://timheuer.com/wpfe/versiontest/" rel="nofollow">http://timheuer.com/wpfe/versiontest/</a></li> </ul> <p>What the client sees is a blank silverlight canvas but is able to right click and bring up the silverlight preferences menu.</p> <p><img src="http://img6.imageshack.us/img6/1309/hardrockerror.jpg" alt="alt text" /></p> <p>Any ideas on how to debug this issue or has anyone else encountered this issue?</p> <p>I should add that it works fine under firefox, but their IT department is unwilling to roll out FF to all the machines. The environment must be XP + IE7</p> <p>Markup:</p> <pre><code>&lt;object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"&gt; &lt;param name="source" value="/ClientBin/RosterUI.xap"/&gt; &lt;param name="onerror" value="onSilverlightError" /&gt; &lt;param name="background" value="white" /&gt; &lt;param name="minRuntimeVersion" value="2.0.31005.0" /&gt; &lt;param name="autoUpgrade" value="true" /&gt; &lt;param name="scaleMode" value="zoom" /&gt; &lt;a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"&gt; &lt;img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/&gt; &lt;/a&gt; &lt;/object&gt; </code></pre>
<p>After months of to-ing and fro-ing the issue has been resolved - although we still don't know the true underlying cause.</p> <p>The client's IT staff recently updated their transparent proxy server (which also filters content) and the silverlight app started working under IE.</p> <p>One of the changes made was to permit the downloading of DLL files (which is bundled in the XAP file). They think that is the cause, although I am not 100% convinced as it doesn't quite explain why it works in Firefox (assuming it also runs through the proxy)</p>
ModelFactory in ASP.NET MVC to solve 'RenderPartial' issue <p>The 'RenderPartial()' method in ASP.NET MVC offeres a very low level of functionality. It does not provide, nor attempt to provide a true 'sub-controller' model *.</p> <p>I have an increasing number of controls being rendered via 'RenderPartial()'. They fall into 3 main categories : </p> <blockquote> <p>1) Controls that are direct descendants of a specific page that use that page's model</p> <p>2) Controls that are direct descendants of a specific page that use that page's model with an <a href="http://stackoverflow.com/questions/369573/how-do-you-pass-an-arbitrary-bit-of-data-to-a-user-control-in-asp-net-mvc-using-h/584752#584752">additional key of some type</a>. Think implementation of 'DataRepeater'.</p> <p>3) Controls that represent unrelated functionality to the page they appear on. This could be anything from a banner rotator, to a feedback form, store locator, mailing list signup. The key point being it doesn't care what page it is put on.</p> </blockquote> <p>Because of the way the <code>ViewData</code> model works there only exists one model object per request - thats to say anything the subcontrols need must be present in the page model.</p> <p>Ultimately the MVC team will hopefully come out with a true 'subcontroller' model, but until then I'm just adding anything to the main page model that the child controls also need. </p> <p>In the case of (3) above this means my model for 'ProductModel' may have to contain a field for 'MailingListSignup' model. Obviously that is not ideal, but i've accepted this at the best compromise with the current framework - and least likely to 'close any doors' to a future subcontroller model.</p> <p>The controller should be responsible for getting the data for a model because the model should really just be a dumb data structure that doesn't know where it gets its data from. But I don't want the controller to have to create the model in several different places.</p> <p>What I have begun doing is creating a factory to create me the model. This factory is called by the controller (the model doesn't know about the factory).</p> <pre><code>public static class JoinMailingListModelFactory { public static JoinMailingListModel CreateJoinMailingListModel() { return new JoinMailingListModel() { MailingLists = MailingListCache.GetPartnerMailingLists(); }; } } </code></pre> <p>So my actual question is how are other people with this same issue actually creating the models. What is going to be the best approach for future compatibility with new MVC features?</p> <p><hr></p> <ul> <li>NB: There are issues with <code>RenderAction()</code> that I won't go into here - not least that its only in MVCContrib and not going to be in the RTM version of ASP.NET-MVC. Other issues caused <a href="http://stackoverflow.com/questions/523695/post-method-called-on-mvc-usercontrols-as-well-as-their-parent-views">sufficent problems</a> that I elected not to use it. So lets pretend for now that only <code>RenderPartial()</code> exists - or at least that thats what I've decided to use.</li> </ul>
<p>Instead of adding things like <code>MailingListSignup</code> as a property of your <code>ProductModel</code>, encapsulate both at the same level in a class like <code>ProductViewModel</code> that looks like:</p> <pre><code>public class ProductViewModel() { public ProductModel productModel; public MailingListSignup signup; } </code></pre> <p>Then get your View to be strongly-typed to the <code>ProductViewModel</code> class. You can access the <code>ProductModel</code> by calling <code>Model.productModel</code>, and you can access the signup class using <code>Model.signup</code>.</p> <p>This is a loose interpretation of Fowler's 'Presentation Model' (<a href="http://martinfowler.com/eaaDev/PresentationModel.html" rel="nofollow">http://martinfowler.com/eaaDev/PresentationModel.html</a>), but I've seen it used by some Microsoft devs, such as Rob Conery and Stephen Walther.</p>
Problem with iPhone application that plays Sound <p>I've developed an iPhone application that plays Sound. </p> <p>However, when I play a sound in the simulator, the console shows the lines below (<a href="http://img12.imageshack.us/img12/7097/picture2mtb.png" rel="nofollow">also shown in this screenshot</a>).</p> <pre><code>[12:07:07.505 &lt;0xb0185000&gt;] could not find audio decoder component 64766938 for registration [12:07:07.506 &lt;0xb0185000&gt;] could not find audio decoder component 6D730011 for registration [12:07:07.514 &lt;0xb0185000&gt;] could not find audio decoder component 696C6263 for registration [12:07:07.514 &lt;0xb0185000&gt;] could not find audio decoder component 6D730031 for registration [12:07:07.515 &lt;0xb0185000&gt;] could not find audio decoder component 696C6263 for registration </code></pre> <p>What is the problem?</p>
<p>How are you loading the file and, how are you adding the file to the application?</p> <p>If you are including your sound file in the app's bundle, this error can be caused because you are incorrectly loading the resource.</p> <p>If that is the case, this is the code you want to retrieve the sound file:</p> <p><code>NSString *resPath = [[NSBundle mainBundle] pathForResource:kMySoundFileName ofType:kMySoundFileNameExtension inDirectory:@""];</code></p>
Will a using statement rollback a database transaction if an error occurs? <p>I've got an IDbTransaction in a using statement but I'm unsure if it will be rolled back if an exception is thrown in a using statement. I know that a using statement will enforce the calling of Dispose()...but does anyone know if the same is true for Rollback()?</p> <p><strong>Update:</strong> Also, do I need to call Commit() explicitly as I have below or will that also be taken care of by the using statement? </p> <p>My code looks sort of like this:</p> <pre><code>using Microsoft.Practices.EnterpriseLibrary.Data; ... using(IDbConnection connection = DatabaseInstance.CreateConnection()) { connection.Open(); using(IDbTransaction transaction = connection.BeginTransaction()) { //Attempt to do stuff in the database //potentially throw an exception transaction.Commit(); } } </code></pre>
<p>Apparently yes. This is how SqlInternalTransaction's Dispose method (which SqlTransaction's Dispose calls) looks like from <a href="http://www.red-gate.com/products/reflector/">Reflector</a>:</p> <pre><code>private void Dispose(bool disposing) { // ... if (disposing &amp;&amp; (this._innerConnection != null)) { this._disposing = true; this.Rollback(); // there you go } } </code></pre>
If the path of a file has space in between the uri cannot fetch the file in the path <p>The message box crops up could not find part of the path of the file"file path" when i try to open a file that has space in its file path. I have used LocalPath instead of AbsolutePath and it works fine for me, but its only limited to WinApps, i needed a more generic solution. Some thing like Uri unescaped data path. I am not sure about the syntax.</p>
<p>If the file can be fetched depends on your implementation of the software. Try to replace the spaces with %20</p> <p>What kind of development are we talking about here? JAVA GUI or WebApps? C/C++?</p>
TreeView control in C#, select() and focus <p>When i select a node in the treeview it highlights and i show data based on that node below. When i select another control (the treeview loses focus) it is no longer highlighted. How do i keep it highlighted after losing focus? While doing a search i cant tell which node is selected since i must keep the focus on the textbox (so the user can type more text).</p>
<p>You have to set the HideSelection property to false - so you'll see the selection, altough the TreeView control lost focus</p>
Django MOD_PYTHON ERROR <p>I have had django running with mod_python for awhile now but today I get the following error</p> <pre><code>MOD_PYTHON ERROR ProcessId: 4551 Interpreter: 'thatch' ServerName: 'thatch' DocumentRoot: '/var/www/thatch' URI: '/' Location: '/' Directory: None Filename: '/var/www/thatch/' PathInfo: '' Phase: 'PythonHandler' Handler: 'django.core.handlers.modpython' Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch default=default_handler, arg=req, silent=hlist.silent) File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1202, in _process_target module = import_module(module_name, path=path) File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 304, in import_module return __import__(module_name, {}, {}, ['*']) ImportError: No module named django.core.handlers.modpython </code></pre> <p>This is my virtual host configuration</p> <pre><code>&lt;VirtualHost *:80&gt; ServerName thatch DocumentRoot /var/www/thatch &lt;Location "/"&gt; SetHandler python-program PythonPath "['/var/www/thatch'] + sys.path" PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE thatch.settings PythonOption django.root /var/www/thatch PythonDebug On &lt;/Location&gt; &lt;Location "/media"&gt; SetHandler None &lt;/Location&gt; &lt;LocationMatch "\.(jpg|gif|png|css|js)$"&gt; SetHandler None &lt;/LocationMatch&gt; &lt;/VirtualHost&gt; </code></pre> <p>Any ideas why this is happening?</p>
<p>I can only guess what your problem might be, but here are two standard checks:</p> <ol> <li>Import modpython in shell, from a couple different working directories</li> <li>Change users (if you have any besides root set up) and repeat step 1</li> </ol> <p>If #2 looks like more trouble than it's worth, then try <em>very, very carefully</em> examining permissions for each folder along the path to modpython to make sure that "other" has read access at every stage along the way. If you've moved django into your home directory (like I did once...not sure why, but got the same error) that'll be the problem. You either need to move it back into a directory where apache can read or you need to add read permission for other.</p>
Can 3D OpenGL game written in Python look good and run fast? <p>I am planning to write an simple 3d(isometric view) game in Java using jMonkeyEngine - nothing to fancy, I just want to learn something about OpenGL and writing efficient algorithms (random map generating ones). </p> <p>When I was planning what to do, I started wondering about switching to Python. I know that Python didn't come into existence to be a tool to write 3d games, but is it possible to write good looking games with this language? </p> <p>I have in mind 3d graphics, nice effects and free CPU time to power to rest of game engine? I had seen good looking java games - and too be honest, I was rather shocked when I saw level of detail achieved in Runescape HD. </p> <p>On the other hand, pygame.org has only 2d games, with some starting 3d projects. Are there any efficient 3d game engines for python? Is pyopengl the only alternative? Good looking games in python aren't popular or possible to achieve? </p> <p>I would be grateful for any information / feedback.</p>
<p>If you are worried about 3D performance: Most of the performance-critical parts will be handled by OpenGL (in a C library or even in hardware), so the language you use to drive it should not matter too much.</p> <p>To really find out if performance is a problem, you'd have to try it. But there is no reason why it cannot work in principle.</p> <p>At any rate, you could still optimize the critical parts, either in Python or by dropping to C. You still gain Python's benefit for most of the game engine which is less performance-critical.</p>
What is a better language-introduction preview than "Hello World"? <p>Many programming languages introduce themselves with a simple "Hello World" program.</p> <p>As a programmer, I must admit that this does not give very good insight into the strenghts and capabilities of the language.</p> <p>What kind of problem would you suggest to use when providing a demo of a programming language?</p>
<p>I think the "Hello World" program has its uses. It says a lot if you can run that program:</p> <ul> <li>You have your IDE/Tools setup correctly</li> <li>You can write a class and or main method in that language</li> <li>You can call a function in that language to print</li> <li>You can edit a file and format it correctly for that language</li> <li>Your compiler is working and you know how to use it.</li> </ul> <p>So, for those reasons I don't find any better alternative to "Hello World."</p> <p>However, in terms of a good intro to languages in general, I'm a big fan of coding challenges like <a href="http://www.pythonchallenge.com/">Python Challenge</a>. You are given a set of challenges/puzzles you have to complete with the language. They start out extremely basic (the first one is easier than writing a hello world). </p> <p>They quickly progress into more difficult and advanced tasks, and usually are tasks that are intended to show off a particular aspect of the language.</p> <p>I only wish every language had such a fun programming challenge. I think a LISP, Haskell, C++, C, Java, etc Challenge would be a fun introduction to the languages for people. They could be tailored to the languages. </p> <p>The C++ challenge could quickly start having challenges involving pointers and other commonly misunderstood aspects to help drive home those difficult bits while the LISP/Haskell challenges could start to ask some questions that are more tailored to functional languages.</p>
is there AES source code (VB.NET) that decrypts AS3CRYPTO crypted msgs <p>Is there a simple ASP.NET (.VB) available for AES-encrypting?</p> <p>here is a link to c# one but its complicate one having pretty much parameters, for example salt. [<a href="http://www.gutgames.com/post/AES-Encryption-in-C.aspx" rel="nofollow">http://www.gutgames.com/post/AES-Encryption-in-C.aspx</a>]</p> <p>I need a simple one that works together with GOOGLEAS3 Class that is called easily like this:</p> <pre><code>var key:ByteArray = Hex.toArray("1234567890abcdef"); var pt:ByteArray = Hex.toArray( Hex.fromString("aaaaaaaaaaaaaaaaaaaa")); var aes:AESKey = new AESKey(key); aes.encrypt(pt); var out:String = Hex.fromArray(pt).toUpperCase(); </code></pre>
<p>AES is built into the framework, as the <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.aes.aspx" rel="nofollow">Aes</a> class in System.Security.Cryptography. There are two concrete implementations, one managed, one using the Windows Crypto Service Provider (faster, but not portable to other platforms). There's also an implementation of <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged.aspx" rel="nofollow">Rijndael</a>, from which AES derives.</p> <p>Remember you need an initialization vector, as well as the key to encrypt/decrypt, as it's a block cipher. If you encrypt without setting one a random one will be used, but you will need to store and retrieve it for decryption.</p> <p>Example Code: (lifted from chapter 6 of my forthcoming book <em>grin</em>)</p> <pre><code>static byte[] Encrypt(byte[] clearText, byte[] key, byte[] iv) { // Create an instance of our encyrption algorithm. RijndaelManaged rijndael = new RijndaelManaged(); // Create an encryptor using our key and IV ICryptoTransform transform = rijndael.CreateEncryptor(key, iv); // Create the streams for input and output MemoryStream outputStream = new MemoryStream(); CryptoStream inputStream = new CryptoStream( outputStream, transform, CryptoStreamMode.Write); // Feed our data into the crypto stream. inputStream.Write(clearText, 0, clearText.Length); // Flush the crypto stream. inputStream.FlushFinalBlock(); // And finally return our encrypted data. return outputStream.ToArray(); } </code></pre> <p>and to decrypt</p> <pre><code>static byte[] Decyrpt(byte[] clearText, byte[] key, byte[] iv) { // Create an instance of our encryption algorithm. RijndaelManaged rijndael = new RijndaelManaged(); // Create an decryptor using our key and IV ICryptoTransform transform = rijndael.CreateDecryptor(key, iv); // Create the streams for input and output MemoryStream outputStream = new MemoryStream(); CryptoStream inputStream = new CryptoStream( outputStream, transform, CryptoStreamMode.Write); // Feed our data into the crypto stream. inputStream.Write(clearText, 0, clearText.Length); // Flush the crypto stream. inputStream.FlushFinalBlock(); // And finally return our decrypted data. return outputStream.ToArray(); } </code></pre> <p>replace the RijndaelManaged class with one of the AES classes and a suitable key.</p>
help with T-SQL on SQL Server 2005 <p>I have a T-SQL that works below:</p> <pre><code> SELECT WP_VTDID AS UTIL_VTDID, (SELECT COUNT(WP_ENGINE) FROM WAYPOINTS WHERE (WP_ENGINE = 1) AND (WP_SPEED > 0) AND WP_VTDID='L083') AS UTIL_RUN, (SELECT COUNT(WP_ENGINE) FROM WAYPOINTS WHERE (WP_ENGINE = 1) AND (WP_SPEED = 0) AND WP_VTDID='L083') AS UTIL_IDLE, (SELECT COUNT(WP_ENGINE) FROM WAYPOINTS WHERE (WP_ENGINE = 0) AND WP_VTDID='L083') AS UTIL_OFF FROM WAYPOINTS WHERE WP_VTDID = 'L083' AND WP_DATETIME BETWEEN '2009-03-13 00:00:00' AND '2009-03-13 23:59:59' GROUP BY WP_VTDID </code></pre> <br> However i have multiple **WP_VTDID** values and i want to fetch all of data, can someone create a T-SQL command that works for multiple value? (value already on database) <br><br> PS: Just ignore the **WP_DATETIME** for now <br><br> So the result could be something like this: <pre> --------------------------------- | UTIL_VTDID | RUN | IDLE | OFF | --------------------------------- | L083 | 100 | 20 | 0 | | L084 | 200 | 50 | 10 | | L085 | 60 | 30 | 50 | | L086 | 0 | 0 | 100 | --------------------------------- </pre> <p><hr> found the solution, thanks to <strong>Jakob Christensen</strong> <pre><code> SELECT WP_VTDID AS UTIL_VTDID, (SELECT COUNT(WP_ENGINE) FROM WAYPOINTS WHERE (WP_ENGINE = 1) AND (WP_SPEED > 0) AND WP_VTDID=t.WP_VTDID) AS UTIL_RUN, (SELECT COUNT(WP_ENGINE) FROM WAYPOINTS WHERE (WP_ENGINE = 1) AND (WP_SPEED = 0) AND WP_VTDID=t.WP_VTDID) AS UTIL_IDLE, (SELECT COUNT(WP_ENGINE) FROM WAYPOINTS WHERE (WP_ENGINE = 0) AND WP_VTDID=t.WP_VTDID) AS UTIL_OFF FROM WAYPOINTS t WHERE WP_DATETIME BETWEEN '2009-03-13 00:00:00' AND '2009-03-13 23:59:59' GROUP BY WP_VTDID </code></pre><br> Thanks,<br> Dels</p>
<p>You want to JOIN your nested SQL statements on the waypoints table.</p> <p>This is untested but see what I've done here:</p> <pre><code>SELECT WAYPOINTS.WP_VTDID AS UTIL_VTDID, COUNT(UTIL_RUN.WP_ENGINE) AS UTIL_RUN FROM WAYPOINTS JOIN WAYPOINTS UTIL_RUN ON WAYPOINTS.PKEY=UTIL_RUN.PKEY AND (UTIL_RUN.WP_ENGINE = 1) AND (UTIL_RUN.WP_SPEED &gt; 0) WHERE WAYPOINTS.WP_DATETIME BETWEEN '2009-03-13 00:00:00' AND '2009-03-13 23:59:59' GROUP BY WAYPOINTS.WP_VTDID </code></pre> <p>Just join for other values.</p> <p>and substitute pkey for your primarykey field.</p>
LINQ to SQL inserting large object from .NET <p>What is the fastest way to get a list object with a count of 100,000 records into SQL using LINQ to SQL?</p>
<p>For mass data, the <em>fastest</em> way is to use something like <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx" rel="nofollow"><code>SqlBulkCopy</code></a> to push the data (via a crafted <code>IDataReader</code>) into a staging table (same layout, but no indexes/etc) - and then use <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.aspx" rel="nofollow">SqlCommand</a> to execute a stored procedure to push the data from the staging table into the real table. But note that LINQ-to-SQL isn't involved here (unless you use it to invoke the stored procedure).</p> <p>You could try just using regular LINQ-to-SQL <code>InsertOnSubmit</code> - assess how big a problem the volume of data is before you try to optimise it; it might be "fast enough" even though sub-optimal.</p> <p>You can create an <code>IDataReader</code> fairly easily; I often use the csv on from <a href="http://www.codeproject.com/KB/database/CsvReader.aspx" rel="nofollow">here</a>. To create one from a list, you could borrow <code>SimpleDataReader</code> from <a href="http://groups.google.co.uk/group/microsoft.public.dotnet.languages.csharp/msg/b1d70b504cdee2ad" rel="nofollow">here</a> and override <code>DoRead</code>.</p>
WCF: Separate service per Business Entity <p>If for example, you have customers, orders and products. Do you create a separate service for each of these business entities?</p> <p>It kinda feels logical that you should create a service contract for each of these. However, since you have to explicitly specify the contract that your service will implement… this sort of forces you to create a separate service for each service contract, does it not?</p> <p>Could you please tell me how you would handle this? Somehow it feels ungainly to have a service for ever business entity… :-(</p> <p>In advance, many thanks and regards.</p>
<p>Services act on business entities, but are not business entities.</p> <p>So customers, orders and products would be data contracts, not service contracts.</p> <p>It's the actions you perform on those data contracts that form your service contract, and the actions you expose on an entity may or not be all the things that entity can do.</p> <p>If, as I think you might be asking, each entity has common functionality (CRUD operations for example) then yes, you should have a separate service contact for a CRUD service on each entity (CustomerCRUDService, OrderCRUDService etc.) because web services don't support overloads on method signatures.</p> <p>(From the comments)</p> <p>There are a couple of ways.</p> <p>1) Composite service contracts: For example I have a service that implements WSTransfer - this actually is comprised of two service contracts, IWSTransferResource and IWSTransferFactory. In turn I have an IWSTransfer service contract that just implements those separate contracts - public interface IWSTransfer : IWSTransferResource, IWSTransferFactory</p> <p>2) But you don't even have to get that complicated, an implementation in WCF can implement multiple service contracts - MyServiceImpl : IMyContract1, IMyContract2. However each contract needs a separate endpoint, because endpoints are for service contracts, not implementation classes.</p>
What's the best way to deprecate a column in a database schema? <p>After reading through many of the questions here about DB schema migration and versions, I've come up with a scheme to safely update DB schema during our update process. The basic idea is that during an update, we export the database to file, drop and re-create all tables, and then re-import everything. Nothing too fancy or risky there.</p> <p>The problem is that this system is somewhat "viral", meaning that it is only safe to <em>add</em> columns or tables, since removing them would cause problems when re-importing the data. Normally, I would be fine just ignoring these columns, but the problem is that many of the removed items have actually been refactored, and the presence of the old ones in the code fools other programmers into thinking that they can use them.</p> <p>So, I would like to find a way to be able to mark columns or tables as deprecated. In the ideal case, the deprecated objects would be marked while updating the schema, but then during the next update our backup script would simply not SELECT the objects which have been marked in this way, allowing us to eventually phase out these parts of the schema.</p> <p>I have found that MySQL (and probably other DB platforms too, but this is the one we are using) supports the COLUMN attribute to both fields and tables. This would be perfect, except that I can't figure out how to actually use it in a meaningful manner. How would I go about writing an SQL query to get all column names which do <em>not</em> contain a comment matching text containing the word "deprecated"? Or am I looking at this problem all wrong, and missing a much better way to do this?</p>
<p>Maybe you should refactor to use views over your tables, where the views never include the deprocated columns.</p>
WPF lost Databinding <p>I'm new to WPF and its Databinding, but I stumbled upon a strange behaviour I could not resolve for myself.</p> <p>In a Dialog I've got a Listbox with Users and a TextBox for a username. Both are bound to a UserLogonLogic-which publishes among others a <code>CurrentUser</code> property.</p> <p>I want the TextBox to update its text when I click on a name in the ListBox. I also want the <code>SelectedItem</code> in the ListBox to be updated when I enter a username directly into the TextBox. Partial names in the TextBox will be resolved to the first matching value in the listbox or null if there is none.</p> <p>At first the TextBox gets updated every time I click into the ListBox. Debug shows me that every time the <code>PropertyChangeEvent</code> for <code>CurrentUser</code> is fired the method <code>txtName_TextChanged</code> method is called. Only after I have typed something into the textbox the <code>DataBinding</code> of the TextBox seems to be lost. There will be no further updates of the TextBox when I click into the ListBox. Debug now shows me that the method <code>txtName_TextChanged</code> is no longer being called after the <code>CurrentUser</code> <code>PropertyChangeEvent</code> is fired.</p> <p>Does anybody have an idea where I could have gone wrong?</p> <p>Thanks a lot<br> Rü</p> <p>UserLogon.xaml:</p> <pre><code> &lt;ListBox Grid.Column="0" Grid.Row="1" Grid.RowSpan="4" MinWidth="100" Margin="5" Name="lstUser" MouseUp="lstUser_MouseUp" ItemsSource="{Binding Path=Users}" SelectedItem="{Binding Path=CurrentUser, Mode=TwoWay}"/&gt; &lt;TextBox Grid.Column="1" Grid.Row="1" Margin="3" Name="txtName" TextChanged="txtName_TextChanged" Text="{Binding Path=CurrentUser, Mode=OneWay}" /&gt; </code></pre> <p></p> <p>UserLogon.xaml.cs:</p> <pre><code> public UserLogon() { InitializeComponent(); _logic = new UserLogonLogic(); TopLevelContainer.DataContext = _logic; } private int _internalChange = 0; private void txtName_TextChanged(object sender, TextChangedEventArgs e) { if (_internalChange &gt; 0) { return; } _internalChange++; string oldName = txtName.Text; User user = _logic.SelectByPartialUserName(oldName); string newName = (user == null) ? "" : user.Name; if (oldName != newName) { txtName.Text = (newName == "") ? oldName : newName; txtName.Select(oldName.Length, newName.Length); } _internalChange--; } </code></pre> <p>UserLogon.Logic.cs:</p> <pre><code>public class UserLogonLogic : INotifyPropertyChanged { private User _currentUser; public User CurrentUser { get { return _currentUser; } set { if (value != CurrentUser) { _currentUser = value; OnPropertyChanged("CurrentUser"); } } private IEnumerable&lt;User&gt; _users; public IEnumerable&lt;User&gt; Users { get { if (_users == null) { List&lt;User&gt; _users = Database.GetAllUsers(); } return _users; } } public event PropertyChangedEventHandler PropertyChanged; public void OnPropertyChanged(string prop) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(prop)); } } public User SelectByPartialUserName(string value) { if (value != "") { IEnumerable&lt;User&gt; allUser = GetAllUserByName(value); if (allUser.Count() &gt; 0) { CurrentUser = allUser.First(); } else { CurrentUser = null; } } else { CurrentUser = null; } return CurrentUser; } private IEnumerable&lt;User&gt; GetAllUserByName(string name) { return from user in Users where user.Name.ToLower().StartsWith(name.ToLower()) select user; } } </code></pre>
<p>This is a job for a good view model. Define two properties on your view model:</p> <ul> <li><code>SelectedUser : User</code></li> <li><code>UserEntry : string</code></li> </ul> <p>Bind the <code>ListBox</code>'s <code>SelectedItem</code> to the <code>SelectedUser</code> property, and the <code>TextBox</code>'s <code>Text</code> property to the <code>UserEntry</code> property. Then, in your view model you can do the work to keep them in sync: - if <code>SelectedUser</code> changes, set <code>UserEntry</code> to that user's <code>Name</code> - if <code>UserEntry</code> changes, do an intelligent search through all users and set <code>SelectedUser</code> to either <code>null</code> if no match was found, or the first matching <code>User</code></p> <p>Here is a complete and working sample. I wish I could easily attach a zip file right about now.</p> <p>First, <em>ViewModel.cs</em>:</p> <pre><code>public abstract class ViewModel : INotifyPropertyChanged { private readonly Dispatcher _dispatcher; protected ViewModel() { if (Application.Current != null) { _dispatcher = Application.Current.Dispatcher; } else { _dispatcher = Dispatcher.CurrentDispatcher; } } public event PropertyChangedEventHandler PropertyChanged; protected Dispatcher Dispatcher { get { return _dispatcher; } } protected virtual void OnPropertyChanged(PropertyChangedEventArgs e) { var handler = PropertyChanged; if (handler != null) { handler(this, e); } } protected void OnPropertyChanged(string propertyName) { OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); } } </code></pre> <p><em>User.cs</em>:</p> <pre><code>public class User : ViewModel { private readonly string _name; public User(string name) { _name = name; } public string Name { get { return _name; } } } </code></pre> <p><em>LogonViewModel.cs</em>:</p> <pre><code>public class LogonViewModel : ViewModel { private readonly ICollection&lt;User&gt; _users; private User _selectedUser; private string _userEntry; public LogonViewModel() { _users = new List&lt;User&gt;(); //fake data _users.Add(new User("Kent")); _users.Add(new User("Tempany")); } public ICollection&lt;User&gt; Users { get { return _users; } } public User SelectedUser { get { return _selectedUser; } set { if (_selectedUser != value) { _selectedUser = value; OnPropertyChanged("SelectedUser"); UserEntry = value == null ? null : value.Name; } } } public string UserEntry { get { return _userEntry; } set { if (_userEntry != value) { _userEntry = value; OnPropertyChanged("UserEntry"); DoSearch(); } } } private void DoSearch() { //do whatever fuzzy logic you want here - I'm just doing a simple match SelectedUser = Users.FirstOrDefault(user =&gt; user.Name.StartsWith(UserEntry, StringComparison.OrdinalIgnoreCase)); } } </code></pre> <p><em>UserLogon.xaml</em>:</p> <pre><code>&lt;UserControl x:Class="WpfApplication1.UserLogon" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="300" Width="300"&gt; &lt;StackPanel&gt; &lt;ListBox ItemsSource="{Binding Users}" SelectedItem="{Binding SelectedUser}" DisplayMemberPath="Name"/&gt; &lt;TextBox Text="{Binding UserEntry, UpdateSourceTrigger=PropertyChanged}"/&gt; &lt;/StackPanel&gt; &lt;/UserControl&gt; </code></pre> <p><em>UserLogon.xaml.cs</em>:</p> <pre><code>public partial class UserLogon : UserControl { public UserLogon() { InitializeComponent(); //would normally map view model to view with a DataTemplate, not manually like this DataContext = new LogonViewModel(); } } </code></pre>
my default.aspx.vb is unable to see another myclass.cs file in same folder ! <p>I am trying to use myclass.cs from aspx.vb but receive error "myclass not declared" when I give command:</p> <p>Imports myclass</p> <p>any ideas how to make a reference?</p>
<ol> <li><p>Ensure you declared your class <strong>public</strong>.</p></li> <li><p>Put your C# class into the App_Code folder.</p></li> </ol>
Firefox onkeydown detect pressed key <p>From an input text I need to call a function to capture the onkeydown event and I need to pass a parameter to that event, for example:</p> <pre><code>&lt;input type="text" onkeydown="TextOnKeyDown('myPrefix');" /&gt;... </code></pre> <p>Then in that function I need to know what key was pressed. I use</p> <pre><code>function TextOnKeyDown(prefix) { var key = event.keyCode; ... } </code></pre> <p>This works like a charm in IE, but not in Firefox. I've read that for firefox you have to pass an argument to the handler and then use it to get the key, something similar to:</p> <pre><code>&lt;input type="text" onkeydown="detectKey(event)"/&gt; ... function detectKey(e){ var key = (document.all) ? e.keyCode : e.which; ... } </code></pre> <p>But I cannot get to pass my parameter and the needed event parameter for firefox. Any suggestions?</p>
<p>I wrote this yesterday, works in both FF and IE => </p> <pre><code>//execute this during initialization document.onkeydown = function(event) { var holder; //IE uses this if(window.event) { holder = window.event.keyCode; } //FF uses this else { holder = event.which; } keyz(holder); } function keyz(key) { if(key === /*desired code*/) { /*execute stuff*/ } } </code></pre> <p>you will want to replace document.onkeydown with [your input].onkeydown</p>
Semi-transparent image border <p>I'd like the image to bleed into the container div.imgborder and i'd like the bleeding to be semitransparent (like an opaque glass effect). Is there a way to achieve this via CSS or maybe setting an image background with some opacity on the div.imgborder? </p> <pre><code>&lt;!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd'&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;meta name='keyword' content=''&gt; &lt;meta name='description' content=''&gt; &lt;link rel='stylesheet' href='reset.css'&gt; &lt;style type='text/css'&gt; body { background-color: #ccc; } div#container { width: 960px; margin-left: auto; margin-right: auto; margin-top: 50px; } img#myimg { overflow: visible; } div.imgborder { background-color: #222; opacity: 0.9; width: 160px; height: 160px; padding: 10px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id='container'&gt; &lt;div class='imgborder' align='center'&gt; &lt;img src='bar.jpg' alt='' width='160' height='160' id='myimg' /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
<p>Gecko and WebKit support setting rgba() as a border-color property, so you could potentially set:</p> <pre><code>border-color: rgba(255,255,255,0.42); </code></pre> <p>..and have a border that is semi-transparent.</p> <p>To accomplish the bleeding, however, you'll probably need to overlay a transparent div on the image and give it a width and height equal to the width and height of the image minus the width of the border. So if the image is 200x200, and you want a 2px border, you'll probably have to make the div 196x196 since the box model dictates that the border width is added to the width/height dimensions.</p>
Retain newlines in HTML but wrap text: possible? <p>I came across an interesting problem today. I have a text email I'm sending from a Web page. I'm displaying a preview and wanted to put the preview in a fixed font retaining the white space since that's the way the plain text email will appear.</p> <p>Basically I want something that'll act like Notepad: the newlines will signal a newline but the text will otherwise wrap to fit inside it's container.</p> <p>Unfortunately this is proving difficult unless I'm missing something really obvious. I've tried:</p> <ol> <li><p>CSS <code>white-space: pre</code>. This retains white space but doesn't wrap lines of text so they go out the borders on long lines;</p></li> <li><p>Styling a textarea element to be read only with no border so it basically apepars like a <code>div</code>. The problem here is that IE doesn't like 100% heights on textareas in strict mode. Bizarrely it's OK with them in quirks mode but that's not an option for me.</p></li> <li><p>CSS <code>white-space: prewrap</code>. This is CSS 2.1 so probably not widely supported (I'm happy if it's supported in IE7 and FF3 though; I don't care about IE6 for this as its an admin function and no one will be running IE6 that will use this page).</p></li> </ol> <p>Any other suggestions? Can this really be that hard?</p> <p>edit: can't comment so more info. Yes at the moment I am using font Courier New (i.e. fixed width) and using a regex on the server side to replace the newlines with <code>&lt;br&gt;</code> tags but now I need to edit the content and it just strikes me as awkward that you need to strip out and add the <code>&lt;br&gt;</code>s to make it work.</p> <p>is there no better way?</p>
<p>Try</p> <pre><code>selector { word-wrap: break-word; /* IE&gt;=5.5 */ white-space: pre; /* IE&gt;=6 */ white-space: -moz-pre-wrap; /* For Fx&lt;=2 */ white-space: pre-wrap; /* Fx&gt;3, Opera&gt;8, Safari&gt;3*/ } </code></pre>
Forcing Installshield to uninstall before an install <p>I have an InstallShield 12 installscript. I want to uninstall the old version before installing the new version. I will keep the name of the package unchanged. How can I do this?</p>
<p>With an MSI-based project, this would be accomplished by configuring a Major Upgrade for your project. Upgrades don't exist for InstallScript projects, but there are no Windows Installer restrictions to keep you from running multiple installations simultaneously. You should be able to simply run the uninstallation of the previous version manually in your InstallScript code (maybe in the OnFirstUIBefore function).</p>
Can't access entity from within the View <p>I'm passing <code>IList&lt;Post&gt;</code> to <code>View(posts)</code>.<br /> <code>Post</code> is a <code>linqToSql</code> generated model class.<br /> <code>Post</code> has an <code>FK</code> relation to the <code>Category</code> table by <code>Id</code>.</p> <p>When I'm iterating over <code>IList&lt;Post&gt;</code> inside my <code>View</code> and trying to access <code>post.Category.Title</code> I'm receiving an error:</p> <blockquote> <p>System.ObjectDisposedException: Cannot access a disposed object. Object name: 'DataContext accessed after Dispose.'.</p> </blockquote> <p>How can I get <code>Category.Title</code> for each of my <code>Posts</code> right from <code>View</code>?</p>
<p>Yes, actually what the error tells you! In other words, keep your DataContext open till you finished working with the data.</p> <p>Previously I just create a DataContext per page request, and dispose it at the end of the request. Worked relatively well.</p>
How to remove projects/ solutions from Recent Projects window in Visual Studio 2005 <p>In the top left corned of the Visual Studio Start Page there is a Recent Projects section that lists as standard 10 last opened Project. I am aware that this number can be changed using <strong>Tools->Options->Environment->Genera</strong>l and then modifying number in Recent Files section</p> <p>But my question is how could I remove some projects from that recent list?</p>
<p>This <a href="http://aspnetcoe.wordpress.com/2007/02/06/how-to-remove-recent-projects-from-visual-studio-start-page/">blog post</a> answers your question quite nicely. I won't duplicate the author's work here.</p> <h3>Steps to Remove Recent Projects</h3> <ol> <li>Close Visual Studio if it is running.</li> <li>Start the Registry Editor (Start...Run... type <code>regedit</code>).</li> <li>Navigate to this registry key: <code>HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\ProjectMRUList</code></li> <li>Then delete the key that has the project you do not want to keep in the list.</li> </ol>
I2C ISR and Interrupts <p>Platform - ARM9</p> <p>I have a third party device connected via I2C to the ARM9. My problem is the I2C read/write is getting in a twist. It appears the IRQ line is asserted but never de-asserted when there is data to read. The read fails as the third-party device NACKs the address packet. So any subsequent write fails.</p> <p>I am wondering if my interrupt handling in ok. In the ISR that services the IRQ, I disable interrupts, unregister the interrupt handler and then signal to the task to go read from the I2C bus. Finally, I re-enable the interrupts.</p> <p>When the task services the signal posted above, I attempt to read data from the I2C bus but this fails. Finally, I always reregister the ISR after ever read attempt. There is no interrupt disabling/enabling that takes place during handling of the read signal.</p> <p>My question is do I need to disable interrupts when reading/writing to the I2C bus? </p> <p>Programming language of choice is c using propriety RTOS.</p>
<p>An important thing is whether your RTOS/system is ready to support nested exceptions. Unless there is a good reason to do so, things are simpler if you avoid nested exceptions and disable all interrupts when entering an ISR and re-enabling when leaving.</p> <p>If you want to allow other higher-priority interrupts to occur while you are serving the I2C interrupt, then disable only the I2C interrupt. It is rather unusual to unregister an interrupt handler when entering an ISR. This may lead to unexpected behaviour, when there is no registered handler, the interrupt itself is enabled and an interrupt occurs. So instead of unregistering the handler, simple disable the I2C interrupt (Perhaps you are already doing so, but as I see it, registering a handler and enabling an interrupt are two different things).</p> <p>A good strategy to solve your problem will be to try to communicate with the device without interrupts. Try to read/write from it in a serial fashion, doesn't matter if everything blocks - it is just testing. This is much easier to debug and after you are successful you can move to the interrupts version.</p>
url does not decode properly with request[] in C# <p>I have an object like this: </p> <pre><code>public class adapterContext { public HttpRequest Request; } adapterContext ac = new adapterContext(); ac.Response = context.Response; </code></pre> <p>I pass this object to my functions and use ac.Request[""] to get my url variables. However this somehow does not translate national/special characters correct. When I use f.ex this as part of the URL: prospectName=Tester+%e6+%f8+%e5</p> <p>I get "Tester ? ? ?" </p> <p>From the debugger I get: ac.Request["prospectName"][7] 65533 '�' char</p> <p>Anyone have any idea how I should fix this?</p>
<p>there's a nice function, you should take care of: <a href="http://msdn.microsoft.com/en-us/library/system.web.httputility.urldecode.aspx" rel="nofollow">HttpUtility.UrlDecode(string, Encoding)</a> ... otherwise you need to adjust the <a href="http://msdn.microsoft.com/en-us/library/hy4kkhe0.aspx" rel="nofollow">globalization setting</a> in your web.config (requestEncoding, responseEncoding ...)</p>
how can i add another object to an already defined IQueryable object? <p>I have IQueryable Products. now i want to add new product to this IQueryable object. so how do i do this?</p>
<p>I've never tried this, but try products.Union(moreProducts).</p>
Making VB.NET debugging like C# <p>I've programmed in C# for the majority of my .NET career - now I'm working on a VB.net project - when debugging it drives me insane the differences of how the debugging works.</p> <p>two off the top of my head are</p> <p>1) having to prefix my immediate window queries with ?</p> <p>2) not being able to mouse over a GUID, I have to ?myGuid.ToString() to actually see the value</p> <p>is there a way I can make it behave like C#?</p>
<p>1 is supported by both VB and C#. When you prefix an immediate window query with ?, you are saying "please evaluate an expression". In the abscence of a ?, anything you will type will be evaluated as a statement. This makes a big difference in the following two lines</p> <pre><code>? a = b a = b </code></pre> <p>The first one is a comparison operation and the second one is an assignment. </p> <p>As for the second issue. Yes, this is an unfortunate experience for the current version of VS. The next version of VS fixes this problem (and several others in the debugging space). </p> <p>There is a work around for VS2008 (and likely VS2005) that will allow you to work around the problem. You can add a custom DebuggerDisplay for GUID that invokes .ToString on the object. I wrote up a blog post awhile back on how to achieve this</p> <p><a href="http://blogs.msdn.com/jaredpar/archive/2007/09/28/customzing-displays-in-the-debugger-for-system-types.aspx" rel="nofollow">http://blogs.msdn.com/jaredpar/archive/2007/09/28/customzing-displays-in-the-debugger-for-system-types.aspx</a></p>
What should I consider when choosing a mocking framework for .Net <p>There are lots of mocking frameworks out there for .Net some of them have been superseded by others that are better in everyway. However that still leaves many mocking frameworks that have different <em>styles</em> of usage.</p> <p>The time it takes to learn all of them well enough to decide witch to use is unreasonable. I don’t believe that we have yet reached a stage that we can talk about <em>the best</em> mocking framework. So what questions should I by asking about the project and myself to help decide on the best mocking framework to use in a given case?</p> <p>It would also be useful to know why you choose the mocking framework you are currently using and if you are still happy with that choose.</p> <p>Is there yet a useful vocabulary to use when comparing the styles of mocking frameworks?</p> <p>(I have limited this question to .Net as Java does not have attributes or lambda expression, so I hope the mocking frameworks can be better for .Net then Jave)</p> <p><strong>Summary so far:</strong></p> <ul> <li>If you need to mock static method, or none virtual methods then the only reasonable option is <a href="http://typemock.com/">TypeMock</a>, however it is not free and does not drive you towards a good design.</li> <li><a href="http://ayende.com/projects/rhino-mocks.aspx">Rhino Mocks</a> is a very good option if you are doing TDD, .e.g the objects you wish to mock implement interfaces. At present it seems to be the "market leader"</li> <li><a href="http://code.google.com/p/moq/">Moq</a> (<a href="http://www.codethinked.com/post/2009/03/13/Beginning-Mocking-With-Moq-3-Part-1.aspx">introduction</a>) should be considered if you are using .NET 3.5 Moq <em>may</em> be againing on Rhino Mocks for new projects</li> </ul> <p>What have I missed from this summary?</p> <p><strong>So what drives the choose between <a href="http://ayende.com/projects/rhino-mocks.aspx">Rhino Mocks</a> and <a href="http://code.google.com/p/moq/">Moq</a>, if you are using .NET 3.5?</strong></p> <p><hr></p> <p>see also:</p> <ul> <li><a href="http://stackoverflow.com/questions/37359/what-c-mocking-framework-to-use">What c# mocking framework to use?</a> </li> <li><a href="http://stackoverflow.com/questions/690769/what-are-the-capabilities-of-moq-and-rhino-mocks">What are the capabilities of Moq and Rhino.mocks?</a></li> <li><a href="http://stackoverflow.com/questions/1718463/what-are-the-real-world-pros-and-cons-of-each-of-the-major-mocking-frameworks">What are the real-world pros and cons of each of the major mocking frameworks?</a></li> </ul> <p>“<a href="http://stackoverflow.com/questions/1267567/what-should-i-consider-when-choosing-a-dependency-injection-framework-for-net">What should I consider when choosing a dependency injection framework for .NET?</a>” may also be of interest as it asks the “other side” of the question.</p>
<p><em>So what questions should I by asking about the project and myself to help decide on the best mocking framework to use in a given case?</em></p> <p>The questions you should be asking about the project is: Has the project been developed with the SOLID principles, or not? Is this a project that has loose coupling and high cohesion? Have good OO principles been utilized in building the project? Is a Dependency Injection container being utilized? Has the system been coded in a Design by Contract method (utilizing Interfaces thoroughly)?</p> <p>If you answer yes to these questions, then you can utilize a mocking framework like RhinoMocks, which is what some would call an "opinionated" framework. RhinoMocks, and some other mocking frameworks, have very strong opinions about how a system should be designed in order for objects to be mocked. A framework like RhinoMocks expects your project to be designed a certain way. Mocking is certainly a lot easier with RhinoMocks when you've built your code the right way (no sealed classes, no statics, heavy use of interfaces, virtual on class methods, etc.)</p> <p>If you answer no to those questions, or if you're working on a legacy system with a lot of highly coupled classes, then your only choice is going to be TypeMock, which can mock just about anything. </p> <p><em>It would also be useful to know why you choose the mocking framework you are currently using and if you are still happy with that choose.</em></p> <p>I chose RhinoMocks because at the time (3+ years ago) it was clearly the most mature mocking framework with the most features. I've stayed with it because it has evolved in away that makes my life much easier (the advent of the AutoMocking container being a gigantic step toward efficiency). </p> <p>What I like about RhinoMocks, other than the feature set and ease of use, is that it guides me toward a better design in my code. I am not a perfect programmer, and I am going to make mistakes in design. But tools like RhinoMocks and NHibernate help guide me toward a better design, because when I do make mistakes and create poor design, these tools become painful to work with. NHibernate, for instance, is painful to work with if you have a bad database design. RhinoMocks is very painful to work with if you have a poor class design, aren't using interfaces, aren't using IoC... etc. </p> <p>I like RhinoMocks because it ultimately helps me be a better developer, and not just because I'm testing my code, but because I'm shaping my code - designing it - in a better manner. </p>
LINQ to SQL - Problem with 1-to-1 association <p>In the L2S designer I have dropped a table and a view. I tried adding an association between the 2 on their primary keys. This should be a one-to-one relationship, so I set the cardinality property of the association as such. </p> <p>But, when coding I can't access the child property.</p> <p>Any suggestions?</p> <p><h1>Edit</h1>I just created a view in sql server that has the fields I want, and dropped that into L2S. Much simpler.</p>
<p>In my experience Linq To SQL requires the Primary/Foreign key relationships established in the DB. Otherwise, you'll have to do a join.</p> <p>Not sure if this applies to your situation, but it may... </p> <p><a href="http://stackoverflow.com/questions/619231/linq-to-sql-without-explicit-foreign-key-relationships">http://stackoverflow.com/questions/619231/linq-to-sql-without-explicit-foreign-key-relationships</a></p> <p><strong>UPDATE:</strong> </p> <p>It appears that you can get what you're looking for without establishing the Primary/Foreign key relationships in the database. In the LinqToSQL designer set primary keys on both columns on each table. I also had to turn off Auto-Sync on Parent Table's column that I assigned as a primary key. </p> <p>Auto-Sync is described here.. <em>Instructs the common language runtime (CLR) to retrieve the value after an insert or update operation.</em> </p> <p>Link: <a href="http://msdn.microsoft.com/en-us/library/bb386971.aspx">http://msdn.microsoft.com/en-us/library/bb386971.aspx</a></p>
How to convert string into float in javascript? <p>I am trying to parse two values from a datagrid.<br> The fields are numeric, and when they have a comma (ex. 554,20), I can't get the numbers after the comma.<br> I've tried <code>parseInt</code> and <code>parseFloat</code>. How can I do this?</p>
<p>If they're meant to be separate values, try this:</p> <pre><code>var values = "554,20".split(",") var v1 = parseFloat(values[0]) var v2 = parseFloat(values[1]) </code></pre> <p>If they're meant to be a single value (like in French, where one-half is written 0,5)</p> <pre><code>var value = parseFloat("554,20".replace(",", ".")); </code></pre>
Faking browser request in ASP.net C# <p>I'm using the code below to pull one of our 3rd party developed pages in so I can parse it as XML for my random bits of work.</p> <p>Irritatingly we stil have a browser detection level set on the server that only allows certain browsers on to the site; so the question is how would I fake it so that the server thinks its a browser request?</p> <pre><code> static string GetHtmlPage(string strURL) { String strResult; System.Net.WebResponse objResponse; System.Net.WebRequest objRequest = System.Net.HttpWebRequest.Create(strURL); objResponse = objRequest.GetResponse(); using (System.IO.StreamReader sr = new System.IO.StreamReader(objResponse.GetResponseStream())) { strResult = sr.ReadToEnd(); sr.Close(); } return strResult; } </code></pre>
<p>Browser detection is done based on a header in the request to the server. All you need to do is set that header. However, with HttpWebRequest you don't set that through the headers collection but rather with the .UserAgent property. </p> <pre><code>... System.Net.WebRequest objRequest = System.Net.HttpWebRequest.Create(strURL); //Pretend to be IE7 ((System.Net.HttpWebRequest)objRequest).UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"; objResponse = objRequest.GetResponse(); ... </code></pre>
How to detect a firewall in Windows? <p>My app needs to make a GET request to a website and I'd like to be able to know if it's being blocked by a firewall, and ask the user to add an exception.</p> <p>How can I find out that my get request failed because of a firewall, instead of something else?</p>
<p>If it's a good firewall, you can't. Among other options, a firewall can:</p> <ul> <li>reply with one of several different <a href="http://en.wikipedia.org/wiki/Internet%5FControl%5FMessage%5FProtocol">ICMP</a> messages, indicating the destination is not accessible, or</li> <li>silently discard the request, resulting in a timeout.</li> </ul> <p>A reasonable option is to explain why the app was unable to access the website, and provide some helpful suggestions:</p> <pre> No response from www.site.com: * Your computer may not be connected to the Internet. * The site may be down. * The site may be blocked by a firewall. </pre> <pre> The network indicated that www.site.com is not accessible: * Helpful messages go here. </pre> <p>The important point is to differentiate, perhaps better than I did above, between the <em>types</em> of failure, and the <em>reasons</em> behind them. For example, the steps for troubleshooting "no response" will be different from those for troubleshooting "the device told me it's not listening on that port."</p>
What language decision in C# annoys you? <p>I was just dealing with strings, and I find myself annoyed that strings can be nullable. So, I have to have </p> <pre><code>if((teststring??string.Empty)==string.Empty) </code></pre> <p>all over the place. Would string? have been so hard for allowing nullability in the relatively few cases where it is needed (dbs, idiot user inputs, etc.). I also find myself irritated with having to export readonly interfaces in the cases where I want some form of const correctness. So, what C# language construct/decision annoys you?</p> <p>EDIT: Thanks for the isnullorempty function, I hadn't seen that before! Still doesn't lessen my annoyance at it being nullable :D</p>
<p>Testing strings for Null or Empty is best done using:</p> <pre><code>if (string.IsNullOrEmpty(testString)) { } </code></pre>
Print without Printer selection dialog <p>I want to print my crystal report directly, without printer selection popup. How can I do this ?</p> <pre><code>myReportDocument.SetDataSource(saveDataSet); //Print crystalReportViewer1.ShowRefreshButton = false; crystalReportViewer1.ShowCloseButton = false; crystalReportViewer1.ShowGroupTreeButton = false; crystalReportViewer1.ReportSource = myReportDocument; crystalReportViewer1.PrintReport(); </code></pre> <p>I'm using the default (and only) printer.</p>
<pre><code>myReportDocument.PrintOptions.PrinterName = "PRINTER_NAME"; myReportDocument.PrintToPrinter(copies, collate, startPage, endPage); </code></pre>
DataTable Copying <p>Hi I have a datatable with 5 columns and I would like to copy only two of those columns to another datatable. What is the best way to do this?</p> <p>DataTable 1:</p> <pre><code>col1 col2 col3 col4 col5 1 2 3 4 5 6 7 8 9 10 </code></pre> <p>DataTable 2:</p> <pre><code>col1 col2 1 2 6 7 </code></pre> <p>Thanks</p>
<p>Would something like this be efficent?</p> <pre><code> DataTable myTable = new DataTable(); myTable.Columns.Add("Col1"); myTable.Columns.Add("Col2"); myTable.Columns.Add("Col3"); myTable.Columns.Add("Col4"); myTable.Columns.Add("Col5"); myTable.Rows.Add(new object[] { "hey", "hey", "Hey", "hey", "Hey" }); GridView1.DataSource = myTable; GridView1.DataBind(); DataTableReader myReader = myTable.CreateDataReader(); DataTable myTable2 = new DataTable(); myTable2.Load(myReader); myTable2.Columns.Remove("Col3"); myTable2.Columns.Remove("Col4"); GridView2.DataSource = myTable2; GridView2.DataBind(); </code></pre>
More examples of Prism (Composite Application Library) Applications? <p>The examples that Microsoft's Patterns and Practices provides are quite helpful:</p> <ul> <li>about a half-dozen simpler <strong>QuickStarts</strong> which touch on specific issues</li> <li>the StockTrader <strong>reference implementation</strong>, which is a fairly rounded application</li> </ul> <p>but it lacks a more useful base <strong>application that reads and writes to a data source</strong> (XML or database), allowing users to <strong>login, edit data, logout</strong>, etc. (something like what ASP.NET MVC comes with).</p> <p>Since Prism applications can get quite complex and lengthy (the StockTrader example is almost 300 files without tests), it would be helpful to have an application that <strong>takes care of the CRUD bulk</strong> that everyone needs to build for most apps anyway.</p> <p>Does anyone know of any <strong>data-editing Prism example apps</strong> out there?</p>
<p>Here (<a href="http://petedoesstuff.net/Blog/?p=79" rel="nofollow">http://petedoesstuff.net/Blog/?p=79</a>) you'll find a bunch of links to the samples of using the Prism. </p> <p>Particularly, LateNight (<a href="http://code.google.com/p/cwpfsamples/" rel="nofollow">http://code.google.com/p/cwpfsamples/</a>) may be what you need. It has login screen and data editing functions.</p>