instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>One of the core fields present on several of my app's major database tables needs to be changed from varchar(5) to varchar(8). The list of stored procedures that depend on these tables is extremely long, not to mention the changes that would have to be made in my Data Access Layer (ASP.NET 2.0 DataSet with TableAdap... | <p>You might be interested in this <a href="http://www.agiledata.org/essays/databaseRefactoring.html" rel="nofollow noreferrer">essay</a> by Scott Ambler on Database Refactoring. I think he also has a book on it. The basic idea, I believe, will be to introduce a new column with the proper width, copy existing data to... | <p>While it doesn't help you much now you could (in the future) look to use a code generation tool that generates data access layers and any necessary (non-custom) stored procedures for you. I use .netTiers and changing something like a field name, data type or column size (like your situation) is very simple.</p>
<p... | 41,784 |
<p>Why does this code:</p>
<pre><code>class A
{
public:
explicit A(int x) {}
};
class B: public A
{
};
int main(void)
{
B *b = new B(5);
delete b;
}
</code></pre>
<p>Result in these errors:</p>
<pre>
main.cpp: In function ‘int main()’:
main.cpp:13: error: no matching function for call to ‘B::B... | <p>If your compiler supports C++11 standard, there is a constructor inheritance using <code>using</code> (pun intended). For more see <a href="http://en.wikipedia.org/wiki/C%2B%2B11#Object_construction_improvement" rel="noreferrer">Wikipedia C++11 article</a>. You write:</p>
<pre><code>class A
{
public:
ex... | <p>derived class inherits all the members(fields and methods) of the base class, but derived class cannot inherit the constructor of the base class because the constructors are not the members of the class. Instead of inheriting the constructors by the derived class, it only allowed to invoke the constructor of the bas... | 45,195 |
<p>I am currently writing a simple, timer based mini app in C# that performs an action n times every k seconds.<br>
I am trying to adopt a test driven development style, so my goal is to unit test all parts of the app.</p>
<p>So, my question is: Is there a good way to unit test a timer based class?</p>
<p>The problem... | <p>What I have done is to mock the timer, and also the current system time, that my events could be triggered immediately, but as far as the code under test was concerned time elapsed was seconds.</p>
| <p>I think what I would do in this case is test the code that actually executes when the timer ticks, rather than the entire sequence. What you really need to decide is whether it is worthwhile for you to test the actual behaviour of the application (for example, if what happens after every tick changes drastically fro... | 3,314 |
<p>Just found this out, so i am answering my own question :)</p>
<p>Use a comma where you would normally use a colon. This can be a problem for named instances, as you seem to need to specify the port even if it is the default port 1433.</p>
<p>Example:</p>
<pre><code>Provider=SQLOLEDB;Data Source=192.168.200.123,14... | <p>I always check out <a href="http://www.connectionstrings.com/" rel="noreferrer">http://www.connectionstrings.com/</a>. It is a brilliant resource for connection strings.</p>
| <p>Good call BlackWasp, actually that is where i found the answer! (But it was somewhat buried, so i wrote this one which is hopefully clearer)</p>
| 18,199 |
<p>I want to load 52 images (deck of cards) in gif format from my recourse folder into an Image[] in c#. Any ideas?</p>
<p>Thanks,
Jon</p>
| <p>You can read a Bitmap from a file like this;</p>
<pre><code> public static Bitmap GetBitmap( string filename )
{
Bitmap retBitmap = null;
string path = String.Concat( BitmapDir, filename );
if ( File.Exists( path ) )
{
try
{
retBitmap = new Bitmap( path, true );
... | <p>Assuming that you have the images in a folder on your local file system and that you are running under .NET 3.5:</p>
<pre><code>Image[] cards = Directory.GetFiles(cardsFolder).Select(f => Image.FromFile(f)).ToArray();
</code></pre>
<p>One-liners are always nice :-)</p>
| 40,742 |
<p>Can LINQ to SQL query using <strong>NOT IN</strong>? </p>
<p>e.g., SELECT au_lname, state FROM authors WHERE state NOT IN ('CA', 'IN', 'MD')</p>
| <pre><code> List<string> states = new List<string> { "CA", "IN", "MD" };
var q = from a in authors
where !states.Contains(a.state)
select new { a.au_lname, a.state };
</code></pre>
<p>or</p>
<pre><code> var q = authors.Where( a => !states.Contains( a.state ) )
... | <p>Yes! </p>
<p>Here's an example from code we already had written:</p>
<pre><code>
List<long> badUserIDs = new List { 10039309, 38300590, 500170561 };
BTDataContext dc = new BTDataContext();
var items = from u in dc.Users
where !badUserIDs.Contains(u.... | 44,809 |
<p>I'm trying to get a background image of a HTML element (body, div, etc.) to stretch its entire width and height.</p>
<p>Not having much luck. Is it even possible or do I have to do it some other way besides it being a background image?</p>
<p>My current css is:</p>
<pre><code>body {
background-position: left ... | <pre><code><style>
{ margin: 0; padding: 0; }
html {
background: url('images/yourimage.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
</code... | <p>You cannot in pure CSS. Having an image covering the whole page behind all other components is probably your best bet (looks like that's the solution given above). Anyway, chances are it will look awful anyway. I would try either an image big enough to cover most screen resolutions (say up to 1600x1200, above it is ... | 29,188 |
<p>Any ideas on how I can acheive 'Hierarchical' gridview?
Basically I want when the user clicks on the '+', i "expand" and insert new rows without a full page post back. </p>
<p>Does this sound like a lot of AJAX stuff? Or should I read on ASP.NET MVC</p>
<p>Please point me in right direction</p>
| <p>Another way to do this is the old Grid view inside a Grid view Trick. The basic concept is to have the [+] and the parent data as the Item data in a single templated column. Attach the to click event of the button and set your grid to edit/selected mode. when its in edit mode, render a second grid view with the chil... | <p>You have two options I suppose: </p>
<ul>
<li>You can render out those rows you want to insert, and the [+] shows them and hides them</li>
<li>You don't render them out, and they are sent to the browser via AJAX, and then inserted into the table.</li>
</ul>
<p>I've done it both ways, and the more gridviewy way to ... | 37,782 |
<p>Are there any tools available for validating a database schema against a set of design rules, naming conventions, etc.</p>
<p>I'm not talking about comparing one database to another (as covered by <a href="https://stackoverflow.com/questions/165401/how-to-comparevalidate-sql-schema">this question</a>).</p>
<p>I wa... | <pre><code>var obj = jQuery.parseJSON('{"name":"John"}');
alert( obj.name === "John" );
</code></pre>
<p><a href="http://api.jquery.com/jQuery.parseJSON/" rel="noreferrer">See the jQuery API</a>.</p>
| <p>I decode JSON this way:</p>
<pre><code>eval( 'var from_json_object = ' + my_json_str + ';' );
</code></pre>
| 22,045 |
<p>This morning, I tried to commit a revision to Subversion and found that all of a sudden I did not have permission to do so.</p>
<pre>Can't move '/svn/db/txn-protorevs/21000-ga9.rev' to '/svn/db/revs/21/21001':
Permission Denied</pre>
<p>Looking at the revs directory, I noticed that somebody had committed the 21000... | <p>If you have more than one developer accessing the repository through the <code>file://</code> protocol, you may want to look into setting up a Subversion server (using <code>svnserve</code> or Apache). With that solution, the server itself is responsible for all access and permissions on the repository files, and yo... | <p>The most likely cause is like Greg said. Someone is accessing the repository through the file:// protocol and has an overly restrictive <a href="http://en.wikipedia.org/wiki/Umask" rel="nofollow noreferrer">umask</a>.</p>
| 49,618 |
<p>I know they're using a jQuery plugin, but I can't seem to find which one they used. In particular, what I'm looking for is autocomplete with exactly the same functionality as SO's autocomplete, where it will perform an AJAX command with each new word typed in and allow you to select one from a dropdown.</p>
| <p>Note that the tag editor <a href="https://meta.stackexchange.com/questions/100669/feedback-wanted-improved-tag-editor">has been completely re-written now</a>, and no longer resembles the original, simple text box w/ suggestion drop-down that adorned the site for nearly three years. </p>
<p>If you're interested in t... | <p>Have a look at <a href="http://www.iog3.com/322/so_tag-tagging-system-based-on-stackoverflows-tag-search/" rel="nofollow">SO_Tag</a>, a tagging system based on StackOverflows tagging system.</p>
<p>And <a href="https://github.com/iog3/SOTag" rel="nofollow">Github</a>.</p>
| 35,745 |
<p>Is it possible to add comments somehow, somewhere? </p>
<p>I don't pretend to be any sort of expert when using MySQL and certainly don't spend all day in it. More often than I would like I forget how I intend to use a column (usally the bit ones) and would be very excited if I could add a comment to remind me if ... | <p><a href="http://dev.mysql.com/doc/refman/5.0/en/create-table.html" rel="noreferrer">http://dev.mysql.com/doc/refman/5.0/en/create-table.html</a></p>
<pre><code>table_option:
{ENGINE|TYPE} [=] engine_name
| AUTO_INCREMENT [=] value
| AVG_ROW_LENGTH [=] value
| [DEFAULT] CHARACTER SET [=] charset_name
| C... | <p>I just wrote an app for this.</p>
<p>Can be found here:
<a href="https://github.com/SplicePHP/mysql-comments" rel="nofollow">https://github.com/SplicePHP/mysql-comments</a></p>
<p>Allows you to to update multiple database tables and columns in a single view.</p>
<p>Instructions in link.</p>
| 24,378 |
<p>I am writing a data conversion in PL/SQL that processes data and loads it into a table. According to the PL/SQL Profiler, one of the slowest parts of the conversion is the actual insert into the target table. The table has a single index.</p>
<p>To prepare the data for load, I populate a variable using the rowtype ... | <p>It's much better to insert a few hundred rows at a time, using PL/SQL tables and FORALL to bind into insert statement. For details on this see <a href="http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2181" rel="noreferrer">here</a>.</p>
<p>Also be careful with how you construct the P... | <p>Maybe one of your best option is to avoid Oracle as much as possible actually.
I've been baffled by this myself, but very often a Java process can outperform many of the Oracle's utilities which either use OCI (read: SQL Plus) or will take up so much of your time to get right (read: SQL*Loader).</p>
<p>This doesn't... | 17,361 |
<p>Is it possible to have a <code><div></code> simultaneously (1) not take up all available width and (2) collapse margins with its neighbors?</p>
<p>I learned recently that setting a <code>div</code> to <code>display:table</code> will stop it from expanding to take up the whole width of the parent container -- ... | <p>You could wrap the <code>display: table</code> <code>div</code> with another <code>div</code> and put the margin on the wrapper <code>div</code> instead. Nasty, but it works.</p>
<pre><code><p style="margin:100px">This is a paragraph with 100px margin all around.</p>
<div style="margin: 100px">&l... | <p>I would probably just float the div (so that it doesn't take up available width) and then clear the float subsequently if necessary. </p>
<pre><code><p style="margin:100px">This is a paragraph with 100px margin all around.</p>
<div style="border: solid red 2px; float: left;">
This should work.
... | 16,564 |
<p>.Net 3.5 doesn't support tuples. Too bad, But not sure whether the future version of .net will support tuples or not? </p>
| <p>I've just read this article from the MSDN Magazine: <a href="http://msdn.microsoft.com/en-us/magazine/dd942829.aspx" rel="noreferrer">Building Tuple</a></p>
<p>Here are excerpts:</p>
<blockquote>
<p>The upcoming 4.0 release of Microsoft
.NET Framework introduces a new type
called System.Tuple. System.Tuple i... | <p>I'd be surprised - C# is a strongly-typed language, whereas tuples are suited for more dynamically typed languages. C# has been drifting more dynamic as time goes on, but that's syntactic sugar, not a real shift in the underlying data types.</p>
<p>If you want two values in one instance, a KeyValuePair<> is a de... | 18,330 |
<p>When an application is behind another applications and
I click on my application's taskbar icon, I expect the entire application to
come to the top of the z-order, even if an app-modal, WS_POPUP dialog box is
open.</p>
<p>However, some of the time, for some of my (and others') dialog boxes, only the dialog box come... | <p>I know this is very old now, but I just stumbled across it, and I know the answer.</p>
<p>In the applications you've seen (and written) where bringing the dialog box to the foreground did <strong>not</strong> bring the main window up along with it, the developer has simply neglected to specify the owner of the dial... | <p>Is the dialog's parent window set correctly?</p>
<p>After I posted this, I started my own Windows Forms application and reproduced the problem you describe. I have two dialogs, one works correctly the other does not and I can't see any immediate reason is to why they behave differently. I'll update this post if I f... | 7,410 |
<p>I wonder if people (meaning the company/developers) really care about having [SuppressMessage] attributes lying around in the shipping assemblies.</p>
<p>Creating separate configs in the Project files that include CODE_ANALYSIS in Release mode and then yanking it off in the final build seems kind of an avoidable ov... | <p>The SuppressMessage attribute will only be added to your code if the CODE_ANALYSIS preprocessor definition is present during a compile. You can verify this by looking at the definition of the attribute in Reflector.exe. By default this is not defined in Release so it won't affect production code. </p>
<p>Typical... | <p>We have a ton scattered around production code, and we don't particularly care. It doesn't effect perf, and having some crufty looking attribute in a class often gives motivation to remove it if at all possible.</p>
| 43,886 |
<p>I want to use Vim's quickfix features with the output from Visual Studio's devenv build process or msbuild.</p>
<p>I've created a batch file called build.bat which executes the devenv build like this:</p>
<pre><code>devenv MySln.sln /Build Debug
</code></pre>
<p>In vim I've pointed the :make command to that batch... | <p>I have a blog post which walks through all the details of getting C# projects building in Vim, including the error format. You can find it here: <a href="http://kevin-berridge.blogspot.com/2008/09/vim-c-compiling.html" rel="noreferrer">http://kevin-berridge.blogspot.com/2008/09/vim-c-compiling.html</a></p>
<p>In s... | <p>None of these errorformats worked in Visual studio 2009 v9.0.21022.8 professional edition. Using cygwin, had to call devenv from bash which made setting makeprg a little tricky (screw batch files). Also had to tweak my errorformat when devenv splits into multiple processes and proceeds error message with "1>" or "... | 12,671 |
<p>Here is some code I could not get to format properly in markdown, this is straight C code, pasted into the text box with the '4 spaces' format to denote code:</p>
<pre><code>#define PRINT(x, format, ...) \
if ( x ) { \
if ( debug_fd != NULL ) { \
fprintf(debug_fd, format, ##__VA_ARGS__); \
} \
e... | <p>You can also use the HTML tags <pre><code> in succession. I find this easier for pasting code into the window.</p>
<p><pre><code>#define PRINT(x, format, ...)
if ( x )
{
if ( debug_fd != NULL )
{
fprintf(debug_fd, format, ##VA_ARGS);
}
else
{
fprintf(stdout, f... | <pre><code>#define PRINT(x, format, ...)
if ( x )
{
if ( debug_fd != NULL )
{
fprintf(debug_fd, format, ##VA_ARGS);
}
else
{
fprintf(stdout, format, ##VA_ARGS);
}
}
</code></pre>
| 6,432 |
<p>I need to try to lock on an object, and if its already locked just continue (after time out, or without it).</p>
<p>The C# lock statement is blocking.</p>
| <p>Ed's got the right function for you. Just don't forget to call <code>Monitor.Exit()</code>. You should use a <code>try-finally</code> block to guarantee proper cleanup.</p>
<pre><code>if (Monitor.TryEnter(someObject))
{
try
{
// use object
}
finally
{
Monitor.Exit(someObject);
... | <p>Based on <a href="https://stackoverflow.com/a/8557/481626">Dereks answer</a> a little helper method:</p>
<pre><code>private bool TryExecuteLocked(object lockObject, Action action)
{
if (!Monitor.TryEnter(lockObject))
return false;
try
{
action();
}
finally
{
Monitor.E... | 2,999 |
<p>The setTimeout function always seems to give me trouble. Right now I have a function that is recursive (calls itself through setTimeout) and changes the elements height.</p>
<p>The function is sent two arguments: the element to be altered and that elements maximum height. The purpose of the function is to unfold th... | <p>When you do this:</p>
<pre><code>var func_call = 'slide_down(' + element + ', ' + max_height + ');';
</code></pre>
<p>you're converting element to a string, so your timeout will look like</p>
<pre><code>slide_down("[Object]", 100);
</code></pre>
<p>which obviously won't work.</p>
<p>What you should be doing is ... | <p>Two things:</p>
<p><strong>1.</strong> There is an alternate way to call <code>setTimeout()</code> in which you pass the function and parameters, rather than a string to execute. In fact, <a href="https://developer.mozilla.org/en/DOM/window.setTimeout" rel="nofollow noreferrer">the Gecko DOM manual states</a> that ... | 44,379 |
<pre><code>y: &pause
cd ptls5.0 &pause
sdp describe Integration.dpk &pause
z: &pause
cd ptls5.0 &pause
dir &pause
</code></pre>
<p>I have those commands in the 1.cmd file. First three are executed fine. The result of it is that after "sdp describe Integration.dpk &pause" is executed I'm giv... | <p>If sdp is a .cmd or .bat file, change it to "call sdp....."</p>
| <p>Is "sdp" another batch file itself? If so, you will need to use <code>call</code>:</p>
<pre><code>call sdp describe Integration.dpk &pause
</code></pre>
| 20,783 |
<p>I have a database in the following format:</p>
<pre><code> ID TYPE SUBTYPE COUNT MONTH
1 A Z 1 7/1/2008
1 A Z 3 7/1/2008
2 B C 2 7/2/2008
1 A Z 3 7/2/2008
</code></pre>
<p>Can I use SQL to convert it i... | <p>SQL Server 2005 offers a very useful PIVOT and UNPIVOT operator which allow you to make this code maintenance-free using PIVOT and some code generation/dynamic SQL</p>
<pre><code>/*
CREATE TABLE [dbo].[stackoverflow_159456](
[ID] [int] NOT NULL,
[TYPE] [char](1) NOT NULL,
[SUBTYPE] [char](1) NOT NULL,
... | <pre><code>select id,
sum(case when type = 'A' and subtype = 'Z' then [count] else 0 end) as A_Z,
sum(case when type = 'B' and subtype = 'C' then [count] else 0 end) as B_C,
month
from tbl_why_would_u_do_this
group by id, month
</code></pre>
<p>You change requirements more than our marketing team! If you want it to b... | 19,285 |
<p>I work with an application which uses rather big numbers and I need to store data as an unsigned 64-bit integer. I prefer to just store it without worrying about bit manipulation or anything like that so different programs can use the data in different ways. </p>
| <p>You can store the value in a <code>NUMERIC</code> type with a <code>scale</code> of 0, which will retain the <code>integer</code> semantics required. The <code>NUMERIC</code> type will allow negative numbers, although you could set up a constraint to require positive integers.</p>
<p>The maximum <code>precision</c... | <p>AFAIK, You would have to create a custom type. Pointers <a href="http://www.julian-kuiters.id.au/article.php/sqlserver2005-unsigned-integer" rel="nofollow noreferrer">here</a> although that article is more for restricting negative numbers...</p>
| 44,521 |
<p>When creating a UIView with a navigation bar in interface builder, the top bar takes some space, but the view still has the same size. This mean that the bottom of the view is not visible.</p>
<p>Is there a way to get the "visible size" of a UIView? I would like to show a subview at the bottom of the screen, but ... | <p>You should use the 'struts-and-springs' control in IB to set your base view to be full-justified. Then it will auto-resize. Once you do this, you can just use the view.bounds property to access its visible area.</p>
| <p>You should use Ben Gottlieb's solution but in terms of calculating the visible area of a view named "<code>view</code>", you could probably use:</p>
<pre><code>CGRect viewBoundsInWindow =
[[[UIApplication sharedApplication] keyWindow] convertRect:view.layer.visibleRect fromView:view];
</code></pre>
| 42,662 |
<p>I've got a Core Data application that has an Event class, which has a start date and a finish date. It's trivial to bind these to a pair of NSDatePicker widgets, but I wanted to make it work with the NSRangeDateMode available in Leopard.</p>
<p>The NSDatePicker has a pair of methods that deal with timeInterval, bu... | <p>Sadly, no. The timeInterval property of the date picker is not even properly key-value observable. Basically, you're stuck either setting up an action method or using the delegate validation method to receive updates to its value. Also, you'll want to round it off to the nearest multiple of 86400.0 (i.e. the numb... | <p><a href="https://stackoverflow.com/questions/1169097/can-you-manually-implement-cocoa-bindings">1169097</a> explains how to implement custom bindings.</p>
| 46,332 |
<p>Is there a way to get all methods (private, privileged, or public) of a javascript object from within? Here's the sample object:</p>
<pre><code>var Test = function() {
// private methods
function testOne() {}
function testTwo() {}
function testThree() {}
// public methods
function getMethods() {
... | <p>The technical reason why those methods are hidden is twofold. </p>
<p>First, when you execute a method on the Test object, "this" will be the untyped object returned at the end of the anonymous function that contains the public methods per the <a href="http://yuiblog.com/blog/2007/06/12/module-pattern/" rel="nofoll... | <p>If you call getMethods() like that, isn't it static? Surely you'd need to properly init the class for <code>this</code> to work as expected?</p>
<pre><code>var t = new Test();
t.getMethods();
</code></pre>
<p>If that doesn't work, please take a look at the <a href="http://www.iconico.com/workshop/jsSerializer/" re... | 34,700 |
<p>I'm currently searching the internet for a custom thread pool implementation.
I found an implementation which uses IOCP's. I'm wondering what the benefit is, of using them? Do they provide work stealing, or something like that, I could really find an answer...</p>
| <p>IOCP = "IO Completion Port". It is a kernel object built into the Windows OS that is there to give you an intelligent way to manage multithreaded asynchronous IO. </p>
<p>In very simplistic (and a little over-simplified) terms, you tell the IOCP about the IO jobs you want done. It will perform them asynchronously a... | <p>the best benefit using IOCP for a thread pool is, it monitors its threads and if a thread blocks more than 100ms for some reason (including page fault, blocking call etc) it realeses another thread which was waiting due to concurrency limit reached. i dont know internal implementation but i dont think it uses work s... | 49,020 |
<p>I have some cross platform DNS client code that I use for doing end to end SMTP and on windows I can find the current DNS server ip addresses by looking in the registry. On the Mac I can probably use the SystemConfiguration framework as mentioned in the first answer, however the exact method of doing so is not immed... | <p>You can use the <a href="http://developer.apple.com/documentation/Networking/Conceptual/SystemConfigFrameworks/SC_Intro/chapter_1_section_1.html" rel="nofollow noreferrer">SystemConfiguration framework</a>. It's in C.</p>
<p>Update: apparently the rest of the web is harder to use than I thought. Search for the key ... | <p>You could read from /etc/resolv.conf.</p>
| 32,569 |
<p>I want to programmatically verify the status of an application to see if it has crashed or stopped. I know how to see if the process exists in C# but can I also see if it is "Not responding"?</p>
| <p>Everything you need is in System.Diagnostics, for example: to check if a process is responding.</p>
<pre><code>using System;
using System.Diagnostics;
namespace ProcessStatus
{
class Program
{
static void Main(string[] args)
{
Process[] processes = Process.GetProcesses();
... | <p>See <a href="http://discuss.fogcreek.com/dotnetquestions/default.asp?cmd=show&ixPost=6167" rel="nofollow noreferrer">"Not Responding" Message in Windows Form Applicati</a> at Fog Creek Software</p>
| 41,485 |
<p>We have in the process of upgrading our application to full Unicode comptibility as we have recently got Delphi 2009 which provides this out of the box. I am looking for anyone who has experience of upgrading an application to accept Unicode characters. Specifically answers to any of the following questions.</p>
... | <p>Oracle doesn't require you to use <code>nvarchar</code> to store Unicode strings—the server can be configured to store <code>varchar2</code> in UTF-8. If you only supported ASCII before, it should be transparent. That should prevent the need for all the application-side search-and-replace for <code>'</code> to <code... | <p>Damien </p>
<p>I'm not sure how useful your answer is. We have a large 700,000 lines of compiled codebase that was written over the last ten years which contains a large number of sql queries. Most are standardised down to a few functions which are the basis for most of the updates on the database. These can be ... | 10,730 |
<p>I'd like to use Oracle's utl_match.edit_distance function. It supposed to compare two strings and return the <a href="http://en.wikipedia.org/wiki/Levenshtein_Distance" rel="nofollow noreferrer">Levenshtein distance</a>.</p>
<pre><code>select utl_match.edit_distance('a','b') from dual
</code></pre>
<p>returns 1 as... | <p>This seems to be related to the character set. If I run the same test in a 10.2.0.3 and 11.1.0.7 database using ISO8859P15 as the character set, I get a distance of 1 as well. I'm guessing that Oracle is computing the distance in terms of bytes rather than characters in variable-width character sets.</p>
<p>You c... | <p>I agree, it appears to be wrong. However, this package is undocumented by Oracle, so is perhaps unsupported at present.</p>
| 29,712 |
<p>I've got a database which I intend to replicate for backup reasons (performance is not a problem at the moment). </p>
<p>We've set up the replication correctly and tested it and all was fine.</p>
<p>Then we realized that it replicates all the writes to the temporary tables, which in effect meant that replication o... | <p>I've come up with the solution. It makes use of replicate-do-db mentioned by Nick. Writing it down here in case somebody had a similar problem.</p>
<p>The problem with just using replicate-(wild-)do* options in this case (like I said, we use temp tables to repopulate a central table) is that either you ignore temp ... | <p>In MySQL, as of 5.0 I believe, you can do table wildcards to replicate specific tables. There are a number of command-line options that can be set but you can also do this via your MySQL config file.</p>
<pre><code>[mysqld]
replicate-do-db = db1
replicate-do-table = db2.mytbl2
replicate-wild-do-table= database_n... | 14,163 |
<p>I'm playing with ASP.NET MVC for the last few days and was able to build a small site. Everything works great. </p>
<p>Now, I need to pass the page's META tags (title, description, keywords, etc.) via the ViewData. (i'm using a master page).</p>
<p>How you're dealing with this? Thank you in advance.</p>
| <p>Here is how I am currently doing it...</p>
<p>In the masterpage, I have a content place holder with a default title, description and keywords:</p>
<pre><code><head>
<asp:ContentPlaceHolder ID="cphHead" runat="server">
<title>Default Title</title>
<meta name="description" content=... | <p>Put it in your viewdata! Do something like the following...</p>
<p>BaseViewData.cs - this is a viewdata class that all other viewdata classes will inherit from</p>
<pre><code>public class BaseViewData
{
public string Title { get; set; }
public string MetaKeywords { get; set; }
public string MetaDescrip... | 17,376 |
<p>I've noticed that sometimes wrapper scripts will use <code>${1:+"$@"}</code> for the parameters rather than just <code>"$@"</code>.</p>
<p>For example, <a href="http://svn.macosforge.org/repository/macports/trunk/dports/editors/vim-app/files/gvim.sh" rel="noreferrer">http://svn.macosforge.org/repository/macports/tr... | <p>'Hysterical Raisins', aka Historical Reasons.</p>
<p>The explanation from JesperE (or the Bash man page on <a href="https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion" rel="noreferrer">shell parameter expansion</a>) is accurate for what it does:</p>
<ul>
<li>If <code>$1</code> exists and ... | <p>Here are some other clues for a more complete answer...</p>
<p>The usage can concern the shebang line, which has never thoroughly be documented and where a single parameter is often expected.</p>
<p>Thereby it seems to be a workaround if filename contains spaces or exceed allowed length.</p>
<p>From <a href="https:/... | 18,692 |
<p>It finally started to annoy me enough to ask this question: how do I do a basic diff between two revisions of a file in CVS? Usually I want to compare the latest revision and some random old one. I'm using the Eclipse CVS plugin. When I use "compare with->Another branch or version..." from the selected file's (lates... | <p>The answer is to show the file's history using context menu->Team->Show history, then choose two revisions and context menu for the selection->compare with each other.</p>
| <p>There seems to be two main ways:</p>
<p><strong>context menu->Team->Show history</strong></p>
<p>which shows a linear history and you can select and compare between them, however it can be very bloated and hard to read when your project has lots of branches / tags. Personally i have found it less useful than:</p>
... | 9,715 |
<p>I sign up Spring courses tomorrow morning (transferring in to the Computer Science program). Since I'm a transfer student, I get the last pick of leftover classes not already taken. Emphasis on 'last pick' and 'leftover'. It's highly probable that whatever classes I intend on picking tomorrow, I might not even get b... | <p><strong>Selenium</strong> can automate most browser based tasks. <a href="http://selenium.seleniumhq.org/" rel="nofollow noreferrer">http://selenium.seleniumhq.org/</a></p>
<p><strong>The Grinder</strong> comes with a local proxy that can record traffic and is scriptable with Python. <a href="http://grinder.sourcef... | <p><a href="http://services.alphaworks.ibm.com/coscripter" rel="nofollow noreferrer">CoScripter</a> does pretty much exactly what you need.</p>
| 38,573 |
<p>Many of my colleagues use SVN in groups of 1-5 people partly working on the specific project. Half of them are inexperienced students. In fact non of us are real software developers with year-long experience. Most of them use Eclipse and subclipse to read and write their contributions to the SVN repositories.</p>
<... | <p>In my experience, one of the main reasons why so many people are "afraid" of, or don't like, version control is because <strong>they don't understand the underlying concepts and how the system works</strong>. This is, unfortunately, also true for many experienced developers. I know people who have used CVS and Subve... | <p>Try <a href="http://polishlinux.org/apps/subversion-howto/" rel="nofollow noreferrer">this</a>. I found it on an 'SVN for dummies' search and it was described as a 'SVN for Dummies, a guide your grandma can understand' :D</p>
| 16,935 |
<p>Ok I have a web application in 2005,. net 2.0 , I converted it to 2008 .net 3.5.
when i attempt to run it in VS 2008 either debug or release I get the above mentioned error:</p>
<blockquote>
<p>Unable to start program
http:\localhost\MyWebApp</p>
</blockquote>
<p>no other message just this. I can access my pr... | <p>Crazy, but may solve the problem. Try this:
Start without debug (ctrl+F5), and when IE opens, start again in debug mode (F5).
Dont exit from IE, just stop debug in VS2008.</p>
| <p>Did you check the project settings to make sure the web application is still using your local copy of IIS? It may be trying to fire up the VS Web Development Server instead, which is causing you problems.</p>
<p>This could also be flipped, is the project being configured to point to the dev server when it should be... | 39,950 |
<p>How do you submit from a dropdownlist "onchange" event from inside of an ajax form?</p>
<p>According to the following question: <a href="https://stackoverflow.com/questions/364505/how-do-you-submit-a-dropdownlist-in-aspnet-mvc">How do you submit a dropdownlist in asp.net mvc</a>, from inside of an Html.BeginFrom yo... | <p>OK, nearly 2 years later, you probably don't care anymore. Who knows: Maybe others (such as me ;-) do.</p>
<p>So here's the (extremely simple) solution:</p>
<p>In your <code>Html.DropDownList(...)</code> call, change</p>
<pre><code>new { onchange = "this.form.submit()" }
</code></pre>
<p>to </p>
<pre><code>new ... | <p>Can we see your Controller code? You can use Request.IsMvcAjaxRequest() in your controller to return only a portion of data if it is an Ajax Request instead of an entire View. In your View move your form to a PartialView and call<br> <code><br>Html.RenderPartial("viewname");</code></p>
<p>In your Controller:<p>
<co... | 47,947 |
<p>I recently bought a new web server 2008 for our company and require a FTP Hosting site that allows customers to upload files and host websites from our server, The site must have the shopping basket / Monthly rates built in.
If I purchased the correct template that is designed for hosting, How do I get it to work wi... | <p>You spend a lot of time and money developing software that provides that functionality in a manner that a potential customer would go somewhere else.</p>
<p>You can install software like CPanel and others that make managing server functionality a lot easier. You can try third party shopping basket software but you ... | <p>You spend a lot of time and money developing software that provides that functionality in a manner that a potential customer would go somewhere else.</p>
<p>You can install software like CPanel and others that make managing server functionality a lot easier. You can try third party shopping basket software but you ... | 42,236 |
<p>I'm looking for an UPDATE statement where it will update a single duplicate row only and remain the rest (duplicate rows) intact
as is, using ROWID or something else or other elements to utilize in Oracle SQL or PL/SQL?</p>
<p>Here is an example duptest table to work with:</p>
<pre><code>CREATE TABLE duptest (ID ... | <p>Will this work for you:</p>
<pre><code>update duptest
set nonid = 'c'
WHERE ROWID IN (SELECT MIN (ROWID)
FROM duptest
GROUP BY id, nonid)
</code></pre>
| <p>I know that this does not answer your initial question, but there is no key on your table and the problem you have adressing a specific row results from that.</p>
<p>So my suggestion - if the specific application allows for it - would be to add a key column to your table (e.g. REAL_ID as INTEGER).</p>
<p>Then you ... | 30,342 |
<p>I am getting back into a bit more .NET after a few-years of not using it full-time and am wondering what the good unit testing packages are these days.</p>
<p>I'm familiar with NUnit (a few years ago) and have played briefly around with <a href="https://en.wikipedia.org/wiki/IronRuby" rel="nofollow noreferrer">IronR... | <p>There are so many it's crazy. Crazy good, I guess.</p>
<ul>
<li>For the conservative types (me), <a href="http://www.nunit.org/" rel="nofollow noreferrer"><strong>NUnit</strong></a> is still available and still more than capable.</li>
<li>For the Microsoft-types, <a href="http://msdn.microsoft.com/en-us/vstudio/defa... | <p>I like <a href="http://www.mbunit.com/" rel="nofollow noreferrer">MbUnit</a>, er, <a href="http://www.gallio.org/" rel="nofollow noreferrer">Gallio</a>. Most importantly to me is having good tools support inside Visual Studio. For that I use <a href="http://www.jetbrains.com/resharper/index.html" rel="nofollow nor... | 2,406 |
<p>I Have a request for the TOTAL's and subtotals column to be moved to the top/left of columns it represents, and by default SSRS does it on the bottom or right hand side of the columns being totaled. Is there a way to this?</p>
| <p>I found my own solution, when you right click on the tiny green triangle, in the top right hand corner of the sub total column. Then select properties, and you can adjust the "Layout" property.. it has 2 options, Before and After. </p>
| <p>You can just add a row which comes before your set of data, for each field you want to total just give that cell an expression which does a SUM() of that particular field.</p>
| 8,202 |
<p>Most of my users have email addresses associated with their profile in <code>/etc/passwd</code>. They are always in the 5th field, which I can grab, but they appear at different places within a comma-separated list in the 5th field.</p>
<p>Can somebody give me a <strong>regex to grab just the email address</strong... | <p>What about:</p>
<blockquote>
<p>,([^@]+@[^,:]+)</p>
</blockquote>
<p>Where the group contains the email address.</p>
<p><strong>[Updated based upon comment that address doesn't always get terminated by a comma]</strong></p>
| <pre><code>[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
</code></pre>
<p>should catch most emials</p>
| 12,091 |
<p>I want to setup a mechanism for tracking DB schema changes, such the one described in <a href="https://stackoverflow.com/questions/1607/mechanisms-for-tracking-db-schema-changes#1666">this answer</a>:</p>
<blockquote>
<p>For every change you make to the
database, you write a new migration.
Migrations typicall... | <p>in sql server every DDL command that i know of is an up/down pair.</p>
| <p>Other than loss of data, every migration I've ever done is reversible. That said, Rails offers a way to mark a migration as "destructive":</p>
<blockquote>
<p>Some transformations are destructive
in a manner that cannot be reversed.
Migrations of that kind should raise
an ActiveRecord::IrreversibleMigrati... | 15,554 |
<p>The docs say that calling sys.exit() raises a SystemExit exception which can be caught in outer levels. I have a situation in which I want to definitively and unquestionably exit from inside a test case, however the unittest module catches SystemExit and prevents the exit. This is normally great, but the specific ... | <p>You can call <a href="https://docs.python.org/library/os.html#os._exit" rel="noreferrer"><code>os._exit()</code></a> to directly exit, without throwing an exception:</p>
<pre><code>import os
os._exit(1)
</code></pre>
<p>This bypasses all of the python shutdown logic, such as the <code>atexit</code> module, and wil... | <p>You can also use quit, see example below:</p>
<pre><code>while True:
print('Type exit to exit.')
response = input()
if response == 'exit':
quit(0)
print('You typed ' + response + '.')
</code></pre>
| 20,877 |
<p>So I'm trying to take a bilinear interpolation algorithm for resizing images and add in alpha values as well. I'm using Actionscript 3 to do this, but I don't really think the language is relevant.</p>
<p>The code I have below actually works really well, but edges around "erased" regions seem to get darker. Is ther... | <p>You need to multiply each of your r,g,b values by the corresponding alpha before working with them, then divide the values by the final alpha when you're done. It's easy to imagine the effect this will have when one of the pixels has an alpha of zero - each of the r,g,b values will be multiplied by zero, so it won'... | <p>This is one of those areas where the use of pre-multiplied alpha is a huge advantage. With pre-multiplied alpha, you can think of the RGB components of your image as having been pre-composited on black in advance.</p>
<p>This removes many of the troublesome effects associated with any kind of image processing on im... | 45,188 |
<p>I have two Sharepoint lists:
- Assignments
- Activities</p>
<p>The activities list has a lookup field to the assignments list as activities (e.g. monthly review of X) are related to an assignment. </p>
<p>My question is, how would I display other fields from Assignments in a view of Activities using standard Sh... | <p>If you can't use the Data View Web Part from SPD, then I think you are going to have to use a content editor webpart and do this all in javascript. <a href="http://www.cleverworkarounds.com/2008/02/28/more-sharepoint-branding-customisation-using-javascript-part-2/" rel="nofollow noreferrer">intro article</a></p>
| <p>I have figured out a workaround that doesn't use Sharepoint designer but it's a bit of a hack. In MS Access, I linked two tables to each of my Sharepoint lists and created a query which linked them together. I then created an Excel file and put it on the Sharepoint that references the MS Access file (the Excel fil... | 47,089 |
<p>Is there a tool that will show me what applications are writing to the hard drive in real time? I'm thinking something like Task Manager but for I/O. I've got a number of background processes running, and can never tell when Visual Studio is holding everything up, or some other process is hogging the disk (especiall... | <p><a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx" rel="noreferrer">ProcMon</a> from Sysinternals/Microsoft.</p>
| <p>One can retrieve information on processes writing to disk by opening the Windows <code>Task Manager</code> --> <code>Performance</code> --> <code>Resource Monitor</code></p>
<p>Resource Monitor can drill down to disk usage by process:</p>
<p><img src="https://i.stack.imgur.com/JdW2W.png" alt="enter image descripti... | 48,103 |
<p>You'd think it would be easy, but keep reading. I can change many of the styles associated with a resizable JQuery Dialog, but not the handles. The code below isolates the problem. Why does the handle disappear entirely? There must be some logic I'm interfering with in ui.resizable.js, but I don't see it.</p>
... | <p>I was able to get it to work. I couldn't find the line of code my css was in conflict with, but when I added positioning and size related css, things worked. There must be some logic that says, "use the default css unless the programmer has supplied his own". So, while I thought I was appending info, I was someh... | <p>I believe the background of the resizeable borders are set as images, which in CSS stacking is on top of backgrounds. Try setting:</p>
<pre><code>.ui-resizable-n{
background-image:none;
background-color:green;
}
</code></pre>
| 29,372 |
<p>I´m currently writing my own firmware for a custom delta printer. Therefore I also need to read G-code from programs like Slic3r. Even with an small example like an cube I´m struggling to find out where the z-coordinate is hidden in the code. Here is a small example of the code.</p>
<pre><code>; generated by Slic3r... | <p>It isn't hidden at all. It's just that the Z-axis position only changes with each layer change, so the Z coordinate is only passed at layer change. On line 17 of your example G-code, it starts the first layer at Z=0.5mm:</p>
<pre><code>G1 Z0.500 F7800.000
</code></pre>
<p>The next time you should expect Z to appea... | <p>It isn't hidden at all. It's just that the Z-axis position only changes with each layer change, so the Z coordinate is only passed at layer change. On line 17 of your example G-code, it starts the first layer at Z=0.5mm:</p>
<pre><code>G1 Z0.500 F7800.000
</code></pre>
<p>The next time you should expect Z to appea... | 518 |
<p>Question: </p>
<pre><code>((lambda (x y) (x y)) (lambda (x) (* x x)) (* 3 3))
</code></pre>
<p>This was #1 on the midterm, I put "81 9" he thought I forgot to cross one out lawl, so I cross out 81, and he goes aww. Anyways, I dont understand why it's 81.</p>
<p>I understand why <code>(lambda (x) (* x x)) (* 3 3) ... | <p>This needs some indentation to clarify</p>
<pre><code>((lambda (x y) (x y))
(lambda (x) (* x x))
(* 3 3))
</code></pre>
<ul>
<li><code>(lambda (x y) (x y))</code>; call <code>x</code> with <code>y</code> as only parameter.</li>
<li><code>(lambda (x) (* x x))</code>; evaluate to the square of its parameter.</li>
... | <p>The answers posted so far are good, so rather than duplicating what they already said, perhaps here is another way you could look at the program:</p>
<pre><code>(define (square x) (* x x))
(define (call-with arg fun) (fun arg))
(call-with (* 3 3) square)
</code></pre>
<p>Does it still look strange?</p>
| 27,593 |
<p>I have read through several reviews on Amazon and some books seem outdated. I am currently using MyEclipse 6.5 which is using Eclipse 3.3. I'm interested in hearing from people that have experience learning RCP and what reference material they used to get started.</p>
| <p>I've been doing Eclipse RCP development for almost 2 years now. When I first started, I wanted a book for help and many people told me, with Eclipse you're better off using the <a href="http://wiki.eclipse.org/index.php/Rich_Client_Platform" rel="nofollow noreferrer">Eclipsepedia</a> and Google.</p>
<p>However, I ... | <p>I read the <a href="https://rads.stackoverflow.com/amzn/click/com/0321334612" rel="nofollow noreferrer" rel="nofollow noreferrer">book</a> suggested by Thomas and it's really worth reading, although not very up-to-date.</p>
| 2,938 |
<p>Is it possible to create and initialise a <a href="http://msdn.microsoft.com/en-us/library/6918612z(VS.80).aspx" rel="noreferrer"><code>System.Collections.Generic.Dictionary</code></a> object with String key/value pairs in one statement?</p>
<p>I'm thinking along the lines of the constructor for an array of Strings... | <p>Like this:</p>
<pre><code>Dim myDic As New Dictionary(Of String, String) From {{"1", "One"}, {"2", "Two"}}
</code></pre>
| <p>I know this is an old post but this question frequently comes up. If </p>
<p>Here is a way to declare & initialize a dictionary in one statement:</p>
<pre><code>Private __sampleDictionary As New Dictionary(Of Integer, String) From
{{1, "This is a string value"}, {2, "Another value"}}
</code></pre>
| 41,166 |
<p>My printer is ignoring the "Z offset" setting in Cura and the "Bed Z" stored in the printer LCD settings? It has been working before but after a firmware update of my printer, it doesn't work. Even after flashing the previous firmware back "Bed Z" changes no longer affect anything. No m... | <h2>Z offset in Cura</h2>
<p>Z offset in Cura is nothing more than an additional increase/decrease in height calculated throughout the whole file. This does require the installment of a plugin from the Ultimaker Cura "Marketplace" called "Z Offset Setting" by developer "fieldOfView". This ... | <p>I have the same problem. You need to check your G-code to detect where's the problem.</p>
<p>Try comparing the G-code file with different values of the Z offset.</p>
<p>In my case it looks like this:</p>
<p>No offset</p>
<pre><code>;LAYER_COUNT:107
;LAYER:0
M106 S255
G1 F300 Z0.84
G0 F6000 X124.645 Y78.208 Z0.84
;TY... | 1,657 |
<p>What's the best way to deal with a sharded database in Rails? Should the sharding be handled at the application layer, the active record layer, the database driver layer, a proxy layer, or something else altogether? What are the pros and cons of each?</p>
| <p>FiveRuns have a gem named <a href="https://github.com/bpot/data_fabric" rel="nofollow noreferrer">DataFabric</a> that does application-level sharding and master/slave replication. It might be worth checking out.</p>
| <p>To my mind, the simplest way is maintain a 1:1 between rails instances and DB shards.</p>
| 6,583 |
<p>Given the following java enum:</p>
<pre><code>public enum AgeRange {
A18TO23 {
public String toString() {
return "18 - 23";
}
},
A24TO29 {
public String toString() {
return "24 - 29";
}
},
A30TO35 {
public String toStr... | <p>The best and simplest way to do it is like this:</p>
<pre><code>public enum AgeRange {
A18TO23 ("18-23"),
A24TO29 ("24-29"),
A30TO35("30-35");
private String value;
AgeRange(String value){
this.value = value;
}
public String toString(){
return value;
}
public ... | <p>You could try something like the following?</p>
<pre><code>static AgeRange fromString(String range) {
for (AgeRange ageRange : values()) {
if (range.equals(ageRange.toString())) {
return ageRange;
}
}
return null;
}
</code></pre>
<p>Or, as others suggested, using a cachin... | 29,721 |
<p>My keyboard acts flaky when I use a terminal session on OS X (another question?), so using the command line is often frustrating. Other native applications seem fine and don't suffer the same problem. Is there another terminal application that might work better for me?</p>
| <p>As the name ssh reveals: it is meant to be a shell application :)</p>
<p>So there will be no gui or what so ever. If you are just pissed using the terminal ... maybe try <a href="http://www.iterm2.com/" rel="nofollow noreferrer">iTerm 2</a>. Works pretty well ...</p>
| <p>Not really an alternative, but you may simply need to set your character set to the correct setting to get it to not be flaky. For instance if the trouble you are seeing is that your deletes aren't deleting, etc.</p>
<p>Sam</p>
| 13,213 |
<p>I've got several modules containing functions, classes and templates that I keep in a directory called (hah!) 'reuse'. I know the content reasonably well, so to find a particular class or bit of code doesn't take too long, but it is slowly growing in size and I need some sensible method to store them for easy search... | <ul>
<li><strong>Group</strong> the sources by <strong>area of use</strong> (network, security, text processing, etc); best in <strong>directories</strong> for easier browsing.</li>
<li><strong>Tag</strong> functions by adding <strong>keywords</strong> into the source documentation. Use an appropriate comment markup sy... | <p>You can divise all you classes in directories.</p>
<p>What language is for the question? Because .Net you could have a librairy like a DLL divised with namespace.</p>
| 16,967 |
<p>I have set up a version control system using <strong>TortoiseSVN</strong> at my home to manage my pet projects, school projects etc...and it works locally.</p>
<p>Now I need to be able to access my code repository remotely, like from school, so that I will be able to update the source at school from the repository,... | <p>There are various approaches to offer remote access. In your case, the simplest thing might be to set up an <a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-serversetup-svnserve.html" rel="nofollow noreferrer">svnserve server</a>. You can either manually start it with --daemon, or install it as a Win... | <p>Martin is right: it needs to run as a daemon or a registered service. On my machine I use the command svnserve -d in order to start it.</p>
<p>Check out the official SVN book, it has lots of info too:</p>
<p><a href="http://svnbook.red-bean.com/en/1.5/svn-book.html" rel="nofollow noreferrer">http://svnbook.red-bea... | 47,649 |
<p>What do you think is the best way to implement an interactive grid similar to a Sudoku board for a native iPhone application? I did not see an object to fill this need in the SDK.</p>
<p>Should I make a custom control for an individual cell, then initialize as many of them as I need in a grid form?</p>
<p><a href... | <p>For such a completely uniform grid, I would create a subclass of <code>UIView</code> and have it determine which row and column the user has touched using a simple calculation:</p>
<pre>int touchedRow = 9 * touch.x / [self bounds].width;
int touchedCol = 9 * touch.y / [self bounds].width;</pre>
<p>I don't see much... | <p>The grid is a means of viewing contents, not of storing the representation. Ultimately, your grid is made of cells which have contents and therefor your underlying model object is perhaps best embodied by the cell. There are a number of ways to design the underlying storage for a Sudoku game and the bigger challeng... | 39,348 |
<p>In windows XP "FileInfo.LastWriteTime" will return the date a picture is taken - regardless of how many times the file is moved around in the filesystem.</p>
<p>In Vista it instead returns the date that the picture is copied from the camera.</p>
<p>How can I find out when a picture is taken in Vista? In windows ex... | <p>Here's as fast and clean as you can get it. By using FileStream, you can tell GDI+ not to load the whole image for verification. It runs over 10 × as fast on my machine.</p>
<pre><code>//we init this once so that if the function is repeatedly called
//it isn't stressing the garbage man
private static Regex r = new ... | <pre><code> //retrieves the datetime WITHOUT loading the whole image
public static DateTime GetDateTakenFromImage(string path)
{
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
using (Image myImage = Image.FromStream(fs, false, false))
{
Proper... | 21,719 |
<p>I have <code>DataTemplate</code> containing a <code>TextBox</code>. I'm setting this template to a listbox item on a selection.</p>
<p>I'm unable to set focus to textbox in the template. I tried to call MyTemplate.FindName, but it ends up with an Invalid Operation Exception: This operation is valid only on elements... | <p>Since you know the name of the <code>TextBox</code> you want to focus, this becomes relatively easy. The idea is to get hold of the template as it's applied to the <code>ListBoxItem</code> itself.</p>
<p>First thing you want to do is get the selected item:</p>
<pre><code>var item = listBox1.ItemContainerGenerator.... | <p>Jay's 2nd suggestion is neat - and can be more generalised by using <code>UIElement</code> rather than <code>TextBox</code>, so that any control can easily be made the default:</p>
<pre><code>private void FocusControlOnLoad(object sender, RoutedEventArgs e)
{
var uiElement = sender as UiElement;
if(uiElemen... | 42,700 |
<p>Specifically, I want to copy a link (with text and location) and then to be able to paste it, e.g., into Word as a link.</p>
| <p>Here's the actual code:</p>
<pre><code>var richText = "<a href=\"" + gContextMenu.linkURL + "\">" + gContextMenu.linkText() + "</a>";
var xfer = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
xfer.addDataFlavor("text/html");
var htmlStrin... | <p>dig around inside <a href="http://lifehacker.com/software/firefox/download-of-the-day-autocopy-firefox-extension-177806.php" rel="nofollow noreferrer">Download of the Day: AutoCopy Firefox extension</a> or <a href="https://addons.mozilla.org/en-US/firefox/addon/1478" rel="nofollow noreferrer">Clipboard-Save-As 1.0.4... | 26,875 |
<p>In a Web application, is it possible to force a PDF file to be printed on the client? If the browser is configured to open the PDF inside the window, I guess that calling window.print() will work, but some browsers (like mine) are configured to open the PDF externally.</p>
| <p>The way google docs does it is by embedding JavaScript into the PDF that tells Acrobat Reader or any other compliant reader to print it.</p>
<p>You would need a PDF toolkit to do this with a random PDF.</p>
| <p>Do you mean that you want to force the file to be sent to a printer? Are you thinking of the Law of Unintended Consequences -- the user's device isn't connected to a printer? Could be a BlackBerry, could be a laptop on wi-fi. What if the user doesn't want it to go to the default printer? </p>
| 25,136 |
<p>When using Resharper to encapsulate a class's properties, is there a way to get it to do more than one property at a time?</p>
| <p>You might or might not already know this (R# does suffer from a lack of discoverability, unless you get the one-page key-shortcut page printed out), but ALT-INS opens a box which can at least mass-generate properties for fields.</p>
<p>Not sure if that's any use - it's not the same as a retrospective encapsulation.... | <p>I don't think there such a feature out of the box.</p>
<p>However, you could write a RS plugin that does this. But this would be another question...</p>
| 5,588 |
<p>I am trying to comment an API (.Net) that I am exposing to a customer.
I am doing this by using XML comments, and extracting via SandCastle.</p>
<p>This is all fine and dandy, however I have unittesting for the API, and thought the code from these would be good to place in the example tags.</p>
<p>So does anyone k... | <p>I am using NUnit and Sandcastle Help File Builder. Please take a look at Sandcastle Help File Builder documentation about The Code Block Component.</p>
<p>Here is an example how I place unit tests code in the example tag:</p>
<pre><code> /// <summary>
/// Returns a string representation of an object.
... | <p>I see that Jon Skeet har an answer, that requires some work:
<a href="https://stackoverflow.com/questions/301365/automatically-unit-test-example-code#301423">Automatically Unit Test Example Code</a>
Has anyone gone and implemented this?
Is there an easier way?
This question is about getting a metod body from a cs fi... | 42,150 |
<pre><code> for m := 0 to 300 do
if Pos(certain_String, string(arrayitem(m)) <> 0 then
begin
randomize;
x := random(100);
begin
case x of
0..69 : function(m); // 70 percent
70..79 : function(m+1); // 10 percent
80..84 : ... | <p>Changed the code a bit:</p>
<pre><code>randomize;
for m := 0 to 300 do begin
if Pos(certain_String, string(arrayitem(m)) <> 0 then begin
x := random(100);
case x of
0..69 : function(m); // 70 percent
70..79 : function(m+1); // 10 percent
80..84 : function(m+2); // 5 percent
... | <p>There must be an equivalent to C's <code>break</code> in Object Pascal. That's a cleaner way to get out of the loop.</p>
| 48,739 |
<p>I need to get an appointment into someone's Outlook calendar based on requests from their employees. The application runs in SharePoint (WSS 3.0). My first impressions are to use iCal or send meeting requests, but I haven't done either before & I'm looking for a very quick & easy way to get it done. Any idea... | <p>Sorry, there's no easy answer that I know of or can find. I'm sure you can do via code but not easily within the SharePoint point-and-click interface. </p>
<p>From <a href="http://social.msdn.microsoft.com/forums/en-US/sharepointworkflow/thread/155ca2fe-60e7-49d3-81b3-2c8a9f3b9433/" rel="nofollow noreferrer">this... | <p>actually, you can do it. using sharepoint designer, set up a workflow to add item to list (calendar) based upon entries to a list (either new or edit). then, you'll need to sync outlook with the sharepoint calendar.</p>
| 36,009 |
<p>I love the way Mac OS <em>beautifully</em> renders fonts (not just browsers). I was wondering if we could somehow get the same rendering in browsers running on Windows?</p>
<p>Someone recommended sIFR but I guess that's useful when I need to use non-standard fonts?</p>
| <p>Check out <strong>GDI++/FreeType</strong> (<a href="http://free.flop.jp/gdi++/" rel="noreferrer">link</a>, <a href="http://offset.skew.org/wiki/User:Mjb/GDI%2B%2B" rel="noreferrer">link</a>). It's a highly configurable font-rendering replacement for Windows. With some configuration of hinting, anti-aliasing, etc, yo... | <p>You could wait until IE9, which apparently has much better text rendering, using DirectX: <a href="http://blogs.msdn.com/ie/archive/2009/11/18/an-early-look-at-ie9-for-developers.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/ie/archive/2009/11/18/an-early-look-at-ie9-for-developers.aspx</a></p>
| 8,275 |
<p>I am trying to create a StringNameSpaceBinding using the wsadmin tool of Websphere 6.1</p>
<p>Here are the steps i take
set cell [$AdminConfig getid /Cell:cell/]
$AdminConfig create StringNameSpaceBinding $cell { {name bindname} {nameInNameSpace Bindings/string} {stringToBind "This is the String value that gets bo... | <p>I'm betting that the following command:</p>
<pre><code>set cell [$AdminConfig getid /Cell:cell/]
</code></pre>
<p>Doesn't work. Most likely, <code>cell</code> is not the name of your cell.
You don't need to specify a cell name; there's only one cell in the WAS topology. I would change this to:</p>
<pre><code>set ... | <p>I have faced a similar issue and it is now resolved after removing both node and cell name from the following line:</p>
<pre><code>cell = AdminConfig.getid('/Cell:/Node:/Server:WebSphere_Portal/')
</code></pre>
| 18,508 |
<p>The topic generically says it all. Basically in a situation like this:</p>
<pre><code>boost::scoped_array<int> p(new int[10]);
</code></pre>
<p>Is there any appreciable difference in performance between doing: <code>&p[0]</code> and <code>p.get()</code>?</p>
<p>I ask because I prefer the first one, it h... | <p>The only way to know is to actually measure it!</p>
<p>But if you have the source of the boost:scoped_array you could llok at the code and see what it does. I am sure it is pretty similar.</p>
<pre><code>T * scoped_array::get() const // never throws
{
return ptr;
}
T & scoped_array::operator[](std::ptrdif... | <p>Is this a question you're asking just for academic interest or is this for some current code you're writing?</p>
<p>In general, people recommend that code clarity is more important that speed, so unless your sure this is going to make a difference you should pick whichever option is clearer and matches your code ba... | 34,504 |
<p>What are the pros and cons of using <a href="http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html/ch17.html" rel="noreferrer">Criteria</a> or <a href="http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html/ch16.html" rel="noreferrer">HQL</a>? The Criteria API is a nice object-oriented way to express queries ... | <p>I mostly prefer Criteria Queries for dynamic queries. For example it is much easier to add some ordering dynamically or leave some parts (e.g. restrictions) out depending on some parameter. </p>
<p>On the other hand I'm using HQL for static and complex queries, because it's much easier to understand/read HQL. Also,... | <p>HQL can cause <strong>security</strong> concerns like SQL injection.</p>
| 24,032 |
<p>The official documentation seems to be light on explanations of 'how to understand the SproutCore way' e. g., why things are done the way they are, how to intuit what to do from where you're at, etc.</p>
| <p>[Update] Latest resource is <a href="http://wiki.sproutcore.com/" rel="nofollow noreferrer">new wiki</a> .</p>
<p>Which have information on how to start with Version 1.0 Alpha</p>
| <p>There is a GitHub Wiki on sproutcore. They give a good list of howtos and tutorials.<br />
<a href="http://github.com/sproutit/sproutcore/wikis" rel="nofollow noreferrer">http://github.com/sproutit/sproutcore/wikis</a></p>
<p>It is supposed to be a fairly easy javascript framework to learn, but it has its moments.<... | 16,421 |
<p>Does .NET have a way to pull email from a POP3 server out of the box or you have to code/buy a 3rd party component?</p>
| <p>You can check <a href="http://www.limilabs.com/mail" rel="nofollow noreferrer">Mail.dll .NET mail component</a>, it has SSL support, unicode, and multi-national email support:</p>
<pre><code>using(Pop3 pop3 = new Pop3())
{
pop3.Connect("mail.host.com"); // Connect to server
pop3.Login("user", "password... | <p>Check out the EasyMail objects from <a href="http://www.quiksoft.com" rel="nofollow noreferrer">Quiksoft</a>. They are very easy to use and the support is really good.</p>
| 38,279 |
<p>After I downloaded the <a href="http://mobile.google.com" rel="noreferrer">Google Mail</a> and <a href="http://mobile.google.com" rel="noreferrer">Google Maps</a> application into my mobile phone I got an idea about a service that I want to implement.</p>
<p>My problem is that I never did any programming for the mo... | <p>Clicking <a href="http://developers.sun.com/mobility/midp/articles/wtoolkit/" rel="nofollow noreferrer">here</a> would be a pretty good place to start, it's where the best J2ME programmers have started before you...</p>
| <p>I would really recommend looking at Blackberry as a target platform to play with, for the following reasons:</p>
<ul>
<li>Lots of documentation</li>
<li>Access to cheap devices for testing</li>
<li>No walled garden (approval system or closed marketplace), you can distribute your app via over the air downloads (user... | 48,591 |
<p>In a brand new program where space isn't really that big a deal, is it better to delete a row or to disable a row by let's say a boolean "Disabled" and have the program just ignore it?</p>
<p>For example, if I wanted to remove a user from a program.</p>
| <p>It depends. (But you guessed that already, I'm sure.) </p>
<p>In practice, the violation of proper usage here is almost always in the direction of deleting. </p>
<p>The main bad consequence of deleting is how often there are dependent records in other tables whose referential integrity is lost when the parent re... | <p>It's a judgment call, but I have ended up adding "disabled" columns on tables where I previously thought I could just delete row. I'd say most of the time you're safer adding a disabled column. This can get tricky with n:n relations however, so that's something to consider.</p>
| 45,171 |
<p>I saw this signature on the ListView class:</p>
<pre><code>public ListView..::.ListViewItemCollection Items { get; }
</code></pre>
<p>When I saw that, "What?!"</p>
<p>I searched "dot dot colon colon dot" and "..::." on Google with no result.</p>
<p><img src="https://i.stack.imgur.com/av0FO.png" alt="alt text"></... | <p>That's not C#; that's JScript. In C#, it would be:</p>
<p>public ListView.ListViewItemCollection Items { get; }</p>
<p>It's a little different because ListViewItemCollection is an inner class of ListView.</p>
<p>I'm guessing that you saw this looking at <a href="http://msdn.microsoft.com/en-us/library/system.wind... | <p>ListViewItemCollection is a nested type of ListView, which means that in the code, the Collection class is defined inside of the ListView definition, like so:</p>
<pre><code>public class ListView {
public ListViewItemCollection Items {get;}
public class ListViewItemCollection : IList {
// more code here
... | 40,870 |
<p>I have a somewhat complex WPF application which seems to be 'hanging' or getting stuck in a Wait call when trying to use the dispatcher to invoke a call on the UI thread.</p>
<p>The general process is:</p>
<ol>
<li>Handle the click event on a button</li>
<li>Create a new thread (STA) which: creates a new instance ... | <p>Invoke is synchronous - you want Dispatcher.BeginInvoke. Also, I believe your code sample should move the "SetValue" inside an "else" statement.</p>
| <p>I know this is an old thread, but here is another solution.</p>
<p>I just fixed a similar problem. My dispatcher was running fine, so...</p>
<p>I had to show the DEBUG -> THREAD WINDOW to identify all the threads that are executing my code anywhere.</p>
<p>By checking each of the threads, I quickly saw which thre... | 33,082 |
<p>Is there any good book or material which covers C# unit testing using mocks in depth?</p>
| <p>How about <a href="http://www.manning.com/osherove/" rel="nofollow noreferrer">The Art of Unit Testing</a>. This is .NET specific, and should be fairly up to date.</p>
| <p>I've found the following articles (especially the first one) from Stephen Walter pretty useful.</p>
<p><a href="http://weblogs.asp.net/stephenwalther/archive/2008/06/11/tdd-introduction-to-moq.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/stephenwalther/archive/2008/06/11/tdd-introduction-to-moq.aspx</a>
<... | 24,538 |
<p>I've to create a Web Based Application, that amongst other things, includes the following tasks</p>
<ul>
<li>Loading a 3D model from a database.</li>
<li>Display the 3D Model.</li>
<li>Doing Inverse Kinematics computations to generate the series of steps for the model to move from an initial to final position.</li>... | <p>If it is a webapp, you should look into Papervision3D (<a href="http://papervision3d.org/" rel="nofollow noreferrer">http://papervision3d.org/</a>) for a Flash-based approach (that would be the way if you want it to be relatively platform-independent).</p>
| <p>There are a number of approaches to this. Some that come to my mind:</p>
<ul>
<li>consider delivering it as an ActiveX component (fastest, but Win32 only).</li>
<li>consider using .NET (Silverlight) (Win32, OSX, *nix in the foreseable future through Moonlight; DirectX/Direct3D only) </li>
<li>consider using Java, w... | 38,718 |
<p>I am writing an application using the <a href="http://en.wikipedia.org/wiki/Microsoft_Enterprise_Library" rel="nofollow noreferrer">Microsoft Enterprise Library</a>. I wrote a wrapper DLL for that Enterprise Library DLL file. I want to use my wrapper in some <a href="http://en.wikipedia.org/wiki/Windows_Forms" rel=... | <p>Assembly references are not transitive.</p>
<p>If you reference and call assembly A, which references assembly B, you don't automatically get a reference to assembly B. If your interaction with A requires types from B, you'll need to refer to B, too.</p>
| <p>You must specify the library you use (and only then it searches it in the local folder and the GAC)</p>
<p>References are not "inherited" and as it is dynamically linked (and not included as part of your dll) they will be opened when needed.</p>
| 40,279 |
<p>I am developing a site that makes extensive use of JavaScript (jQuery). I regularly get the IE 'Stop running this script?' error dialog when I try to close the browser. </p>
<p>I'm guessing the problem occurs because the site is a single page that uses AJAX, so there are no postbacks to reset IE's count of commands... | <p>Do you by chance use a window.onunload handler? If you do, you might check that you don't have an infinite loop in there.</p>
<p>To check, at the bottom of your javascript do:</p>
<pre><code>window.onunload = null;
</code></pre>
<p>and test again.</p>
| <p>May also consider split the long operation into $(document).ready() and $(window).load()</p>
| 38,023 |
<p>my ruby (on rails) class looks like:</p>
<p>class Foo
def self.method1
someAction
end</p>
<p>def self.method2
someAction
end</p>
<p>def someAction
//doSmth
end
end</p>
<p>any ideas how to make this work or achieve the same behavior some other way?</p>
<p>thanks!</p>
| <p>If some_action is appropriate as a class method, I'd do it like this:</p>
<pre><code> class Foo
def self.method1
some_action
end
def self.some_action
# do stuff
end
def some_action
self.class.some_action
end
end
</code></pre>
<p>If method1 is supposed to be a convenience method, t... | <p>You cannot call an instance method from a class method, without an actual instance of the class itself. You can do it as such:</p>
<pre><code>class Foo
def self.method1
myFoo = Foo.new
myFoo.someAction
end
def someAction
//doSmth
end
end
</code></pre>
| 49,093 |
<p>What is the best compiler to experiment with C++0x features? I have been experimenting with GNU g++ 4.4. </p>
| <p>Definitely <strong>GCC Trunk</strong>. <strong>ConceptGCC</strong> misses many features GCC trunk has. It is being merged into GCC currently though. It has all these features, including the new <code>auto</code>-typed variables (no new function declaration syntax yet though): <a href="http://gcc.gnu.org/projects/cxx... | <p><a href="http://www.generic-programming.org/software/ConceptGCC/" rel="nofollow noreferrer">ConceptGCC</a> <a href="http://en.wikipedia.org/wiki/ConceptGCC" rel="nofollow noreferrer">(wiki)</a> was made for that purpose, if I am not mistaken.</p>
| 35,207 |
<p>When learning a new programming language, one of the possible roadblocks you might encounter is the question whether the language is, by default, <em>pass-by-value or pass-by-reference</em>.</p>
<p>So here is my question to all of you, in your favorite language, <em>how</em> is it actually done? And what are the <e... | <p>Here is my own contribution for the <a href="http://en.wikipedia.org/wiki/Java_(programming_language)" rel="nofollow noreferrer">Java programming language</a>.</p>
<p>first some code:</p>
<pre><code>public void swap(int x, int y)
{
int tmp = x;
x = y;
y = tmp;
}
</code></pre>
<p>calling this method will res... | <p>By default, ANSI/ISO C uses either--it depends on how you declare your function and its parameters.</p>
<p>If you declare your function parameters as pointers then the function will be pass-by-reference, and if you declare your function parameters as not-pointer variables then the function will be pass-by-value.</p... | 2,423 |
<p>I own an image hosting site and would like to generate one popup per visitor per day. The easiest way for me to do this was to write a php script that called subdomains, like ads1.sitename.com
ads2.sitename.com</p>
<p>unfortunatly most of my advertisers want to give me a block of javascript code to use rather than... | <p>I doubt you'll find much sympathy for help with pop-up ads.</p>
| <p>At the risk of helping someone who wants to deploy popup ads (which is bound to fail due to most popup blockers anyway), why can't you just have the subdomains load pages that load the block of Javascript the advertisers give you?</p>
| 11,239 |
<p>I have a self-developed program which I want to use as the default opening tool for .jpg and .bmp files. How can I achieve the goal progrmmatically? </p>
<p>Some said that I have to add some registry entries. But I don't konw exactly what I should do. Can anyone tell me the method?</p>
<p>Thank you!</p>
| <p>If it's Windows:</p>
<p><a href="http://www.codeproject.com/KB/shell/cgfiletype.aspx" rel="nofollow noreferrer">CodeProject.com</a></p>
| <p>You have to change these registry entries (for Windows, .REG syntax):</p>
<pre><code>[HKEY_CLASSES_ROOT\.txt]
@="textfile"
[HKEY_CLASSES_ROOT\textfile\shell\open\command]
@="C:\\WINDOWS\\NOTEPAD.EXE %1"
[HKEY_CLASSES_ROOT\textfile\shell\print\command]
@="C:\\WINDOWS\\NOTEPAD.EXE /p %1"
[HKEY_CLASSES_ROOT\textfil... | 40,439 |
<p>I'm looking at using OpenID for my authentication scheme and wanted to know what the best .NET library is to use for MVC specific applications?</p>
<p>thx</p>
| <p><a href="http://code.google.com/p/dotnetopenid/" rel="nofollow noreferrer">.Net OpenID project</a> is the best library to use right now that I know of. I think SO used it also. The source includes a sample ASP.NET MVC project using the library.</p>
<p>Scott Hanselman did a <a href="http://www.hanselman.com/blog/T... | <p>We have been using .Net Open Id project and are pretty happy with it so far. Andrew Arnott does a great work of answering the queries and suggesting workarounds if you are struck. Give it a try and you will love it :)</p>
| 7,154 |
<p>Sometimes when I'm editing page or control the .designer files stop being updated with the new controls I'm putting on the page. I'm not sure what's causing this to happen, but I'm wondering if there's any way of forcing Visual Studio to regenerate the .designer file. I'm using Visual Studio 2008</p>
<p><strong>E... | <p>If you open the .aspx file and switch between design view and html view and
back it will prompt VS to check the controls and add any that are missing to
the designer file.</p>
<p>In VS2013-15 there is a <strong>Convert to Web Application</strong> command under the <strong>Project</strong> menu. Prior to VS2013 th... | <ol>
<li>replace your custom tag with a invalid tag name. Save it</li>
<li>restore the invalid tag name back to custom tag name. Save it. Then you will be prompted to checkout the *.designer.cs files(or silently modify the designer.cs) and produce correct variable of custom tag control.</li>
</ol>
| 6,717 |
<p>I'm using Eclipse 3.4 (on Mac) and I've got an annoyance with the text comparison having the files I'm comparing in a specific order which is not what I want.</p>
<p>When I compare two files it always seems to put the first file (alphabetically) on the left, and the latter one on the right, but I want to be able to... | <p>Yes, that's actually very annoying. We use an external tool called Beyond Compare (we have a corporate licence) which can swap the two sides easily.</p>
<p>What you should probably do is raise an enhancement request on the relevant Eclipse team with Bugzilla. If there's enough demand, it'll either make it into th... | <p>There's a "Swap From and To" button when the Compare screen comes up. Using Eclipse 3.6. I'm actually looking for a way to change default behavior. For example, when I compare revisions, it always have the latest revision on the left side instead of right unless I click the swap button before comparing. </p>
| 12,505 |
<p>Dictionaries unlike lists are not ordered (and do not have the 'sort' attribute). Therefore, you can not rely on getting the items in the same order when first added. </p>
<p>What is the easiest way to loop through a dictionary containing strings as the key value and retrieving them in ascending order by key?</p>
... | <p>Do you mean that you need the values sorted by the value of the key?
In that case, this should do it:</p>
<pre><code>for key in sorted(d):
print d[key]
</code></pre>
<p><strong>EDIT:</strong> changed to use sorted(d) instead of sorted(d.keys()), thanks <a href="https://stackoverflow.com/users/1694/eli-courtwri... | <pre><code>>>> d = {'b' : 'this is b', 'a': 'this is a' , 'c' : 'this is c'}
>>> for k,v in sorted(d.items()):
... print v, k
...
this is a a
this is b b
this is c c
</code></pre>
| 7,891 |
<p>Currently I'm doing something like this in markup </p>
<pre><code><input type="text" ONKEYPRESS="InputNumeric(event);" id="txtNumber" />
</code></pre>
<p>But I want to use the jQuery bind method instead for all the obvious reasons.</p>
<pre><code>jQuery(function($)
{
$("#txtNumber").bind("keyup", InputN... | <pre><code>jQuery(function($)
{
$("#txtNumber").bind("keyup", function(event) {InputNumeric(event);});
});
</code></pre>
| <p>looks like InputNumeric is an existing function that takes an event as parameter, In that case this should also work</p>
<p><code>
$("#txtNumber").bind("keyup",InputNumeric);
</code></p>
| 44,722 |
<p>I have been trying to explain the difference between switch statements and pattern matching(F#) to a couple of people but I haven't really been able to explain it well..most of the time they just look at me and say "so why don't you just use if..then..else".</p>
<p>How would you explain it to them? </p>
<p>EDIT! T... | <p>Having formerly been one of "those people", I don't know that there's a succinct way to sum up why pattern-matching is such tasty goodness. It's experiential.</p>
<p>Back when I had just glanced at pattern-matching and thought it was a glorified switch statement, I think that I didn't have experience programming w... | <p>Perhaps you could draw an analogy with strings and regular expressions? You describe <em>what</em> you are looking for, and let the compiler figure out <em>how</em> for itself. It makes your code much simpler and clearer.</p>
<p>As an aside: I find that the most useful thing about pattern matching is that it enco... | 24,380 |
<p>I tend to use <a href="http://en.wikipedia.org/wiki/SQLite" rel="noreferrer">SQLite</a> when doing <a href="http://en.wikipedia.org/wiki/Django_(web_framework)" rel="noreferrer">Django</a>
development, but on a live server something more robust is
often needed (<a href="http://en.wikipedia.org/wiki/MySQL" rel="noref... | <p><strong>Update:</strong> <a href="http://django-configurations.readthedocs.org/en/latest/" rel="noreferrer">django-configurations</a> has been released which is probably a better option for most people than doing it manually.</p>
<p>If you would prefer to do things manually, my earlier answer still applies:</p>
<p... | <p>In fact you should probably consider having the same (or almost the same) configs for your development and production environment. Otherwise, situations like "Hey, it works on my machine" will happen from time to time.</p>
<p>So in order to automate your deployment and eliminate those WOMM issues, just use <a href=... | 11,385 |
<p>I am about to start a web project and have been working almost exclusively with a LAMP stack for the past 5 years. I would like to build something larger and more scalable and hence have been looking into Java EE. The division of logic between JSP and EJB seems ideal for what I want to do.</p>
<p>Can anyone recom... | <p>I strongly recommend starting with a good book. This is a complex topic and even an experienced developer needs some help to get started. </p>
<p>I also recommend to get familiar with non Sun technologies right for the beginning. Database persistence is much easier with frameworks such as Hibernate and iBatis than ... | <p>I think given your background in Linux and MySQL, the best place to start would be Java's <a href="http://java.sun.com/products/servlet/" rel="nofollow noreferrer">Servlet API</a>. Java Servlets are the basic unit in Java EE for handling HTTP requests and responses on the server side. In most of the Java EE work t... | 37,146 |
<p>We're currently replacing all special characters and spaces in our URLs with hypens (-). From an SEO and readability point-of-view this works fine. However, in some cases, we are feeding parts of the URL into a search after stripping the hyphens out. The problem occurs when the search term <em>should</em> have hyphe... | <p>Would ~ (<a href="http://en.wikipedia.org/wiki/Tilde" rel="nofollow noreferrer">tilde</a>) work?</p>
<p>Edit: Google now treats <a href="http://news.cnet.com/8301-10784_3-9748779-7.html" rel="nofollow noreferrer">underscores and dashes as word separators</a> so you can use dashes as dashes and underscores as space... | <p>Why not use Url Encoding? Most frameworks have built in utilities to do this.</p>
| 34,010 |
<p>its out of question that a dao will not hold any state.</p>
<p>however, for easiest access to the class, is it better to use prototype( = new every time) or singleton?</p>
<p>simple object creation is cheap for dao's.. it typically only holds a sessionfactory,
accessing the object from a list of singletons may be ... | <p>If your question is about <strong>architecture</strong>, I'd go with scoping DAOs to the <strong>Unit of Work</strong> or Transaction you are doing. This <strong>reduces</strong> the potential for <strong>cross-transaction pollution</strong> and <strong>threading-issues</strong>.</p>
<p>If your question is about <s... | <p>i have come to the conclusion that there is no "perfect" way of deciding this. singleton scope is most likely the wrong way of doing it in a web app, since you will have different sessions - one per request. so in a webapp - request scope may be the correct answer, but only if you are using it exclusively in request... | 24,540 |
<p>I have a tool that I want to install on my main development box (Windows Server 2008). The installer tells me that it requires Vista. Of course I'm not saying Server 2008 is Vista, but I figure something that installs on Vista should be able to install on Server 2008. </p>
<p>Is there some way (perhaps via a tempor... | <p><a href="http://www.win2008workstation.com/wordpress/2008/03/29/installing-unreal-tournament-3/" rel="nofollow noreferrer">Win2008Workstation has an example guide</a> of how to use Orca to patch an MSI file.</p>
| <p>Have you tried the emulator for running the install, when right clicking and going in to the properties of the installer?</p>
<p>right click > properties > compatiblity > and change the compatibility mode to Windows XP or Windows Server 2003</p>
| 42,906 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.