input
stringlengths 51
42.3k
| output
stringlengths 18
55k
|
|---|---|
Why don't my HtmlHelper extensions work? <p>I'm building an ASP.Net MVC website. Rather than have everything in one project, I've decided to separate the Web, Model and Controller out into different projects in the same solution, that reference each-other.</p>
<p>The referencing goes like this:</p>
<blockquote>
<p>Web ---[references]---> Controller ---[references]---> Model</p>
</blockquote>
<p>Now I wanted to add 2 custom methods to the HtmlHelper class - they're called "IncludeScript" and "IncludeStyle". They each take a single string parameter, and generate a script or link tag respectively.</p>
<p>I've created an extender class, according to documentation on the web, and written the two methods and compiled the application.</p>
<p>Now, when I go into the Public.Master page (which is my main master-page, and one of the places where I intend to use these methods), I can enter code such as below:</p>
<p><code><%= Html.IncludeScript("\js\jquery.js") %></code></p>
<p>The IntelliSense picks up and IncludeScript method and shows me the syntax just fine. So I'd expect that everything should work.</p>
<p>But it doesn't.</p>
<p>Everything compiles, but as soon as I run the application, I get the following run-time error from line 14 of Default.aspx.cs:</p>
<p><code>c:\\Projects\\PhoneReel\\PhoneReel.Web\\Views\\Shared\\Public.Master(11): error CS0117: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'IncludeScript'</code></p>
<p>Here's the line of code that the error happens on:</p>
<p><code>httpHandler.ProcessRequest(HttpContext.Current);</code></p>
<p>Any ideas what could be going wrong here?</p>
|
<p>Check to make sure that the namespace of your extensions is accessible to our view. You need either this in your view:</p>
<pre><code><%@ Import Namespace="MyRootNamespace.NamespaceForMyHtmlHelperExtensions"%>
</code></pre>
<p>or this in your web config namespaces section:</p>
<pre><code><add namespace="MyRootNamespace.NamespaceForMyHtmlHelperExtensions"/>
</code></pre>
|
Ideal PHP Session Size? <p>I have a PHP form (mortgage app) that is about 400 fields, traffic on the site will be low.</p>
<p>What is the ideal Session size for 400 fields going into a MySQL db?</p>
<p>In <code>php.ini</code> what do I set?</p>
<p>Anything I should set that I am missing?</p>
|
<p>There is no limit to the size of the session, BUT there is a limit to the memory PHP can take: <a href="http://ca.php.net/manual/en/ini.core.php#ini.memory-limit">http://ca.php.net/manual/en/ini.core.php#ini.memory-limit</a></p>
|
Formatting an if statement for readability <p>What's the best way to format this for readability?</p>
<pre><code>if (strpos($file, '.jpg',1) && file_exists("$thumbsdir/$file") == false || strpos($file, '.gif',1) && file_exists("$thumbsdir/$file") == false || strpos($file, '.png',1) && file_exists("$thumbsdir/$file") == false) {
createThumb("$gallerydir/$file", "$thumbsdir/$file",$thumbsize);
fwrite($log,date("Y-m-d")." @ ".date("H:i:s")." CREATED: $thumbsdir/$file\n");
}
</code></pre>
|
<p>I'd extract the "is an image" logic into its own function, which makes the <code>if</code> more readable and also allows you to centralize the logic.</p>
<pre><code>function is_image($filename) {
$image_extensions = array('png', 'gif', 'jpg');
foreach ($image_extensions as $extension)
if (strrpos($filename, ".$extension") !== FALSE)
return true;
return false;
}
if (is_image($file) && !file_exists("$thumbsdir/$file")) {
createThumb("$gallerydir/$file", "$thumbsdir/$file",$thumbsize);
fwrite($log,date("Y-m-d")." @ ".date("H:i:s")." CREATED: $thumbsdir/$file\n");
}
</code></pre>
|
silverlight blogs? <p>With the asp.net MVC framework the blogs of the team members (Rob Conery, Phil Haack etc) really helped me on my way and made me feel comfortable the development was going in the right direction.
Is there something similar for Silverlight?</p>
<p>-Edit:
I would like to mention that I would like to find members of the dev team themselves.
Currently the support for Silverlight across OS and browser is just too poor to make me care and invest time in it.
But I would like to keep a spying eye out so I can start caring when the framework fulfils it's potentials.</p>
|
<p>Method ~ of ~ failed by Tim Heuer:
<a href="http://feeds.timheuer.com/timheuer-silverlight" rel="nofollow">http://feeds.timheuer.com/timheuer-silverlight</a></p>
<p>Jesse Liberty - Silverlight Geek:
<a href="http://feeds.feedburner.com/JesseLiberty-SilverlightGeek" rel="nofollow">http://feeds.feedburner.com/JesseLiberty-SilverlightGeek</a></p>
<p>Community Silverlight content:
<a href="http://silverlight.net/blogs/community/rss.aspx" rel="nofollow">http://silverlight.net/blogs/community/rss.aspx</a></p>
<p>Silverlight Tips of the Day
<a href="http://silverlight.net/blogs/msnow/default.aspx" rel="nofollow">http://silverlight.net/blogs/msnow/default.aspx</a></p>
<p>Podcasts:
<a href="http://www.sparklingclient.com/" rel="nofollow">http://www.sparklingclient.com/</a></p>
<p>Wynapse (Mining the Web for Silverlight so YOU don't have to):
<a href="http://geekswithblogs.net/WynApseTechnicalMusings/Default.aspx" rel="nofollow">http://geekswithblogs.net/WynApseTechnicalMusings/Default.aspx</a></p>
|
Using C# to display powerpoint <p>Is there any good way to use a windows application written in C# to display/control a powerpoint slideshow? Ultimately I would like to show thumbnails in a form and clicking these thumbnails would advance the slides shown on a second monitor (similar to using Powerpoint itself to show a slideshow on a second monitor).</p>
<p>I would like to be able to use Powerpoint Viewer if Powerpoint is not installed.</p>
<p>There seems to be some ActiveX-controls that allows integration of Powerpoint in a form, but most of these seem to cost money, does anyone have experience using one of these controls?</p>
<p>Edit: I know that there is an object model accessable by adding a reference to Microsoft.Office.InterOp.Powerpoint, but I want to be able to distribute the resulting program without having Microsoft Office as a prerequisite, that was why I mentioned Powerpoint Viewer because it can be distributed freely.</p>
|
<p>This kb lays out the basics for working with the powerpoint presentation viewer object model. I'd suggest you include the viewer when you distribute your application.</p>
<p><a href="http://support.microsoft.com/kb/265385" rel="nofollow">http://support.microsoft.com/kb/265385</a></p>
<p>Once you get a reference to the viewer (top level) object it is basically the same as working with the powerpoint.presentation object model, but with less functionality (i.e. editing, etc)</p>
<p>If you are working with Powerpoint 2007, then you can add editing functionality by using the System.XML and related namespaces to work with the presentation file as an open xml file.</p>
<p>Regarding the comments about UNO/openoffice.org, I think these miss the point, as you cannot use UNO for working with powerpoint, it is for openoffice and that was not the origianl requirement of the questioner.</p>
<p>there are 3rd party toolsets like aspose, but then your goal was to work with the powerpoint viewer component (free) so I'm guessing you want to avoid paying for dev tools? Either way viewer components OM is perfectly suitable for displaying and previewing and existing slide show. (you will need one copy of Powerpoint so that you can author the presentation from scratch, plus Visual Studio to create the VSTO project).</p>
|
how to generate unit test code for methods <p>i want to write code for unit test to test my application code. I have different methods and now want to test these methods one by one in python script.
but i do not how to i write. can any one give me example of small code for unit testing in python.
i am thankful </p>
|
<p>Read the <a href="http://www.python.org/doc/2.5.2/lib/module-unittest.html" rel="nofollow">unit testing framework section</a> of the <a href="http://www.python.org/doc/2.5.2/lib/lib.html" rel="nofollow">Python Library Reference</a>.</p>
<p>A <a href="http://www.python.org/doc/2.5.2/lib/minimal-example.html" rel="nofollow">basic example</a> from the documentation:</p>
<pre><code>import random
import unittest
class TestSequenceFunctions(unittest.TestCase):
def setUp(self):
self.seq = range(10)
def testshuffle(self):
# make sure the shuffled sequence does not lose any elements
random.shuffle(self.seq)
self.seq.sort()
self.assertEqual(self.seq, range(10))
def testchoice(self):
element = random.choice(self.seq)
self.assert_(element in self.seq)
def testsample(self):
self.assertRaises(ValueError, random.sample, self.seq, 20)
for element in random.sample(self.seq, 5):
self.assert_(element in self.seq)
if __name__ == '__main__':
unittest.main()
</code></pre>
|
WCF Unknown Message Received Event <p>Does anywone know when a UnknownMessageReceived event on a WCF ServiceHost will be fired?</p>
<p>I have some code where I capture the Faulted en UnknownMessageReceived event but even when I post a wrong message to a particular service I never get the event.</p>
<p>Jochen</p>
|
<p>I ran into this event when I, incorrectly specified an address like this:
<a href="http://localhost:4000/SomeService//mex" rel="nofollow">http://localhost:4000/SomeService//mex</a></p>
<p><strong>Note the double forward slash</strong></p>
<p>The service was hosted in a WPF application. Because of that I also found out that this event is raised on a different thread than the main/ui thread. </p>
|
How can I create a friendly URL in ASP.NET MVC? <p>How do I generate friendly URLs within the ASP.NET MVC Framework? For example, we've got a URL that looks like this:</p>
<pre>http://site/catalogue/BrowseByStyleLevel/1</pre>
<p>The 1 is Id of the study level (Higher in this case) to browse, but I'l like to reformat the URL in the same way StackOverflow does it.</p>
<p>For example, these two URLs will take you to the same place:</p>
<blockquote>
<p><a href="http://stackoverflow.com/questions/119323/nested-for-loops-in-different-languages">http://stackoverflow.com/questions/119323/nested-for-loops-in-different-languages</a></p>
<p><a href="http://stackoverflow.com/questions/119323/">http://stackoverflow.com/questions/119323/</a></p>
</blockquote>
<p><strong>EDIT:</strong> The friendly part of the url is referred to as a <em>slug</em>.</p>
|
<p>There are two steps to solve this problem. First, create a new route or change the default route to accept an additional parameter:</p>
<pre><code>routes.MapRoute( "Default", // Route name
"{controller}/{action}/{id}/{ignoreThisBit}",
new { controller = "Home",
action = "Index",
id = "",
ignoreThisBit = ""} // Parameter defaults )
</code></pre>
<p>Now you can type whatever you want to at the end of your URI and the application will ignore it.</p>
<p>When you render the links, you need to add the "friendly" text:</p>
<pre><code><%= Html.ActionLink("Link text", "ActionName", "ControllerName",
new { id = 1234, ignoreThisBit="friendly-text-here" });
</code></pre>
|
C# little endian or big endian? <p>In the documentation of hardware that allows us to control it via UDP/IP,
I found the following fragment:</p>
<blockquote>
<p>In this communication protocol, DWORD is a 4 bytes data, WORD is a 2 bytes data,
BYTE is a single byte data. The storage format is little endian, namely 4 bytes (32bits) data is stored as: d7-d0, d15-d8, d23-d16, d31-d24; double bytes (16bits) data is stored as: d7-d0 , d15-d8.</p>
</blockquote>
<p>I am wondering how this translates to C#?
Do I have to convert stuff before sending it over?
For example, if I want to send over a 32 bit integer, or a 4 character string?</p>
|
<p>C# itself doesn't define the endianness. Whenever you convert to bytes, however, you're making a choice. The <a href="http://msdn.microsoft.com/en-us/library/system.bitconverter.aspx">BitConverter</a> class has an <a href="http://msdn.microsoft.com/en-us/library/system.bitconverter.islittleendian.aspx">IsLittleEndian</a> field to tell you how it will behave, but it doesn't give the choice. The same goes for BinaryReader/BinaryWriter.</p>
<p>My <a href="http://pobox.com/~skeet/csharp/miscutil">MiscUtil</a> library has an EndianBitConverter class which allows you to define the endianness; there are similar equivalents for BinaryReader/Writer. No online usage guide I'm afraid, but they're trivial :)</p>
<p>(EndianBitConverter also has a piece of functionality which isn't present in the normal BitConverter, which is to do conversions in-place in a byte array.)</p>
|
Random Gaussian Variables <p>Is there a class in the standard library of .NET that gives me the functionality to create random variables that follow Gaussian distribution? </p>
|
<p>Jarrett's suggestion of using a Box-Muller transform is good for a quick-and-dirty solution. A simple implementation:</p>
<pre><code>Random rand = new Random(); //reuse this if you are generating many
double u1 = rand.NextDouble(); //these are uniform(0,1) random doubles
double u2 = rand.NextDouble();
double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) *
Math.Sin(2.0 * Math.PI * u2); //random normal(0,1)
double randNormal =
mean + stdDev * randStdNormal; //random normal(mean,stdDev^2)
</code></pre>
|
Best Database With ColdFusion on OS X <p>ColdFusion 8 Standard Edition on OS X Leopard.</p>
<p>Developing a new website.</p>
<p>What is the best database to use in conjunction with ColdFusion?</p>
<p>Will be storing simple Credit Card operations, registration information, CRM info for an indie software company</p>
|
<p>I would look into MySQL and/or PostgreSQL. </p>
<p>I'm more familiar with MySQL. I rather like it a lot. It is solid, with good administration tools. I've used it on OSX servers (years ago) with PHP, and it delivered performance that was more than adequate for our small operation. Definitely worth looking in to.</p>
|
ORM support for compound primary keys <p>I've read that compound primary keys will <a href="http://stackoverflow.com/questions/107404/what-are-the-down-sides-of-using-a-compositecompound-primary-key#108337">confuse the hell out of typical ORM code generators</a>. Which ORMs work best with compound PKs and which to avoid? (I've a particular interest in .NET)</p>
|
<p>I'm using NHibernate successfully with compound keys.</p>
<pre><code><class name="UserProfileField" table="UserProfileFields">
<composite-id>
<key-many-to-one name="Parent" column="UserId" lazy="false"/>
<key-property name="FieldName"/>
</composite-id>
...
</code></pre>
|
Xaml not WPF <p>I am interested in using Xaml with expression blend for creating user interfaces in an application. However, because of the limitations of the target architecture, I cannot use WPF or C#.</p>
<p>So, what I am interested in is in any examples / existing projects or advice from anyone who has experiance of this technology on the use of Xaml in it's "Pure" form as a specification language not tied to WPF.</p>
<p>Specific questions:</p>
<p>1) Is it possible to use Blend + Xaml without the WPF elements, or without C# backing classes?</p>
<p>2) Are there any other implementations of Xaml parsers etc. which use different architectures, and can they work with blend or similar tools.</p>
<p>3) Are there alternative editor / designer tools which can help in this situation?</p>
<p>I am aware of the MyXaml and MycroXaml projects, and have found a lot of resources on the web about Xaml, but 99% of it relates directly to WPF. This is fine for understanding the concepts of Xaml, but doesn't help with the implimentation I need.</p>
<p>Many thanks!</p>
|
<p>Does Silverlight help you in anyway?. Now there is an Eclipse plug-in available for you to use Silverlight with eclispe. So you will be able to use Expression blend to design your UI and use Java for the backend coding(Future plan I think). Check out this link for more details. <a href="http://www.eclipse4sl.org/" rel="nofollow">http://www.eclipse4sl.org/</a></p>
|
Which built-in .NET exceptions can I throw from my application? <p>If I need to throw an exception from within my application which of the built-in .NET exception classes can I use? Are they all fair game? When should I derive my own?</p>
|
<p>See <a href="http://msdn.microsoft.com/en-us/library/ms173163.aspx" rel="nofollow">Creating and Throwing Exceptions</a>.</p>
<p>On throwing built-in exceptions, it says:</p>
<blockquote>
<p>Do not throw System.Exception, System.SystemException, System.NullReferenceException, or System.IndexOutOfRangeException intentionally from your own source code.</p>
</blockquote>
<p>and</p>
<blockquote>
<p>Do Not Throw General Exceptions </p>
<p>If you throw a general exception type, such as Exception or SystemException in a library or framework, it forces consumers to catch all exceptions, including unknown exceptions that they do not know how to handle. </p>
<p>Instead, either throw a more derived type that already exists in the framework, or create your own type that derives from Exception."</p>
</blockquote>
<p>This <a href="http://blogs.msdn.com/fxcop/archive/2007/01/22/faq-what-exception-should-i-throw-instead-of-the-reserved-exceptions-found-by-donotraisereservedexceptiontypes.aspx" rel="nofollow">blog entry</a> also has some useful guidelines.</p>
<p>Also, FxCop code analysis defines a list of "do not raise exceptions" as <a href="http://msdn.microsoft.com/en-us/library/ms182338.aspx" rel="nofollow">described here</a>. It recommends:</p>
<blockquote>
<p>The following exception types are too general to provide sufficient information to the user: </p>
<ul>
<li>System.Exception </li>
<li>System.ApplicationException </li>
<li>System.SystemException</li>
</ul>
<p>The following exception types are reserved and should be thrown only by the common language runtime: </p>
<ul>
<li>System.ExecutionEngineException </li>
<li>System.IndexOutOfRangeException </li>
<li>System.NullReferenceException </li>
<li>System.OutOfMemoryException</li>
</ul>
</blockquote>
<p>So in theory you can raise any other framework exception type, providing you clearly understand the intent of the exception as described by Microsoft (see MSDN documentation).</p>
<p>Note, these are "guidelines" and as some others have said, there is debate around System.IndexOutOfRangeException (ie many developers throw this exception).</p>
|
Can Rhino Mocks Write My Expect Statements For Me? <p>I have a set of Visual Studio Team System unit (integration really) tests that talk to a remote database. The tests are getting too slow and unwieldy. I'd like to replace the entire set of tests with mocked out versions. The problem is it's painful to write all the expect statements that mimic what an entire database does. </p>
<p>Does anyone know of a tool or add-on that will run an existing test, figure out what the non-mocked version actually returns and write out the Expect.Call's to duplicate the functionality? I know this is a long shot, but I feel like it should be possible.</p>
|
<p>Ok, I ended up writing it myself. Here is the blog post overview:</p>
<p><a href="http://rapidapplicationdevelopment.blogspot.com/2008/11/write-my-rhino-mocks-expect-statement.html" rel="nofollow">Write My Rhino Mocks Expect Statement</a></p>
<p>And here is the CodePlex project:</p>
<p><a href="http://www.codeplex.com/WriteMyExpect" rel="nofollow">WriteMyExpectStatement</a></p>
<p>Hope this helps someone somewhere.</p>
|
Is Functional to Relational mapping easier than Object to Relational? <p>Object-relational mapping has been well discussed, including on here. I have experience with a few approaches and the pitfalls and compromises. True resolution seems like it requires changes to the OO or relational models themselves.</p>
<p>If using a functional language, does the same problem present itself? It seems to me that these two paradigms should fit together better than OO and RDBMS. The idea of thinking in sets in an RDBMS seems to mesh with the automatic parallelism that functional approaches seem to promise. </p>
<p>Does anyone have any interesting opinions or insights? What's the state of play in the industry?</p>
|
<p>The hard problems of extending the relational database are extended transactions, data-type mismatches, automated query translation and things like <a href="http://ayende.com/Blog/archive/2006/05/02/CombatingTheSelectN1ProblemInNHibernate.aspx">N+1 Select</a> that are fundamental problems of leaving the relational system and -- in my opinion -- do not change by changing the receiving programming paradigm.</p>
|
Does Java Connection.close rollback? <p>Does Java Connection.close rollback into a finally block?.</p>
<p>I know .Net SqlConnection.close does it.</p>
<p>With this I could make try/finally blocks without catch...</p>
<p>Example:</p>
<pre><code>try {
conn.setAutoCommit(false);
ResultSet rs = executeQuery(conn, ...);
....
executeNonQuery(conn, ...);
....
conn.commit();
} finally {
conn.close();
}
</code></pre>
|
<p>According to <a href="http://java.sun.com/javase/6/docs/api/java/sql/Connection.html#close()">the javadoc</a>, you should try to either commit or roll back before calling the close method. The results otherwise are implementation-defined.</p>
|
How to reverse engineer undocumented legacy application? <p>Once I was assigned to a project which was about adding couple new features to the existing Java based web application. Because it was a matter of just couple simple features there was no chance for rewrite. </p>
<p>Unfortunately, the code base came from a client without any documentation and the code itself wasn't commented too well. The original developers had left the client company so there wasn't too much knowledge available. To spice up thing structure of the user interface was stored in the DB. </p>
<p>We managed to solve the rather interesting logic with debugger, some DB visualizing tools and plenty of mind map/relationship drawings on the paper. This was then documented in our wiki. But for some reason we did not create extensive test coverage to protect us - maybe the reason was that nobody really knew how the application and its business cases should work...</p>
<p>How people have dealt with similar cases? Are there any specific tools for understanding application or its creator's logic?</p>
|
<p>I did this a couple of times. </p>
<p>What really helped was to create a graphical representation of the datamodel. You can use tools, but sometimes creating it by hand is suitable because you will learn a lot while browsing through the code.</p>
<p>I tried sequence diagrams but those are not very helpful because they rapidly grow.</p>
|
Loading custom framework in iPhone <p>I'm trying to use an <a href="http://www.cybergarage.org/net/upnp/c/index.html" rel="nofollow">external framework</a> for UPnP browsing on the iPhone. The framework works perfectly on the Mac, But when I copy it to the iPhone app, it wouldn't run even if there's no code using the framework yet. </p>
<p>It gives weird error that I can't understand.</p>
<pre><code>[Session started at 2008-10-20 15:32:34 +0200.]
objc[2701]: Class CAAnimationGroup is implemented in both /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.
objc[2701]: Class CATransition is implemented in both /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.
objc[2701]: Class CAKeyframeAnimation is implemented in both /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.
objc[2701]: Class CABasicAnimation is implemented in both /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.
objc[2701]: Class CAPropertyAnimation is implemented in both /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.
objc[2701]: Class CAAnimation is implemented in both /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.
objc[2701]: Class CASlotProxy is implemented in both /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.
objc[2701]: Class CAContextImpl is implemented in both /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.
objc[2701]: Class CAContext is implemented in both /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.
objc[2701]: Class CAFilter is implemented in both /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.
objc[2701]: Class CALayer is implemented in both /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.
objc[2701]: Class CAMediaTimingFunction is implemented in both /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.
objc[2701]: Class CAScrollLayer is implemented in both /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.
objc[2701]: Class CATransaction is implemented in both /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.
objc[2701]: Class CATransformLayer is implemented in both /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.
objc[2701]: Class CATiledLayer is implemented in both /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.
objc[2701]: Class NSCursor is implemented in both /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks/WebCore.framework/WebCore. Using implementation from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks/WebCore.framework/WebCore.
[Session started at 2008-10-20 15:32:37 +0200.]
Loading program into debuggerâ¦
GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".warning: Unable to read symbols for "/System/Library/Frameworks/UIKit.framework/UIKit" (file not found).
warning: Unable to read symbols from "UIKit" (not yet mapped into memory).
warning: Unable to read symbols for "/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics" (file not found).
warning: Unable to read symbols from "CoreGraphics" (not yet mapped into memory).
Program loaded.
sharedlibrary apply-load-rules all
Attaching to program: `/Users/danielchong/Library/Application Support/iPhone Simulator/User/Applications/305F04A8-840D-4A1A-ADD8-59CEC674152E/uPnP Browser2.app/uPnP Browser2', process 2701.
(gdb)
</code></pre>
|
<p>Dynamic linking of any kind is not supported on the iPhone. I think the fact you're trying to do dynamic linking is confusing the simulator's careful library loading thingamagig (which if I'm not mistaken it's the source of the errors above).</p>
<p>If the license allows this, link the external UPnP code statically into your app instead.</p>
|
Ocx control in win form <p>How to create instance of AxHost abstract class</p>
|
<p><a href="http://msdn.microsoft.com/en-us/library/sf985hc5(VS.71).aspx" rel="nofollow">You cannot create an instance of an abstract class.</a></p>
<p><em>You typically do not use the AxHost class directly. You can use the Windows Forms ActiveX Control Importer (Aximp.exe) to generate the wrappers that extend AxHost.</em> </p>
<p>See <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.axhost.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.windows.forms.axhost.aspx</a> for an example.</p>
|
Can I test if a regex is valid in C# without throwing exception <p>I allow users to enter a regular expression to match IP addresses, for doing an IP filtration in a related system. I would like to validate if the entered regular expressions are valid as a lot of userse will mess op, with good intentions though.</p>
<p>I can of course do a Regex.IsMatch() inside a try/catch and see if it blows up that way, but are there any smarter ways of doing it? Speed is not an issue as such, I just prefer to avoid throwing exceptions for no reason.</p>
|
<p>As long as you catch very specific exceptions, just do the try/catch.</p>
<p>Exceptions are not evil if used correctly.</p>
|
How do you keep parents of floated elements from collapsing? <p>Although elements like <code><div></code>s normally grow to fit their contents, using the <code>float</code> property can cause a startling problem for CSS newbies: <strong>if floated elements have non-floated parent elements, the parent will collapse.</strong></p>
<p>For example:</p>
<pre><code><div>
<div style="float: left;">Div 1</div>
<div style="float: left;">Div 2</div>
</div>
</code></pre>
<p>The parent div in this example will <strong>not expand</strong> to contain its floated children - it will appear to have <code>height: 0</code>.</p>
<h1>How do you solve this problem?</h1>
<p><em>I would like to create an exhaustive list of solutions here. If you're aware of cross-browser compatibility issues, please point them out.</em> </p>
<h2>Solution 1</h2>
<p>Float the parent.</p>
<pre><code><div style="float: left;">
<div style="float: left;">Div 1</div>
<div style="float: left;">Div 2</div>
</div>
</code></pre>
<p><strong>Pros</strong>: Semantic code.<br />
<strong>Cons</strong>: You may not always want the parent floated. Even if you do, do you float the parents' parent, and so on? Must you float every ancestor element?</p>
<h2>Solution 2</h2>
<p>Give the parent an explicit height.</p>
<pre><code><div style="height: 300px;">
<div style="float: left;">Div 1</div>
<div style="float: left;">Div 2</div>
</div>
</code></pre>
<p><strong>Pros</strong>: Semantic code.<br />
<strong>Cons</strong>: Not flexible - if the content changes or the browser is resized, the layout will break.</p>
<h2>Solution 3</h2>
<p>Append a "spacer" element inside the parent element, like this:</p>
<pre><code><div>
<div style="float: left;">Div 1</div>
<div style="float: left;">Div 2</div>
<div class="spacer" style="clear: both;"></div>
</div>
</code></pre>
<p><strong>Pros</strong>: Straightforward to code.<br />
<strong>Cons</strong>: Not semantic; the spacer div exists only as a layout hack.</p>
<h2>Solution 4</h2>
<p>Set parent to <code>overflow: auto</code>.</p>
<pre><code><div style="overflow: auto;">
<div style="float: left;">Div 1</div>
<div style="float: left;">Div 2</div>
</div>
</code></pre>
<p><strong>Pros</strong>: Doesn't require extra div.<br />
<strong>Cons</strong>: Seems like a hack - that's not the <code>overflow</code> property's stated purpose.</p>
<h1>Comments? Other suggestions?</h1>
|
<h2>Solution 1:</h2>
<p>The most reliable and unobtrusive method appears to be this:</p>
<p>Demo: <a href="http://jsfiddle.net/SO_AMK/wXaEH/">http://jsfiddle.net/SO_AMK/wXaEH/</a></p>
<p>HTML: </p>
<pre><code><div class="clearfix">
<div style="float: left;">Div 1</div>
<div style="float: left;">Div 2</div>
</div>â
</code></pre>
<p>CSS: </p>
<pre><code>.clearfix:after {
content: " ";
display: block;
height: 0;
clear: both;
}
</code></pre>
<p>âWith a little CSS targeting you don't even need to add a class to the parent <code>DIV</code>.</p>
<p>This solution is backwards compatible to IE8 so you don't need to worry about older browsers failing.</p>
<h2>Solution 2:</h2>
<p>An adaptation on solution 1 has been suggested and is as follows:</p>
<p>Demo: <a href="http://jsfiddle.net/wXaEH/162/">http://jsfiddle.net/wXaEH/162/</a></p>
<p>HTML: </p>
<pre><code><div class="clearfix">
<div style="float: left;">Div 1</div>
<div style="float: left;">Div 2</div>
</div>â
</code></pre>
<p>CSS: </p>
<pre><code>.clearfix:after {
content: " ";
display: block;
height: 0;
clear: both;
*zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML += '<div class="ie7-clear"></div>' );
}
.ie7-clear {
display: block;
clear: both;
}
</code></pre>
<p>This solution appears to be backwards compatible to IE5.5 but is untested.</p>
<h2>Solution 3:</h2>
<p>It's also possible to set <code>display: inline-block;</code> and <code>width: 100%;</code> to emulate a normal block element while not collapsing.</p>
<p>Demo: <a href="http://jsfiddle.net/SO_AMK/ae5ey/">http://jsfiddle.net/SO_AMK/ae5ey/</a></p>
<p>CSS: </p>
<pre><code>.clearfix {
display: inline-block;
width: 100%;
}
</code></pre>
<p>This solution should be backwards compatible to IE5.5 but has only been tested in IE6.</p>
|
How can I open a port in iptables for RMI access <p>I'm trying to connect from my Java application to a development server that has port 8088 closed which is used for RMI. I appreciate any help on how to open that port.</p>
|
<p>Assuming </p>
<ul>
<li>you want to allow access from everywhere</li>
<li>you want to allow access via the first ethernet device (eth0) </li>
<li>you want to allow access to port 8088 using tcp</li>
</ul>
<p>then you could try running</p>
<blockquote>
<p>iptables -I INPUT -i eth0 -p tcp --dport 8088 -j ACCEPT</p>
</blockquote>
<p>as root. </p>
|
Detecting Virus Scanners <p>We've had problems with a virus scanner murdering the performance of our app by slowing down writes to an <a href="http://en.wikipedia.org/wiki/H2_(DBMS)" rel="nofollow">H2 db</a>. So we'd like to be able to detect the presence of any virus scanner and alert the user of the potential problem. It would be part of a problem detection retue that would alert users to known performance factors specific to their systems.</p>
<p>The current suggestion is a write test that displays the warning if a disk write takes an unreasonable amount of time. That does get to the actual problem, but not to the cause. So, is there any reliable and direct way to detect virus protection, one that doesn't rely on indirect effects? We might end up doing both, but it would be nice to be curtain in our 'suggestions'.</p>
|
<p>On Windows Vista, MS added some API calls to allow you to query the status of the Windows Security Centre, which should tell you if A/V software is installed. Obviously this is not a particularly generic solution, nor a Java-based one, but it's the only way I can think of, short of attempting to install a virus. Um - don't do that!</p>
|
How Python web frameworks, WSGI and CGI fit together <p>I have a <a href="http://en.wikipedia.org/wiki/Bluehost">Bluehost</a> account where I can run Python scripts as CGI. I guess it's the simplest CGI, because to run I have to define the following in <code>.htaccess</code>:</p>
<pre><code>Options +ExecCGI
AddType text/html py
AddHandler cgi-script .py
</code></pre>
<p>Now, whenever I look up web programming with Python, I hear a lot about WSGI and how most frameworks use it. But I just don't understand how it all fits together, especially when my web server is given (Apache running at a host's machine) and not something I can really play with (except defining <code>.htaccess</code> commands).</p>
<p>How are <a href="http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface">WSGI</a>, CGI, and the frameworks all connected? What do I need to know, install, and do if I want to run a web framework (say <a href="http://webpy.org/">web.py</a> or <a href="http://en.wikipedia.org/wiki/CherryPy">CherryPy</a>) on my basic CGI configuration? How to install WSGI support?</p>
|
<p><strong>How WSGI, CGI, and the frameworks are all connected ?</strong></p>
<p>Apache listens on port 80. It gets an HTTP request. It parses the request to find a way to respond. Apache has a LOT of choices for responding. One way to respond is to use CGI to run a script. Another way to respond is to simply serve a file. </p>
<p>In the case of CGI, Apache prepares an environment and invokes the script through the CGI protocol. This is a standard Unix Fork/Exec situation -- the CGI subprocess inherits an OS environment including the socket and stdout. The CGI subprocess writes a response, which goes back to Apache; Apache sends this response to the browser.</p>
<p>CGI is primitive and annoying. Mostly because it forks a subprocess for every request, and subprocess must exit or close stdout and stderr to signify end of response.</p>
<p>WSGI is an interface that is based on the CGI design pattern. It is not necessarily CGI -- it does not have to fork a subprocess for each request. It can be CGI, but it doesn't have to be.</p>
<p>WSGI adds to the CGI design pattern in several important ways. It parses the HTTP Request Headers for you and adds these to the environment. It supplies any POST-oriented input as a file-like object in the environment. It also provides you a function that will formulate the response, saving you from a lot of formatting details.</p>
<p><strong>What do I need to know / install / do if I want to run a web framework (say web.py or cherrypy) on my basic CGI configuration ?</strong></p>
<p>Recall that forking a subprocess is expensive. There are two ways to work around this.</p>
<ol>
<li><p><strong>Embedded</strong> <code>mod_wsgi</code> or <code>mod_python</code> embeds Python inside Apache; no process is forked. Apache runs the Django application directly.</p></li>
<li><p><strong>Daemon</strong> <code>mod_wsgi</code> or <code>mod_fastcgi</code> allows Apache to interact with a separate daemon (or "long-running process"), using the WSGI protocol. You start your long-running Django process, then you configure Apache's mod_fastcgi to communicate with this process.</p></li>
</ol>
<p>Note that <code>mod_wsgi</code> can work in either mode: embedded or daemon.</p>
<p>When you read up on mod_fastcgi, you'll see that Django uses <a href="http://pypi.python.org/pypi/flup/">flup</a> to create a WSGI-compatible interface from the information provided by mod_fastcgi. The pipeline works like this.</p>
<pre><code>Apache -> mod_fastcgi -> FLUP (via FastCGI protocol) -> Django (via WSGI protocol)
</code></pre>
<p>Django has several "django.core.handlers" for the various interfaces.</p>
<p>For mod_fastcgi, Django provides a <code>manage.py runfcgi</code> that integrates FLUP and the handler.</p>
<p>For mod_wsgi, there's a core handler for this.</p>
<p><strong>How to install WSGI support ?</strong></p>
<p>Follow these instructions.</p>
<p><a href="http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango">http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango</a></p>
<p>For background see this</p>
<p><a href="http://docs.djangoproject.com/en/dev/howto/deployment/#howto-deployment-index">http://docs.djangoproject.com/en/dev/howto/deployment/#howto-deployment-index</a></p>
|
Protected Mode Keyboard Access on x86 Assembly <p>I'm working on keyboard input for a very basic kernel that I'm developing and I'm completely stuck. I can't seem to find any information online that can show me the information I need to know.</p>
<p>My kernel is running in protected mode right now, so I can't use the real mode keyboard routines without jumping into real mode and back, which I'm trying to avoid. I want to be able to access my keyboard from protected mode. Does anyone know how to do this? The only thing I have found so far is that it involves talking to the controller directly using in/out ports, but beyond that I'm stumped. This is, of course, is not something that comes up very often. Normally, Assembly tutorials assume you're running an operating system underneath.</p>
<p>I'm very new to the x86 assembly, so I'm just looking for some good resources for working with the standard hardware from protected mode. I'm compiling the Assembly source code with NASM and linking it to the C source code compiled with DJGPP. Any suggestions?</p>
|
<p>The <a href="http://course.mit.edu/6.828">MIT operating systems class</a> has lots of good references. In particular, check out <a href="http://www.computer-engineering.org/index.html">Adam Chapweske's resources</a> on keyboard and mouse programming.</p>
<p>In short, yes, you will be using the raw in/out ports, which requires either running in kernel mode, or having the I/O permission bits (IOPL) set in the EFLAGS register. See <a href="http://pdos.csail.mit.edu/6.828/2008/readings/i386/s08_03.htm">this page</a> for more details on I/O permissions.</p>
|
How do you change the colors of the text when doing a Schema Compare in Visual Studio 2008 Database Edition? <p>I am trying to find out how to modify the <code>Colors/Fonts</code> used in the Schema Compare "<code>Object Definitions</code>" window that appears after a comparison is done between two databases.</p>
<p>The color scheme I have is unreadable, but I cannot seem to find the right settings in the <code>Tools/Options/Environment/Fonts</code> and <code>Colors</code> dialog.</p>
<p>Thanks for any help.</p>
<p>Jason</p>
|
<p>I think this may help you...</p>
<p><a href="http://msdn.microsoft.com/en-us/library/kw7t0545%28v=VS.90%29.aspx" rel="nofollow">Fonts and Colors, Environment, Options Dialog Box</a></p>
|
Rake db:migration aborted <p>I've got a unfinished project that a developer just didn't finish and didn't leave any documentation about the installation process. I've downloaded the production directory to my windows machine (running InstantRails 2), I created the databases as required in the <code>database.yml</code> and I tried to run the <code>rake:db:migrate --trace</code> but I'm receiving the following error message:</p>
<pre><code>(in D:/projects/broke2)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
uninitialized constant Admin
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:279:in `load_missing_constant'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:468:in `const_missing'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:480:in `const_missing'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/inflector.rb:285:in `constantize'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/inflector.rb:284:in `each'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/inflector.rb:284:in `constantize'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/core_ext/string/inflections.rb:143:in `constantize'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/migration.rb:481:in `migrations'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/connection_adapters/mysql_adapter.rb:15:in `inject'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/migration.rb:465:in `each'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/migration.rb:465:in `inject'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/migration.rb:465:in `migrations'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/migration.rb:431:in `migrate'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/migration.rb:373:in `up'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/migration.rb:356:in `migrate'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/tasks/databases.rake:99
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `call'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in `invoke_with_call_chain'
D:/InstantRails-2.0-win/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in `invoke_with_call_chain'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in `invoke_task'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in `top_level'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in `run'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run'
D:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31
D:/InstantRails-2.0-win/ruby/bin/rake:19:in `load'
D:/InstantRails-2.0-win/ruby/bin/rake:19
</code></pre>
<p>I'm a regular Rails developer (it's not my first app) but I never saw this error and I don't have a clue where to start to debug.</p>
|
<p>Sometimes Rails will throw this error if there's a syntax error where Admin is defined.</p>
<p>Try looking for admin.rb and make sure that it parses.</p>
<p>Also, you may want to try running the migrations one at a time (<code>rake db:migrate VERSION=1</code>, etc.) to see if that helps you track down which migration causes the error, or if it is a problem simply booting the application.</p>
|
How do you upgrade a web site that uses #include files to a Web Application <p>I've recently inherited a fairly large web site. The project is set up as a web site in Visual studio, and not a Web Application. For a number of reasons, I would like to convert it to a web application.</p>
<p>I started converting the application using these directions from Scott Gu: <a href="http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx" rel="nofollow">Migrating a VS 2005 Web Site Project to VS 2005 Web Application Project</a>.</p>
<p>While doing the conversion I discovered that this web site uses a ton of #include directives to include other .aspx files. The main problem with this is that currently each code-behind file directly calls controls (using this.) from the pages it is including. </p>
<p>This behavior seems to be allowed by the way that the compiler dynamically creates the .designer files in memory at compile time.</p>
<p>The problem is that since I'm converting the application to a Web Application, I'm creating physical versions of the .designer files. Now the same call to controls on the included pages (using this.), no longer work.</p>
<p>I've tried a few things to try and remedy this:</p>
<p>First, I noticed that the .aspx include files didn't have a @ Page directive, so I tried adding one. This prevented the app from compiling because the main page now had multiple @page directives.</p>
<p>Second, I tried to just rename the included .aspx files to .inc, but I still have the same problem of the main page no longer being able to access the controls as they could before.</p>
<p>Anyone ever done this before and have any thoughts on how to proceed without changing the entire structure of the web site?</p>
<p><em>edit: I decided not to go through with the conversion at this time simply because any benefits gained wouldn't be worth the trouble. Thanks for the help.</em></p>
|
<ul>
<li>You should convert included aspx files to classes, if they are used as code libraries in the old situation</li>
<li>You should convert aspx files, which contain html, server- and/or HTML-controls to usercontrols (ascx files)</li>
</ul>
<p>This should be a good starter for now. Later on you could refactor to your own taste.</p>
<p>Hope it helps. </p>
|
How would you improve this algorithm? (c string reversal) <p>Working through some programming interview challenges I found online, I had to write an algorithm to reverse a const char * and return a pointer to a new char *. I think I have it, but to make it work properly I had to do some wonky stuff - basically having to account for the null-terminating character myself. Somehow I feel this is wrong, but I'm stumped, and I was wondering if someone could help me out:</p>
<pre><code>char * reverse(const char * str)
{
int length = strlen(str);
char * reversed_string = new char[length+1];
for(int i = 0; i < length; ++i)
{
reversed_string[i] = str[(length-1) - i];
}
//need to null terminate the string
reversed_string[length] = '\0';
return reversed_string;
}
int main(int argc, char * argv[])
{
char * rev_str = reverse("Testing");
cout << "Your string reversed is this: " << rev_str << endl;
delete rev_str;
rev_str = 0;
return 0;
}
</code></pre>
|
<p><a href="http://cppreference.com/wiki/stl/algorithm/reverse"><code>std::reverse</code></a> from <code><algorithm></code> works for strings and <code>char</code> arrays:</p>
<pre><code>string str = "Hello";
char chx[] = "Hello";
reverse(str.begin(), str.end());
reverse(chx, chx + strlen(chx));
cout << str << endl;
cout << chx << endl;
</code></pre>
<p>/EDIT: This, of course, modifies the original string. But STL to the rescue. The following creates a new reversed string. Unfortunately (?), this doesn't work directly on C <code>char</code> arrays without creating an additional (implicit) copy:</p>
<pre><code>string reverse_string(string const& old) {
return string(old.rbegin(), old.rend());
}
cout << reverse_string("Hello") << endl;
</code></pre>
|
Is it possible to view the history of a line in SVN? <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/53629/history-of-changes-to-a-particular-line-of-code-in-subversion">History of changes to a particular line of code in Subversion?</a> </p>
</blockquote>
<p>Using SVN and/or Tortoise SVN (or any other SVN tool, really), is it possible to view the history for a specific line of a file?</p>
<p>Recently I've had several occurrences of coming across a line in a file and wanting to find the log entry associated with its creation (either to determine how old the line of code was, or to get a larger context for why it was added).</p>
<p>Right now I'm doing this by hand. I can display the log for the file, go back a ways, and see if the line in question is present. If it is, I go back further. If it isn't, I go look at a more recent revision. Repeat until the revision where the change was made is found.</p>
<p>Needless to say, this process is awkward at best, especially for particularly old files. Does anyone know of an automated method of accomplishing this?</p>
|
<p>I am not sure blame alone does what the asker needs.</p>
<p>I have found the TortoiseSVN command "blame changes" to be handy. It runs a blame on two revisions and compares them together in the diff tool. </p>
<p>The result gives you what the line currently is, what it was at the targeted revision, and who modified it. This works best when you select two consecutive revisions.</p>
<p>You can access this by using "Show Log", right clicking on the file in the lower pane and selecting "blame changes".</p>
<p>Also, for anyone who does not like the term "blame", you can run "svn praise", which gives the same results. :)</p>
|
Cross-Platform Way of Creating Safari Webarchives <p>I've been searching around and haven't found any reference to tools that can create Safari's webarchive format.</p>
<p>Does anyone have pointers to code for creating this format, or at least a format reference documentation?</p>
<p>Ideally I'd like to build a tool that takes a directory and splits out a webarchive, for loading into a iPhone.</p>
|
<p>I believe the format for .webarchives is officially undocumented, but it's just a plist. You can open it in the Property List Editor and examine its contents. Shouldn't be to hard to replicate most, if not all, of what's in there.</p>
|
Should you collect the young generation first in a full garbage collection? <p>I'm writing a program that contains a generational garbage collector. There are just two generations. What I wonder is: When doing a full collection, do I gain anything (performance-wise) by first collecting the younger objects, promoting the survivors to the old generation, and then collecting the old generation, or should I just garbage collect everything in one sweep? I'm not sure which way people usually do it.</p>
<p>I'm using the two-step method now, since it was a bit simpler to implement, but perhaps a one-step method would be more efficient?</p>
<p>The garbage collector is non-copying, if that matters.</p>
|
<p>It depends on how often you promote survivors. If you promote them often, then it looks like you'll do a lot better by doing GC in one sweep. If you don't, then it looks like they'll be pretty similar. </p>
<p>Either way, it seems as if you do a little bit of redundant work by doing it in two phases. For example, anyone that gets promoted gets inherently checked twice (once as young and again as old). Again, if this doesn't happen too often, I'd stick with the simpler two-step method (since you already have it working and there's little to gain).</p>
|
How do I calculate the SIZE of stored procedures in SQL Server 2005? <p>I was asked for a comprehensive breakdown on space used within a specific database.
I know I can use *sys.dm_db_partition_stats* in SQL Server 2005 to figure out how much space each <em>table</em> in a database is using, but is there any way to determine the individual and total size of the <em>stored procedures</em> in a database? (Short of opening each one and counting the characters, of course.)</p>
<p>Total space used by stored procs is not likely to be significant (compared to actual <em>data</em>), but with hundreds of them, it could add up.</p>
|
<pre><code>;WITH ROUTINES AS (
-- CANNOT use INFORMATION_SCHEMA.ROUTINES because of 4000 character limit
SELECT o.type_desc AS ROUTINE_TYPE
,o.[name] AS ROUTINE_NAME
,m.definition AS ROUTINE_DEFINITION
FROM sys.sql_modules AS m
INNER JOIN sys.objects AS o
ON m.object_id = o.object_id
)
SELECT SUM(LEN(ROUTINE_DEFINITION))
FROM ROUTINES
</code></pre>
|
What is the best way to localize an IEnumerable? <p>What is the best way to localize a collection (IEnumerable)?
From the BL I retrieve a collection of entities which still need to localized, I figured I write a method which extends the IEnumerable and returns the localized list. </p>
<p>How can i get the code underneath working? Any ideas? Maybe better options? </p>
<pre><code>public static IEnumerable Localize(this IEnumerable items, CultureInfo cultureInfo)
{
foreach(string item in items)
{
/*Error underneath, cannot assign to item*/
item = ResourceHelper.GetString(item, cultureInfo);
}
return (items);
}
</code></pre>
|
<p>have you tried something where you <a href="http://msdn.microsoft.com/en-us/library/9k7k7cf0.aspx" rel="nofollow">yield</a> the item?</p>
<pre><code>public static IEnumerable<string> Localize(this IEnumerable<string> items, CultureInfo culture)
{
foreach (string item in items)
{
yield return ResourceHelper.GetString(item,culture);
}
}
</code></pre>
<p>this won't change any other the items in the collection you are enumerating over, but it will return what you want it to.</p>
|
Dealing with C++ "initialized but not referenced" warning for destruction of scope helpers? <p>In Visual Studio, I often use objects only for RAII purposes. For example:</p>
<pre><code>ScopeGuard close_guard = MakeGuard( &close_file, file );
</code></pre>
<p>The whole purpose of *close_guard* is to make sure that the file will be close on function exit, it is not used anywhere else. However, Visual Studio gives me a warning that a "<em>local variable is initialized but not referenced</em>". I want to turn this warning off for this specific case.</p>
<p>How do you deal with this kind of situation? Visual Studio thinks that this object is useless, but this is wrong since it has a non-trivial destructor.</p>
<p>I wouldn't want to use a <em>#pragma warning</em> directive for this since it would turn off this warning even for legitimate reasons.</p>
|
<p>If your object has a non-trivial destructor, Visual Studio should <em>not</em> be giving you that warning. The following code does not generate any warnings in VS2005 with warnings turned all the way up (/W4):</p>
<pre><code>
class Test
{
public:
~Test(void) { printf("destructor\n"); }
};
Test foo(void) { return Test(); }
int main(void)
{
Test t = foo();
printf("moo\n");
return 0;
}
</code></pre>
<p>Commenting out the destructor gives a warning; the code as-is does not.</p>
|
Convert memory address range in running Linux process to symbols in object file? <p>Here is a snippet of the file <em>/proc/self/smaps</em>:</p>
<pre><code>00af8000-00b14000 r-xp 00000000 fd:00 16417 /lib/ld-2.8.so
Size: 112 kB
Rss: 88 kB
Pss: 1 kB
Shared_Clean: 88 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 0 kB
Referenced: 88 kB
Swap: 0 kB
00b14000-00b15000 r--p 0001c000 fd:00 16417 /lib/ld-2.8.so
Size: 4 kB
Rss: 4 kB
Pss: 4 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 4 kB
Referenced: 4 kB
Swap: 0 kB
</code></pre>
<p>It shows that this process <em>(self)</em> is linked to <em>/lib/ld-2.8.so</em> and two (of the many) byte ranges mapped into memory.</p>
<p>The first range of 88kb (22 4kb pages) is <em>shared</em> and <em>clean</em>, that is it has not been written to. This is probably code.</p>
<p>The second range of 4kb (a single page) is not shared and it is <em>dirty</em> -- the process has written to it since it was memory mapped from the file on disk. This is probably data.</p>
<p><em>But what is in that memory?</em></p>
<p>How do you convert the memory range <em>00b14000-00b15000</em> into useful information such as the line number of the file in which a large static structure is declared?</p>
<p>The technique will need to take account of <a href="http://en.wikipedia.org/wiki/Prelinking" rel="nofollow">prelinking</a> and <a href="http://en.wikipedia.org/wiki/Address_space_layout_randomization" rel="nofollow">address space randomization</a>, such as from <a href="http://en.wikipedia.org/wiki/ExecShield" rel="nofollow">execshield</a>, and also <a href="http://fedoraproject.org/wiki/StackTraces" rel="nofollow">separate debugging symbols</a>.</p>
<p><em>(The motivation is to identify popular libraries which also create dirty memory and to fix them, for example by by declaring structures const).</em></p>
|
<p>The format of smaps is: </p>
<p>[BOTTOM]-[TOP] [PERM] [FILE OFFSET]</p>
<p>b80e9000-b80ea000 rw-p 0001b000 08:05 605294 /lib/ld-2.8.90.so</p>
<p>So there the actual content of the file '/lib/ld-2.8.90.so' at file offset 0x0001b000 is mapped at 0xb80e9000 in that program's memory.</p>
<p>To extract the line number or C code of the mapped address you need to match it with the ELF section of the executable or library file and then extract the GDB symbols (if said executable or library still has them).</p>
<p>The GDB file formats are documented (superficially) at <a href="http://sourceware.org/gdb/current/onlinedocs/gdbint_7.html#SEC60" rel="nofollow">http://sourceware.org/gdb/current/onlinedocs/gdbint_7.html#SEC60</a></p>
|
WordPress: I got rid of the second "home" page, but it's not good enough <p>I have a WordPress site (2.6.2) in which I have set the Home page to a static page instead of the normal posts page. The ID of this page is 2, so in the WordPress template I have changed the <code>wp_list_pages</code> to look like this:</p>
<pre><code><?php wp_list_pages('exclude=2&title_li=&depth=1' ); ?>
</code></pre>
<p>this works fine, but now the Home page doesn't get "lit up" when it's selected (because in fact it's page_id 2 that is selected, and it doesn't show in the menu). Is there any easy way around this?</p>
<p>If not, in broad outlines, what's the hard way around this? Make my own version of the <code>wp_list_pages</code> function?</p>
<p>Thanks!</p>
|
<p>You can set a static page as the front page in the Administration > Settings > Reading panel after logging in as the administrator.</p>
<p>The Wordpress manual entry on this subject can be found <a href="http://codex.wordpress.org/Creating_a_Static_Front_Page" rel="nofollow">here</a>.</p>
|
Does a Poco to DataSet project exist? <p>I have a <code>POCO</code> object that goes 4 levels deep contained objects (like <code>Invoice</code> has line items that have taxes that have gl entries), and I want to turn the entire thing into a <code>DataSet</code>. So there would be 4 tables, each with constraints being applied to the parent table.</p>
<p>Does anyone know of something that would automated this?</p>
|
<p>How do you populate this object? If it's from the database, there are two methods to structure your query such that the dataset is populated with separate, automatically related DataTable-s. Old and probably not supported anymore is the <a href="http://support.microsoft.com/kb/189657" rel="nofollow">SHAPE command</a>.
A better and more recent approach is to use <a href="http://dotnetslackers.com/articles/ado_net/MappingDataSetToXMLAndBackwards.aspx" rel="nofollow">FOR XML</a>. </p>
<p>The later approach will also allow you to load a dataset from XML-serialized representation of your `POCO' (not FOR XML, but loading XML into DataSet)</p>
|
Where do you put program scope variables in UI driven application? <p>Ok, so I know that global variables are considered bad, and the singleton pattern is overused. And I have read in many places that a class should do only one task and contain only those variables that allow it to accomplish that one task. However, while working on my latest project, I actually thought about these rules before writing any code and have noticed that I tend to break them at the very beginning of the program. </p>
<p>I'm currently working on an MFC dialog based application, but this question could be applied to any UI driven application. I have separate classes that handle state machines, file reading/writing, and hardware interfacing. All of these objects will need some type of UI control or property display/editing. In the MFC dialog applications, the dialog is the program, so it must exist until the program is closed. I've usually just put the objects in the main dialog class for the application and had the dialog class serve double duty; as both the main UI and the home for all other objects in the application. In other applications, I've created these objects globally and referenced them from wherever they were needed. Neither of these ways seem correct. The first option breaks the one class, one task rule, and the second relies on globals and also creates hidden dependencies. I could institute some type of dependency injection, but where would all these variables that I would inject reside?</p>
<p>I'm just wondering what others do to organize their programs without breaking the rules?</p>
|
<p>I find that storing singletons as public data attributes of the main dialog class of an MFC dialog application works OK for a quick and dirty program. However, as the program becomes larger and more complex, things begin to get untidy.</p>
<p>The point where storing singletons in the dialog class needs to be refactored is probably when you start passing pointers to the dialog around, so that other classes can access the singletons it contains.</p>
<p>The singletons can be moved into the global namespace. This is still a bit untidy, especially when there are a large number of them. Since you have to write a separate extern for each one in a header file then define each one somewhere, you soon end up with something that looks a lot like an old fashioned C program.</p>
<p>A neat thing to do is to make use of the singleton that the framework has already defined for you.- the application object which is always called theApp, a specialization of CWinApp. If you place your singletons as public data members of this, then any code can get easily get access to them .</p>
<p>Suppose that you called your application âsolverâ. The dialog application creation wizard will create a class CsolverApp. Now suppose you have a singleton called âtheDataâ an instance of the class âcDataâ.</p>
<p>Place your singleton in the theApp</p>
<pre><code>class CsolverApp : public CWinApp
{
public:
cData theData;
â¦
</code></pre>
<p>Now to access this from anywhere in your code</p>
<pre><code>#include âsolver.hâ
theApp.theData.somepublicmethod();
</code></pre>
|
How to handle checkboxes in ASP.NET MVC forms? <h2>Caution: This question is over five years old!</h2>
<p>Your best option is to search for newer questions, or to search the answers below looking for your specific version of MVC, as many answers here are obsolete now. </p>
<p>If you do find an answer that works for your version, please make sure the answer contains the version of MVC you are using.<br>
<sub><sub>(The original question starts below)</sub></sub></p>
<hr>
<p>This seems a bit bizarre to me, but as far as I can tell, this is how you do it.</p>
<p>I have a collection of objects, and I want users to select one or more of them. This says to me "form with checkboxes." My objects don't have any concept of "selected" (they're rudimentary POCO's formed by deserializing a wcf call). So, I do the following:</p>
<pre><code>public class SampleObject{
public Guid Id {get;set;}
public string Name {get;set;}
}
</code></pre>
<p>In the view:</p>
<pre><code><%
using (Html.BeginForm())
{
%>
<%foreach (var o in ViewData.Model) {%>
<%=Html.CheckBox(o.Id)%>&nbsp;<%= o.Name %>
<%}%>
<input type="submit" value="Submit" />
<%}%>
</code></pre>
<p>And, in the controller, this is the only way I can see to figure out what objects the user checked:</p>
<pre><code>public ActionResult ThisLooksWeird(FormCollection result)
{
var winnars = from x in result.AllKeys
where result[x] != "false"
select x;
// yadda
}
</code></pre>
<p>Its freaky in the first place, and secondly, for those items the user checked, the FormCollection lists its value as "true false" rather than just true. </p>
<p>Obviously, I'm missing something. I think this is built with the idea in mind that the objects in the collection that are acted upon within the html form are updated using <code>UpdateModel()</code> or through a ModelBinder. </p>
<p>But my objects aren't set up for this; does that mean that this is the only way? Is there another way to do it?</p>
|
<p>Html.CheckBox is doing something weird - if you view source on the resulting page, you'll see there's an <code><input type="hidden" /></code> being generated alongside each checkbox, which explains the "true false" values you're seeing for each form element.</p>
<p>Try this, which definitely works on ASP.NET MVC Beta because I've just tried it.</p>
<p>Put this in the view instead of using Html.CheckBox():</p>
<pre><code><% using (Html.BeginForm("ShowData", "Home")) { %>
<% foreach (var o in ViewData.Model) { %>
<input type="checkbox" name="selectedObjects" value="<%=o.Id%>">
<%= o.Name %>
<%}%>
<input type="submit" value="Submit" />
<%}%>
</code></pre>
<p>Your checkboxes are all called <code>selectedObjects</code>, and the <code>value</code> of each checkbox is the GUID of the corresponding object.</p>
<p>Then post to the following controller action (or something similar that does something useful instead of Response.Write())</p>
<pre><code>public ActionResult ShowData(Guid[] selectedObjects) {
foreach (Guid guid in selectedObjects) {
Response.Write(guid.ToString());
}
Response.End();
return (new EmptyResult());
}
</code></pre>
<p>This example will just write the GUIDs of the boxes you checked; ASP.NET MVC maps the GUID values of the selected checkboxes into the <code>Guid[] selectedObjects</code> parameter for you, and even parses the strings from the Request.Form collection into instantied GUID objects, which I think is rather nice.</p>
|
how to get as much as possible from dbx <p>I do TDD on a daily basis for my C++ development on Solaris10. It has greatly reduced the time I have to spend using my debugger but sometime this is the only option.</p>
<p>DBX is pretty powerful but not that user friendly. Note that I'm talking about console DBX not the SunStudio GUI for DBX).</p>
<p>What are the best productivity tips you can give for dbx C++ debugging?</p>
<p>PS. Changing debugger is not an option.</p>
|
<p>I have bookmarked a few sites related to dbx. Here they are, in no particular order in case they might be useful to you:</p>
<ul>
<li><a href="http://developers.sun.com/solaris/articles/dbxerr.html" rel="nofollow">Why Can't dbx Find My Function?</a></li>
<li><a href="http://blogs.oracle.com/quenelle/resource/dbxhelp.html" rel="nofollow">Online Help for the Dbx Debugger</a></li>
<li><a href="http://technopark02.blogspot.com/2005/12/sun-studio-debugging-multi-threaded.html" rel="nofollow">Sun Studio: debugging a multi-threaded application w/ dbx</a></li>
<li><a href="https://blogs.oracle.com/quenelle/entry/dbx_versus_gdb" rel="nofollow">gdb vs. dbx: commands mapping and feature comparison</a></li>
<li><a href="http://quenelle.org/unix/2005/importing-debug-information-into-dbx/" rel="nofollow">Importing debug information into dbx</a></li>
<li><a href="http://blogs.oracle.com/quenelle/entry/command_line_dbx_see_more" rel="nofollow">command line dbx : See more source</a></li>
<li><a href="http://forums.sun.com/thread.jspa?threadID=5070229&messageID=9258271" rel="nofollow">Sun Studio C++ - Your .dbxrc</a> (NB: adapt the integer type used to cast pointers according to your pointer size)</li>
<li><a href="http://technopark02.blogspot.com/2005/10/sun-studio-investigating-memory-leaks.html" rel="nofollow">Sun Studio: Investigating memory leaks with dbx</a></li>
<li><a href="http://technopark02.blogspot.com/2005/11/sun-studio-gathering-memory.html" rel="nofollow">Sun Studio: Gathering memory allocations/leaks data, from a running process</a></li>
</ul>
<p>EDIT on 2012 july 19th: I've tried to fix several link since Chris Quenelle's blog has moved. Some articles can still be accessed thanks to the wayback machine.</p>
|
How do I enable double-buffering of a control using C# (Windows forms)? <p>How do I enable double-buffering of a control using C# (Windows forms)?</p>
<p>I have a panel control which I am drawing stuff into and also an owner-drawn tab control. Both suffer from flicker, so how can I enable double-buffering?</p>
|
<p>In the constructor of your control, set the DoubleBuffered property, and/or ControlStyle appropriately.</p>
<p>For example, I have a simple DoubleBufferedPanel whose constructor is the following:</p>
<pre><code>this.DoubleBuffered = true;
this.SetStyle(ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.ResizeRedraw |
ControlStyles.ContainerControl |
ControlStyles.OptimizedDoubleBuffer |
ControlStyles.SupportsTransparentBackColor
, true);
</code></pre>
|
A good Java library for network math <p>I'm looking for a Java library that is geared towards network math and already tested. Nothing particularly fancy, just something to hold ips and subnets, and do things like print a subnet mask or calculate whether an IP is within a given subnet. </p>
<p>Should I roll my own, or is there already a robust library for this?</p>
|
<p>We developed a Java IPv4 arithmetic library ourselves.
See it here: <a href="http://tufar.com/ipcalculator/">http://tufar.com/ipcalculator/</a>
It is under BSD license. </p>
|
In C# why can't a conditional operator implicitly cast to a nullable type <p>I am curious as to why an implicit cast fails in...</p>
<pre><code>int? someValue = SomeCondition ? ResultOfSomeCalc() : null;
</code></pre>
<p>and why I have to perform an explicit cast instead</p>
<pre><code>int? someValue = SomeCondition ? ResultofSomeCalc() : (int?)null;
</code></pre>
<p>It seems to me that the compiler has all the information it need to make an implicit casting decision, no?</p>
|
<p>The relevant section of the C# 3.0 spec is 7.13, the conditional operator:</p>
<p>The second and third operands of the ?: operator control the type of the conditional expression. Let X and Y be the types of the second and third operands. Then,</p>
<p>If X and Y are the same type, then this is the type of the conditional
Otherwise, if an implicit conversion (§6.1) exists from X to Y, but not from Y to X, then Y is the type of the conditional expression.
Otherwise, if an implicit conversion (§6.1) exists from Y to X, but not from X to Y, then X is the type of the conditional expression.
Otherwise, no expression type can be determined, and a compile-time error occurs.</p>
|
How do I check SQL replication status via T-SQL? <p>I want to be able to check the status of a publication and subscription in SQL Server 2008 T-SQL. I want to be able to determine if its okay, when was the last successful, sync, etc.. Is this possible?</p>
|
<p>I know this is a little late....</p>
<pre><code>SELECT
(CASE
WHEN mdh.runstatus = '1' THEN 'Start - '+cast(mdh.runstatus as varchar)
WHEN mdh.runstatus = '2' THEN 'Succeed - '+cast(mdh.runstatus as varchar)
WHEN mdh.runstatus = '3' THEN 'InProgress - '+cast(mdh.runstatus as varchar)
WHEN mdh.runstatus = '4' THEN 'Idle - '+cast(mdh.runstatus as varchar)
WHEN mdh.runstatus = '5' THEN 'Retry - '+cast(mdh.runstatus as varchar)
WHEN mdh.runstatus = '6' THEN 'Fail - '+cast(mdh.runstatus as varchar)
ELSE CAST(mdh.runstatus AS VARCHAR)
END) [Run Status],
mda.subscriber_db [Subscriber DB],
mda.publication [PUB Name],
right(left(mda.name,LEN(mda.name)-(len(mda.id)+1)), LEN(left(mda.name,LEN(mda.name)-(len(mda.id)+1)))-(10+len(mda.publisher_db)+(case when mda.publisher_db='ALL' then 1 else LEN(mda.publication)+2 end))) [SUBSCRIBER],
CONVERT(VARCHAR(25),mdh.[time]) [LastSynchronized],
und.UndelivCmdsInDistDB [UndistCom],
mdh.comments [Comments],
'select * from distribution.dbo.msrepl_errors (nolock) where id = ' + CAST(mdh.error_id AS VARCHAR(8)) [Query More Info],
mdh.xact_seqno [SEQ_NO],
(CASE
WHEN mda.subscription_type = '0' THEN 'Push'
WHEN mda.subscription_type = '1' THEN 'Pull'
WHEN mda.subscription_type = '2' THEN 'Anonymous'
ELSE CAST(mda.subscription_type AS VARCHAR)
END) [SUB Type],
mda.publisher_db+' - '+CAST(mda.publisher_database_id as varchar) [Publisher DB],
mda.name [Pub - DB - Publication - SUB - AgentID]
FROM distribution.dbo.MSdistribution_agents mda
LEFT JOIN distribution.dbo.MSdistribution_history mdh ON mdh.agent_id = mda.id
JOIN
(SELECT s.agent_id, MaxAgentValue.[time], SUM(CASE WHEN xact_seqno > MaxAgentValue.maxseq THEN 1 ELSE 0 END) AS UndelivCmdsInDistDB
FROM distribution.dbo.MSrepl_commands t (NOLOCK)
JOIN distribution.dbo.MSsubscriptions AS s (NOLOCK) ON (t.article_id = s.article_id AND t.publisher_database_id=s.publisher_database_id )
JOIN
(SELECT hist.agent_id, MAX(hist.[time]) AS [time], h.maxseq
FROM distribution.dbo.MSdistribution_history hist (NOLOCK)
JOIN (SELECT agent_id,ISNULL(MAX(xact_seqno),0x0) AS maxseq
FROM distribution.dbo.MSdistribution_history (NOLOCK)
GROUP BY agent_id) AS h
ON (hist.agent_id=h.agent_id AND h.maxseq=hist.xact_seqno)
GROUP BY hist.agent_id, h.maxseq
) AS MaxAgentValue
ON MaxAgentValue.agent_id = s.agent_id
GROUP BY s.agent_id, MaxAgentValue.[time]
) und
ON mda.id = und.agent_id AND und.[time] = mdh.[time]
where mda.subscriber_db<>'virtual' -- created when your publication has the immediate_sync property set to true. This property dictates whether snapshot is available all the time for new subscriptions to be initialized. This affects the cleanup behavior of transactional replication. If this property is set to true, the transactions will be retained for max retention period instead of it getting cleaned up as soon as all the subscriptions got the change.
--and mdh.runstatus='6' --Fail
--and mdh.runstatus<>'2' --Succeed
order by mdh.[time]
</code></pre>
|
How to avoid screen flickering when showing form with user drawn controls? <p>So the <a href="http://stackoverflow.com/questions/214215/user-drawn-controls-are-using-the-previous-forms-background">transparent background problem</a> is solved. Now, every time I show the form (or have to have it repainted), I get a lot of flickering. Is there any way I can not update the screen until the paint event is complete, or any other way to stop the 1/2 second of flickering and flashing while all the objects are being painted?</p>
<p><strong>ANSWER</strong>: Double buffering is the way to go. I was already double buffering on the control, but it has to be set on the form. I though double buffering only worked when you were subclassing OnPaint yourself. </p>
|
<p>Did you try setting the <a href="http://stackoverflow.com/questions/220100/how-do-i-enable-double-buffering-of-a-control-using-c-window-forms">DoubleBuffered</a> property for the form?</p>
|
Practical limit for the number of databases in SQL Server? <p>In one of the stackoverflow podcasts (#18 I think) Jeff and Joel were talking about multi vs single tenant databases. Joel mentioned that "FogBugz on Demand" used a database per customer architecture and I was wondering if there is a point beyond which you'll need to have multiple database servers to distribute the load?</p>
|
<p>Technically the limit of databases per instance in SQL Server is 32,767, but I doubt that you could use a SQL Server instance that has more than 2,000 databases, at that point the server would probably be not responsive.</p>
<p>You may be able to have close to 30,000 databases if they were all auto-closed and not being used. you can find more information about capacity limits here:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms143432.aspx">Maximum Capacity Specifications for SQL Server</a></p>
|
As a C# developer who wants to do some PHP work, what [book/online articles] should I [buy/read] to introduce myself to PHP? <p>I've got the bare minimum to handle the Linux/MySQL parts of the stack, but I want to have a basic grasp of PHP before I dive in. I'll be working on WordPress plugins, in case there's anything specifically interesting for that.</p>
<p>PS - any recommendations regarding recommended source control/IDEs would also be great, but I guess that's a separate question.</p>
|
<p>I would recomment the <a href="http://www.php.net/manual/en/">PHP manual</a> too!</p>
|
What is the proper way to maintain state in a custom server control? <p>This works, but is it the proper way to do it???</p>
<p>I have a custom server control that has an [input] box on it. I want it to kinda mimic the ASP.NET TextBox, but not completely. When the textbox is rendered i have a javascript that allows users to select values that are then placed in that input box.</p>
<p>I have a public text property on the control. In the get/set i get/set the viewstate for the control - that part is easy, but when the control is populated via the javascript, the Text get is not actually called, what is the proper way to set this exposed property using JavaScript (or even if the user just types in the box) ?</p>
<p>Edit:
In the OnInit i ensure the state is maintained by reaching into the form values.</p>
<pre><code> protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (HttpContext.Current.Request.Form["MyInputBoxValue"] != "")
{
ViewState["MyInputBoxValue"]
= HttpContext.Current.Request.Form["MyInputBoxValue"];
}
}
</code></pre>
<p>Then to get the value actually back in place in the HtmlTextWrite, i do this:</p>
<pre><code>protected override void RenderContents(HtmlTextWriter output)
{
// There is an input control here and i set its value property
// like this using the Text internal defined.
output.Write("<input value=" + Text + ">.....
}
</code></pre>
<p>thanks</p>
|
<p>I find using IStateManager works the best. </p>
<p>For example:</p>
<pre><code>partial class MyControl : System.Web.UI.UserControl, IStateManager
{
[Serializable()]
protected struct MyControlState
{
public bool someValue;
public string name;
}
protected MyControlState state;
public bool someValue {
get { return state.someValue; }
set { state.someValue = value; }
}
public bool IsTrackingViewState {
get { return true; }
}
protected override void LoadViewState(object state)
{
if ((state != null) && state is MyControlState) {
this.state = state;
}
}
protected override object SaveViewState()
{
return state;
}
protected override void TrackViewState()
{
base.TrackViewState();
}
}
</code></pre>
<p>getDefaultState() would just load some sane defaults into a new state struct. state gets tracked in the viewstate of the page, and ASP will take care of bring it in/out for you.</p>
<p>(above code ported from VB and not checked, hopefully I didn't make any errors but it should get the point across anyways)</p>
|
Does anyone know the language used to code Orkut? <p>For sure this question will not help anyone in a heavy way, but it can be useful somehow. In the beginning, all <strong>Orkut</strong> pages had the extension <code>*.aspx</code>, but now all pages are <strong>masqueraded</strong> under a <code>Main#page.aspx</code>.</p>
<p>Sorry if this <code>Main#</code> is an ASP feature, but it does not look like one to me. Does anyone know the language Orkut was coded in? (I meant the language behind the "Main#")</p>
|
<p>browsing around, it seems like a lot of the stuff ends up as <a href="http://help.orkut.com/support/bin/answer.py?answer=30993&src=top5" rel="nofollow">.py</a> (python) files. From what I remember, Orkut was created, and then bought out by Google, so they may be in the process of switching it over to python, which is a more standard Google Language.</p>
|
Tibco & Windows Process Activation <p>I'm thinking about how I could scale out Tibco EMS queue listeners written in managed code (C# in this instance). I'm looking for predominantly isolation and clustering characteristics.</p>
<p>In MSMQ I could use Windows Process Activation Service to host and manage the number and lifetime of queue listeners. Is there a Tibco equivalent?</p>
<p>Otherwise I suspect I'll end up with a simple NT service to host EMS listeners. (which in turn could perform process-activation). Workable but fairly tricky to build a 24x7 monitorable, robust, production service.</p>
|
<p>If I understand your question correctly, then the TIBCO equivalent is <a href="http://www.tibco.com/products/soa/composite-applications/activematrix-service-grid/default.jsp" rel="nofollow">TIBCO ActiveMatrix Service Grid</a>. It supports C# service containers and can host and manage your C# listeners.</p>
<p>Couple this with <a href="http://www.tibco.com/products/soa/governance/activematrix-spm/default.jsp" rel="nofollow">TIBCO ActiveMatrix Service Performance Manager</a> and you can have it automatically deploy and start more instances to more nodes during high load situations.</p>
|
Word macro error messages <p>I am changing document template macros. The one thing I can't find out how to do is to customize error messages. For example an error message in a document is</p>
<p>"Error! No table of figures entries found"</p>
<p>I would like to change this to display something else. Is it possible to do this with Word VBA or VBScript?</p>
|
<blockquote>
<p>Is it possible to put this in some
kind of global error handler? â Craig</p>
</blockquote>
<p>It is possible. Here is a very rough example.</p>
<p>In a standard module:</p>
<pre><code>Sub HandleErr(ErrNo As Long)
Select Case ErrNo
Case vbObjectError + 1024
MsgBox "No table of figures entries found.", vbOKOnly + vbCritical
Case vbObjectError + 1034 To vbObjectError + 4999
MsgBox "Still no table of figures entries found.", vbOKOnly + vbCritical
Case Else
MsgBox "I give up.", vbOKOnly + vbCritical, _
"Application Error"
End Select
End Sub
</code></pre>
<p>Some code:</p>
<pre><code>Sub ShowError()
Dim i As Integer
On Error GoTo Proc_Err
'VBA Error
i = "a"
'Custom error
If Dir("C:\Docs\TableFigs.txt") = "" Then
Err.Raise vbObjectError + 1024
End If
Exit_Here:
Exit Sub
Proc_Err:
If Err.Number > vbObjectError And Err.Number < vbObjectError + 9999 Then
HandleErr Err.Number
Else
MsgBox Err.Description
End If
End Sub
</code></pre>
|
How to share custom data between iPhone applications? <p>If I make two iPhone applications, how can/should I share custom data (not contacts and stuff like that) among them?</p>
<p>Thanks!</p>
|
<p>There are two different ways you might go about this.</p>
<p>1) The data you need to share is non-persistent. In other words you need to launch one application with a piece of data that it can do something with. In this case you would register a special URL scheme per application.</p>
<p>You can find out more information about URL schemes via Craig Hockenberry in his <a href="http://furbo.org/2008/10/01/redacted/">[redacted] blog post</a>.</p>
<p>2) The data you need to share is persistent. In other words you need something like a data file that both applications can read and write too. As far as I know there isn't a safe way to do this other than storing your data on a remote server. If you need the data accessible without a data connection then you would need to figure out a way to sync data between the individual apps and the remote server.</p>
|
Is there a webservice available for checking a person's credit score? <p>I'm developing an application that should automatically check a person's credit score and present him different payment options based on that score.</p>
<p>The closest I could find is <a href="http://www.google.com/url?sa=t&source=web&ct=res&cd=1&url=http%3A%2F%2Fwww.strikeiron.com%2FCorteraCreditPulse&ei=Nlv9SNfHGJGUsAP6ovE0&usg=AFQjCNGC4y9x0sY1pW7xu-htXTDcsR9IMA&sig2=1H8S469j2BBpzT2jj7GkHA">Cortera Credit Pulse</a> but it's meant for checking a business' credit score and not an indivdual's.</p>
<p>Thanks in advance!</p>
|
<p>Here is a list of <a href="http://www.calyxsoftware.com/connections/services/list.asp?Cat=7" rel="nofollow">credit vendors</a> you can check if they service your industry.
The vendor that you choose should provide an integration guide for you.</p>
|
How do I add a new replicated table to a SQL Server 2005 DB that is in merge replication? <p>We have merge replication set up over a distributed environment (50 to 1500km between offices) for a SQL Server 2005 database of about 350Gb. We now need to add a couple of new tables that must also be in replication, but without pushing the new snapshot to all the subscribers. Is this possible, and if so, what would be the best way to go about doing this?</p>
|
<p>sp_addmergearticle - Adds an article to an existing merge publication. This stored procedure is executed at the Publisher on the publication database.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms174329.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms174329.aspx</a> </p>
|
Record level permissions <p><p>In a database I am designing I have implemented profile based object level security.
<p>Each user can view, edit, insert, update database tables according to the profiles (roles) he is a member of.
<p>Now there is a need to implement "External Users" who can view only the relevant records and edit some of them (but not the bulk of the database).</p>
<p><p>I am working on an "record ownership" model.
<p>Are there any ideas on how to restrict the users belonging to an "External Users" profile to see and work with some records of each table, but not all.</p>
|
<p>You should probably create a VIEW which limits the records and then apply the proper rights on the view. </p>
|
ASP.NET MVC ready for business applications (integrating 3rd party controls/components)? <p>My company has developed (and still continues to develope) a large ASP.NET business application. Our platform is ASP.NET 2.0 using some ASP.NET Ajax. We're <strong>extensively using third-party components</strong>, like webgrids, comboboxes, treeviews, calendar and scheduling controls etc.</p>
<p>Now, I don't know a lot of ASP.NET MVC and I'd like to know if there <strong>is a way to use these third-party-controls in the ASP.NET MVC model</strong>. Or do vendors have to rewrite their products in order to make them suitable for ASP.NET MVC?</p>
|
<p>If they use the ASP.NET Control Model (That will be about 99,9% of controls written by ASP.NET Control vendors), they have to rewrite their controls. How much work there is in that, is very different depending of there arhitecture of their controls - the more ajax they already use, the more posible it is that they easily can change it to MVC.</p>
<p>ASP.NET AJAX Control toolkit for exsample can work with MVC. You can see how to do this in a video on WWW.ASP.NET: <a href="http://www.asp.net/learn/mvc-videos/video-373.aspx" rel="nofollow">http://www.asp.net/learn/mvc-videos/video-373.aspx</a> </p>
|
What are TIOCM_OUT1 and TIOCM_OUT2 good for? <p><code>termios.h</code> defines:</p>
<pre><code>#define TIOCM_OUT1 0x2000
#define TIOCM_OUT2 0x4000
</code></pre>
<p>But what are the flags good for?</p>
|
<pre><code>TIOCM_OUT1 = Unassigned Programmable Output #1
TIOCM_OUT2 = Unassigned Programmable Output #2
</code></pre>
<p>It looks like they can be used to set the <code>OUT1</code> and <code>OUT2</code> bits in the MCR.<br>
But what are the Unassigned Programmable Outputs good for?<br>
My best understanding is they are used during loopback mode for interrupts and are best NOT used for anything (since they are intended to be used internally).</p>
|
Private function in Fortran <p>How do I declare a private function in Fortran?</p>
|
<p>This will only work with a Fortran 90 module. In your module declaration, you can specify the access limits for a list of variables and routines using the "public" and "private" keywords. I usually find it helpful to use the private keyword by itself initially, which specifies that everything within the module is private unless explicitly marked public.</p>
<p>In the code sample below, subroutine_1() and function_1() are accessible from outside the module via the requisite "use" statement, but any other variable/subroutine/function will be private.</p>
<pre><code>module so_example
implicit none
private
public :: subroutine_1
public :: function_1
contains
! Implementation of subroutines and functions goes here
end module so_example
</code></pre>
|
Reducing coding standards 'brainwashing' duration and effort of new hires <p>At my current job we're pretty strict about code quality and coding standards. All new hires go through a 'brainwashing' period in which time senior developers coach them to write (hopefully) better code.</p>
<p>The code review process is meticulous and it normally halves the productivity of the developers doing the review. And sometimes the 'brainwashing' period drags on for 2 or 3 months. Sometimes corrections are subtle (e.g. structuring an IF statement so that it short circuits as early as possible) and sometimes you can't help but to raise an eyebrow (e.g. declare a string and set it to String.Empty and on the very next line assign it another value).</p>
<p><strong>I'm looking for suggestions to reduce the time and effort to get new hires assimilated to coding standards of the team.</strong></p>
<p>What are others doing in similar circumstances? What processes or tools are you guys using? Is there a way to automate this? I've considered <em>FxCop</em> but haven't actually tried it and don't know if it would really help reduce time and effort or if it is even the right tool? For logistical reasons we can't do <em>pair programming</em> if that was a suggestion. And I would be dubious about it reducing the effort.</p>
<p>We have tried maintaining an in-house wiki of 'corrections' but that is failing dismally. Lack of enforcement and also because it's easier to 'have someone correct your mistakes' rather then 'read up and try and prevent the mistakes'.</p>
<p>Also, how are you guys drilling it into new hires that code quality is important? And do you guys weed out those who are lackadaisical towards quality at the interview or do you try to change them after they're hired?</p>
<p>Many thanks.</p>
<p>EDIT: Thanks for all the answers. Not sure if there is a correct answer for this question but I'm going to mark as correct the one that I'll definitely be trying out.</p>
|
<p>Spend some time writing an application that demonstrates all of your principles of optimal code. The source of this can be turned into a handbook on "What to aim for". People do much better at achieving a goal with concrete aims rather than continually being penalised by striking "anti-goals". Also it takes less time to point people in the right direction than to describe the right direction in terms of all the ones that are wrong.</p>
<p>Your optimal code primer project may also be deliberately suboptimised with common gotchas and poor algorithmic construction. Notes on the difference between the two may be inserted into the primer with hard facts about how one is demonstrably sub-optimal in comparison to the other.</p>
<p>It's not just newbies who can benefit from such an artifact, I myself am quite isolated in my job and rely on online coding communities for most of my professional development. Some clear cut examples of best practice that everyone could agree on would be of much interest to me.</p>
|
What are the benefits of MS Word content controls? <p>Office 2007 brings a new goodie called as 'content controls'.
I need to evaluate this to see if this serves as a solution for a problem under research.</p>
<p>Due to paucity of time and my general disdain for Office-interop-pains, </p>
<ul>
<li>can someone summarize the benefits?</li>
<li>Is it possible to define custom content controls?</li>
<li>where do all the word programmers (if there are any) hang out :) ? </li>
</ul>
<p>RTFMsdn links also welcome.</p>
<p>So far I see (from some screencasts) that its now possible to define
- template word docs whose content can be stubbed in from a data-behind-XML. You could create this XML as you wish.. e.g. translate contents of your DB into an XML form. The word doc can now 'data-bind' to this XML.</p>
|
<p>Well after 2 days of research, here's what I found.</p>
<p>Content Controls are the next step in evolution from the old bookmarks..</p>
<ol>
<li><strong>Protection</strong> - you can protect content-controls in your document such that the user cannot edit them. e.g. the terms of the contract may not be editable like the rest of the doc</li>
<li><strong>Data binding</strong> - you can create 'forms' in a word doc with content controls that bind to a custom xml via a visual designer. 2-way: Changing the xml updates the controls in the word doc and vice versa. Throw in an xml schema for your xml and you can have user-input validation as well. Content Controls can bind to individual xml nodes via XPath.</li>
<li><strong>Events</strong> - content controls expose events that you can handle to do custom processing.</li>
<li><strong>Document auto-generation</strong> - With some knowledge of the IO.Packaging namespace, the Open XML specs + Visual Studio, You can create a skeleton document and then churn out actual documents (e.g. invoices) by supplying a different data store/object (custom xml). You can also do something like .net 'DataTemplates' - e.g. This is how each order line item should look like.. repeat this for n line items in the xml</li>
</ol>
<p>Best at-a-glance post: <a href="http://blogs.msdn.com/kathleen/archive/2007/06/20/my-favorite-feature-word-content-controls.aspx" rel="nofollow">http://blogs.msdn.com/kathleen/archive/2007/06/20/my-favorite-feature-word-content-controls.aspx</a><br />
Mike Ormondâs screencasts - <a href="http://blogs.msdn.com/mikeormond/archive/2007/05/24/office-open-xml-file-format-nuggets.aspx" rel="nofollow">http://blogs.msdn.com/mikeormond/archive/2007/05/24/office-open-xml-file-format-nuggets.aspx</a></p>
|
What code highlighting libs are there for Ruby? <p>What'd also interest me is which have more or less dependencies.</p>
|
<p>I'm using <a href="http://coderay.rubychan.de/" rel="nofollow">Coderay</a> (<a href="http://blog.logeek.fr/2008/3/31/data-visualization-with-ruby-and-rmagick-where-are-those-bikes" rel="nofollow">see it in action at the bottom of this article</a>)</p>
<p>Not sure how many (if any) dependencies it has.</p>
|
Standard File Naming Conventions in Ruby <p>For a file containing the given class, SomeCoolClass, what would be the proper or standard filename?</p>
<pre>
1. somecoolclass.rb
2. some_cool_class.rb
3. some-cool-class.rb
4. SomeCoolClass.rb
</pre>
<p>or some other variation?</p>
<p>I noticed in the Ruby stdlib, versions 1, 2 and 3 are used.</p>
|
<p>With just <a href="http://www.ruby-lang.org">Ruby</a> (i.e. not Rails), naming is only a convention. In <a href="http://rubyonrails.org">Rails</a> the <a href="http://itsignals.cascadia.com.au/?p=7">convention</a> of using underscores is necessary (almost).</p>
<p>I think convention #2 <code>lowercase_and_underscore.rb</code> is more common and looks pretty good, though an article <a href="http://rails.learnhub.com/lesson/page/5028-ruby-coding-convention">Here</a> says <code>lowercasenounderscore.rb</code> is the Ruby convention.</p>
<p><strong>Pick either</strong> which ever convention is more common or which ever one you like more. The most important thing is to <strong>be consistent within a project</strong>.</p>
|
Easy way to flatten XML file with LINQ <p>Is there an easy way with LINQ to flatten an XML file?</p>
<p>I can see a number of ways with XSLT but wondered what the best option with LINQ would be?</p>
<p>I cant put the xml structure up exactly as stackoverflow seems to filter chevron chars. But its something like this </p>
<p>nodeA </p>
<p>--nodeA1 </p>
<p>--nodeA2 </p>
<p>NodeB </p>
<p>I want to end up with </p>
<p>nodeA </p>
<p>nodeA1</p>
<p>nodeA2 </p>
<p>NodeB</p>
|
<p>OK; it depends on the output you want - with XElement you'd need to do a bit of work to remove all the descendent nodes etc. However, it is actually quite simple with XmlDocument:</p>
<pre class="lang-cs prettyprint-override"><code>string xml = @"<xml><nodeA><nodeA1/><nodeA2/></nodeA><NodeB/></xml>";
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
XmlDocument clone = new XmlDocument();
XmlElement root = (XmlElement) clone.AppendChild(clone.CreateElement("xml"));
foreach(XmlElement el in doc.SelectNodes("//*")) {
root.AppendChild(clone.ImportNode(el, false));
}
Console.WriteLine(clone.OuterXml);
</code></pre>
<p>Outputs:</p>
<pre><code><xml><xml /><nodeA /><nodeA1 /><nodeA2 /><NodeB /></xml>
</code></pre>
<hr>
<p>[was]
Care to define "flatten" in this context? i.e. "before" and "after"?
XDocument has Descendants() and DescendantNodes() which might do the job...</p>
|
remotely and programatically logoff an active domain user <p>I need to be able to logoff any user from his windows session from a program. </p>
<p>I know I could log in as an admin and force a remote logoff. Is there any other way to force a logoff without logging in? </p>
<p>The tool will run as admin so that's not a problem, being able to remote logoff without logging in is.</p>
<p>Tool is in .NET, but any other way is welcome (JScript, command line tool to run from PInvoke, etc.)</p>
|
<p>Perhaps with Sysinternals' <a href="http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx" rel="nofollow" title="PsTools">PsTools</a>, particularly <a href="http://technet.microsoft.com/en-us/sysinternals/bb897541.aspx" rel="nofollow" title="PsShutdown">PsShutdown</a>?</p>
|
Raise CellValueChanged from a custom editing control in a DataGridView <p>I have a DataGridView (WinForms) in which I have defined a custom EditingControl derived from DataGridViewTextBoxEditingControl that only allows numeric characters.</p>
<p>I need to raise CellValueChanged event on the DataGridView each time the user press a key, but the default behaviour is to raise the event only when edition has been completed.</p>
<p>How can I raise the event each time a key is pressed?</p>
<pre><code>public class DataGridViewNumericTextBoxEditingControl : DataGridViewTextBoxEditingControl
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
e.Handled = Char.IsLetter(e.KeyChar);
if (!e.Handled)
RaiseDataGridViewCellValueChanged(); // <-- Any way?
}
}
</code></pre>
<p><strong>Update:</strong></p>
<p>I've found a workaround, but I'm not sure it's a good solution:</p>
<pre><code>public class DataGridViewNumericTextBoxEditingControl : DataGridViewTextBoxEditingControl
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
e.Handled = Char.IsLetter(e.KeyChar);
if (!e.Handled)
{
EditingControlDataGridView.EndEdit();
EditingControlDataGridView.BeginEdit(false);
}
}
}
</code></pre>
|
<p>What is the goal here? It appears you are attempting to create a keyboard mask, where any non confirming character raises an alert? If so, you may find happiness in the DataGridView by adding a MaskedTextBoxColumn. A MaskedTextBoxColumn controls the input in a much more reasonable way than forcing edit commits. </p>
<p>See here for code that shows how to use it: <a href="http://msdn.microsoft.com/en-us/library/ms180996.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms180996.aspx</a></p>
<p>According to your updated criteria in the comments, it sounds like your solution is probably about as good as it will get. Realize, however, that it is <em>very</em> easy to get into infinite event loops when you have other controls updating on another based on keyboard events. You are probably best served to have a single delegate on the form that handles all of the events as it can prevent infinite loops of event triggers by discarding spurious events them based on state. </p>
<p>Effectively this would be using the Model View Presenter pattern, where your delegate acts as the presenter and manages the traffic on your View (your UI).</p>
<p>Doing this, you can even move the Presenter logic into a new class that you then data bind to, allowing you complete control over the UI from one logical construct, rather than a hodgepodge of event handlers.</p>
|
Why ^*$ matches "127.0.0.1" <p>I don't understand, why does the following regular expression:</p>
<pre><code>^*$
</code></pre>
<p>Match the string "127.0.0.1"? Using <code>Regex.IsMatch("127.0.0.1", "^*$");</code></p>
<p>Using Expresso, it does not match, which is also what I would expect. Using the expression <code>^.*$</code> does match the string, which I would also expect.</p>
<p>Technically, <code>^*$</code> should match the beginning of a string/line any number of times, followed by the ending of the string/line. It seems * is implicitly treated as a <code>.*</code></p>
<p>What am I missing?</p>
<p>EDIT:
Run the following to see an example of the problem.</p>
<pre><code>using System;
using System.Text.RegularExpressions;
namespace RegexFubar
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Regex.IsMatch("127.0.0.1", "^*$"));
Console.Read();
}
}
}
</code></pre>
<p>I do not wish to have ^*$ match my string, I am wondering why it <strong>does</strong> match it. I would think that the expression should result in an exception being thrown, or at least a non-match.</p>
<p>EDIT2:
To clear up any confusion. I did not write this regex with the intention of having it match "127.0.0.1". A user of our application entered the expression and wondered why it matched the string when it should not. After looking at it, I could not come up with an explanation for why it matched - especially not since Expresso and .NET seems to handle it differently.</p>
<p>I guess the question is answered by it being due to the .NET implementation avoiding throwing an exception, even thought it's technically an incorrect expression. But is this really what we want?</p>
|
<p>Well, theoretically you are right, it should not match. But this depends on how the implementation works internally. Most regex impl. will take your regex and strip ^ from the front (taking note that it must match from start of the string) and strip $ from the end (noting that it must to the end of the string), what is left over is just "*" and "*" on its own is a valid regex. The implementation you are using is just wrong regarding how to handle it. You could try what happens if you replace "^*$" just with "*"; I guess it will also match everything. It seems like the implementation treats a single asterisk like a ".*".</p>
<p>According to ISO/IEC 9945-2:1993 standard, which is also described in the <a href="http://www.opengroup.org/onlinepubs/007908799/xbd/re.html">POSIX standard</a>, it is broken. It is broken because the standard says that after a ^ character, an asterisk has no special meaning at all. That means "^*$" should actually only match a single string and this string is <strong>"*"</strong>!</p>
<p>To quote the standard:</p>
<blockquote>
<p>The asterisk is special except when used:</p>
<ul>
<li>in a bracket expression</li>
<li>as the first character of an entire BRE (after an initial ^, if any)</li>
<li>as the first character of a subexpression (after an initial ^, if any); see BREs Matching Multiple Characters . </li>
</ul>
</blockquote>
<p>So if it is the first character (and ^ doesn't count as first character if present) it has no special meaning. That means in this case an asterisk should only match one character and that is an asterisk.</p>
<p><hr /></p>
<h2>Update</h2>
<p>Microsoft says</p>
<blockquote>
<p>Microsoft .NET Framework regular
expressions incorporate the most
popular features of other regular
expression implementations such as
those in Perl and awk. Designed to be
compatible with Perl 5 regular
expressions, .NET Framework regular
expressions include features not yet
seen in other implementations, such as
right-to-left matching and on-the-fly
compilation.</p>
</blockquote>
<p>Source: <a href="http://msdn.microsoft.com/en-us/library/hs600312.aspx">http://msdn.microsoft.com/en-us/library/hs600312.aspx</a></p>
<p>Okay, let's test this:</p>
<pre><code># echo -n 127.0.0.1 | perl -n -e 'print (($_ =~ m/(^.*$)/)[0]),"\n";'
-> 127.0.0.1
# echo -n 127.0.0.1 | perl -n -e 'print (($_ =~ m/(^*$)/)[0]),"\n";'
->
</code></pre>
<p>Nope, it does not. Perl works correctly. ^.*$ matches the string, ^*$ doesn't => .NET's regex implementation is broken and it does not work like Perl 5 as MS claims.</p>
|
C# Generics/Design Patterns: Should I use the template method? <p><strong>Scenario:</strong></p>
<p>(If anyone has answered/viewed my questions recently this will be somewhat familar)</p>
<p>I have 3 different web services which expose a set of objects that have commonality. I've written wrapper classes and conversion logic using generic methods to change between the intermediary objects and the service object. </p>
<p>I have an interface for the Webservice, let it be called IService for the purpose of this question. I have 3 implementation classes Service1Impl, Service2Impl and Service3Impl. Each of these referencing a different web service and using my aforementioned generic methods to convert between the appropriate objects.</p>
<p>These are injected into my ServiceWrapper class at runtime via the constructor (a factory is used to create the appopriate implementation of the ISerivice</p>
<p>e.g: </p>
<pre><code>_service = ServiceWrapper.GetServiceWrapper("2");
</code></pre>
<p>Will give me a ServiceWrapper instantiated with the Service2Impl.</p>
<p>(Dammit diagrams would be hella useful!)</p>
<p>Ok so each implementation of IService has a method called for arguments sake.. GetProperties: </p>
<pre><code>public IProperty[] GetProperties(string item, IProperty[] properties)
{
Property[] props = ServiceObjectFactory.CreateProperties<Property>(properties);
Property[] result = _service.GetProperties(item, props);
return ServiceObjectFactory.CreateProperties(result);
}
</code></pre>
<p>This looks a little confusing (I think I'm going to refactor the names). </p>
<p>Basically what is happening is:</p>
<ol>
<li><p>The call to this function from ServiceWrapper is made with the intermediary objects (IProperty) (as you can see from the parameters).</p></li>
<li><p>The intermediary objects are converted to Property objects which are service specific.</p></li>
<li><p>The result comes back as service specific Property objects.</p></li>
<li><p>The result is converted to the intermediary objects before being passed back to the ServiceWrapper.</p></li>
</ol>
<p>Now, this code is going to be exactly the same for Service1Impl, Service2Impl and Service3Impl. Except of course that the types used are different.</p>
<p>Can anyone think of a way to do this so that I don't have the same code 3 times? </p>
<p><strong>N.B: This is not true of every method in each Implementation. Just most of them.</strong></p>
|
<p>I think in general, if you want your code to have different type signatures, you'll have to write the code three different times. Since the types are different, it's not "the same code" at all.</p>
<p>You could put what you have into an inherited method and then wrap the results in each subclass.</p>
|
What code highlighting libs are there for Java? <p>I'd like them to be easy to bundle, with few dependencies and easy to use.</p>
|
<p>Do you want to highlight Java code or use a Java lib to highlight some other code?</p>
<p>I use these two: <a href="https://jhighlight.dev.java.net/">https://jhighlight.dev.java.net/</a> (server-side) for xml and <a href="http://code.google.com/p/syntaxhighlighter/">http://code.google.com/p/syntaxhighlighter/</a> (js lib) for other stuff. The latter has something called 'brushes' which are "pluggable" .js for several langauges. If you are doing simple highlighting, I recommend the ,js approach.</p>
|
Best ways to deal with UTC and daylight saving times <p>What are the best ways of dealing with UTC Conversion and daylight saving times conversion. What are the problems and their solutions. All in C# .Net 2.0. Also any existing problems with this in .Net 2.0.</p>
|
<p>If you use UTC times you shouldn't worry about clients timezones or daylight saving... (if they have set a standard)</p>
|
Are there any good Javascript graphics libraries? <p>After staring at <a href="http://maettig.com/code/javascript/3d_dots.html">this 3D cube</a> and <a href="http://www.uselesspickles.com/triangles/demo.html">these triangles</a> for a while I started wondering if there's any good reliable Javascript graphics library with basic 3D support.</p>
<p>Any suggestion?</p>
|
<p>John Resig's port of the Processing library to Javascript:</p>
<p><a href="http://ejohn.org/blog/processingjs">http://ejohn.org/blog/processingjs</a></p>
|
Bat file to run a .exe at the command prompt <p>I want to create a .bat file so I can just click on it so it can run:</p>
<pre><code>svcutil.exe /language:cs /out:generatedProxy.cs /config:app.config http://localhost:8000/ServiceModelSamples/service
</code></pre>
<p>Can someone help me with the structure of the .bat file?</p>
|
<p>To start a program and then close command prompt without waiting for program to exit:</p>
<pre><code>start /d "path" file.exe
</code></pre>
|
MSBuild, example that filters entire solution of .cs files <p>I want to learn MSBuild, was wondering if someone could get me started with a simple build script to filter out my vs.net 2008 project of all files with the .cs extension.</p>
<ol>
<li>how do I run the build?</li>
<li>where do you usually store the build also?</li>
</ol>
|
<p>You typically run an MSBuild script from the command line using the following syntax:</p>
<pre><code>MSBuild <scriptfilename> /t:targetname
</code></pre>
<p>You can get more information here: <a href="http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx</a></p>
<p>What are you trying to accomplish by parsing out all of the .cs files from the project file? Keep in mind that with VS2005 and later, the project files <strong>are</strong> MSBuild scripts in their own right, so you can simply call MSBuild on the command line and give it the name of the project file as the and the appropriate target.</p>
<p>That being said, if you create a separate script file I typically store them in the root project folder.</p>
<p>If you want the list of files as a single string property that is semicolon delimited:</p>
<pre><code><Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<Import Project="Project.csproj" Condition="Exists(Project.csproj')"/>
<Target Name="Test">
<Message Text="@(Compile)"/>
</Target>
</Project>
</code></pre>
<p>If you want to be able to dispaly each file individually:</p>
<pre><code><Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<Import Project="Project.csproj" Condition="Exists(Project.csproj')"/>
<Target Name="Test">
<Message Text="%(Compile.FullPath)"/>
</Target>
</Project>
</code></pre>
<p>Walking through each of these samples, the first line (<code><Project ...></code>) identifies the fact that this is an MSBuild project file, defines the DefaultTargets (those targets that will run if no target (/t: targetname) is given on the command line) the XML schema (xmlns) used to validate the file and the version of MSBuild to use (ToolsVersion).</p>
<p>The second line (<code><Import ...></code>) tells MSBuild to include the contents of the MSBuild script named "Project.csproj" if it exists.</p>
<p>Finally, we define a target named "Test" that contains one task. That task is the "Message" task, which prints a message (whatever is contained in "Text") on the screen.</p>
<p>In the first sample, <code><Message Text="@(Compile)"/></code>, we are referencing an ItemGroup named "Compile" as a semicolon delimited list. In the second example, we are referencing the same ItemGroup but looping over each item in that ItemGroup and printing the "FullPath" metadata contents. (The Compile ItemGroup is defined in the .csproj that we imported in line 2.)</p>
|
Set BufferedImage alpha mask in Java <p>I have two BufferedImages I loaded in from pngs. The first contains an image, the second an alpha mask for the image.</p>
<p>I want to create a combined image from the two, by applying the alpha mask. My google-fu fails me.</p>
<p>I know how to load/save the images, I just need the bit where I go from two BufferedImages to one BufferedImage with the right alpha channel.</p>
|
<p>I'm too late with this answer, but maybe it is of use for someone anyway. This is a simpler and more efficient version of Michael Myers' method:</p>
<pre><code>public void applyGrayscaleMaskToAlpha(BufferedImage image, BufferedImage mask)
{
int width = image.getWidth();
int height = image.getHeight();
int[] imagePixels = image.getRGB(0, 0, width, height, null, 0, width);
int[] maskPixels = mask.getRGB(0, 0, width, height, null, 0, width);
for (int i = 0; i < imagePixels.length; i++)
{
int color = imagePixels[i] & 0x00ffffff; // Mask preexisting alpha
int alpha = maskPixels[i] << 24; // Shift blue to alpha
imagePixels[i] = color | alpha;
}
image.setRGB(0, 0, width, height, imagePixels, 0, width);
}
</code></pre>
<p>It reads all the pixels into an array at the beginning, thus requiring only one for-loop. Also, it directly shifts the blue byte to the alpha (of the mask color), instead of first masking the red byte and then shifting it.</p>
<p>Like the other methods, it assumes both images have the same dimensions.</p>
|
How can I stop ASP.NET Menu controls from generating inline html style elements <p>I have a master page that contains an ASP.NET server side Menu control (System.Web.UI.WebControls.Menu)</p>
<p>I <em>am</em> using the CSSFriendly adapters from here</p>
<p><a href="http://www.asp.net/CSSAdapters/Menu.aspx">http://www.asp.net/CSSAdapters/Menu.aspx</a></p>
<p>and they do make the rendered HTML much cleaner however I am still getting inline styles output into the HEAD element in the HTML like this</p>
<pre><code><style type="text/css">
.ctl00_SiteHeader1_TabBar1_Menu1_0 { background-color:white;visibility:hidden;display:none;position:absolute;left:0px;top:0px; }
.ctl00_SiteHeader1_TabBar1_Menu1_1 { text-decoration:none; }
.ctl00_SiteHeader1_TabBar1_Menu1_2 { }
.ctl00_LeftColumnContent_LeftHandNavigator1_Menu1_0 { text-decoration:none; }
</style>
</head>
<body>
</code></pre>
<p>I thik these styles are being generated by ASP.NET, I don't think I need them as I am using the CSSAdapters so is there any way of stopping them from being generated?</p>
<p>Derek</p>
|
<p>In .NET Framework 4, ASP.NET menu has a new property, <code>IncludeStyleBlock</code>, that you can set to false to avoid generation of <code><style></code> block. However, it still generates a <code>style="float:left"</code> attribute that can only be overridden with a <code>float: none !important</code> in your stylesheet.</p>
|
Operations on arbitrary value types <p>This <a href="http://themechanicalbride.blogspot.com/2008/04/using-operators-with-generics.html" rel="nofollow">article</a> describes a way, in C#, to allow the addition of arbitrary value types which have a + operator defined for them. In essence it allows the following code:</p>
<pre><code>public T Add(T val1, T val2)
{
return val1 + val2;
}
</code></pre>
<p>This code does not compile as there is no guarantee that the T type has a definition for the '+' operator, but the effect is achieved with code like this:</p>
<pre><code>public T Add(T val1, T val2)
{
//Num<T> defines a '+' operation which returns a value of type T
return (new Num<T>(val1) + new Num<T>(val2));
}
</code></pre>
<p>Follow the link to see how the Num class achieves this. Anyways, on to the question. Is there any way to achieve the same effect in C or C++? For the curious, the problem I'm trying to solve is to allow a CUDA kernel to be more flexible/general by allowing it to operate on more types.</p>
<p><strong>Update:</strong> For .NET, Marc Gravell has made a <a href="http://www.yoda.arachsys.com/csharp/miscutil/usage/genericoperators.html" rel="nofollow">utility library</a> which solves the operator problem very elegantly.</p>
|
<p>Due to the way templates are compiled in C++, simply doing:</p>
<pre><code>template < class T >
T add(T const & val1, T const & val2)
{
return val1 + val2;
}
</code></pre>
<p>will work, you'll get a compile error for every type where an operator+ is not defined.</p>
<p>C++ templates generate code for every type instantiation, so for every type T code will be generated that does the right thing. This way C++ doesn't need Num<> trickery.</p>
<p>In plain C, this is not possible as far as I know.</p>
|
How do I create 7-Zip archives with .NET? <p>How can I create 7-Zip archives from my C# console application? I need to be able to extract the archives using the regular, widely available <a href="http://www.7-zip.org/">7-Zip</a> program.</p>
<p><hr /></p>
<h2>Here are my results with the examples provided as answers to this question</h2>
<ul>
<li>"Shelling out" to 7z.exe - this is the simplest and most effective approach, and I can confirm that <strong>it works nicely</strong>. As <a href="http://stackoverflow.com/questions/222030/how-do-i-create-7-zip-archives-with-net#222047">workmad3 mentions</a>, I just need to guarantee that 7z.exe is installed on all target machines, which is something I can guarantee.</li>
<li><a href="http://www.eggheadcafe.com/tutorials/aspnet/064b41e4-60bc-4d35-9136-368603bcc27a/7zip-lzma-inmemory-com.aspx">7Zip in memory compression</a> - this refers to compressing cookies "in-memory" before sending to the client; this method seems somewhat promising. The wrapper methods (wrapping the <a href="http://www.7-zip.org/sdk.html">LZMA SDK</a>) return type <code>byte[]</code>. When I write the <code>byte[]</code> array to a file, I can't extract it using 7-Zip (<code>File.7z is not supported archive</code>).</li>
<li><a href="http://www.codeplex.com/7zsharp">7zSharp</a> Wrapper (found on CodePlex) - this wraps the 7z exe/<a href="http://www.7-zip.org/sdk.html">LZMA SDK</a>. I referenced the project from my app, and it successfully created some archive files, but I was unable to extract the files using the regular 7-Zip program (<code>File.7z is not supported archive</code>).</li>
<li><a href="http://www.7-zip.org/sdk.html">7Zip SDK aka LZMA SDK</a> - I guess I'm not smart enough to figure out how to use this (which is why I posted here)... Any working code examples that demonstrate creating a 7zip archive that is able to be extracted by the regular 7zip program?</li>
<li><a href="http://www.codeproject.com/KB/DLL/cs_interface_7zip.aspx">CodeProject C# (.NET) Interface for 7-Zip Archive DLLs</a> - only supports extracting from 7zip archives... I need to create them!</li>
<li><a href="http://sharpdevelop.net/OpenSource/SharpZipLib/Default.aspx">SharpZipLib</a> - According to their <a href="http://wiki.sharpdevelop.net/SharpZipLib_FAQ.ashx">FAQ</a>, SharpZipLib doesn't support 7zip.</li>
</ul>
|
<p><a href="http://www.eggheadcafe.com/tutorials/aspnet/064b41e4-60bc-4d35-9136-368603bcc27a/7zip-lzma-inmemory-com.aspx">EggCafe 7Zip cookie example</a> This is an example (zipping cookie) with the DLL of 7Zip.</p>
<p><a href="http://www.codeplex.com/7zsharp">CodePlex Warper</a>
This is an open source project that warp zipping function of 7z.</p>
<p><a href="http://www.7-zip.org/sdk.html">7Zip SDK</a> The official SDK for 7zip (C, C++, C#, Java) <---My suggestion</p>
<p>.Net zipping library by <a href="http://sharpdevelop.net/OpenSource/SharpzipLib/">SharpDevelop.net</a></p>
<p><a href="http://www.codeproject.com/KB/DLL/cs_interface_7zip.aspx">CodeProject</a> example with 7zip</p>
<p><a href="http://community.sharpdevelop.net/blogs/johnreilly/default.aspx">SharpZipLib</a> Many zipping</p>
|
ASP.NET Tab Controls <p>I'm currently attempting to create a tabbed interface in a web application, and based on my search, there aren't any 'built in' tab controls in ASP.NET. There are some in the <a href="http://www.asp.net/ajax/" rel="nofollow">ASP.NET AJAX</a> downloadable toolkit, as well as a wealth of 'pay for use' third party Tab Controls.</p>
<p>My question is: What Tab control have you used for ASP.NET applications, and why do you use it?</p>
|
<p>You can use MultiView/Views and your own navigation to get tabs in ASP.NET. </p>
|
How to speed up WPF programs? <p>I love programming with and for Windows Presentation Framework. Mostly I write browser-like apps using WPF and XAML.</p>
<p>But what really annoys me is the slowness of WPF. A simple page with only a few controls loads fast enough, but as soon as a page is a teeny weeny bit more complex, like containing a lot of data entry fields, one or two tab controls, and stuff, it gets painful.</p>
<p>Loading of such a page can take more than one second. Seconds, indeed, especially on not so fast computers (read: the customers computers) it can take ages.</p>
<p>Same with changing values on the page. Everything about the WPF UI is somehow sluggy.</p>
<p>This is so mean! They give me this beautiful framework, but make it so excruciatingly slow so I'll have to apologize to our customers all the time!</p>
<p>My Question: </p>
<ol>
<li>How do you speed up WPF?</li>
<li>How do you profile bottlenecks?</li>
<li>How do you deal with the slowness?</li>
</ol>
<p>Since this seems to be an universal problem with WPF, I'm looking for general advice, useful for many situations and problems.</p>
<p>Some other related questions:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/38642/what-tools-do-you-use-for-wpf-development">What tools do you use for WPF development</a></li>
<li><a href="http://stackoverflow.com/questions/189244/tools-to-develop-wpf-or-silverlight-applications">Tools to develop WPF or Silverlight applications</a></li>
</ul>
|
<ol>
<li><p><strong>How do you speed up WPF?</strong><br /><br>
Often after using one of the following profiling tools it is obvious what is causing my bottlenecks.</p>
<ul>
<li>If memory is the issue then I virtualize my data.</li>
<li>If render time is the issue then I virtualize the controls or simplify control templates where possible.</li>
<li>If processing time is the issue I try to improve my algorithm or move that work to a background thread and show a throbber in my ui while the work is going.<br>
<br/></li>
</ul></li>
<li><p><strong>How do you profile bottlenecks?</strong></p>
<ul>
<li><a href="http://memprofiler.com/">.NET Memory Pofiler</a></li>
<li><a href="http://www.jetbrains.com/profiler/">dotTrace</a></li>
<li><a href="http://windowsclient.net/wpf/perf/wpf-perf-tool.aspx">Performance Profiling Tools for WPF</a></li>
<li><a href="http://blois.us/Snoop/">Snoop</a></li>
<li><a href="http://www.codeplex.com/cracknetproject">Crack.NET</a><br>
<br/></li>
</ul></li>
<li><p><strong>How do you deal with the slowness?</strong><br /><br>
Profiling and counseling.</p></li>
</ol>
|
How do I force a rollover at application startup with Log4net RolloverFileAppender? <p>Have Log4Net configured in our application to use a date stamped name and a 10Meg file size limit.<br />
This automatically causes a rollover to a new file at midnight and whenever the 10Meg limit is reached.
I would also like to roll over the logging to a new file each time the application is started (or closed).<br />
Can I get all three roll over behaviours?</p>
|
<p>Set <a href="http://logging.apache.org/log4net/release/sdk/log4net.Appender.FileAppender.AppendToFile.html" rel="nofollow">appendToFile</a> to false in your config file.</p>
<pre><code><appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
....
<appendToFile value="false" />
....
</appender>
</code></pre>
<p>EDIT: To answer Craig's comment:</p>
<p>If you properly setup StaticLogFileName and CountDirection (see <a href="http://logging.apache.org/log4net/release/sdk/log4net.Appender.RollingFileAppender.html" rel="nofollow">http://logging.apache.org/log4net/release/sdk/log4net.Appender.RollingFileAppender.html</a> for more), then things roll as desired. We programmatically configure the logger in our app where we use this, but this is what the code looks like:</p>
<pre><code>Dim Layout As New PatternLayout("%date{yyyy-MM-dd HH:mm:ss,fff} [%-6thread] %-5level %type{2}.%method(%line) - %message%newline")
Dim Appender As New log4net.Appender.RollingFileAppender()
Appender.File = Path.Combine(FileSystemHelper.LogDirectory, LogFileName)
Appender.Layout = Layout
Appender.AppendToFile = False ' we will start a new one when the program starts'
Appender.Name = "RollingLogFileAppender"
Appender.Threshold = LogLevel() 'May want to set this by configuration'
Appender.RollingStyle = log4net.Appender.RollingFileAppender.RollingMode.Size 'This means it will start a new log file each time the log grows to 10Mb'
Appender.MaximumFileSize = "10MB"
Appender.MaxSizeRollBackups = -1 'keep an infinite number of logs'
Appender.StaticLogFileName = True
Appender.CountDirection = 1 ' to reduce rollover costs'
log4net.Config.BasicConfigurator.Configure(Appender)
Appender.ActivateOptions()
</code></pre>
|
In PHP, how can I correct missing keys in an array? <p>After using <a href="http://us.php.net/array_unique"><code>array_unique</code></a>, an array without the duplicate values is removed. However, it appears that the keys are also removed, which leaves gaps in an array with numerical indexes (although is fine for an associative array). If I iterate using a for loop, I have to account for the missing indexes and just copy the keys to a new array, but that seems clumsy.</p>
|
<p><code>$foo = array_values($foo);</code> will re-number an array for you</p>
|
IIS 7.0 Multiple Domain Site Bindings <p>I've got three web sites each with its own domain going to my one Windows Server 2008 IIS 7.0 web server.</p>
<ul>
<li><code>example1.com</code></li>
<li><code>example2.com</code></li>
<li><code>example3.com</code></li>
</ul>
<p>The site bindings for each:</p>
<p><img src="http://img371.imageshack.us/img371/4215/example1pf4.gif" alt="IIS 7.0 Site Bindings example1.com" /></p>
<p><img src="http://img371.imageshack.us/img371/2567/example2xx0.gif" alt="IIS 7.0 Site Bindings example2.com" /></p>
<p><img src="http://img266.imageshack.us/img266/8186/example3rh9.gif" alt="IIS 7.0 Site Bindings example3.com" /></p>
<p>When I navigate to <code>example1.com</code>, then I see my <em>example1</em> web site.</p>
<p>When I navigate to <code>example2.com</code>, then I see my <em>example2</em> web site.</p>
<p>But, when I navigate to <code>example3.com</code>, I see my <em>example1</em> web site--not the <em>example3</em> web site I expect.</p>
<p>What's going on? Why might <code>example2.com</code> work, but <code>example3.com</code> fail?</p>
<p><hr /></p>
<p><del>Issue resolved!</p>
<p>I removed and then recreated the <em>example3.com</em> web site within IIS and it's now working.</p>
<p>I didn't change anything. It either originally had a simple typo or the act of recreating it just happened to fix a hiccup within IIS.</del></p>
<p><hr /></p>
<p><del>It's stopped working again after I setup additional redirects within IIS forcing web sites to use sub domains:</p>
<p><code>http://example1.com/</code> redirects to <code>http://www.example1.com/</code></p>
<p>I've again removed and then recreated the <em>example3.com</em> web sites; I've reset IIS; I've rebooted the server. It's still not working correctly.</del></p>
<p><hr /></p>
<p>I've figured it out. It's not an IIS issue. It's a DNS issue.</p>
<p>The <code>example3.com</code> traffic is for some reason directed to a web server at a different company. THEY serve up a page with only an HTML frame on it. That frame loads a page with the address <code>http://example3.example1.com</code>. That's what I need to handle on MY web server.</p>
|
<p>I would validate that you have example3.com pointing to the proper location on disk. Also ensure that it is not stopped.</p>
<p>The fallback to example1 is due to the binding entry with no header value.</p>
|
Asp.Net MVC Beta: Previous RouteData overrides current RouteData? <p>I have something similar to the following method: </p>
<pre><code> public ActionResult Details(int id)
{
var viewData = new DetailsViewData
{
Booth = BoothRepository.Find(id),
Category = ItemType.HotBuy
};
return View(viewData);
}
</code></pre>
<p>and the following Route:</p>
<pre><code>routes.MapRoute("shows","shows/{controller}/{action}/{id}", new {id = 0});
</code></pre>
<p>Everything worked fine before the Beta, when I had Preview 3. Now the method will fill the id correctly the first time I execute the action. However the second time the controller's <code>ModelState</code> contains the last-use id value. This causes the <code>ActionInvoker</code> to use it in the method's parameter instead of the <code>Route</code> value.</p>
<p>So if I call the action twice on two different entities the results are such:</p>
<pre><code>www.mysite.com/shows/Booth/Details/1 => Details(1)
www.mysite.com/shows/Booth/Details/2 => Details(1) //from ModelState["id"]
</code></pre>
<p>From my quick scan with Reflector it seems it first binds parameters to the ModelState then to Routes. However, I never even posted anything from the model. As far as I can tell the ModelState should not contain anything. </p>
<p>Is this a bug in the Beta, possibly a bug somewhere in my code, or is there some design feature that I am ignorant of? Any insight into the nature of ModelState and why this happens is appreciated.</p>
<p>EDIT:
I discovered that this issue is actually a symptom of what appears to be a bug with the DefaultValueProvider if you instantiate a Controller from an IoC container that exists for the lifetime of the Asp.Net application.What happens is that the DefaultValueProvider uses the first ControllerContext given to the Controller and never updates it until the controller is recreated. This causes old RouteData to be used for method parameters instead of the current RouteData.</p>
|
<p>It's hard for me to tell what you expect to happen and what is happening from your post. Is it possible there's an error in your BoothRepository.Find method such that it returns the same thing every time?</p>
<p>ModelBinder should not be affecting this method because the parameter to the action method is a simple type, int.</p>
<p>Were both of these requests GET requests? If you still are having problems, can you try and create the simplest repro possible and email it to philha - microsoft dot com?</p>
<p>EDIT: The problem ended up being that the developer was attempting to re-use the valueprovider across requests (by having Castle Windsor manage the lifecycle of Controllers). Right now, there's no support for re-using controller instances across requests like you would with IHttpHandler which has a IsReusable property. So in general, reusing controllers across requests requires doing a lot more work on your end. :)</p>
|
Option Strict On and .NET for VB6 programmers <p>I'm preparing a class on Visual Basic 2005 targeting Visual Basic 6 programmers migrating to the .NET platform.<br /><br/>
I would like a word of advice about whether to recommend them to always enable <strong>Option Strict</strong> or not.<br /><br/>
I've worked exclusively with C-style programming languages, mostly Java and C#, so for me <strong>explicit casting</strong> is something I always expect I have to do, since it's never been an option.<br/>However I recognize the value of working with a language that has built-in support for <strong>late-binding</strong>, because not having to be excessively explicit about types in the code indeed saves time. This is further proved by the popular diffusion of <strong>dynamic typed languages</strong>, even on the .NET platform with the Dynamic Language Runtime.
<br><br/>
With this in mind, should someone who is approaching .NET for the first time using VB.NET and with a VB6 background be encouraged to get into the mindset of <strong>having to work with compile-time type checking</strong> because that's the "best practice" in the CLR? Or is it "OK" to continue enjoying the benefits of late-binding?</p>
|
<p>Yes! Option Strict is definitely a best practice with .Net. Emphasize that .Net is at it's core a strongly typed platform, and will be until the DLR is more completely supported. With few exceptions, every <code>Dim</code> and <code>Function</code> should have an explicit type declared to go with it. Things like LINQ or Boo and JScript are the exceptions that prove the rule.</p>
<p>Here are some other things to point out. I'm sure you're well aware of all this, but I've had to work with and maintain a lot of VB.Net code written by former VB6ers, and so this is something of a sore spot for me:</p>
<ul>
<li>Don't use the old string functions: <code>LEN()</code>, <code>REPLACE()</code>, <code>TRIM()</code>, etc</li>
<li>Hungarian warts are no longer recommended. <code>oMyObject</code> and <code>sMyString</code> are not kosher. Show them the reference in <a href="http://msdn.microsoft.com/en-us/library/ms229042.aspx">Microsoft's Design Guidelines</a> if they don't believe you.</li>
<li>Make sure they learn about the new <code>AndAlso</code>/<code>OrElse</code> logical operators</li>
<li>PARAMETERIZED QUERIES and modern ADO.Net. Can't emphasize that enough. They should never need to call <code>CreateObject()</code> again.</li>
<li>Scope works differently (and is more important) in .Net than it was in VB6. VB.Net still has modules, but they're now more analogous to a static class. It's important to understand how developing in a real object oriented environment be different, as opposed to the partial OOP support provided by VB6. There's no good reason anymore to allow methods to run to ungodly lengths.</li>
<li>Make sure they get an introduction to Generics and Interfaces (including <code>IEnumeralbe(Of T)</code>), and learn why they should never use an <code>ArrayList</code> again.</li>
</ul>
<p>I could keep going, but I'll just point you to the <a href="http://stackoverflow.com/questions/102084/hidden-features-of-vbnet">Hidden Features of VB.Net</a> Question to close out this rant.</p>
|
How should I manage developing on SQL Server 2008 and SQL Server 2005 for different clients? <p>The company I work for has several clients. I'm currently splitting my time between 2 .net projects. For Client A I need Visual Studio 2008, SQL Server 2008 and the 3.5 framework. For Client B 2005 versions/2.0 Framework.</p>
<p>Others in the company are using Microsoft Virtual PC to keep the development environments separate.</p>
<p>What do you suggest?</p>
<p><strong>Additional Info:</strong>
The main benefit I see is that you are able to share your virtual machine setup with anyone. This allows a new developer to step right in on a project without spending half a day setting up the new development environment and all its idiosyncrasies.</p>
|
<p>I personally have both installed on the same system and use the proper tool for each project</p>
<p>VS 2005/SQL Server 2005</p>
<p>VS 2008/SQL Server 2008</p>
<p>I find that it works jsut fine, and I don't have the hassle of switching VM's.. I see the VM as just added overhead.</p>
|
How to script Visual Studio 2008 from Python? <p>I'd like to write Python scripts that drive Visual Studio 2008 and Visual C++ 2008. All the examples I've found so far use <code>win32com.client.Dispatch</code>. This works fine for Excel 2007 and Word 2007 but fails for Visual Studio 2008:</p>
<pre><code>import win32com.client
app1 = win32com.client.Dispatch( 'Excel.Application' ) # ok
app2 = win32com.client.Dispatch( 'Word.Application' ) # ok
app3 = win32com.client.Dispatch( 'MSDev.Application' ) # error
</code></pre>
<p>Any ideas? Does Visual Studio 2008 use a different string to identify itself? Is the above method out-dated?</p>
|
<p>Depending on what exactly you're trying to do, <a href="http://www.autoitscript.com/autoit3/index.shtml" rel="nofollow">AutoIt</a> may meet your needs. In fact, I'm sure it will do anything you need it to do.</p>
<p>Taken from my <a href="http://stackoverflow.com/questions/151846/get-other-running-processes-window-sizes-in-python#155587">other post</a> about how to use AutoIt with Python:</p>
<pre><code>import win32com.client
oAutoItX = win32com.client.Dispatch( "AutoItX3.Control" )
oAutoItX.Opt("WinTitleMatchMode", 2) #Match text anywhere in a window title
width = oAutoItX.WinGetClientSizeWidth("Firefox")
height = oAutoItX.WinGetClientSizeHeight("Firefox")
print width, height
</code></pre>
<p>You can of course use any of the <a href="http://www.autoitscript.com/autoit3/docs/functions.htm" rel="nofollow">AutoItX functions</a> (note that that link goes to the AutoIt function reference, the com version of AutoIt - AutoItX has a subset of that list...the documentation is included in the download) in this way. I don't know what you're wanting to do, so I can't point you towards the appropriate functions, but this should get you started.</p>
|
Effective copying multiple files <p>I have to copy quite a lot of files from one folder to another. Currently I am doing it in this way:</p>
<pre><code>string[] files = Directory.GetFiles(rootFolder, "*.xml");
foreach (string file in files)
{
string otherFile = Path.Combine(otherFolder, Path.GetFileName(file));
File.Copy(file, otherFile);
}
</code></pre>
<p>Is that the most efficient way? Seems to take ages.</p>
<p>EDIT: I am really asking if there is a faster way to do a batch copy, instead of copying individual files, but I guess the answer is no.</p>
|
<p>I can't think of a more efficient way than File.Copy, it goes directly to the OS. </p>
<p>On the other hand if it takes that long, I would strongly suggest to show a progress dialog - like <a href="http://msdn.microsoft.com/en-us/library/bb762164(VS.85).aspx">SHFileOperation</a> does it for you. At least your users will know what is happening.</p>
|
How to check for optional fields in $_POST <p>At the moment my code looks like this:</p>
<pre><code># Assign values for saving to the db
$data = array(
'table_of_contents' => $_POST['table_of_contents'],
'length' => $_POST['length']
);
# Check for fields that may not be set
if ( isset($_POST['lossless_copy']) )
{
$data = array(
'lossless_copy' => $_POST['lossless_copy']
);
}
// etc.
</code></pre>
<p>This would lead to endless if statements though... Even with the ternary syntax it's still messy. Is there a better way?</p>
|
<p>How about this:</p>
<pre><code>// this is an array of default values for the fields that could be in the POST
$defaultValues = array(
'table_of_contents' => '',
'length' => 25,
'lossless_copy' => false,
);
$data = array_merge($defaultValues, $_POST);
// $data is now the post with all the keys set
</code></pre>
<p><code>array_merge()</code> will merge the values, having the later values override the previous ones.</p>
<p>If you don't want to trust <code>array_merge()</code> then you can do a <code>foreach()</code> loop.</p>
|
Should I use multi-byte overloading (mbstring.func_overload)? <p>I'm in the process of making my PHP site Unicode-aware. I'm wondering if anyone has experience with the <code>mbstring.func_overload</code> setting, which replaces the normal string functions (e.g. <code>strlen</code>) with their multi-byte equivalents (<code>mb_strlen</code>). There aren't any comments on the PHP manual page.</p>
<p>Are there any potential problems that I should be aware of? Any cases where calling the multi-byte version is a bad idea?</p>
<p>I suppose one example would be functions that deal with encryption, since they may expect to deal with strings of bytes, rather than strings of characters.</p>
<p>Also, the manual page includes a note: "It is not recommended to use the function overloading option in the per-directory context, because it's not confirmed yet to be stable enough in a production environment and may lead to undefined behaviour."</p>
<p>Does that mean that it's not stable in a per-directory context, or it's generally not stable? The wording is unclear.</p>
|
<p>My answer is: <em>definitely not</em>!</p>
<p>The problem is that there is no easy way to "reset" str* functions once they are overloaded. </p>
<p>For some time this can work well with your project, but almost surely you will run into an external library that uses string functions to, for example, implement a binary protocol, and they will fail. They will fail and you will spend hours trying to find out why they are failing.</p>
<p>After you have found that it's <code>mbstring.func_overload</code>, you don't have too much option. You can ini_set the <code>mbstring.internal_encoding</code> to some one-byte-per-char encoding every time you call the external library and set it back right after, but if your library makes callbacks to your application, it will just mess up things.</p>
<p>Another option is to tweak the library manually, changing all str* functions to their mb_string counterpart and passing a one-byte-per-char as encoding parameter. This, however, isn't a great idea either, because you lose the ability to easily update your external, and you might cause some performance issues as well.</p>
<p>So, again, don't use <code>func_overload</code>. If you work with multi-byte strings, use the appropriate mb_ functions.</p>
|
ASP.NET PasswordRecovery Control with Localized content <p>I am working on a simple portal application using the ASP.NET membership and login controls. I would like to use the PasswordRecovery control to send emails containing forgotten passwords, however my portal requires localization. I have an existing Content Management System that I am pulling the localized strings out of and I would like to link the PasswordRecovery control to that system.</p>
<p>But, it appears that the PasswordRecovery control will ONLY accept a .txt file for the email body...the property is PasswordRecovery1.MailDefinition.BodyFileName</p>
<p>I do not want to use a file on disk, I would like to use the localized content in my CMS.</p>
<p>Is there any way to do this? It occurred to me that I might be able to use the SendingMail event to send my OWN email through the normal System.Net namespace, but that seems sorta cludgy...</p>
<p>Any thoughts?</p>
<p>Thanks,
Max</p>
|
<p>Try handling the SendingMail event of the PasswordRecovery control. In that event, set the e.Message.Body and e.Message.Subject properties to your localized text.</p>
|
How to get the new value of an HTML input after a keypress has modified it? <p>I have an HTML input box</p>
<pre><code><input type="text" id="foo" value="bar">
</code></pre>
<p>I've attached a handler for the '<em>keyup</em>' event, but if I retrieve the current value of the input box during the event handler, I get the value as it was, and not as it will be!</p>
<p>I've tried picking up '<em>keypress</em>' and '<em>change</em>' events, same problem. </p>
<p>I'm sure this is simple to solve, but at present I think the only solution is for me to use a short timeout to trigger some code a few milliseconds in the future!</p>
<p><em>Is there anyway to obtain the current value during those events?</em></p>
<p>EDIT: looks like I had a caching problem with my js file as I checked the same code later on and it worked just fine. I would delete the question, but not sure if that loses rep for the kind folk who posted ideas :)</p>
|
<p>can you post your code? i'm not finding an issue with this. tested on firefox 3.01/safari 3.1.2 with:</p>
<pre><code>function showMe(e) {
// i am spammy!
alert(e.value);
}
....
<input type="text" id="foo" value="bar" onkeyup="showMe(this)" />
</code></pre>
|
Insert cell comments in excel programmaticaly <p>What's the better way to insert cell comments in excel 2007 files programmaticaly using c# and .net 3.5?</p>
|
<p>I just did exactly that but with MS Word (using Microsoft.Office.Interop.Word</p>
<p>range.Comments.Add ( range, ref _categoryMessage );</p>
<p>So, I would suggest using Microsoft.Office.Interop.Excel and the similar method.
Consider this from MSDN:</p>
<p><a href="http://msdn.microsoft.com/es-es/library/microsoft.office.interop.excel.range.addcomment.aspx" rel="nofollow">http://msdn.microsoft.com/es-es/library/microsoft.office.interop.excel.range.addcomment.aspx</a></p>
<p>Also see <a href="http://stackoverflow.com/questions/213303/sofware-requirements-analysis#213452">this</a> too</p>
|
Class will compile for Tests/Console but not in Asp.net application <p>I have a simple interface:</p>
<pre><code>public interface IVisitorsLogController
{
List<VisitorsLog> GetVisitorsLog();
int GetUniqueSubscribersCount();
int GetVisitorsCount();
string GetVisitorsSummary();
}
</code></pre>
<p>the class VisitorsLogController implements this interface.</p>
<p>From a console application or a TestFixture - no problem - the console/test fixture compile perfectly.</p>
<p>However, from an Asp.Net web site (not application) in the same solution with this code in the code behind</p>
<pre><code>private IVisitorsLogController ctl;
protected int GetUniqueMembersCount()
{
ctl = new VisitorsLogController();
return ctl.GetUniqueSubscribersCount();
}
</code></pre>
<p>the compiler throws this exception:</p>
<blockquote>
<p>Error 1 'WebSiteBusinessRules.Interfaces.IVisitorsLogController'
does not contain a definition for
'GetUniqueSubscribersCount' and no
extension method
'GetUniqueSubscribersCount' accepting
a first argument of type
'WebSiteBusinessRules.Interfaces.IVisitorsLogController'
could be found (are you missing a
using directive or an assembly
reference?)</p>
</blockquote>
<p>yet for this code in the same file:</p>
<pre><code> protected static int GetVisitorsCount()
{
return VisitorsLogController.Instance.GetVisitorsCount(DateTime.Today);
}
</code></pre>
<p>the compiler compiles these lines without complaining. In fact if I add anything new to the Interface the compiler now complains when trying to compile the asp.net page.</p>
<p>It can't be a missing using directive or assembly reference otherwise both methods would fail.</p>
<p>This is driving me nuts!</p>
<p>Any thoughts please?</p>
<p>Thanks,</p>
<p>Jeremy</p>
|
<p>Out of interest, can you compile the following line:</p>
<pre><code>ctl = VisitorsLogController.Instance;
</code></pre>
<p>? I'm just wondering if somehow you've got two interfaces named the same thing.</p>
<p>What does Intellisense prompt you with when you type <code>ctl.</code> and press Ctrl-Space?</p>
|
Corel draw 13 mysql query <p>Is there a way to do a mysql database query in Corel Draw 13(X3)? </p>
|
<p>If I recall correctly, CorelDraw uses VBA as scripting language, no?</p>
<p>If so, if it is not restricted, you can probably use ODBC to do that. See <a href="http://dev.mysql.com/doc/refman/5.0/en/connector-odbc.html" rel="nofollow" title="MySQL Connector/ODBC">MySQL Connector/ODBC</a> for details.</p>
|
Want to host WCF Webservice as Windows Service as against to Hosting in IIS <p>I want to expose few web services but thinking of hosting those as Windows Service as against hosting in IIS.</p>
<p>Is it a good practice? </p>
<p>If yes? How do I make it secured? </p>
<p>I want to authenticate the users who are accessing it (against our custom security database and also want to make sure that the request is originating from our business partner (X.509 certificates???? not worked much with this).</p>
<p>appreciate your pointers in this regards.</p>
<p>Thanks & Regards,
Ajay</p>
|
<p>You might want to read <a href="http://msdn.microsoft.com/en-us/library/bb332338.aspx" rel="nofollow">this Microsoft article</a> , which clearly points Pros/cons of each hosting method, including: Console/WinForms App, IIS 6 and 7 (there are differences) and Windows Services. </p>
|
How Do You Get the Height of the Titlebar Using Java (Swing)? <p>I am getting a <code>MouseEvent</code> in Java. the <code>getPoint()</code> method is adding the height of the title bar into the y portion of the coordinate.</p>
<p>I was wondering how I can find the height of the title bar of the current window in order to offset the y value by the correct amount.</p>
|
<p>You can find the frame insets by calling the getInsets method (defined in Container). Frame insets are discussed at the top of the Frame API docs. <a href="http://stackoverflow.com/questions/193457/getting-drawable-area-of-an-awt-frame-in-mac-os-x">See this question.</a></p>
<p>Of course you could always add your mouse listener to the content pane. JFrame has some unexpected behaviour on some methods such as <code>add</code> and <code>setLayout</code>.</p>
|
Scalability on the web <p>I've been arguing with some friends on the university, and we can't get to a point to which is the framework with more scalability for web applications (and still very fast).</p>
<p>One calls for jsp, the other one for ruby other for php and so on. Could i ask you to clarify us on what as more scalability potential?</p>
<p>Tks, hope I'm not duplicating anything I've searched but didn't found any previous question like this.</p>
<p>Edit: If you could point a comparison about this it would be good :)</p>
|
<p>Ruby and PHP are not webapp frameworks. They are programming languages which are popular for web development.</p>
<p>Generally speaking, webapp scalability is not a property of a programming language, and a given webapp framework may at most <em>not hamper</em> scalability. Good scalability is more a property of application design.</p>
<p>There are way too many webapp frameworks out there for a point-by-point comparison that is anything short of encyclopedic.</p>
<p>Also, you can tackle scalability for a given application in several ways. One way is to have a well defined and narrow scope and aim awesome raw performance, so a single machine can serve bazillion of work units. The best example around is <a href="http://www.mailinator.com/">Mailinator</a>.</p>
<p>Another way is to make it easier to serve increasing loads by "just" adding more hardware. Pretty much any database-backed webapp framework can scale this way: just add more application servers between a load balancer and a shared database back-end. If you frame the problem this way, your main concern is designing the application to minimize 1. database contention 2. database load.</p>
<p>The last way is design the system to be insanely parallel all the way. Google being the prime example.</p>
<p>In summary: languages or frameworks do not make scalable applications, software architects do.</p>
<p>EDIT: To be clear, my answer is focusing on <em>scalability</em>, that is the ability to handle increasing loads without changing design. This is a different property than speed of execution.</p>
|
What methods do wikis use for merging concurrent edits? <p>If two users edit the same wiki topic, what methods have been used in wikis (or in similar collaborative editing software) to merge the second user's edits with the first?</p>
<p>I'd like a solution that:</p>
<ul>
<li>doesn't require locking</li>
<li>doesn't lose any additions to the page.</li>
<li>It may add extra "boilerplate" text to indicate where differing changes were made.</li>
</ul>
<p>(I'm interested in a solution that could be used to implement <a href="http://stackoverflow.uservoice.com/pages/general/suggestions/28245" rel="nofollow">this uservoice idea</a> for stack overflow.)</p>
|
<p><a href="http://twiki.org" rel="nofollow">TWiki</a> automatically merges <a href="http://twiki.org/cgi-bin/view/TWiki.SimultaneousEdits" rel="nofollow">Simultaneous Edits</a>.</p>
<blockquote>
<p>TWiki allows multiple simultaneous edits of the same topic, and then merges the different changes automatically. You probably won't even notice this happening unless there is a conflict that cannot be merged automatically. In this case, you may see TWiki inserting "change marks" into the text to highlight conflicts between your edits and another person's. These change marks are only used if you edit the same part of a topic as someone else, and they indicate what the text used to look like, what the other person's edits were, and what your edits were.</p>
<p>TWiki will warn if you attempt to edit a topic that someone else is editing. It will also warn if a merge was required during a save. </p>
</blockquote>
<p>There was also some <a href="http://twiki.org/cgi-bin/view/Codev/DakarMergeModel" rel="nofollow">documentation</a> from that feature being developed detailing how it would behave.</p>
<blockquote>
<p>The basic principles I used in coding up the mergeing algorithm were:</p>
<ol>
<li>If it's possible to merge without using conflict markers, do so.</li>
<li>If it's possible to merge using conflict markers, do so.</li>
<li>If it's not possible to merge, then the most recent checkin wins. </li>
</ol>
</blockquote>
<p>It's worth noting that TWiki has a similar feature to Stack Overflow for collapsing subsequent revisions by the same user within a certain time limit and this <a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1897" rel="nofollow">caused a bug when happening in conjunction with a merge</a>.</p>
<blockquote>
<ol>
<li>User A edits topic</li>
<li>User A saves rev N</li>
<li>User B edits topic, picks up rev N</li>
<li>User A edits topic again, picks up rev N</li>
<li>User A saves changes; save sees that the change is within the ReplceIfEditiedWithin? window, <strong>so does not increment the rev number</strong></li>
<li>User B saves, code sees that <strong>the rev number on disc has not changed since they started editing</strong> so doesn't detect a need to merge. </li>
</ol>
</blockquote>
<p>Also worth noting is that TWiki will warn the second user that the topic is being edited:</p>
<blockquote>
<p>So I invented the concept of "leases". When a topic is edited, a lease is taken on the topic for a fixed period of time (default 1h). If someone else tries to edit, they are told that there is already a lease on the topic, but that doesn't stop them from editing. It isn't a lock, it's just a way of advising them. Mergeing is still the prime resolution mechanism; the lease is purely advisory. If a user - or a plugin - chooses to back away from a topic because someone has a lease out on it, well, that's up to the plugin.</p>
<p>The descriptive comment in TWiki.cfg is as follows:</p>
<pre><code> # When a topic is edited, the user takes a "lease" on that topic.
# If another user tries to also edit the topic while the lease
# is still active, they will get a warning. The warning text will
# be different depending on whether the lease has "expired" or
# not i.e. if it was taken out more than LeaseLength seconds ago.
</code></pre>
</blockquote>
<p>note that the lease terminology is only for developers, not end users.</p>
|
Database of Software <p>I'm looking for a database of commonly installed Windows software. At minimum I need the name of the software and the executable name, but it'd also be nice to have the publisher and the common installation path, etc. Basically, I'd like to be able to query it to find all the software by Adobe and the associated executable name, etc. </p>
<p>Basically I'm looking to be able to do </p>
<pre><code>SELECT * FROM Software WHERE Publisher = 'Microsoft'
SELECT * FROM Software WHERE Executable = 'devenv.com'
</code></pre>
<p>I came across an effort to create such a database a long time ago, but can't seem to find it now. Maybe it fizzled out. Any help would be greatly appreciated. Thanks.</p>
|
<p>Your best bet would be to <a href="http://www.developer.com/net/asp/article.php/3079381">query</a> amazon.com, since they sell lots of software and provide public interfaces to access their database.</p>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.