instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I am making a small game number game in Java (Nim) in OS X and was thinking about trying to make the GUI interface of the game using something other than Swing. I looked at SWT, but I read somewhere that SWT has some problems with OS X. I also looked at GTK+ bindings for Java, but I am not sure if that's a good choi... | <p>It depends, with eclipse 3.4, SWT 3.4 is quite supported with <a href="http://www.eclipse.org/swt/macosx/" rel="nofollow noreferrer">MacOs</a>.</p>
<p><img src="https://www.eclipse.org/swt/macosx/downloaded.png" alt="alt text"></p>
<p>Now, SWT is OS specific, and you may not have the same flexibility than Swing, s... | <p>You might consider <a href="http://javafx.com/" rel="nofollow">JavaFX 2.0</a>. </p>
<p>Still early days but it looks quite promising for the kind of interactive / graphical applications that you might otherwise use Flash for.</p>
| 36,372 |
<p>When browsing ASP.NET MVC source code in <a href="http://www.codeplex.com/aspnet/SourceControl/FileView.aspx?itemId=266503&changeSetId=17272" rel="noreferrer">codeplex</a>, I found it is common to have a class explicitly implementing interface. The explicitly implemented method/property then invoke another "prot... | <p>Well, not specific to MVC, but this approach allows you to <strong>keep the core public API clean</strong>. It is also useful if there is ever a risk of different interfaces / etc having the same name & signature, but different meaning. In reality this is rare.</p>
<p>It also allows you to provide an implementa... | <ol>
<li>When a member is explicitly implemented, it cannot be accessed through a class instance, but only through an instance of the interface. reference : <a href="http://msdn.microsoft.com/en-us/library/aa288461%28v=vs.71%29.aspx" rel="nofollow">Explicit Interface Implementation Tutorial</a></li>
<li>As my experienc... | 35,473 |
<p>I want to know if responsetimes are good, not just if it scales. Anyone with experiences?</p>
| <p>A scalable architecture like GAE is not the same as one based on optimizing speed. A different approach is needed.</p>
<p>The DataStore isn't designed to be super fast at the small scale, but rather handle large amounts of data, and be distributed. We could say that database access is "very slow" at the small scal... | <p>I've implemented some ajax popups for a GAE application and the popups need a server round trip to be less than half second on average to be usable. And it turned out to work pretty well. The support for memcache also makes it easy to optimize for speed on GAE.</p>
| 16,171 |
<p>I am currently storing many different types of objects in the ASP.NET HttpRuntime.Cache and I was wondering if there is a way to figure out how big each object is?</p>
| <p>Look at these questions:</p>
<p><a href="https://stackoverflow.com/questions/207592/getting-the-size-of-a-field-in-bytes-with-c">Getting the size of a field in bytes with C#</a><br>
<a href="https://stackoverflow.com/questions/324053/find-out-the-size-of-a-net-object">Find out the size of a .net object</a></p>
<p>... | <p>One thing you can do is serialize the object to a file on disk. That should give you an idea.</p>
<p>This <a href="http://aspalliance.com/cachemanager/" rel="nofollow noreferrer">cache manager</a> from ASP Alliance might help as well </p>
| 42,317 |
<p>I've got a dictionary, something like</p>
<pre><code>Dictionary<Foo,String> fooDict
</code></pre>
<p>I step through everything in the dictionary, e.g.</p>
<pre><code>foreach (Foo foo in fooDict.Keys)
MessageBox.show(fooDict[foo]);
</code></pre>
<p>It does that in the order the foos were added to the di... | <p>If you read the documentation on MSDN you'll see this:</p>
<p>"The order in which the items are returned is undefined."</p>
<p>You can't gaurantee the order, because a Dictionary is not a list or an array. It's meant to look up a value by the key, and any ability to iterate values is just a convenience but the o... | <p>I am <em>not fully educated in the domain</em> to properly answer the question, but I have <strong>a feeling</strong> that the dictionary sorts the values according to the key, in order to perform quick key search. This would suggest that the dictionary is sorted by key values according to key comparison. However, l... | 15,863 |
<p>What is the easiest way to highlight the difference between two strings in PHP?</p>
<p>I'm thinking along the lines of the Stack Overflow edit history page, where new text is in green and removed text is in red. If there are any pre-written functions or classes available, that would be ideal.</p>
| <p>You were able to use the PHP Horde_Text_Diff package.</p>
<p>However this package is no longer available.</p>
| <p>I came across this PHP diff class by Chris Boulton based on Python difflib which could be a good solution:</p>
<p><a href="https://github.com/chrisboulton/php-diff" rel="nofollow">PHP Diff Lib</a></p>
| 41,582 |
<p>I've build a WCF Service to accept a file and write it to disk. The front-end consists of a page with SWFUpload which is handling the upload on the client side. Apparently, SWFUpload posts the data with a Content Type of: multipart/form-data.</p>
<p>I would think this ok but on the Service side I get an error. The ... | <p>@jdiaz,</p>
<p>@JasonS is right, to upload file you need to transfer it as a byte stream. You need to use <a href="http://msdn2.microsoft.com/en-us/library/ms733742.aspx" rel="noreferrer">WCF streaming</a>. For example on how to upload file via WCF see <a href="http://kjellsj.blogspot.com/2007/02/wcf-streaming-uplo... | <p>I believe you are going to have to tranfer the file as a byte array to WCF. You will need to handle the post from SWFUpload and convert to a byte array before sending to your service.</p>
| 7,425 |
<p>I´ve have read an article to change different pattern depending on amount of layers, but my question is if is possible to have different infill in the same part? For example:</p>
<ul>
<li>Base: has the infill of 25 % but the same base has some tabs for screws and mount the part for this area the infill need to... | <p>This answer explains that you can have different infill within the same part. Firstly the implementation in <strong>Ultimaker Cura</strong> is described, secondly how you can do this in <strong>Slic3r</strong>.</p>
<hr />
<h2>Ultimaker Cura</h2>
<p>I've used a feature in <strong>Ultimaker Cura</strong> that can be u... | <p>Yes, it's possible, and not just limited to Cura. If you use GrabCAD Print (for Stratasys printers), the <em>Advanced FDM</em> feature allows different infill in different regions of your part - not based on layers, but based on your CAD geometry. Because of this, you have to start the process in CAD, by creating a ... | 980 |
<p>I currently have a Visual Studio solution with 8 web applications.
When I try run one of these applications, 8 instances of the Casini Web Development Servers are launched.</p>
<p>Is there anyway to specify that only the web application I have set as startup project will be launched and not all 8.</p>
<p>I am usin... | <p>Select the Solution. Right click and select Properties. Under Common Properties select Startup Projects. The select Single Startup Project, select the project you want to startup, and press Apply/OK.</p>
| <p>Also there is a project option <code>Always start when debugging</code>. Select Project in Solution View and in Properties Window set this option to <code>false</code>. Without it the server is started even if project is not chosen as startup project.</p>
| 29,590 |
<p>Say you create a form using ASP.NET MVC that has a dynamic number of form elements.</p>
<p>For instance, you need a checkbox for each product, and the number of products changes day by day.</p>
<p>How would you handle that form data being posted back to the controller? You can't set up parameters on the action met... | <p>Just give each checkbox a unique name value:</p>
<pre><code><input class="approveCheck" id="<%= "approveCheck" + recordId %>"
name="<%= "approveCheck" + recordId %>" type="checkbox" />
</code></pre>
<p>Then parse the list of form values in the Action, after submit:</p>
<pre><code>foreach (var ... | <p>Depending on your data, you could either output a 'CheckboxList' (which is not possible in the newer versions any more) and use a <code>string[]</code> parameter, or you could set up multiple forms and just modify the action.</p>
| 27,544 |
<ul>
<li><p>What are your experiences regarding
project planning and creating hour
estimates for new projects? </p></li>
<li><p>What is the approach you are using,
and why has or has it not worked
for you?</p></li>
<li><p>Are there any best practices to take
into account?</p></li>
</ul>
| <h2>Estimation Tasks</h2>
<p>The principles that I try to use (I don't always get the opportunity) are:</p>
<ul>
<li>Step-wise refinement</li>
<li>3 point estimates</li>
<li>Risk analysis</li>
</ul>
<h3>Step-wise refinement</h3>
<p>When estimating it's important to estimate at the right granularity and to continual... | <p>Log the time spent in your actual projects and that will help you plan to for the next one, <a href="http://es.wikipedia.org/wiki/Personal_Software_Process" rel="nofollow noreferrer">PSP</a>/<a href="http://en.wikipedia.org/wiki/Team_Software_Process" rel="nofollow noreferrer">TSP</a> offer a way to do it</p>
| 39,316 |
<p>I have a WCF Service that should not enter the faulted state. If there's an exception, it should be logged and the service should continue uninterrupted. The service has a one-way operation contract and is reading messages from an MSMQ.</p>
<p>My problems are twofold:</p>
<ol>
<li>The service appears to be swallow... | <p>Most, if not all exceptions can be seen in the WCF Trace (<a href="http://msdn.microsoft.com/en-us/library/ms733025.aspx" rel="noreferrer">Configuring Tracing</a>) and the trace is best viewed with the <a href="http://msdn.microsoft.com/en-us/library/ms733025.aspx" rel="noreferrer">Service Trace Viewer</a>.</p>
<p>... | <p>About 2)...</p>
<p>The trick is that you should use "using" and should always call Abort() on the proxy that threw an exception. The article <a href="https://web.archive.org/web/20110111204151/http://old.iserviceoriented.com/blog/post/Indisposable+-+WCF+Gotcha+1.aspx" rel="nofollow noreferrer">WCF Gotcha</a> explai... | 40,761 |
<p>I'm working on an import (from Excel) dialog to select ranges of cells.</p>
<p>When the range is selected, I use the event sink to catch the event and highlight the first row and first column.</p>
<p>I need to unhighlight the previous selection's first row and column. I don't think it's safe to just get the selec... | <p>If you were working in Excel VBA, you could </p>
<pre><code>Set Rng = Application.Selection
</code></pre>
<p>where Rng is an Excel Range object. I imagine you could replicate this object from where you are.</p>
<p>Or you could store the cell address in a string variable as you suggested, which of course doesn't r... | <p>If you do not expect the range to move or change in size I would store the address and later use Range(myAddress) to return the range object for highlighting.</p>
<p>An address reference will always refer to a fixed area of the sheet whereas a range will be updated to reflect cell insertions/deletions. Either of th... | 31,437 |
<p>Recently I've been doing lots of weekend coding, and have began to really need a bugtracker as things are gaining speed. This is probably the worst case scenario because I basically have to let things cool down over the week,so I simply can't remember the bugs in my head. So far I've been using a text file to jot do... | <p>FogBugz has a student/startup edition that's free indefinitely, for 2 or less users.</p>
| <p>Ontime 2008 by Axosoft is free for a single user licence. It's industrial strength and will give you alot more that just bug tracking!</p>
<p><a href="http://www.axosoft.com" rel="nofollow noreferrer">http://www.axosoft.com</a></p>
| 31,688 |
<p>Assume I allow the user to input a arbitrary numerical expression that allows usage of the explicit set of functions and predefined variables.</p>
<p>Interpreting this is pretty straight forward but what if performance is a critical factor?</p>
<p>I need a way to compile (in runtime) a string with a expression int... | <p>So really you want to parse the string into (eventually) a typed delegate.</p>
<p>One option, then it to parse the string into an <code>Expression</code>, which you can then compile to a lambda. This is quite complex, but I have some code that will do much of this - but there may be existing parsers that already do... | <p>In C# 4.0, it'll become very easy and straightforward. However, before C# 4.0, I suggest you use <code>Microsoft.JScript</code> libraries to accomplish it.</p>
<p>This is all you want: <a href="http://www.odetocode.com/Articles/80.aspx" rel="nofollow noreferrer">http://www.odetocode.com/Articles/80.aspx</a></p>
| 49,852 |
<p>We've pre-defined <strong>Excel</strong> document structure with lots of formulas and macros written.</p>
<p>During download of Excel, thru Java application we populate certain cells in Excel with data. After download when user open <strong>Excel</strong>, macros & formulas embedded in it will read the pre-popu... | <p>I quite liked using the Apache POI Project HSSF library (<a href="http://poi.apache.org/" rel="noreferrer">http://poi.apache.org/</a>) - it was fairly easy to use. I didn't use it in that much depth, but it seemed fairly powerful. Also, there's JExcelAPI (<a href="http://sourceforge.net/projects/jexcelapi/" rel="nor... | <p>If your users will have a recent version of Excel, it isn't too hard to tweak the XML file format by hand. Just save an existing document as XML, and find the places you want to replace.</p>
| 14,520 |
<p>How can we write an update sql statement that would update records and the 'set' value changes every time?</p>
<p>For example:
If we have records like this</p>
<pre><code>SomeNumber SomeV CurCode WhatCodeShouldBe
200802754 432 B08 B09
200802754 432 B08 B09
200802754 432 B08 B09
200808388 714 64B C00
200804119 270 ... | <pre><code>update a
set
3rdColumn = b.2ndColumn
from
tableA a
inner join tableB b
on a.linkToB = b.linkToA
</code></pre>
<p>That is based on <a href="https://stackoverflow.com/questions/317822/update-with-changing-set-value#317942">your new comments</a> </p>
| <p><code>UPDATE yourtable SET CurCode = WhatCodeShouldBe</code></p>
| 41,061 |
<p>I've recently changed my Ender3's hotend to E3D v6 clone with Titan direct extruder, so I can print faster than on stock. But when I increased the speed up to 70 mm/s for walls and 80 mm/s for infill (PETG, nozzle temperature of 225 °C, bed temperature of 80 °C, 0.2 mm layer height, 0.4 mm layer width), I've faced t... | <p>In my experience, 225 °C is the lower range for PETG, that combined with a higher than normal printing speed of 70 mm/s might be your issue. The lower your print temps the lower the maximum nozzle flow rate. I would recommend increasing the nozzle temperature.</p>
<p>For a point of reference, on my printer with an E... | <p>In other words, your print exhibits issues when the hotend is accelerating, like if not enough filament were pushed in.</p>
<p>It is advised to calibrate for linear advance after replacing the extruder.</p>
<p>Check <a href="https://marlinfw.org/docs/features/lin_advance.html" rel="nofollow noreferrer">https://marli... | 1,998 |
<p>I followed this <a href="http://svn.rubyonrails.org/rails/plugins/exception_notification/README" rel="nofollow noreferrer">tutorial</a> on configuring the Rails plugin ExceptionNotifier.</p>
<p>I know that I have ActionMailer configured correctly because I am getting mail from other forms. I even have local_address... | <p>You're using the SVN version of the plugin, which is probably unmaintained. <a href="http://github.com/rails/exception_notification/tree/master" rel="nofollow noreferrer">Latest version can be found here</a>.</p>
<p>Second thing which you can do is check the production log. Mailings get written to the log, so you'l... | <p>Check your production log, exceptions can be throw in side the exception_notifier plugin, which prevent it from sending mails</p>
| 13,507 |
<p>I'm looking for an implementation of IDictionary with better performance of the standard BCL one.</p>
<p>I'm looking for something with constant lookup time that performs really well with large number of elements (>10K) and is more GC friendly.</p>
<p>Ps: No, I'm not able to write one by myself :)</p>
| <p>The BCL dictionary already performs with amortized constant time and can easily handle 10K elements.</p>
<p>You say it should be "more GC friendly" - what's bothering you about the current version?</p>
<p>Are you adding elements to the dictionary frequently? If so, create it with a large initial capacity to avoid ... | <p>I think you will be hard pressed to find a managed dictionary that is faster than the BCL one. I've attempted to write one, and I quickly found that is about as fast as it's going to get when you balance read\write performance.</p>
| 46,522 |
<p>Each Java object (and its class) has an associated monitor. In pthread terms a Java monitor is equivalent to the combination of a reentrant mutex and a condition variable.</p>
<p>For locking, the Win32 API provides Mutex objects (which are reentrant but heavyweight) and Critical Sections (which are non-reentrant bu... | <p>Windows has SignalObjectAndWait() which can be used very much like a wait on a condition variable in a monitor. You can use an Event (that is Reset) and a Mutex and then use PulseEvent() to do the equivalent of signalling the condition variable.</p>
| <p>I suggest you take a look at the <a href="http://openjdk.java.net/" rel="nofollow noreferrer">OpenJDK</a> source to see how the class ReentrantLock was implemented.</p>
<p>(I haven't checked it myself so i'm not sure of the answer).</p>
<p>the util.concurrent locks are implemented using native API.</p>
| 21,024 |
<p>How can I write a semi transparent text on an Image (Jpg,Bmp), or a transparent text (color as same background Image) but with a shadow, something I want to do to watermark the images.</p>
<p>I want to accomplish that using Delphi win32.</p>
| <p>I presume what you're trying to accomplish is a little more complicated than simply writing text with a transparent background; i.e. you are trying to get some form of alpha-blended text written on the image.<br>
The simplest method would be to make use of the GDI+ routines. They are encapsulated for delphi and avai... | <p>You could use the <a href="http://users.telenet.be/ws36637/transbmp.html" rel="nofollow noreferrer">bitblt</a> routines to merge an image to a common canvas, then save the image again.</p>
| 47,048 |
<p>I am tring to get the <a href="http://www.herrodius.com/blog/85" rel="nofollow noreferrer">ASDoc Ant task</a> to work:</p>
<pre><code><target name="asdoc" depends="compile">
<mkdir dir="${dist_asdocs}"/>
<asdoc
docSources="${srcdir}"
output="${dist_asdocs}"
executable="${FLEX_HOM... | <p>Well, I can't test it because it is implemented for Windows only (tries to execute asdoc.exe).</p>
<p>But I have written my own solution for the lack of an ant task for asdoc:</p>
<pre><code><exec executable="${FLEX_HOME}/bin/asdoc" dir="${basedir}">
<arg value="-source-path"/>
<arg path="${... | <p>I would suggest not using the asdoc ant task since I haven't developed it further since I first released it. As mentioned by Simon, it only supports a small subset of what is possible so you're most likely better off using the exec task.</p>
| 24,248 |
<p>Is there a way to read a locked file across a network given that you are the machine admin on the remote machine? I haven't been able to read the locked file locally, and attempting it over the network adds another layer of difficulty.</p>
| <p>There's a very straightforward web based solution over at ISBNDB.com that you may want to look at.</p>
<p><strong>Edit:</strong> Updated API documentation link, now there's version 2 available as well</p>
<p><a href="https://isbndb.com/isbn-database" rel="noreferrer">Link to prices and tiers here</a></p>
<p>You can ... | <p>Working in the library world we simply connect to the LMS pass in the barcode and hey presto back comes the data. I believe there are a number of free LMS providers - Google for "open source lms".</p>
<p>Note: This probably works off ISBN...</p>
| 13,254 |
<p>Is there a way to get stored procedures from a SQL Server 2005 Express database using C#? I would like to export all of this data in the same manner that you can script it our using SQL Server Management Studio, without having to install the GUI.</p>
<p>I've seen some references to do thing via the PowerShell but i... | <p>You can use SMO for that. First of all, add references to these assemblies to your project:</p>
<ul>
<li>Microsoft.SqlServer.ConnectionInfo</li>
<li>Microsoft.SqlServer.Smo</li>
<li>Microsoft.SqlServer.SmoEnum</li>
</ul>
<p>They are located in the GAC (browse to C:\WINDOWS\assembly folder). </p>
<p>Use the follo... | <p>Assuming you have <code>SqlConnection</code> object called <strong>sqlCon</strong>, simplest way is to call sqlCon.GetSchema("Procedures")</p>
| 20,440 |
<p>I've seen lots of examples of making an entire regular expression case-insensitive. What I'm wondering about is having just part of the expression be case-insensitive.</p>
<p>For example, let's say I have a string like this:</p>
<pre><code>fooFOOfOoFoOBARBARbarbarbAr
</code></pre>
<p>What if I want to match all ... | <p>Perl lets you make part of your regular expression case-insensitive by using the (?i:) pattern modifier.</p>
<p>Modern regex flavors allow you to apply modifiers to only part of the regular expression. If you insert the modifier (?ism) in the middle of the regex, the modifier only applies to the part of the regex t... | <p>You could use </p>
<pre><code>(?:F|f)(?:O|o)(?:O|o)
</code></pre>
<p>The ?: in the brackets in .Net means it's non-capturing, and just used to group the terms of the | (or) statement.</p>
| 6,522 |
<p>How can I get the name of a file in in PHP? What I want to do is have a function take a string of a filename and then do some stuff if it's actually on the page.</p>
<pre><code>function onThisPageFunction(fileNameFromFunction)
{
if(onThisPage == fileNameFromFunction)
{
do stuff
}
}
</code></... | <p>There are two variables that will give you file names.</p>
<p>eg: you call /test/test1.php as the url and test1.php includes test2.php.</p>
<p><a href="http://pl.php.net/manual/en/language.constants.predefined.php" rel="nofollow noreferrer"><code>__FILE__</code></a> will give you the current file of the executing ... | <p>I think you want to use:</p>
<pre><code>_SERVER["PHP_SELF"]
</code></pre>
<p>eg:</p>
<pre><code> if (isset($_SERVER["PHP_SELF"]) AND ($_SERVER["PHP_SELF"] == 'foo')){
echo 'do stuff';
}
</code></pre>
<p>Will</p>
| 37,959 |
<p>I've read everywhere about how great they are, but for some reason I can't seem to figure out how exactly I'm supposed to test something. Could someone perhaps post a piece of example code and how they would test it? If it's not too much trouble :)</p>
| <p>There are two frameworks you can use for unit testing. <a href="//web.archive.org/web/20180916202612/http://simpletest.org/" rel="nofollow noreferrer">Simpletest</a> and <a href="http://www.phpunit.de/" rel="nofollow noreferrer">PHPUnit</a>, which I prefer. Read the tutorials on how to write and run tests on the hom... | <p>Besides the excellent suggestions about test frameworks already given, are you building your application with one of the PHP web frameworks that has automated testing built in, such as <a href="http://www.symfony-project.org/book/1_0/15-Unit-and-Functional-Testing" rel="nofollow noreferrer">Symfony</a> or <a href="h... | 35,724 |
<p>User equals untrustworthy. Never trust untrustworthy user's input. I get that. However, I am wondering when the best time to sanitize input is. For example, do you blindly store user input and then sanitize it whenever it is accessed/used, or do you sanitize the input immediately and then store this "cleaned" versio... | <p>Unfortunately, almost no one of the participants ever clearly understands what are they talking about. Literally. Only <a href="https://stackoverflow.com/a/36088/285587">Kibbee</a> managed to make it straight.</p>
<p>This topic is all about sanitization. But the truth is, such a thing like wide-termed "general ... | <p>I find that cleaning it immediately has two advantages. One, you can validate against it and provide feedback to the user. Two, you do not have to worry about consuming the data in other places.</p>
| 5,526 |
<p>The ListChanged event for an IBindingList fires a type ListChangedType.ItemDeleted when items are deleted, perhaps by a user deleting a row in a datagrid control bound to the list. The problem is that the NewIndex into the list is invalid in this event, it's been deleted, and the item that was deleted is not availab... | <p>Yeah it's pretty annoying, but there is an easy workaround. I create a <code>BindingListBase<T></code> class that I use for all of my lists instead of using a normal <code>BindingList<T></code>. Because my class inherits from the <code>BindingList<T></code>, I have access to all of it's protected m... | <p>I did something similar to what Adam Valpied did, i.e. implemented my own class with a ListChanging event-handler. That lets me work with the item that's about to be removed from the list before it actually does.</p>
<p>In response to Sunlight's question regarding the use case...among other things, I use it to rem... | 37,691 |
<p>I met a problem when deveoping a photo viewer application.
I use ListBox to Show Images, which is contained in a ObservableCollection.
I bind the ListBox's ItemsSource to the ObservableCollection.</p>
<pre><code> <DataTemplate DataType="{x:Type modeldata:ImageInfo}">
<Image
Margin="6"... | <p>The problem is that your new Layout Panel is the WrapPanel and it doesn't support Virtualization! It is possible to create your own Virtualized WrapPanel... Read more <a href="http://jerryclin.wordpress.com/2008/02/06/making-a-virtualizing-wrappanel/" rel="noreferrer">here</a></p>
<p>Also read more about other issu... | <p>What does your PhotoListBoxStyle style look like? If it's changing the ListBox's ItemsPanelTemplate then there's a good chance your ListBox isn't using a VirtualizingStackPanel as its underlying list panel. Non-virtualized ListBoxes are a lot slower with many items.</p>
| 21,960 |
<p>Suppose I attach an <code>blur</code> function to an HTML input box like this:</p>
<pre><code><input id="myInput" onblur="function() { ... }"></input>
</code></pre>
<p>Is there a way to get the ID of the element which caused the <code>blur</code> event to fire (the element which was clicked) inside the... | <p>Hmm... In Firefox, you can use <code>explicitOriginalTarget</code> to pull the element that was clicked on. I expected <code>toElement</code> to do the same for IE, but it does not appear to work... However, you can pull the newly-focused element from the document:</p>
<pre><code>function showBlur(ev)
{
var targ... | <p>This way:</p>
<pre><code><script type="text/javascript">
function yourFunction(element) {
alert(element);
}
</script>
<input id="myinput" onblur="yourFunction(this)">
</code></pre>
<p>Or if you attach the listener via JavaScript (jQuery in this example):</p>
<pre><code>var input ... | 14,775 |
<p>I have seen a codebase recently that I fear is violating alignment constraints. I've scrubbed it to produce a minimal example, given below. Briefly, the players are:</p>
<ul>
<li><p><em>Pool</em>. This is a class which allocates memory efficiently, for some definition of 'efficient'. <em>Pool</em> is guaranteed to ... | <p>Ok - had a chance to read it properly. You have an alignment problem, and invoke undefined behaviour when you access the char array as an Obj_list. Most likely your platform will do one of three things: let you get away with it, let you get away with it at a runtime penalty or occasionally crash with a bus error.<... | <p>Allocate the char array <code>member_list_store_d</code> with malloc or global operator new[], either of which will give storage aligned for any type.</p>
<p>Edit: Just read the OP again - you don't want to pay for another pointer. Will read again in the morning.</p>
| 30,759 |
<p>I have a Grid in WPF. The Grid has a transparent background (necessary) and each of the cells potentially has a different colored solid background, or maybe no background. When I put arbitrary content in these cells, when two adjacent cells both have colored backgrounds (same or different color, it doesn't matter) t... | <p>Correct me if I'm wrong, but the entity framework should only come into play when you need to transform the back-end objects, like when you're combining tables from different data sources, splitting tables, etc. It adds the entity layer so you can hide all the plumbing and just deal with your cleaned up entities. If... | <p>Before you dive in to Linq To SQL, check out <a href="http://blogs.msdn.com/adonet/archive/2008/10/31/clarifying-the-message-on-l2s-futures.aspx" rel="nofollow noreferrer">this article</a> by its program manager. He poses a straightforward question "Is LINQ to SQL Dead?" The answer is not as straightforward. It's... | 33,534 |
<p>In the past, and intermittently now, I've used simulation tools like <a href="http://www.um.es/fem/EjsWiki/index.php/Main/WhatIsEJS?" rel="nofollow noreferrer">Easy Java Simulations</a> and <a href="http://ccl.northwestern.edu/netlogo/" rel="nofollow noreferrer">NetLogo</a>.</p>
<p>They are great tools for visually... | <p>If all else fails, you can use a combination of these two approaches:</p>
<ul>
<li>Second-guess the environment: ask yourself how YOU would implement its features, and then deduce which feature is probably going to require the least computational work.</li>
<li>Trial-and-error: just compare different methods by tes... | <p>If all else fails, you can use a combination of these two approaches:</p>
<ul>
<li>Second-guess the environment: ask yourself how YOU would implement its features, and then deduce which feature is probably going to require the least computational work.</li>
<li>Trial-and-error: just compare different methods by tes... | 42,144 |
<p>I've been using PHP & MySQL for ages and am about to start using PostgreSQL instead.</p>
<p>What's the preferred method? </p>
<p>Is it via the PDO objects or is there something better?</p>
| <p>PDO objects are the new hotness. I'd recommend that as long as you can ensure that your target platform will always be running PHP 5.2+.</p>
<p>There are many other database abstraction layers that support PostgreSQL that are compatible with older versions of PHP; I'd recommend <a href="http://adodb.sourceforge.ne... | <p>I would also suggest creating an inherited PDO class or a wrapper class if you decide not to use PDO. This would provide you with a lot more flexibility in the future. ie. Calculating query execution time.</p>
| 3,173 |
<p>I have a problem with Crystal Reports 8. When exporting a report from my application, Crystal Reports <strong>sometimes</strong> freezes. The progress windows just stays, saying X of X records exported.</p>
<ol>
<li>Smaller reports with less data are more likley to freeze.</li>
<li>Faster workstations (P4, Core2) t... | <p>After a long search we finally tracked down the source to a <code>WaitForSingleObject(?, INFINITE)</code> call. It seems like CR8 has some synchronization errors which become obvious on fast workstations.</p>
<p>It is somehow related to the progress window, and the animations in Vista seem to mitigate the problem.<... | <p>CR 8 is a fairly old product, you may want to check whomever owns it now (Business Objects still?) for updates (hotfixes for v8 specifically). This could be something they've fixed in the past with a service release.</p>
| 27,265 |
<p>I'm not looking for a full implementation, I'm more interested in how they do it. I know they use GWT, but I'd like a more low level answer. Naively, I would start by thinking when you click the popout link they simply open a new window and copy content into it. There are lots of reasons why that won't work out w... | <p>I recently needed to solve exactly this problem in an app. I ended up using this great little jQuery plugin to do the trick: WindowMsg (see link at bottom) While I'm sure there are other ways to accomplish the same task, that plugin does works thusly:</p>
<ul>
<li>first you create a new child window from your origi... | <p>I would say the easiest way would be to have the data stored on the server (which you probably do already), then just have the new window retrieve that data.</p>
<p>Of course that wouldn't persist things like contents of a text-box the user has input, so depending on what the window is for, it may be impractical.. ... | 20,500 |
<p>How can you measure the amount of time a function will take to execute? </p>
<p>This is a relatively short function and the execution time would probably be in the millisecond range.</p>
<p>This particular question relates to an embedded system, programmed in C or C++.</p>
| <p>The best way to do that on an embedded system is to set an external hardware pin when you enter the function and clear it when you leave the function. This is done preferably with a little assembly instruction so you don't skew your results too much. </p>
<p>Edit: One of the benefits is that you can do it in your a... | <p>If you're looking for sub-millisecond resolution, try one of these timing methods. They'll all get you resolution in at least the tens or hundreds of microseconds:</p>
<p>If it's embedded Linux, look at Linux timers:</p>
<p><a href="http://linux.die.net/man/3/clock_gettime" rel="nofollow noreferrer">http://linux.... | 9,438 |
<p>In a product I work on, there is an iteration loop which can have anywhere between a few hundred to a few million iterations. Each iteration computes a set of statistic variables (double precision), and the number of variables can be up to 1000 (typically 15-50).</p>
<p>As part of the loop, we graph the change in ... | <p>You should ask yourself how valuable it is to display data for every iteration, and what about this data the user really cares about. I think the main thing you need to do here is just reduce the amount of data you display to the user.</p>
<p>For example, if the user only care about the trend, then you could easil... | <p>Why you don't produce a bitmap (or pixmap like XPM)? Each column (or row) correspond to iteration, and height of same colors (width for rows) correspond to the variable value. XPM format is simpler since it is textual (one character for pixel) and cross-platform.</p>
| 33,016 |
<p>I have a GridView with several fields, one of which can potentially have a crazy wide value in it like this:</p>
<p>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
<p>If <em>that</em> sort of thing is in the field, I want it to wrap.</p>
<p>I can easily insert a cha... | <p>ItemStyle-Wrap="true" ItemStyle-Width="100" doesn't work for one long word with no space.</p>
<p><strong>Found the solution:</strong></p>
<pre><code>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
... | <p>You can do a few things here. </p>
<p>One option is change the column in question to a TemplateColumn, and place a div in it, with the ability to generate scrollbars. I'd <em>really</em> suggest against this.</p>
<p>If you use a CRLF (\r\n) then you'd need to wrap it into <strong>PRE</strong> tags, and you'd want... | 43,994 |
<p>What is the difference between the following 2 ways to allocate and init an object?</p>
<pre><code>AController *tempAController = [[AController alloc] init];
self.aController = tempAController;
[tempAController release];
</code></pre>
<p>and</p>
<pre><code>self.aController= [[AController alloc] init];
</code></pr... | <p>Every object has a reference count. When it goes to 0, the object is deallocated.</p>
<p>Assuming the property was declared as <code>@property (retain)</code>:</p>
<p>Your first example, line by line:</p>
<ol>
<li>The object is created by <code>alloc</code>, it has a reference count of 1.</li>
<li>The object is ... | <p>One other thing to note is that your example depends on the @property definition of aController also.</p>
<p>If it were defined as <code>@property (readwrite, retain) id aController;</code> then your example works, while if it is defined as <code>@property (readwrite, assign) id aController;</code> then the extra c... | 18,897 |
<p>We have a couple of mirrored SQL Server databases.</p>
<p>My first problem - the key problem - is to get a notification when the db fails over. I don't <em>need</em> to know because, erm, its mirrored and so it (almost) all carries on working automagically but it would useful to be advised and I'm currently getting... | <p>Right, </p>
<p>The two answers and a little thought got me to something approaching an answer.</p>
<p>First a little more clarification:</p>
<p>The app is written in C# (2.0+) and uses ADO.NET to talk to SQL Server 2005.
The mirror setup is two W2k3 servers hosting the Principal and the Mirror plus a third server... | <p>If the failover logic is in your application you could write a status screen that shows which box you're connected by writing to a var when the first connection attempt fails.</p>
<p>I think your best bet would be a ping daemon/cron job that checks the status of each box periodically and sends an email if one doesn... | 4,800 |
<p>Wanting to build and test a bunch of Borland Delphi 6 projects that are integrated with ASP.NET services. Had been using WANT and CruiseControl for building Delphi. With TFS Build agent we can tie all together and do some testing. I am looking for guidance and direction. </p>
<p>One issue I see is that there is ... | <p>No.. lightroom plugins are written in the scripting language lua, photoshop plugins are written in C++.</p>
| <p>As pointed out by Rob, the Lightroom SDK does not expose any interface that allows manipulations of the image files themselves. Partly this is because Lightroom is a non-destructive editor. None of the edits made in its Develop module are applied to the original image file; they are applied to the file generated whe... | 34,314 |
<p>I've been wanting to play around with writing my own language for a while now (ostensibly for the learning experience) and as such need to be relatively grounded in the construction of Parsers, Interpreters, and Compilers. So:</p>
<ul>
<li><strong>Does anyone know of any good resources on constructing Parsers, Inte... | <p>The best paper I ever read on compilers is dated <strong>1964</strong>
"META II a syntax-oriented compiler writing language" by Val Schorre.
(<a href="http://doi.acm.org/10.1145/800257.808896" rel="noreferrer">http://doi.acm.org/10.1145/800257.808896</a>)</p>
<p>In 10 pages, he shows you how to build an astoundingl... | <p>It's an old book, and rather dated, but I've found <em>Brinch Hansen on Pascal Compilers</em> to be a very practical introduction to creating a language and building the elements of a compiler. Despite the name, it's not specific to Pascal. It's very worthwhile if you can find a copy.</p>
| 6,317 |
<p>I do some C# fat application on Citrix/Terminal Server.</p>
<p>How to measure actual memory usage per-session?
What can I do to reduce the memory usage in total?</p>
<p>We still working on .NET 1.1. Does it have a difference if we upgrade our .NET runtime?</p>
| <p>Its very difficult to get metrics on actual memory usage in .NET. About the closest approximation you can get is on a per-object basis by calling Marshal.SizeOf(). My understanding of that method is that it is essentially measuring the size of a serialized version of the object, and the in-memory footprint may be ... | <p><a href="http://msdn.microsoft.com/en-us/library/ms998579.aspx" rel="nofollow noreferrer">Here is an article</a> from MSDN on measuring application performance. It includes doing measurements on memory usage. </p>
<p>I don't think upgrading the .NET Runtime will have a significant effect on the application as it is... | 40,443 |
<p>I have a server that hosts my Subversion code base. That server is currently a <a href="http://en.wikipedia.org/wiki/Windows_Server_2003" rel="noreferrer">Windows Server 2003</a> box, and my IT administrator wants to update it to <a href="http://en.wikipedia.org/wiki/Windows_Server_2008" rel="noreferrer">Windows Ser... | <p>Yes, dumping and loading the repository is a way to go. Copying the repository folder directly is a viable option if, and only if, you are certain nobody will be accessing the repository while the copy process is in progress (or you can do a "hot copy" of the repository, which can handle these cases in a safe manner... | <p>If you are using the File System type repository, you can just literally take the folder containing your repository and move it. If you are changing servers, then chances are you will need to change the location that your local working directory looks for the repository by using the 'Relocate' command.</p>
| 47,080 |
<p>I'm writing a DLL which talks to Excel via its IDispatch interface. From VBA I pass in a Variant containing <code>Application.Caller</code> from which I draw the IDispatch pointer via <code>.pDispVal</code>. </p>
<p>What I'd like to know is how to query the interface via that IDispatch pointer. I want to set up a c... | <p>Please clarify the browser you are trying to fix this in.</p>
<p>You should be using <code><div></code>'s anyway if you want to do things properly ;)</p>
| <p>I'm no web dev, but isn't height just applicable to block objects? Hence try setting the TR's height, and not the TD's.</p>
| 46,789 |
<pre><code>func()
{
Object* pNext;
func1(pNext);
}
func1(Object* pNext)
{
pNext = Segement->GetFirstPara(0);
}
</code></pre>
<p>I was expecting it to be pointer to firstpara returned from func1() but I'm seeing NULL can some explain and how to fix it to actually return the firstpara() pointer?</p>
| <p>For C++ only, you can make the parameter a reference</p>
<pre><code>func()
{
Object* pNext;
func1(pNext);
}
func1(Object*& pNext)
{
pNext = Segement->GetFirstPara(0);
}
</code></pre>
<p>What is going on here is the difference between passing parameters by value and passing by reference. C alway... | <p>It should be</p>
<pre><code>
func()
{
Object *pNext;
func1(&pNext);
}
void func1(Object **pNext)
{
*pNext = Segment->GetFirstPara(0);
}
</code></pre>
| 23,512 |
<p>Can WampServer be used successfully in production? Is this a bad idea?</p>
<p>So everyone knows, and I don't see how this mattered, we've paid for a windows dedicated box and we have existing IIS apps. We just wanted to use a PHP based CMS which installs easier on apache (since it has some dependencies). So, as the... | <p>If you're not going onto the internet, there isn't any reason really not to. Of course you'd have to look at all the normal caveats - backups etc.</p>
<p>Instead of using an already made one, why not try to do your own? It would be a good learning experience and really they aren't that hard to get working togethe... | <p>Why not just use LAMP? PHP code is portable. I used WAMP for development, LAMP for production.</p>
<p>WAMP would probably work for production, but why not just use LAMP?</p>
| 14,991 |
<p>What is the "<em>best</em>" way to store international addresses in a database? Answer in the form of a schema and an explanation of the reasons why you chose to normalize (or not) the way you did. Also explain why you chose the type and length of each field.</p>
<p><strong>Note: You decide what fields you think ar... | <p>Plain freeform text.</p>
<p>Validating all the world's post/zip codes is too hard; a fixed list of countries is too politically sensitive; mandatory state/region/other administrative subdivision is just plain inappropriate (all too often I'm asked which county I live in--when I don't, because Greater London is not ... | <p>You need to provide a bit more details about how you are planning to use the data. For example, fields like City, State, Country can either be text in the single table, or be codes which are linked to a separate table with a Foreign Key.</p>
<p>Simplest would be</p>
<p>Address_Line_01 (Required, Non blank)
Address... | 4,409 |
<p>Can I create a Controller that simply returns an image asset?</p>
<p>I would like to route this logic through a controller, whenever a URL such as the following is requested:</p>
<pre><code>www.mywebsite.com/resource/image/topbanner
</code></pre>
<p>The controller will look up <code>topbanner.png</code> and send ... | <p>Use the base controllers File method.</p>
<pre><code>public ActionResult Image(string id)
{
var dir = Server.MapPath("/Images");
var path = Path.Combine(dir, id + ".jpg"); //validate the path for security or use other means to generate the path.
return base.File(path, "image/jpeg");
}
</code></pre>
<p>... | <p><strong>Yes you can return Image</strong></p>
<pre><code>public ActionResult GetImage(string imageFileName)
{
var path = Path.Combine(Server.MapPath("/Images"), imageFileName + ".jpg");
return base.File(path, "image/jpeg");
}
</code></pre>
<p><strong>(Please don't forget to mar... | 22,509 |
<p>Given an SQLConnection object how can you get a schema for a single table?</p>
<p>I seemed to be able to get the schema from a <code>DataSet</code> which I'd gotten from running a query, but all the schema info I could get from the connection seemed to be related to what tables were available and not the actual deta... | <p>I think accessing the schema from the query (via GetSchemaTable) is the only way to do it.
You can run a query which returns no rows (select * from table where 1=2) if the schema is all you're interested in.</p>
<p>You should use the KeyInfo CommandBehaviour to execute the source query, as otherwise not all the in... | <p>SQL Server - query the catalog views... sysobjects, syscolumns etc if SQL 2000 or earlier... sys.objects, sys.columns etc if SQL 2005 or higher. (although the older views are still available it is advisable to use the newer ones)</p>
<p>Complete reference here:
<a href="http://msdn.microsoft.com/en-us/library/ms... | 20,947 |
<p>I have a table User which has an identity column <code>UserID</code>, now what is the correct Linq to Entity line of code that would return me the max <code>UserID</code>?</p>
<p>I've tried:</p>
<pre><code>using (MyDBEntities db = new MyDBEntities())
{
var User = db.Users.Last();
// or
var User = db.Us... | <p>Do that like this</p>
<pre><code>db.Users.OrderByDescending(u => u.UserId).FirstOrDefault();
</code></pre>
| <p>The best way to get the id of the entity you added is like this:</p>
<pre><code>public int InsertEntity(Entity factor)
{
Db.Entities.Add(factor);
Db.SaveChanges();
var id = factor.id;
return id;
}
</code></pre>
| 40,793 |
<p>Hey. I have a problem with the highlighter in ComboBox. Recently I had to gray out certain items in a ComboBox and I did that by manually (programitically) drawing strings in the <strong>ComboBox</strong>. In a .NET combobox under the <strong>DrawMode.NORMAL</strong>, the lighlighter will automatically come when you... | <p>By default the text in a ComboBox is drawn in one of two colors:</p>
<pre><code>SystemColors.WindowText
</code></pre>
<p>for non-highlighted items, or</p>
<pre><code>SystemColors.HighlightText
</code></pre>
<p>for highlighted items.</p>
<p>These colors are not fixed, but can be configured by the user (e.g., thr... | <p>Yeah. That was really helpful. Also I tried to do:</p>
<pre><code>if (e.State == ((DrawItemState.NoAccelerator | DrawItemState.NoFocusRect) |
(DrawItemState.Selected |
DrawItemState.NoAccelerator |
DrawItemState.NoFocusRect)))
{
e.Graphics.DrawString(aFunctio... | 45,424 |
<p>I need to remotely install windows service on number of computers, so I use CreateService() and other service functions from winapi. I know admin password and user name for machines that I need access to. In order to gain access to remote machine I impersonate calling process with help of LogonUser like this: </p... | <p>You can do it , the account needs to exist on the remote machine and you need to use the machine name for the domain name in the LogonUser call.</p>
| <p>Rather than rolling your own, why not just use the SC built-in command?</p>
| 8,794 |
<p>I am working a standalone c# desktop application that sends out documents and then imports them from Outlook when they are sent back. The application picks up the emails from a specified folder processes them and then saves the senders name plus other stuff to a database.</p>
<p>This works well for Outlook 2003 and... | <p>I'm using the Outlook Redemption solution in a C# production code. It works beautifully.
With it, you can get the SenderID of a mail message (IRDOMail), and from there, you can use the GetAddressEntryFromID() method of the IRDOSession object.</p>
| <p>I've never actually used these, but you could try the Outlook <a href="http://www.microsoft.com/downloads/details.aspx?familyid=2714320d-c997-4de1-986f-24f081725d36&displaylang=en" rel="nofollow noreferrer">Collaboration Data Objects</a> (CDO). They used to be an add-on that you could install with outlook, but n... | 13,737 |
<p>I'm looking for the best method to parse various XML documents using a Java application. I'm currently doing this with SAX and a custom content handler and it works great - zippy and stable. </p>
<p>I've decided to explore the option having the same program, that currently recieves a single format XML document, re... | <p>As I understand it, the problem is that you don't know what format the document is prior to parsing. You could use a delegate pattern. I'm assuming you're not validating against a DTD/XSD/etcetera and that it is OK for the DefaultHandler to have state.</p>
<pre><code>public class DelegatingHandler extends DefaultHa... | <p>If you want more dynamic handling, Stax approach would probably work better than Sax.
That's quite low-level, still; if you want simpler approach, XStream and JAXB are my favorites. But they do require quite rigid objects to map to.</p>
| 5,050 |
<p>I'm working on a tool to simplify an application's deployment. Hence I'm aiming to automate the build of the setup project.</p>
<p>The Situation:
When I use Visual Studio to build the setup project this, creates the msi and exe files and concludes successfully. The problem occurs when I run a command in the command... | <p>You can't do this.</p>
<p>The issue is that you have defined your inputs to the setup project as outputs from the other projects in the solution. You have to build the entire solution to use this method.</p>
<p>You can do this but you have to manually link all the files you want into your setup project. It is a ... | <p>I suspect that you have a setup project that is referencing the output of another project. in this case you need to use</p>
<pre><code>devenv [solutionname] /build
</code></pre>
<p>the reason you are getting the error is because visual studio has not compiled the referenced project.</p>
<p>side note: if you are t... | 42,019 |
<p>I have a configuration file where a developer can specify a text color by passing in a string:</p>
<pre><code> <text value="Hello, World" color="Red"/>
</code></pre>
<p>Rather than have a gigantic switch statement look for all of the possible colors, it'd be nice to just use the properties in the class Syste... | <p>Recap of all previous answers, different ways to convert a string to a Color or Brush:</p>
<pre><code>// best, using Color's static method
Color red1 = Color.FromName("Red");
// using a ColorConverter
TypeConverter tc1 = TypeDescriptor.GetConverter(typeof(Color)); // ..or..
TypeConverter tc2 = new ColorConverter()... | <p>Try using a <code>TypeConverter</code>. Example:</p>
<pre><code>var tc = TypeDescriptor.GetConverter(typeof(Brush));
</code></pre>
<p>Another alternative is to use reflection, and go over the properties in <code>SystemBrushes</code>.</p>
| 48,717 |
<p>.</p>
<p><strong>Inspiration -- <a href="http://www.megaderek.com/southpark/" rel="nofollow noreferrer">Southpark game</a></strong> </p>
<p>(very popular if you see download count on download.com ,,, did he ask for permission ??) </p>
<p>I am making a 2d game based on dexter's lab theme. I've got the sprite of d... | <p>I am not a lawyer. This is not legal advice.</p>
<p>If you made the sprite yourself, you'd be fine. If you got a release to use it from the creator, you'd be fine. If it was released into the public domain, you'd be fine.</p>
<p>Anything else, you'd have a definate problem with.</p>
<p>There's also the possibl... | <p>probably not legal, since <a href="http://www.toonopedia.com/dexter.htm" rel="nofollow noreferrer">Dexter's lab</a> is published by Hanna-Barbera and was created by Genndy Tartakovsky. They would have to grant you a license - but it can't hurt to ask!</p>
| 13,548 |
<p>Is there an easy way to parse the user's HTTP_ACCEPT_LANGUAGE and set the locale in PHP?</p>
<p>I know the Zend framework has a method to do this, but I'd rather not install the whole framework just to use that one bit of functionality.</p>
<p>The PEAR I18Nv2 package is in beta and hasn't been changed for almost t... | <p>Nice solution is <a href="http://php.net/manual/en/locale.acceptfromhttp.php" rel="nofollow noreferrer">on its way</a>.</p>
<p>Without that you'll need to parse that header. It's a comma-separated list of semicolon-separated locales and attributes.</p>
<p>It can look like this:</p>
<pre><code>en_US, en;q=0.8, fr_... | <p>There's <a href="http://www.php.net/manual/en/function.http-negotiate-language.php" rel="nofollow noreferrer"><code>http_negotiate_language</code></a>, but it depends on the http-extension. Alternatively, see the comments on the manual page, for a userland implementation.</p>
| 42,352 |
<p>I have a web application that is using a data store that has it's own built in paging. The PagedResult class tells me the number of total pages. What I would like to do it (after binding my ASP.NET GridView) do this:</p>
<pre><code>MyGridView.PageCount = thePageCount;
</code></pre>
<p>And then have the GridView ma... | <p>To use the built-in paging the GridView interacts with the data source. The GridView has a settable property for PageSize.</p>
<p>If you use an ObjectDataSource, you configure both a SelectMethod and a SelectCountMethod. You could either modify your PagedResult class to return record count instead of page count, or... | <p>You could create your own class that extends GridView and override the PageCount getter method to return the value from your PagedResult class.</p>
| 36,274 |
<p>After my <code>form.Form</code> validates the user input values I pass them to a separate (external) process for further processing. This external process can potentially find further errors in the values.</p>
<p>Is there a way to inject these errors into the already validated form so they can be displayed via the ... | <p><code>Form._errors</code> can be treated like a standard dictionary. It's considered good form to use the <code>ErrorList</code> class, and to append errors to the existing list:</p>
<pre><code>from django.forms.utils import ErrorList
errors = form._errors.setdefault("myfield", ErrorList())
errors.append(u"My error... | <p><strong>Add error to specific field :</strong></p>
<pre><code>form.add_error('fieldName', 'error description')
</code></pre>
<p>**Add error to non fields **</p>
<pre><code>form.add_error(None, 'error description')
#Only pass None instead of field name
</code></pre>
| 22,909 |
<p>I have Excel add-in which I add so many class modules that it is now very bulky. I want to convert it into a type library or a COM package so that I can re-use it for the other apps in the MS Office suite.</p>
<p>I ported the add-in to Visual Studio as a class library project but Excel Automation doesn't recognize ... | <p>I hope we will not discuss prefixes for field names and brace styles here :)</p>
<p>Here is my bible for .NET:</p>
<p><a href="https://i.stack.imgur.com/aZnVG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aZnVG.jpg" alt="alt text"></a>
</p>
<p>Also <a href="http://msdn.microsoft.com/en-us/lib... | <p>Folks, please don't post answers like "I like __field" or "I like m__field". It's a very personal and subjective question without a single answers. </p>
<p>If <em>you have any guidlines</em> it's already a big win. Worse thing in dev team is a lack of common conventions. </p>
<p>It would be nice if would try to de... | 15,508 |
<p>Is something like the following possible in PHP?</p>
<pre><code>$blah = 'foo1';
class foo2 extends $blah {
//...
}
class foo1 {
//...
}
</code></pre>
<p>This gives an error.</p>
<p>I want to dynamically set $blah so I can extend whatever class I want.</p>
<p><strong>Edit:</strong> The reason for wantin... | <p>You're assuming here php executes top to bottom, but it doesn't quite work like that: </p>
<pre><code><?php
foo(); # works
function foo(){
print "bar";
}
</code></pre>
<hr>
<pre><code><?php
foo(); #dies
if( $i == 1 )
{
function foo(){
print "bar";
}
}
</code></pre>
<hr>
<pre><code><?php
... | <p>you should have tried $$</p>
<pre><code>$blah = 'foo1';
class foo2 extends $$blah {
//...
}
class foo1 {
//...
}
</code></pre>
| 39,132 |
<p>Here is the scenario that I have. I have a cvs repository in one location (A) and I want to replicate it and keep it in sync with a repository in another location(B). This would be a single directional sync from A to B. What is the best way to do this? If it is not really feasible in CVS then which source code contr... | <p>When using CVS, I don't know any tools to do that other than files syncing. You can achieve that using tools like <code>rsync</code> (Unix) or <code>xcopy</code>/<code>robocopy</code> (Windows).</p>
<p>If you plan on migrating to Subversion, it provides a tool called svnsync that allows to sync a repository from an... | <p>The Best (and perhaps costliest) way is <a href="http://www-01.ibm.com/software/awdtools/clearcase/multisite/" rel="nofollow noreferrer">Clearcase Multisite</a></p>
<p>But if you are looking for opensource, <a href="http://git.or.cz/" rel="nofollow noreferrer">Git</a> is becoming quickly replacing svn everywhere.. ... | 3,681 |
<p>I am currently trying to program my first ajax interface using Rails.</p>
<p>The application currently shows a table populated with list items. The user has to approve or reject each of the list items. I currently have an edit link at the end of each row that shows a form in which I can approve the list item.</p>
... | <p>I don't think that a checkbox is the correct control for what you're looking for.
You said you want user's to be able to approve or reject items which means that you have 3 states: unhandled, approved and rejected. A checkbox only supports 2 states: off and on</p>
<p>I would use two links accept and reject and then... | <p>This is a comment to solution proposed by Andrew,</p>
<p>I had to write params of <code>link_to_remote</code> function like this</p>
<pre><code>link_to_remote 'reject', :url => {:action => :reject, :id => item.id, :method => :post}
</code></pre>
<p>Also, remember to add new actions to your routes.rb i... | 24,381 |
<p>I'm firing off a Java application from inside of a C# <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="noreferrer">.NET</a> console application. It works fine for the case where the Java application doesn't care what the "default" directory is, but fails for a Java application that only searches the curren... | <p>Yes!
ProcessStartInfo Has a property called <em>WorkingDirectory</em>, just use:</p>
<pre><code>...
using System.Diagnostics;
...
var startInfo = new ProcessStartInfo();
startInfo.WorkingDirectory = // working directory
// set additional properties
Process proc = Process.Start(startInfo);
</code></pre>
| <p>Use the <code>ProcessStartInfo</code> class and assign a value to the <code>WorkingDirectory</code> property.</p>
| 14,023 |
<p>I want to put relief text on curved surface but can't find way to do that in OpenSCAD. I'm aware it's possible to bend text in Blender and then <code>import stl</code>, but I don't like this workflow. I found sort of working solution but it's not perfect.</p>
<pre><code>$fn=50;
module bend_text(caption, angle, text... | <p>Yes - you should be able to turn the extruder by hand when it is unplugged and therefore not powered.</p>
<p>The V2 comes with a blue plastic knob for this purpose, it may be too small to turn the shaft by hand.</p>
<p>When powered and "steppers enabled" the motors need a lot more force to overcome, but ev... | <p>Criggie's answer is basically correct, but I disagree with the conclusion that it:</p>
<blockquote>
<p>Could be expensive - you might want to compare cost of parts with cost of a new printer, remembering there may be other non-functional components still undiscovered.</p>
</blockquote>
<p>If you want to turn the End... | 2,146 |
<p>I have a simple extension method on the int type so I can do the following:</p>
<pre><code>string timeLength = 61.ToTime() // timeLength will be "1:01"
</code></pre>
<p>This works great in code, but I want to use this extension method in a Repeater Template. When databinding I want to do the following:</p>
<pre><... | <p>Looks like I get to answer my own question! Asp.Net was compiling the .aspx,.ascx templates using the .Net 2.0 compiler. I needed to add the following to my web.config to make it work</p>
<pre><code> <system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Micro... | <p>Does Eval("LengthInSeconds") work by itself?</p>
| 48,680 |
<p>Hey printing junkies need some pointers to send me in the right direction for this development.</p>
<p>I am developing an epos system for a local shop which we are later going to tie into an ecommerce site. </p>
<p>The front end of the epos system is going to be WinForms so we can handle USB devices easily and we ... | <p>The best way to do this (unfortunately) is to periodically query all of the sites and check to see if inheritance is disabled. I had a similar problem and used powershell scripting to create a <a href="http://www.mobiusdevelopment.com/dev/Download.asp?ArticleID=7156531513977360024" rel="nofollow noreferrer">report o... | <p>You can use SharePoint auditing to monitor permission changes. It will track changes down to item level. The downside is that you have to turn this feature on and it will hurt performance somewhat.</p>
<p>As for notification, I don't think auditing tells you about changes. I'm pretty sure you would need to poll the... | 44,918 |
<p>Is it possible somehow to close StreamReader after calling ReadToEnd method in construction like this:</p>
<pre><code>string s = new StreamReader("filename", Encoding.UTF8).ReadToEnd();
</code></pre>
<p>Any alternative elegant construction with the same semantics will be also accepted.</p>
| <p>I think the method you're really after is <a href="http://msdn.microsoft.com/en-us/library/system.io.file.readalltext.aspx" rel="noreferrer">File.ReadAllText</a>, if you're just trying to read all the text from a file in the shortest possible code.</p>
<p>If you don't specify the encoding, it will use UTF-8 automat... | <p>You could use a <em><a href="http://msdn.microsoft.com/en-us/library/yh598w02(VS.80).aspx" rel="nofollow noreferrer">using</a></em> statement, which <em>automatically</em> closes the stream:</p>
<pre><code>string s = null;
using ( StreamReader reader = new StreamReader( "filename", Encoding.UTF8 ) { s = reader.... | 43,637 |
<p>We have an MSI installer for a .Net WinForms app for Windows XP that installs and runs only as an admin. Users have to log in to the app when it runs. Customers want it to install and run under a user account under Vista, and to use their Windows account.</p>
<p>A preliminary look through the code shows lots of pro... | <p>"the app must be installable and uninstallable by any user"
"all users share the same data files"</p>
<p>You're going to have trouble with having to meet both of these requirements. Vista's new security features are designed to keep users from trampling on each other (and on the system).</p>
<p>About the only way... | <p>Thanks guys. I checked with the client and the requirement to install only as a user account is firm, they are removing admin access from floor staff. This rules out admin-installed components and per-machine installs.</p>
<p>Our solution was to create a new Standard User account for our app. Staff who need to use ... | 17,159 |
<p>Is it possible to sign only part of an applet? Ie, have an applet that pops up no security warnings about being signed, but if some particular function is used (that requires privileges) then use the signed jar?</p>
<p>From what I can tell, some (perhaps most) browsers will pop up the warning for a signed applet e... | <p>Try splitting your code into an unsigned jar and a signed jar.</p>
| <p>I've been given the impression that Sun wants to discourage the creation of Applets and encourage the usage of Java Web Start. I think this issue of signing applets is part of the problem. See this documentation from Sun: <a href="http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/faq.html" rel="nofo... | 10,315 |
<p>I have databases with different collations. I want to be able to script out tables from one database and create them in another. However, when I script out the tables, it includes the collation in the column definitions.</p>
<p>Is there a way to exclude the collations from the generated table creation scripts?</p... | <p>Tools -> Options</p>
<p>Under Scripting (in the Table/View section)</p>
<p>Set Include Collation to False! </p>
| <p>Pretty lame - but do a search and replace on the script after it has been generated??</p>
| 33,932 |
<p>Because of a space-issue I have to make 'single-character-links' for crud actions:</p>
<p>In characters I would symbolise:<br>
'delete' with character <strong>x</strong><br>
'add' with <strong>+</strong><br>
…<br>
How would you symbolise 'change' ?</p>
| <p>How about the delta character? Δ<br>
Or, what about the +/- character ? ±</p>
| <p><strong>^</strong></p>
<p>perhaps to symbolize "UPdate"?</p>
| 44,954 |
<p>How can I use vimdiff to view the differences described in a diff file?</p>
| <p>Instead of using <code>/usr/bin/vimdiff</code> command, try this:</p>
<pre>$ vim file
:vertical diffpatch path/to/diff</pre>
<p>(<code>:vert diffpa</code> for short.)<br>
This is equivalent to calling <code>vimdiff</code> on the original file and the subsequently patched file, but <code>vim</code> calls <code>patc... | <p>Would you say more about why you want to use vimdiff for this?</p>
<p>For instance, do you want to <a href="https://stackoverflow.com/questions/3231759/how-can-i-visualize-per-character-differences-in-a-unified-diff-file">visualize per-character differences in a (unified) diff file?</a>. If so, someone answered <a ... | 30,045 |
<p>A while ago, I started on a project where I designed a html-esque XML schema so that authors could write their content (educational course material) in a simplified format which would then be transformed into HTML via XSLT. I played around (struggled) with it for a while and got it to a very basic level but then was... | <p>Advantages of XSLT:</p>
<ul>
<li>Domain-specific to XML, so for example no need to quote literal XML in the output.</li>
<li>Supports XPath/XQuery, which can be a nice way to query DOMs, in the same way that regular expressions can be a nice way to query strings.</li>
<li>Functional language.</li>
</ul>
<p>Disadva... | <p>XSLT is not the end-all be-all of xml transformation. However, it's very difficult to judge based on the information given if it would have been the best solution to your problem or if there are other more efficient and maintainable approaches. You say the authors could enter their content in a simplified format -... | 10,413 |
<p>Are there any ncurses libraries in C/C++ for Windows that emulate ncurses in native resizable Win32 windows (<em>not</em> in console mode)?</p>
| <p>There's an ongoing effort for a PDCurses port:</p>
<p><a href="http://www.mail-archive.com/pdcurses-l@lightlink.com/msg00129.html" rel="noreferrer">http://www.mail-archive.com/pdcurses-l@lightlink.com/msg00129.html</a></p>
<p><a href="http://www.projectpluto.com/win32a.htm" rel="noreferrer">http://www.projectpluto... | <p>Such a thing probably does not exist "as-is". It doesn't really exist on Linux or other UNIX-like operating systems either though.</p>
<p>ncurses is only a library that helps you manage interactions with the underlying terminal environment. But it doesn't provide a terminal emulator itself.</p>
<p>The thing that a... | 16,719 |
<p>In Java, web apps are bundled in to WARs. By default, many servlet containers will use the WAR name as the context name for the application.</p>
<p>Thus myapp.war gets deployed to <a href="http://example.com/myapp" rel="noreferrer">http://example.com/myapp</a>.</p>
<p>The problem is that the webapp considers its "... | <p>You can use JSTL for creating urls.</p>
<p>For example, <code><c:url value="/images/header.jpg" /></code> will prefix the context root.</p>
<p>With CSS, this usually isn't an issue for me.</p>
<p>I have a web root structure like this:</p>
<p>/css<br>
/images</p>
<p>In the CSS file, you then just need to u... | <p>I by <em>no</em> means claim that the following is an elegant issue. In fact, in hindsight, I wouldn't recommend this issue given the (most likely) performance hit. </p>
<p>Our web app's JSPs were strictly XML raw data. This raw data was then sent into an XSL (server-side) which applied the right CSS tags, and spit... | 15,236 |
<p>I feel like I die a little on the inside every time I work on converting this legacy code to Web app. The database is crap. All the filed and column are nvarchar and blank (Empty string) suppose to mean Nothing (Null) instead using Null to mean nothing. For something like percentage instead of using decimal. You tag... | <p>Yes everday. We have a mixture of utilities that are either really really bad C++ (MFC) or VB6 which by implication is bad ;-) </p>
<p>I worked for 5 years as a contractor and part of that job is working on really really bad code. By the time a contractor is brought in, things are usually pretty dire. My soul died ... | <p>I'm doing it right now. I'm working on architectural assessment of migrating <strong>to</strong> a .NET solution <strong>from</strong>:</p>
<ul>
<li>old VB6 code that has dozens of forms and only a couple of classes</li>
<li>a SQL Server 7 back-end with 60+ DTS packages</li>
</ul>
<p>It's all <strong>very old</st... | 49,196 |
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/91071/emacs-switch-to-previous-window">Emacs, switch to previous window</a> </p>
</blockquote>
<p><code>other-window</code> advances me to the next window in the current frame, but I also want a way to move bac... | <p>Provide a negative argument with <kbd>C-u -</kbd> ("Control+U" then "minus"), or even more simply <kbd>C--</kbd> ("Control minus").</p>
<ul>
<li>Move to previous window: <kbd>C-- C-x o</kbd></li>
<li>Move to previous frame: <kbd>C-- C-x 5 o</kbd></li>
</ul>
<p>From code, <code>(other-window -1)</code> or <code>(ot... | <p>Instead of <code>C-u -</code>, you can also give a negative prefix argument with just <code>M--</code> (Meta-Minus) , i.e. switch to previous window with <code>M-- C-x o</code>.</p>
| 17,281 |
<p>What I'd like to know is if there is a nice way to queue jQuery functions to execute after a set amount of time. This wouldn't pause the execution of other functions, just the ones following in the chain. Perhaps an example of what I'd envisage it would look like would illustrate:</p>
<pre><code>$('#alert')
.sh... | <p>You can't do that, and you probably don't want to. While it certainly looks pretty, there is no mechanism in Javascript that will allow you do to that without just looping in "wait" until the time has passed. You could certainly do that but you risk seriously degrading the browser performance and if your timeout i... | <p>The <a href="http://web.archive.org/web/20111025005225/http://plugins.jquery.com:80/project/fxqueues" rel="nofollow noreferrer">jQuery FxQueues plug-in</a> does just what you need:</p>
<pre><code>$('#element').fadeOut({
speed: 'fast',
preDelay: 5000
});
</code></pre>
| 11,467 |
<p>I have a two part question</p>
<p><strong>Best-Practice</strong></p>
<ul>
<li>I have an algorithm that performs some operation on a data structure using the public interface</li>
<li>It is currently a module with numerous static methods, all private except for the one public interface method.</li>
<li>There is one... | <p>I think the best way (and mostly how existing libs are written) to do this is by creating a class within the module that deals with all the logic, and the module just provides a convenient method, e.g.</p>
<pre><code>module GTranslate
class Translator
def perform(text)
translate(text)
end
privat... | <h2>Make a private module or class</h2>
<p>Constants are never private. However, it's possible to create a module or class without assigning it to a constant.</p>
<p>So an alternative to <code>:private_class_method</code> is to create a private module or class and define public methods on it.</p>
<pre><code>module P... | 41,218 |
<p>I have code like this to move the player in my game left, right, up, and down:</p>
<pre><code>keysSetRepeat(20, 5);
while (lives) {
scanKeys();
if (keysDownRepeat() & (KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN)) {
u8 new_x = x;
u8 new_y = y;
if (keysDownRepeat() & KEY_LEFT)... | <p>I had to find the libnds source code to figure this out. Look at the implementation of keysDownRepeat():</p>
<pre><code>uint32 keysDownRepeat(void) {
uint32 tmp = keysrepeat;
keysrepeat = 0;
return tmp;
}
</code></pre>
<p>It actually returns the keys then resets them back to 0. This wasn't documented... | <p>Note also that you have keysHeld() to identify keys that are "still hold down" from the previous frame, while keysDown() is typically designed to help you identify "keys that have just beeing pressed this frame" (that is, between two calls of scanKeys()). keysDownRepeat() is obviously useful for people that wants ke... | 40,382 |
<p>I was <a href="https://3dprinting.stackexchange.com/questions/1536/what-does-uses-mains-voltage-mean-on-this-200200mm-square-silicone-heater-pad">advised</a> that it would be possible to use an AC SSR to wire up a Mains Based heat bed. Any idea how one would do this with a RAMPs 1.4 board; Also, what do I hook a he... | <p>If you take a kettle lead with a wall plug and cut off the other end, it will expose 3 wires: earth, live and neutral. These are <a href="https://en.wikipedia.org/wiki/Electrical_wiring" rel="nofollow">color coded</a> depending on your country, usually earth is green (possibly with yellow stripes), neutral is blue, ... | <p>A link to the bed you have/are buying would be very helpful. AC heated beds exist but are fairly uncommon.</p>
<p>As <a href="https://3dprinting.stackexchange.com/a/1548/1404">one of the answers</a> in the question you linked notes, the heat bed is probably not actually intended to use the 110 VAC/220 VAC directly ... | 354 |
<p>Lets say we have something like:</p>
<pre><code> <div class="row">
<div class="box">
<a class="more" href="#more"/>
</div>
<div class="hidden">
stuff
</div>
</div>
<div class="row">
<div class="box">
... | <p>I use <a href="http://www.winmerge.org" rel="noreferrer">WinMerge</a>. Not as good as Beyond Compare but it's free and open source.</p>
<p>Also check out <a href="http://www.codeplex.com/ComparisonTools" rel="noreferrer">Visual Studio Comparison Tools</a>, it's a Visual Studio add-in that connects it to WinMerge.</... | <p>Not that I know of, but <a href="http://www.scootersoftware.com/index.php" rel="nofollow noreferrer">Beyond Compare</a> is probably worth a look anyway.</p>
| 45,752 |
<p>We have 2 new GIS programmer/analyst in our department (new to programming and ArcObjects) and I don't feel I'm qualified enough or have the time to teach them. So I'm looking for entry level books/tutorials for them to use as reference.</p>
<p>The only books I can find for developing Extensions for ArcMap are wri... | <p>Trying to teach programmers both ArcObjects and general software development is a really bad idea. I am struggling with the exact same problem right now. You run the risk of getting two developers who program neither ArcObjects nor C# very well.</p>
<p>Teach them to be good developers first. Do this by having them ... | <p>Practice by example.</p>
<p>I had some fun when I was first starting with simple but interesting tools like one that took a screenshot of the current map and posted it a MediaWiki site (with just one click). Much of the API seems like Deep Magic and more than once I've stumbled across completely undocumented featur... | 27,621 |
<p>Let's say I have code like this:</p>
<pre><code>$dbh = new PDO("blahblah");
$stmt = $dbh->prepare('SELECT * FROM users where username = :username');
$stmt->execute( array(':username' => $_REQUEST['username']) );
</code></pre>
<p>The PDO documentation says:</p>
<blockquote>
<p>The parameters to prepare... | <p>The short answer is <strong>YES</strong>, PDO prepares are secure enough if used properly.</p>
<hr />
<p>I'm adapting <a href="https://stackoverflow.com/a/12118602/338665">this answer</a> to talk about PDO...</p>
<p>The long answer isn't so easy. It's based off an attack <a href="http://shiflett.org/blog/2006/jan/ad... | <p>Eaven if you are going to prevent sql injection front-end, using html or js checks, you'd have to consider that front-end checks are "bypassable".</p>
<p>You can disable js or edit a pattern with a front-end development tool (built in with firefox or chrome nowadays).</p>
<p>So, in order to prevent SQL injection, ... | 16,235 |
<p>I'm working on a P2P application, and I need to get it to communicate through NAT Routers / Firewalls using UPnP. However, it doesn't seem that the .NET Framework includes support for UPnP.</p>
<p>Is there a UPnP Library for .NET? C# or VB.NET?</p>
<p>UPDATE: I have since found the NATUPnP 1.0 Type Library (NATUPN... | <p>There is a COM library that's easy enough to access:</p>
<blockquote>
<p><strong><a href="http://msdn.microsoft.com/en-us/library/aa382303.aspx" rel="noreferrer">UPnP APIs</a> Purpose</strong></p>
<p>The UPnP™ framework enables dynamic
networking of intelligent appliances,
wireless devices, and PCs. Ther... | <p>I use this, which seems to work fine:</p>
<p><a href="http://code.google.com/p/dotnetportmapper/" rel="nofollow noreferrer">http://code.google.com/p/dotnetportmapper/</a></p>
| 43,169 |
<ul>
<li>It's been out for almost five years.</li>
<li>It's got tens of millions of users</li>
<li>I suspect several businesses rely on it.</li>
</ul>
<p>How is it still "beta"? At what point will it no longer be beta? When it completely owns the e-mail market?</p>
| <p><a href="http://www.networkworld.com/community/node/33131" rel="noreferrer">According to a Google spokesman</a>: </p>
<blockquote>
<p>"We have very high internal metrics
our consumer products have to meet
before coming out of beta. Our teams
continue to work to improve these
products and provide users wit... | <p>I suspect that beta, in this case, means that they are avoiding the hassles and complications of being accused of being a monopoly. Conspiracy anybody?</p>
| 44,916 |
<p>I want to change the order of XML using XDocument</p>
<pre><code><root>
<one>1</one>
<two>2</two>
</root>
</code></pre>
<p>I want to change the order so that 2 appears before 1. Is this capability baked in or do I have to do it myself. For example, remove then AddBeforeSe... | <p>Similar to above, but wrapping it in an extension method. In my case this works fine for me as I just want to ensure a certain element order is applied in my document before the user saves the xml.</p>
<pre><code>public static class XElementExtensions
{
public static void OrderElements(this XElement parent, pa... | <p>This should do the trick. It order the child nodes of the root based on their content and then changes their order in the document. This is likely not the most effective way but judging by your tags you wanted to see it with LINQ.</p>
<pre><code>static void Main(string[] args)
{
XDocument doc = new XDocument(
... | 27,704 |
<p>After upgrading to the latest version of TortoiseSVN (1.5.2.13595), it's context menu is no longer available.</p>
<p>When attempting to run it manually, I get this error:</p>
<pre><code>The application has failed to start because its side-by-side configuration is incorrect.
Please see the application event log for... | <p>I remembered I'd seen this thing before just after posting to SO</p>
<p>It seems that later versions of TortoiseSVN are built with Visual Studio 2008 SP1 (hence the 9.0.30411.0 build number)</p>
<p>Installing the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2... | <p>Confirmed working on windows 7 x64.</p>
| 3,955 |
<p>what is the best practice for multilanguage website using DOM Manipulating with javascript? I build some dynamic parts of the website using javascript. My first thought was using an array with the text strings and the language code as index. Is this a good idea?</p>
| <p>When I've built multi-lingual sites before (not very large ones, so this might not scale too well), I keep a series of "language" files:</p>
<ul>
<li>lang.en.js</li>
<li>lang.it.js</li>
<li>lang.fr.js</li>
</ul>
<p>Each of the files declares an object which is basically just a map from key word to language phrase:... | <p>For Spring bundles and JavaScript there are simple solution: generate i18n array in template (e.g. JSP) and use it in JavaScript:</p>
<p>JSP:</p>
<pre><code><html>
<script type="text/javascript">
var i18n = [];
<c:forEach var='key' items='<%=new String[]{"common.deleted","common.saved","c... | 28,322 |
<p>A <a href="https://stackoverflow.com/questions/217618/construct-vs-sameasclassname-for-constructor-in-php">similar question discusses <code>__construct</code></a>, but I left it in my title for people searching who find this one.</p>
<p>Apparently, __get and __set take a parameter that is the variable being gotten ... | <p><a href="http://uk.php.net/manual/en/language.oop5.overloading.php" rel="nofollow noreferrer">This page</a> will probably be useful. (Note that what you say is incorrect - <code>__set()</code> takes as a parameter both the name of the variable and the value. <code>__get()</code> just takes the name of the variable).... | <p>They're for doing "clever" things.</p>
<p>For example you could use <code>__set()</code> and <code>__get()</code> to talk to a database. Your code would then be: <code>$myObject->foo = "bar";</code> and this could update a database record behind the scenes. Of course you'd have to be pretty careful with this o... | 31,190 |
<p>I am creating an installer in IzPack. It is quite large, and I have broken up my XML files appropriately using <xinclude> and <xfragment> tags. Unfortunately, IzPack does not combine them together when you build your installer. This requires you to package the files with the installer, which just won't w... | <p>If you can't get xinclude to work and you're using Ant, I'd recommend <a href="http://www.oopsconsultancy.com/software/xmltask" rel="nofollow noreferrer">XMLTask</a>, which is a plugin task for Ant. It'll do lots of clever stuff, including the one thing you're interested in - constructing a XML file out of fragments... | <p>I'm not sure if java supports automatic xinclude. But you will have to use namespaces to make it work. So don't use <code><xinclude ....></code>, but use: </p>
<pre><code><xi:xinclude xmlns:xi="http://www.w3.org/2001/XInclude" href="example/File2.xml" />
</code></pre>
<p>Normally the included file shou... | 9,861 |
<p>What is the best way to delete a database record using LINQ when I have the primary key? </p>
| <p>If you set <strong>update checks</strong> on all your columns to <strong>never</strong> or <strong>when changed</strong>, you can simply attach an instance with the primary key and delete the row without a load.</p>
<pre><code>public void DeleteCustomer(int CustomerID)
{
NorthwindContext c = new NorthwindContex... | <p>You can map a stored procedure to a method on the DataContext that deletes a record with a given value for the primary key.</p>
| 27,717 |
<p>Is there a machine (for hobbyists) that will make filament based on the type of plastic I put in. I will sort the plastic before I will put it in the machine.</p>
<p>I have seen the <a href="http://filabot.com" rel="nofollow noreferrer">filabot</a> but this uses only plastic from previous prints not plastic types Po... | <blockquote>
<p>I am asking if there is a machine that can turn a plastic bottle into usable filament.</p>
</blockquote>
<p>I've seen several projects (<a href="https://hackaday.com/2021/06/29/petbot-turn-pet-bottles-into-filament/" rel="nofollow noreferrer">one example</a>, and <a href="https://youtu.be/Eecbdb0bQWQ" r... | <p>The source of the plastic doesn't matter a lot.</p>
<p>What matters is the plastic's composition and chemistry and how well shredded it is.</p>
<p>Issues are:</p>
<ul>
<li>Is it a thermoplast that can be remelted?</li>
<li>Is the working melt temperature range compatible with your printer and/or the filament forming... | 2,091 |
<p>I'm doing a personal organizer for learning purposes, and i've never worked with XML so i'm not sure if my solution is the best. Here's the basic structure for the XML file i came with:</p>
<pre><code><calendar>
<year value="2008">
<month value="october">
<day value="16"... | <p>Your way is quite adequate to me. However, I prefer child tags to attributes, so my way would be more like:</p>
<pre><code><activity>
<name>Mike's Birthday</name>
<time>2100</time>
<address>Mike's Place</address>
<urgency>10</urgency>
<description&g... | <p>You could flatten that hierarchy down to:</p>
<pre><code><calendar>
<activity
id="123456"
name="mike's birthday"
year="2008"
month="10"
day="16"
time="21:00"
address="mike's apartment"
urgency="10">
activity description.
... | 25,734 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.