input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
.NET referenced assemblies - version numbers <p>I've recently taken over a project, and the original developer has gone. I'm now trying to install the app on a new server, and I've got a problem with dependent assembly versions.</p>
<p>The project is a reporting tool, with (unfortunately) a reference to Crystal. On my... | <p>It comes from the references in the vs. project file. Open the project file in a text editor and check it out. Anyway, to fix re-add the references in the visual studio.</p>
|
Why does Unity's RegisterInstance<...> cause Unity to return multiple instances? <p>Unity's documentation says of the RegisterInstance<> method that registers an instance so that <strong>that particular instance is returned everytime Resolve<> is called</strong>. </p>
<p>However, this example below shows that ea... | <p>You have configured your container with IValidator so you will have to resolve using IValidator instead of Validator:</p>
<pre><code>Validator validator1 = new Validator();
IUnityContainer container = new UnityContainer();
container.RegisterInstance<IValidator>(validator1);
Validator validatorCopied = vali... |
OneWayToSource binding from readonly property in XAML <p>I'm trying to bind to a <code>Readonly</code> property with <code>OneWayToSource</code> as mode, but it seems this cannot be done in XAML:</p>
<pre><code><controls:FlagThingy IsModified="{Binding FlagIsModified,
Elem... | <p>Some research results for OneWayToSource...</p>
<p>Option # 1.</p>
<pre class="lang-cs prettyprint-override"><code>// Control definition
public partial class FlagThingy : UserControl
{
public static readonly DependencyProperty IsModifiedProperty =
DependencyProperty.Register("IsModified", typeof(b... |
Select item from a string of items <p>I have a string of email recipients in the format like this:</p>
<pre><code> DECLARE @recipients VARCHAR(MAX);
....
PRINT @recipients;
/* the result
person1@yahoo.com;person2@hotmail.com;person1@yahoo.com;...
*/
</code></pre>
<p>"SELECT DISTIECT ..." is a simple and powerful... | <p>Here's a solution for you that uses a temporary table.</p>
<pre><code>declare @emails varchar(2000)
set @emails = 'person1@yahoo.com;person2@hotmail.com;person1@yahoo.com;'
declare @results table (row int identity(1,1), email varchar(500))
while ((select charindex(';',@emails)) > 0)
begin
insert into @r... |
winforms newbie trying to get into wpf, looking for resources <p>I am brand new in the world of Wpf, and am thinking it's time to get into it for my next project. </p>
<p>I'm a hardcore Winforms guy. Many of my projects perform tons of custom drawing - for example drawing a virtual baseball strike zone and then draw... | <p>I also come from a WinForms background and the best book I've found is "Windows Presentation Foundation Unleashed" by Adam Nathan. </p>
<p>Amazon: <a href="http://rads.stackoverflow.com/amzn/click/0672328917" rel="nofollow">http://www.amazon.com/Windows-Presentation-Foundation-Unleashed-WPF/dp/0672328917</a></p>
... |
How to get Unity's automatic injection to work on interface injected constructors? <p>The Unity documentation states:</p>
<blockquote>
<p><em>if a class that developers instantiate
using the Resolve method of the Unity
container has a constructor that
defines one or more dependencies on
other classes, <stron... | <p>I've never used Unity, but every other DI framework I know does that and I'm sure Unity must do that too. </p>
<p>Have you tried changing the Customer constructor and seeing if it works? Cos it should.</p>
|
Recent Windows Updates and Credentials <p>Hi I recently applied Windows Updates to my server and all of a sudden most of my applications which have credentials such as DefaultNetworkCredentials or hard-coded username/passwords have stopped working. I am unable to get these functioning... is this a known issue? Any wo... | <p>Here is your approach:</p>
<ul>
<li>figure out what is not working</li>
<li>figure out what was installed during the update</li>
<li>figure out which of the updated components caused the problem</li>
<li>take steps to either roll-back the update or fix your application</li>
</ul>
|
WPF - Creating a custom ItemsControl <p>I'm looking into creating custom controls for WPF and I've found some reasonably useful blogs and such that vaguely go into enough detail but I'm still struggling a bit.</p>
<p>Basically, what I'm trying to create is something akin to the infamous 'Coda Slider' but i just don't ... | <p>Building a <strong>custom WPF control</strong> is nothing more than writing a class and inheriting the class from a base class that is provided in WPF.</p>
<p><a href="http://nayyeri.net/blog/how-to-create-a-custom-wpf-control/" rel="nofollow">How to Create a Custom WPF Control</a></p>
|
Web site reports xxx does not exist in current context after upgrade to VS2008 Sp1 <p>I just upgraded to VS2008 Sp1, and I have a weird issue going on. I get a lot of errors from my code behind pages indicating that a control doesn't exist in the current context and I am also getting an errors that the pages do not hav... | <p>Check to make sure you are targeting the correct version of the .NET Framework. You can view this in the properties of the Solution file.</p>
<p>VS2008 allows you to target multiple framework versions.</p>
<p>Also check the Web.config, I know there can be differences between VS Web Developer and VS Standard/Pro wi... |
Interactive services dialog detection in Windows Vista <p>I have installed cc.net 1.4.3 version on Windows Vista. But It keeps giving me Interactive services dialog detection when I execute tests. I even have disabled the interactive services from services panel. but still getting this.</p>
<p>Any idea how to get rid ... | <p>No easy fix that you can do. The service is trying to pop up UI on the user desktop. In XP this worked because services and the first user log on both run in session 0. In Vista, services run in session 0 and the first user runs in session 1, so there is no way for a service to directly show UI to the user. This... |
Extract substring from string with Regex <p>Imagine that users are inserting strings in several computers.</p>
<p>On one computer, the pattern in the configuration will extract some characters of that string, lets say position 4 to 5.
On another computer, the extract pattern will return other characters, for instance,... | <p>Why do you want to use regex for this? What is wrong with:</p>
<pre><code>string foo = s.Substring(4,2);
string bar = s.Substring(s.Length-3,3);
</code></pre>
<p>(you can wrap those up to do a bit of bounds-checking on the length easily enough)</p>
<p>If you really want, you could wrap it up in a <code>Func<st... |
What are the advantages of using generics in method signatures? <p><strong>(Thanks everyone for the answers, <a href="http://stackoverflow.com/questions/659232/it-this-an-example-of-the-single-responsibility-principle">here is my refactored example</a>, in turn another StackOverflow question about the Single Responsibi... | <p>A primary reason is the type safety at compile time. If you are passing two <code>Type</code> objects you are placing the responsibility at the developer instead of the compiler.</p>
<p>This is also why many IoC containers utilizes it, as your compiler will complain if an concrete type isn't inheriting the abstract... |
Passing stored procedure to sp_send_dbmail <p>I am using sp_send_dbmail in SQL Server 2008 to send out the results of a query. I moved the query into a proc and am trying to use the proc in the sp_send_dbmail prcedure like so:</p>
<pre><code>EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'myprofile',
@from_address ... | <p>You need to add the database context:</p>
<pre><code>@execute_query_database = 'MyDatabaseName',
</code></pre>
<p>I just ran this with no problems against AdventureWorks2008:</p>
<pre><code>EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'DBMail',
@recipients = 'mitch@domain.com',
@query = 'exec dbo.uspG... |
PHP Get Rid of Nasty \n Squares <p>Hardest problem to explain:</p>
<pre><code>$lol = "hello";
$that = "* music
* books
* games
* asos
* cry";
$lol = str_replace("*", $line, $that);
$name = str_replace(" ", "-", $line);
$myFile = "output/$name.csv";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = ... | <p>In the mists of pre-history, the Windows Folk, Mac Folk, and Unix folk couldn't agree on what character(s) should denote the end of a line. On classic Mac OS, it was a carriage return (\r). On Unix, it was a newline (\n). On windows, it was a carriage return followed by a newline (\r\n).</p>
<p>Historically speak... |
Visual SVN Specify URL with new port <p>Our SVN server was initially setup to run on port 443, we had to change it to run on port 8443 because it was causing conflicts with IIS.</p>
<p>My question is how do I change the repository URL of all my projects to point to the new address? </p>
| <p>select your projects folder click realocate in the subversion menu and add the new address</p>
|
RegisterDeviceNotification Returns NULL but notifications still recieved <p>I'm using RegisterDeviceNotification to watch for changes to a USB device, using the WM_DEVICECHANGE event. However, when I call RegisterDeviceNotification() it returns NULL for the notification handle, which should indicate that it failed. B... | <ol>
<li><p>Make sure you are not making another Win32 API call between <code>RegisterDeviceNotification</code> and <code>GetLastError</code>.</p></li>
<li><p>Check the value of <code>devBrHdr.dbch_hdevnotify</code>. It should contain the same handle returned by <code>RegisterDeviceNotification</code>.</p></li>
<li><p>... |
EntLib 4.0: Exception Handling Application Block <p>I'm just starting to use the Enterprise Library Exception Handling block.</p>
<p>It seems a little cumbersome. </p>
<p>Do I really have to do </p>
<pre><code> try
{
//Do something with a DirectoryInfo object
}
catch(DirectoryNotFoundException ex)
{
bool... | <p>How many places do you need to handle exceptions?</p>
<p>This Application Block is mainly used for handling exceptions on the boundaries of layers. For instance, the top-level code of your Data Access Layer might use this so you can configure whether and how to log DAL exceptions, whether to wrap a non-DAL exceptio... |
Url Hash with Html Base Tag <h2>window.location.hash</h2>
<p>When using a link for a javascript action, I usually do something like this:</p>
<pre><code><a href="#">Link Text</a>
</code></pre>
<p>That way, when someone clicks the link before the page loads nothing terrible happens.</p>
<h2>Html Base Tag... | <p>Either remove your <code>base</code> tag or change your <code>href</code> attributes to be fully qualified. What you are observing is the intended behavior when you mix <code>base</code> with <code>a</code> elements.</p>
|
Ruby on Rails ActiveRecord conditional validation (and more..) <p>I have a <strong>Product</strong> model which validates multiple attributes (including a Paperclip image attachment) like so:</p>
<pre><code>validates_presence_of :name
validates_format_of :name, :with => /^([a-zA-Z0-9\ \-]{3,128})$/i
...
has_attache... | <p><a href="http://railscasts.com/episodes/41-conditional-validations" rel="nofollow">Railscasts</a> have a nice video screencast about conditional validations.</p>
|
Why is there a special new and delete for arrays? <p>What is wrong with using <code>delete</code> instead of <code>delete[]</code>?</p>
<p>Is there something special happening under the covers for allocating and freeing arrays?</p>
<p>Why would it be different from <code>malloc</code> and free?</p>
| <p>Objects created with <code>new[]</code> must use <code>delete[]</code>. Using delete is undefined on arrays.</p>
<p>With malloc and free you have a more simple situation. There is only 1 function that frees the data you allocate, there is no concept of a destructor being called either. The confusion just comes i... |
<h2> background-color is not changing with Jquery? <p>I have an h2 element with an id of title and I have the following script:</p>
<pre><code><script type="text/javascript">
$(document).ready(function(){
$("#title").css("background-color","red");
)};
</script>
</code></pre>
<p>The background-colo... | <p>Replace</p>
<pre><code><link type="text/javascript" src="/js/jquery-1.3.2.min.js"/>
</code></pre>
<p>with</p>
<pre><code><script type="text/javascript" src="/js/jquery-1.3.2.min.js"></script>
</code></pre>
<p>You also have a syntax error in your jQuery function at the closing brackets. They sh... |
Tools and tutorials for examining the gen 2 heap <p>So you're at that time in your project when looking at Performance monitor, wondering "why is my gen 2 heap so large??"</p>
<p>That's where I am, currently. I'm interested in tools and tutorials for examining the contents of the gen 2 heap (and, by extension, gen 1... | <p>You could try the <a href="http://memprofiler.com/OnlineDocs/default.htm?turl=introduction.htm" rel="nofollow">.NET Memory Profiler</a>. It has the ability to track <a href="http://memprofiler.com/OnlineDocs/default.htm?turl=heaputilizationtracker.htm" rel="nofollow">heap space utilization</a>.</p>
|
Java stack trace on Windows <p>I need to get a stack trace for a JVM process running on a client machine that uses windows.</p>
<p>The client has the JRE installed but not the JDK. </p>
<p>I want to use JStack but it is not installed and we can't install a JDK on the client's machine. I also tried using AdaptJ stack... | <p>You probably want to use <a href="http://www.latenighthacking.com/projects/2003/sendSignal/">SendSignal</a>, which was designed for exactly this purpose.</p>
|
Does this Ruby code look up identifiers or the values associated with them? <p>I've been trying to understand this example Ruby code <a href="http://www.randomhacks.net/articles/2007/01/20/13-ways-of-looking-at-a-ruby-symbol" rel="nofollow">from a blog entry</a> which says it uses the symbols :DEFAULT, :say and :@messa... | <p>The sample code uses symbols to get at three things: the value of the <code>DEFAULT</code> const (accessed via <code>:DEFAULT</code>), a method object (accessed via <code>:say</code>), and the value of an instance variable (accessed via <code>:@message</code>). None of the three objects were defined using a symbol, ... |
Transaction implementation for a simple file <p>I'm a part of a team writing an application for embedded systems. The application often suffers from data corruption caused by power shortage. I thought that implementing some kind of transactions would stop this from happening. One scenario would include copying the area... | <p>Databases use a variety of techniques to assure that the state is properly persisted.</p>
<ol>
<li><p>The DBMS often retains a replicated control file -- several synchronized copies on several devices. Two is enough. More if your're paranoid. The control file provides a few key parameters used to locate the othe... |
How well does SVN work for Office 2007 documents? <p>I'm considering using our SVN repository to manage all our documents. We mostly use Office 2007 (docx, xlsx) files. I thought the x was for xml but opening these files in notepad reveals a binary format. </p>
<p>I'm looking to find out what people's experience is... | <p>They are xml, mostly, but they're in a zipped format. In other words, try renaming the file to .zip and check how it looks then.</p>
<p>And no, SVN won't work terribly well with that format. I mean, it will certainly be able to store them, but it won't be able to diff them, and parallel editing won't work either.</... |
How can I migrate TFS source from one team project to another? <p>We've decided to go with a different template for our team project and want to move all of source under that team project. We are not concerned with migrating work items, but we would like to keep the version history of the source files, if possible. I t... | <p>If you do a move from within TFS, that should register as just another action to be saved in the history. Your other history should be kept intact, even when moving across projects.</p>
|
What is your favorite open source debugging tool? <p>I've been giving a talk recently on a plethora of Open Source (some are borderline open-source, I'll admit) debugging tools and the audiences have been making great additions to my list.</p>
<p>I'd like to gather the knowledge (and give credit) to the oft-brilliant ... | <p>For the gcc crowd, there's gdb and gprof. I've gotten a lot done with those two.</p>
|
Do I need to Dispose() or Close() an EventWaitHandle? <p>If I am using <code>EventWaitHandle</code> (or <code>AutoResetEvent</code>, <code>ManualResetEvent</code>) to synchronise between threads then do I need to call the <code>Close()</code> or <code>Dispose()</code> methods on that event handle when I am done with it... | <p>The disposable resource of an <code>EventWaitHandle</code> is actually a <code>SafeHandle</code> (wrapped in a <code>SafeWaitHandle</code>). <code>SafeHandle</code> implements a finalizer, which eventually makes sure the necessary resource is release, so it should be safe to let the garbage collector / finalizer thr... |
Where to specify flag for Base class use <p>I've got a base class called Request.cs</p>
<p>In this class I have the following private fields:</p>
<pre><code>protected string _requestURI = xxpConfig.xxEndpoint;
protected string _requestURIAuthBased = xxConfig.xxEndpoint + "?SessionID=";
</code></pre>
<p>endpoint is j... | <p>If I follow what you ask, the best way I can think of is to follow the model of the EventArgs class. All event handlers take an EventArgs object, however, sometime a derived class is passed:</p>
<pre><code> public class RequestArgs { }
public class Request
{ // ...
void virtual SendRequest(RequestArgs ar... |
Should validation be done in Form objects, or the model? <p>This question is mainly geared towards Zend in PHP, although it certainly applies to other languages and frameworks, so I welcome everyone's opinion.</p>
<p>I've only recently been using the Zend framework, and while it's not perfect, I have had a pretty good... | <p>Well, the validation can be done at many different levels and usually none of them is "the best". Of course, the model can be populated with invalid data that do not come from the form, but we can also create forms whose data do not go to any model.</p>
<p>Moreover, the direct validation in models is unsually not i... |
Why is it not advisable to have the database and web server on the same machine? <p>Listening to Scott Hanselman's interview with the Stack Overflow team (<a href="http://www.hanselminutes.com/default.aspx?showID=152">part 1</a> and <a href="http://www.hanselminutes.com/default.aspx?showID=153">2</a>), he was adamant t... | <ol>
<li>Security. Your web server lives in a DMZ, accessible to the public internet and taking untrusted input from anonymous users. If your web server gets compromised, and you've followed least privilege rules in connecting to your DB, the maximum exposure is what your app can do through the database API. If you hav... |
C# - How can I cut a string at its end to fit in a div? <p>I'm making a list of recent news. So, it will show something like this:</p>
<pre><code>- Take a look at the new Volks...
- John Doe is looking for a jo...
- Microsoft is launching the n...
</code></pre>
<p>So, the list above only shows me the title of the new... | <p>"text-overflow: ellipsis" is what you want but not everybody supports it. <a href="http://www.blakems.com/archives/000077.html" rel="nofollow">More info here...</a></p>
|
How can I avoid a segmentation fault while resize a vector like this <p>I think it is a simple question for you....i am pretty new in c++.....</p>
<p>So i have a vector defined like this:</p>
<p><code>vector<vector<float> > big_vector;</code></p>
<p>I read a file and initialized this vector, then the big... | <p>First you need to resize big_vector, so that it has some vectors to resize.</p>
<pre><code>int total_vectors = 100;
big_vector.resize(total_vectors);
for(int i = 0; i < total_vectors; ++i)
big_vector[i].resize(new_size);
</code></pre>
|
How do I list all tga files in a directory (non recursive) in Python? <p>How do I list all tga files in a directory (non recursive) in Python?</p>
| <p>If you are doing it based on file extension, you can do something like this:</p>
<pre><code>import os
directory = "C:/"
extension = ".tga"
list_of_files = [file for file in os.listdir(directory) if file.lower().endswith(extension)]
</code></pre>
<p>Obviously you can omit the lower() if you can garantee the case of... |
Django Admin Form for Many to many relationship <p>I have a many to many relationship between 2 tables Users an Domains.
I have defined this relationship in the Domains class.
So in the admin interface I see the Users when I am viewing Domains.
But I do not see Domains when I am viewing Users.
How can I achieve this.<... | <p>I know that this is an older thread, but this was the first result that came up on google and I thought a better answer was necessary. </p>
<p>Via <a href="https://code.djangoproject.com/ticket/897#comment:28">this django bug report</a> I found the best way to have your ManyToManyField show up on both models:</p>
... |
How to automate a process with the sqlite3.exe command line tool? <p>I'm trying to bulk load a lot of data ( 5.5 million rows ) into an SQLite database file.
Loading via INSERTs seems to be far too slow, so I'm trying to use the sqlite3 command line tool and the .import command.</p>
<p>It works perfectly if I enter th... | <p>Create a text file with the lines you want to enter into the sqlite command line program, like this:</p>
<pre>
CREATE TABLE log_entry ( );
.separator "\t"
.import logfile.log log_entry</pre>
<p>and then just call <code>sqlite3 database.db < commands.txt</code></p>
|
Is the "sender" in Button_Click(object sender... really the sender? <p>Ted Faison in a <a href="http://www.dotnetrocks.com/default.aspx?showNum=355" rel="nofollow">podcast on event-based software design</a> mentioned that "sender" and "self" objects in .NET, C++ and Java event statements such as:</p>
<pre><code>privat... | <p>First - the 'sender' will hold a reference to the button you clicked. If you have multiple buttons all hooked to the same event, this is how you see which one of the buttons you hit (if you're not passing something in the event arguments to read this).</p>
<p>Also I do to some extend agree that writing new eventarg... |
Unit Testing a 'SetDefaults()' method <p>I am in the process of learning to unit test. I have a 'domain object' that doesn't do much apart from hold state (i.e. 'Employee' without any business logic). It has a method SetDefaults() which just fills its state with reasonable values. A simple method.</p>
<p>But when I... | <p>Trivial getters and setters sometimes don't have unit tests written for them. If that's all that SetDefaults() does, it probably won't hurt to skip it.</p>
<p>One thing you would want to consider testing, though, is that none of the set properties of the <code>employee</code> instance are null after calling <code>S... |
C# XML Serialization - Leading Question Marks <h2>Problem</h2>
<p>By leveraging some samples I found online <a href="http://www.dotnetjohn.com/articles.aspx?articleid=173">here</a>, I've written some XML serialization methods.</p>
<ul>
<li><strong>Method1:</strong> Serialize an Object and return: (a) the type, (b) th... | <p>When I've come across this before, it usually had to do with encoding. I'd try specifying the encoding when you serialize your object. Try using the following code. Also, is there any specific reason why you need to return a <code>string[]</code> array? I've changed your methods to use generics so you don't have to ... |
Determine list of event handlers bound to event <p>I have a WinForms form that won't close. In OnFormClosing, e.Cancel is set to true. I am guessing that some object in my application has bound to the Closing or FormClosing event, and is blocking the close. To find out, I'd like to determine what delegates are bound to... | <p>In short, you're not meant to do this - but for debugging purposes...</p>
<p>An event is <strong>often</strong> backed by a private field - but not with controls; they use the <code>EventHandlerList</code> approach. You would have to access the form's protected <code>Events</code> member, looking for the object map... |
Change the alpha value of a BufferedImage? <p>How do I change the global alpha value of a BufferedImage in Java? (I.E. make every pixel in the image that has a alpha value of 100 have a alpha value of 80)</p>
| <p>@Neil Coffey:
Thanks, I've been looking for this too; however, Your code didn't work very well for me (white background became black).</p>
<p>I coded something like this and it works perfectly:</p>
<pre><code>public void setAlpha(byte alpha) {
alpha %= 0xff;
for (int cx=0;cx<obj_img.getWidth();c... |
Delegating Control on change of a value/property <p>I'm trying to do something I've been historically available to do using Visual FoxPro (VFP). By use of a "SETALL()" function, I am able to do something like pertaining to a current form... this.SetAll( "someProperty", "toSomeNewValue" ) and it goes through and assign... | <p>I would just do something like this: </p>
<pre><code>this.Visible = false;
Controls.ForEach<Control>(c => c.Visible = false);
</code></pre>
<p>If you have GroupBoxes or other Controls that have Controls, you may want to put that into a recursive function: </p>
<pre><code>static void DoForEachControl(Cont... |
WPF No Events from Controls in RichTextBox <p>I am using WPF and have a Table inside a RichTextBox control. I need to get the background colour of the table cell to change it gets the focus. My problem is that I can't get the GotFocus or any other events to fire for the TableCell.</p>
<pre><code><RichTextBox>
... | <p>The half answer is to set the IsDocumentEnabled property on the RichTextBox to true. That allows controls within it to be enabled as per <a href="http://social.msdn.microsoft.com/forums/en-US/wpf/thread/5372c48e-3040-4312-8263-59616e6728a8/" rel="nofollow">Embedded UI Elements in RichTextBox</a>. Unfortunately that ... |
How do you tell the Visual Studio project type from an existing Visual Studio project <p>Using Visual Studio 2005.</p>
<p>Is there anything in the .sln or .vcproj files (or anywhere else) that defines the project type / subtype? </p>
<p>Edit: What I mean is that when you create a project, you first choose a language ... | <p>In the project XML files:</p>
<p>Console applications contain:</p>
<pre><code><OutputType>Exe</OutputType>
</code></pre>
<p>WinForms applications contain:</p>
<pre><code><OutputType>WinExe</OutputType>
</code></pre>
<p>Library (.dll) projects contain:</p>
<pre><code><OutputType>Li... |
How do I submit an HTML form to a Popup windows with resize disabled? <p>I had designed an HTML form with submit button. But instead of submit it to another page I want to submit to pop up windows where I can limit the size of the pop up windows say "320x240" hide all the toolbar, disable resize.</p>
| <p>Here's my go at it; this JavaScript snippet should go into the head of your page:</p>
<pre><code><script>
process = function()
{
window.open('about:blank', 'popup', 'width=320,height=240,resizeable=no');
document.login.setAttribute('target', 'popup');
document.login.setAttribute('onsubmit', '');
... |
Using Unmapped Class with NHibernate Named Query <p>I'm using a custom named query with NHibernate which I want to return a collection of Person objects. The Person object is not mapped with an NHibernate mapping which means I'm getting the following exception:</p>
<blockquote>
<p>System.Collections.Generic.KeyNotFo... | <p>Why don't you use:</p>
<p><code>
query.SetResultTransformer(Transformers.AliasToBean(typeof(Person)));
</code></p>
<p>It will insert data from each column in your query into Person object properties using column alias as a property name.</p>
|
The Three Systems of Man - How do you build a Third System? <p>I've been thinking about the story of the Three Systems of Man from the book <a href="http://rads.stackoverflow.com/amzn/click/1555581234">The UNIX Philosophy</a>. For those of you who aren't familiar, it goes something like this:</p>
<ul>
<li>The First S... | <p>I think the key to this is the difference between having the time and money, and experience. If you've built something before, been burned, built it again, got it wrong and then build it again, and you're that rare developer who just knows what works, then you'll get the 'Third System'. </p>
<p>Just having money, t... |
Is there an HTML version of the ECMA-335 CLI Specification? <p>I'm currently writing a blog post about the internals of the CLI, and I try to cite where something gets said. Mainly in the Partition III docs.</p>
<p>I'm currently linking to the ECMA page for it, where there are a bunch of pdf- and zip-files, and makin... | <p><em>Edit: as pointed out in the comments, this is actually an older draft, I'm not sure if it is "close enough" for you to use, but I'm not having any luck finding the current version in HTML.</em></p>
<p>It's not going to be a pretty link, but this will probably do the job (Google's HTML version of a DOC file):</p... |
Grails Eclipse plugin <p>I've seen various posts on SO criticising the Eclipse Grails plugin, and am wondering if anyone has found a way to work productively with Grails within Eclipse?</p>
<p>I had a look at the <a href="http://www.grails.org/Eclipse+IDE+Integration" rel="nofollow">Grails plugin page</a>, and the inf... | <p>The Grails Eclipse Tooling available in STS is now becoming mature. I'd recommend trying this if you are still looking for a good way to develop Grails apps in Eclipse.</p>
<p><a href="http://www.grails.org/STS+Integration">http://www.grails.org/STS+Integration</a></p>
|
How do you add a directory of java classes to a project? <p>I have a Java project I'm working on, and wish to include a directory full of classes. These are the "JEdit Syntax" classes, and come within two packages:</p>
<pre><code>org.syntax.jedit
org.syntax.jedit.tokenmarker
</code></pre>
<p>However, everywhere I lo... | <p>It sounds like you have tried to add the two packages to your classpath seperately - and at the wrong level.
If you are pointing at a folder, you have to point to the "root" folder of the package hierarchy - ie in this case the folder which is the parent of "org"
Then from there it will look down the package/folder... |
How do I include .class files in my project in Eclipse? (Java) <p>Hey all. I am working on a project for school where we are given the .class file but not the source to include in our code. I am using Eclipse, and I want to include the file in my project so I can instantiate objects from it and use it. <p>The file is T... | <p>You can add a directory containing the class files to the Eclipse project, only if it is inside one of your Eclipse projects, either in a generated directory or in one you have created.</p>
<p>This can be done by adding the class folder to the Java build path of the application. You can set this in the Project prop... |
jQuery Simpletip plugin to use the title attribute <p>How can you make the <a href="http://craigsworks.com/projects/simpletip/" rel="nofollow">SimpleTip</a> plugin use each element's <code>title</code> attribute for the tooltip text when you're applying it to a group of elements?</p>
<pre><code>$('td[title]').simpleti... | <p>I think this will work for you</p>
<pre><code>$('td[title]').each(function() {
$(this).simpletip({
content : $(this).attr('title')
});
});
</code></pre>
|
Combine PHP prepared statments with LIKE <p>Anyone know how to combine PHP prepared statements with LIKE? i.e. </p>
<p><code>"SELECT * FROM table WHERE name LIKE %?%";</code></p>
| <p>The % signs need to go in the variable that you assign to the parameter, instead of in the query.</p>
<p>I don't know if you're using mysqli or PDO, but with PDO it would be something like:</p>
<pre><code>$st = $db->prepare("SELECT * FROM table WHERE name LIKE ?");
$st->execute(array('%'.$test_string.'%'));
... |
Flash transparent background not working on Mac <p>Hi I just can't seem to get the background to be transparent on a Mac, see here: <a href="http://www.digiflipconcepts.com/smokinhot/templates/smokinhot/" rel="nofollow">http://www.digiflipconcepts.com/smokinhot/templates/smokinhot/</a></p>
<p>I'm using wmode=transpare... | <p>Seeing that your background position is static you could skip the transparent background and just add that part of the image in the flash. You will need to pull some other tricks to get the position exactly right across browsers, but it will work better and improve performance.</p>
|
How to take a screenshot of the Active Window in Delphi? <p>For full screenshots, I use this code:</p>
<pre><code>form1.Hide;
sleep(500);
bmp := TBitmap.Create;
bmp.Height := Screen.Height;
bmp.Width := Screen.Width;
DCDesk := GetWindowDC(GetDesktopWindow);
BitBlt(bmp.Canvas.Handle, 0, 0, Screen.Width, Screen.Height, ... | <ol>
<li>First of all you have to get the right window. As sharptooth already noted you should use <code>GetForegroundWindow</code> instead of <code>GetDesktopWindow</code>. You have done it right in your <a href="http://pastebin.com/m2e334a4a">improved version</a>.</li>
<li>But then you have to resize your bitmap to t... |
How to add native library to "java.library.path" with Eclipse launch (instead of overriding it) <p>I got a native library that needs to be added to <em>java.library.path</em>. With JVM argument <em>-Djava.library.path=path...</em> I can set the path as I want.</p>
<p>My problem is that my other library (pentaho report... | <p>Had forgotten this issue... I was actually asking with Eclipse, sorry for not stating that originally.
And the answer seems to be too simple (at least with 3.5; probably with older versions also):</p>
<p>Java run configuration's Arguments : VM arguments:</p>
<pre><code>-Djava.library.path="${workspace_loc:project}... |
ruby-aaws Get specific Album <p>I am trying to get a specific music cd from Amazon using ruby-aaws. </p>
<pre><code>il = ItemSearch.new( 'Music', { 'Artist' => artist_title,
'Title' => album_name } )
rg = ResponseGroup.new( 'Large' )
req = Request.new(AMAZON_KEY_ID, AMAZON_ASSOCI... | <p>I've had a bit of a look at the code of <code>ruby-aaws</code>. It looks like you should be able to set <code>$DEBUG</code> to <code>true</code> before calling any of the <code>ruby-aaws</code> methods/classes and see what URLs are being requested. If there are any discrepancies between your handcrafted URL and the ... |
elisp functions as parameters and as return value <p>I have the following code </p>
<pre><code>(defun avg-damp(f)
#'(lambda(x) (/ (+ (funcall f x) x) 2.0)))
</code></pre>
<p>A call </p>
<pre><code>(funcall (avg-damp #'(lambda(v) (* v v))) 10)
</code></pre>
<p>returns 55.0 (the correct value) in SBCL but crashe... | <p>This style of programming does not work in plain Emacs Lisp. Emacs Lisp uses dynamic binding and languages like Scheme and Common Lisp are using lexical binding. Your code exposes the difference. See: <a href="http://www.gnu.org/software/emacs/elisp/html_node/Extent.html" rel="nofollow">Extent in Emacs Lisp</a></p>
... |
Layering a WCF Service the right way <p>My question is more of an architectural nature, less involved with the actual implementation.</p>
<p>I have build an API based on WCF, but can't really decide on how to separate the PL from the BL. I have made my service thin, so that it holds only a minimum of implementation, ... | <p>First, I assume that by PL you mean presentation layer, not persistence layer?</p>
<p>When implementing a layered application design, the main question should always be: can I replace the implementation of a lower layer without impacting the implementation of the layer(s) above.</p>
<p>This is usually best illustr... |
WPF - UserControl default Content attribute <p>I'm creating a UserControl and I just can't remember the name of the attribute which you use to decorate the property which you want to act as the default content property. </p>
<p>To give a concrete example, say i have a property called 'Title' which i can set using pro... | <p><a href="http://msdn.microsoft.com/en-us/library/system.windows.markup.contentpropertyattribute.aspx">ContentPropertyAttribute</a></p>
|
CollectionViewSource Filter not refreshed when Source is changed <p>I have a WPF ListView bound to a CollectionViewSource. The source of that is bound to a property, which can change if the user selects an option.</p>
<p>When the list view source is updated due to a property changed event, everything updates correctly... | <p>A bit late perhaps, but this may help other users so I'll post anyway...</p>
<p>Updating the CollectionView.Filter based on a PropertyChanged event is not supported by the framework.
There are a number of solutions around this.</p>
<p>1) Implementing the IEditableObject interface on the objects inside your collect... |
How to implement conditional formatting in a GridView <p>I have a GridView on my aspx page which displays a collection of objects defined by the following class</p>
<pre><code>public class Item
{
public string ItemName{get; set;}
public object ItemValue{get; set;}
}
</code></pre>
<p>Then in my aspx markup I h... | <p>Not sure if you can use a BoundField, but if you change it to a TemplateField you could use a formatting function like in <a href="http://www.vbforums.com/showthread.php?t=545143">this link</a>.</p>
<p>ie something like</p>
<pre><code><%# FormatDataValue(DataBinder.Eval(Container.DataItem,"ItemValue")) %>
</... |
C++ Transformer scripting <p>Im looking to see if there are any pre-existing projects that do this.</p>
<p>Generally, I need something that will load in a c++ file and parse it and then based on a set of rules in script, transform it, say to add headers, reformat, or remove coding quirks for example, turning const int... | <p><a href="http://blog.mozilla.com/tglek/" rel="nofollow">Taras Glek</a> of Mozilla has been working on the <a href="https://developer.mozilla.org/en/Dehydra" rel="nofollow">dehydra tool</a>, based on <a href="http://www.eecs.berkeley.edu/~smcpeak/elkhound/" rel="nofollow">Elkhound</a> and scripted using JavaScript to... |
jFeed - sucess function not being executed (jQuery plugin) <p>I have the following Javascript code, where feed is a valid url to an rss feed.</p>
<pre><code>jQuery(function() {
jQuery.getFeed({
url:feed,
success: function(feed){
alert(feed);
... | <p>With the information you give, we can see that your call is correct. The problem is probably somewhere else. In suggest that you dig in jFeed source code and disable feed parsing in $.ajax success method:</p>
<pre><code> $.ajax({
type: 'GET',
url: options.url,
data: options.data,
... |
Changing values in Web.config with a Batch file or in .NET code <p>I have a web.config file on my computer.</p>
<p>There are alot of things i need to change and add in the file.
<em>(I am actually working with my SharePoint web.config file)</em></p>
<p>Can i do this with a Batch file, if so how would i do it.
Or how ... | <p>You can modify it from C# code, for example:</p>
<pre><code>Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~");
AppSettingsSection appSettingsSection = (AppSettingsSection)configuration.GetSection("appSettings");
if (appSettingsSection != null)
{
appSettingsSection.Settings["f... |
Handling multiple records in a MS SQL trigger <p>I am having to use triggers in MSSQL for the first time, well triggers in general. Having read around and tested this myself I realise now that a trigger fires per command and not per row inserted, deleted or updated.</p>
<p>The entire thing is some statistics for an ad... | <p>The trick with these kinds of situations is to turn the sequential operation (for each record do <em>xyz</em>) into a set-based operation (an UPDATE statement).</p>
<p>I have analyzed your stored procedure and merged your separate UPDATE statements into a single one. This single statement can then be transformed in... |
Getting a column definition by name in wpf <p>For example:</p>
<pre><code><Grid Name="TestGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Name="TestColumnName" Width="*" />
</Grid.ColumnDefinitions>
</Grid>
</code></pre>
<p>I would like to be able to access the column d... | <p>Use the x:Name property instead of Name :)</p>
|
How can I eval environment variables in Perl? <p>I would like to evaluate an environment variable and set the result to a variable:</p>
<pre><code>$x=eval($ENV{EDITOR});
print $x;
</code></pre>
<p>outputs:</p>
<pre><code>/bin/vi
</code></pre>
<p>works fine.</p>
<p>If I set an environment variable QUOTE to \' and t... | <p>Well, of course it does nothing. </p>
<p>If your ENV varaible contains text which is half code, but isn't and you give the resulting string to something that <b>eval</b>uates that code as Perl, of <strong>course</strong> it's not going to work.</p>
<p>You only have 3 options: </p>
<ol>
<li>Programmatically proce... |
How to efficiently scale and crop images in an ASP.NET app? <p>We're having problems with an ASP.NET application which allows users to upload, and crop images. The images are all scaled to fixed sizes afterwards. We basically run out of memory when a large file is processed; it seems that the handling of JPEG is rather... | <p>I had the same problem, the solution was to use System.Drawing.Graphics to do the transformations and dispose every bitmap object as soon as I was finished with it. Here's a sample from my library (resizing) :</p>
<pre><code> public Bitmap ApplyTo(Bitmap bitmap)
{
using (bitmap)
{
... |
Combining joint probabilities <p>I am trying to work out the expression for a probability distribution (related to bioinformatics), and am having trouble combining the information about a random variable from two different sources. Essentially, here is the scenario:
There are 3 discrete random variables X, A & B. X... | <p>What you're dealing with here is an undirected acyclic graph. A is conditionally independent of B given X, but X depends (I assume directly) on A and B. I'm a little confused about the nature of your problem, i.e. what form your probability distributions are specified in, but you could look at <a href="http://en.w... |
Would you use the S#arp Architecture in a new commercial project? <p>The <a href="http://code.google.com/p/sharp-architecture/">S#arp Architecture</a> seems really cool, but do you think it's still too new to make the commitment to it in an important new project? (Let's assume the project appears to be a good fit for i... | <p><a href="http://fancydressoutfitters.co.uk">http://fancydressoutfitters.co.uk</a> was built using:</p>
<ul>
<li>Sharp Architecture (ASP.NET MVC, NHibernate, Fluent NHibernate), </li>
<li>Spark View Engine</li>
<li>AutoMapper</li>
<li>NHibernate Validator</li>
<li>xVal Validation Framework</li>
<li>N2CMS</li>
<li>Po... |
How do I change the ForeColor of a GroupBox without having that color applied to every child control as well? <p>I need to change the group box text to a specific color without changing the color of what is inside the group box. </p>
<p>The following code sets the <code>ForeColor</code> of the <code>GroupBox</code> to... | <p>You could iterate through all the controls in the GroupBox and set their respective ForeColor properties:</p>
<pre><code>groupBox1.ForeColor = Color.Pink;
foreach (Control ctl in groupBox1.Controls) {
ctl.ForeColor = SystemColors.ControlText;
}
</code></pre>
|
How to change the pop-up position of the jQuery DatePicker control <p>Any idea how to get the DatePicker to appear at the end of the associated text box instead of directly below it? What tends to happen is that the text box is towards the bottom of the page and the DatePicker shifts up to account for it and totally co... | <p>Here's what I'm using:</p>
<pre><code>$('input.date').datepicker({
beforeShow: function(input, inst)
{
inst.dpDiv.css({marginTop: -input.offsetHeight + 'px', marginLeft: input.offsetWidth + 'px'});
}
});
</code></pre>
<p>You may also want to add a bit more to the left margin so it's not right u... |
Hierarchical RSS Feeds <p>Is it possible to create an RSS feed with a multi-level hierarchy, sort of like a directory structure? Is this allowed per the RSS spec?
If this is possible, does anyone know of what limitations there might be? As in, are there any particular readers that would not support it?
My main conce... | <p>It's not possible per the <a href="http://cyber.law.harvard.edu/rss/rss.html" rel="nofollow">Rss Spec</a>, and if you attempt to do so i'm afraid that a lot of browsers will not recognize rss format.</p>
|
Android SMS Content (content://sms/sent) <p>I'm having a problem reading the SMS messages from the device.
When acquiring a content provider for the URI '<code>content://sms/inbox</code>',
everything is fine, I can read the "person" column to find the foreign key
into the people table and ultimately reach the contact a... | <p>Use the address column. I guess the person column is ignored because people can send SMSs to phone numbers that are not in the contacts list.</p>
<pre><code>// address contains the phone number
Uri phoneUri = Uri.withAppendedPath(Contacts.Phones.CONTENT_FILTER_URL, address);
if (phoneUri != null) {
Cursor phoneCu... |
Palette Animation in OpenGL <p>I am making an old-school 2d game, and I want to animate a specific color in my texture.</p>
<p>Only ways I know are:</p>
<ol>
<li>opengl shaders.</li>
<li>animating one color channel only.</li>
<li>white texture under the color-animated texture.</li>
</ol>
<p>But I don't want to use s... | <p>While I am unfamiliar with the palette texture extension I still recommend using a fragment shader for this sort of effect. It is almost trivial to do a color-key replacement with a shader, versus the other methods you mentioned, and will be way faster than writing the palette functionality yourself.</p>
<p>Here's... |
Is EJB inheritance through different EJB modules possible? <p>Is it possible to have an entity class which inherits from another (abstract) entity class from another ejb module?</p>
<p>EclipseLink for example doesn't create the depending columns in database table of the subclass. It simply ignores the (abstract) super... | <p>The annotation @Entity didn't work in my project but the annotation @MappedSuperclass which is also part of JPA 1.0 now works very well.</p>
<p>Sorry for that maybe stupid question. ;-)</p>
|
Why can't I enter text in Winform hosted in ATL dialog? <p>I am working on embedding winform controls into an ATL dialog (see <a href="http://stackoverflow.com/questions/642082/how-to-embed-windows-form-in-unmanaged-atl-gui">here</a> for how I did so far).</p>
<p>Now I have encountered a rather strange problem.<br />
... | <p>There's something wrong with your message loop. TranslateMessage() is the likely candidate, that's the one that generates WM_CHAR messages from a WM_KEYDOWN message.</p>
|
javascript form - bypassing default behaviour for ajax <p>I am trying to use the following code below. What I want is to get the value of which radio button is selected, sent back to the javascript method. Any variation I try seems to fail.</p>
<pre><code><html>
<head>
<style type="text/css">
... | <p>Your code is cut of but I think that you want to do something like this:</p>
<pre><code><html>
<head>
<script type="text/javascript">
function alertThing() {
alert(document.getElementsByName('textBox1')[0].value);
return false;
}
</script>
<... |
Convention over configuration with Spring MVC using ControllerClassNameHandlerMapping? <p>Following the directions from <a href="http://static.springframework.org/spring/docs/2.5.x/reference/mvc.html#mvc-coc" rel="nofollow">Spring Source</a> and the book Spring in Action, I am trying to set up Spring MVC in a way that ... | <p>There are actually two different things going on here: </p>
<ol>
<li>the mapping between URLs and controllers </li>
<li>the definition of controllers as Spring beans</li>
</ol>
<p>For #1, if you define the ControllerClassNameHandlerMapping as you've done, that takes care of the URL-to-controller mapping. E.g., ... |
Anonymous Generics - Where would I use this? <p>I recently discovered a trick using casting by example to instantiate a generic with an anonymous type.</p>
<p><a href="http://brendanjerwin.com/blog/2009/03/19/anonymous-generics/" rel="nofollow">http://brendanjerwin.com/blog/2009/03/19/anonymous-generics/</a></p>
<p>S... | <p>The primary place I use this trick is for creating a collection container for anonymous types. </p>
<pre><code>public static List<T> CreateListOfAnonymous<T>(T unused) {
return new List<T>();
}
</code></pre>
<p>Usage:</p>
<pre><code>public void Foo() {
var list = CreateListOfAnonymous(new {... |
Whats the best way to get data from other websites programmatically? "amazon offers for example" <p>I want to build a small application which will go to some websites and read specific data from these website, i want the application to be generic as i can so it work on any website i want later.
So there is a good way t... | <p>I have been told that a good toolkit for doing screen scraping in .NET is <a href="http://www.codeplex.com/htmlagilitypack" rel="nofollow">HTML Agility Pack</a>.</p>
<p>You should be aware that it's always very hard to make a screen scraping solution stable, or general-purpose as you describe.</p>
<p>Also see othe... |
C# Synchronized object - duplicate code with writing accessors <p>I like to use objects which sync itself using a private object which is locked when the property is changed.
Is there any generic way to achieve this?
My code looks always like this for each property (with one locker object)</p>
<pre><code>private Objec... | <p>Your code shouldn't look like that - you should lock on the <em>get</em> as well. Otherwise threads fetching data may not get the most recent value, for complicated memory model reasons.</p>
<p>But no, I don't know of any ways around this. You could do odd stuff with lambda expressions and extension methods, but it... |
ASP.NET Server Side Viewstate <p>I have read some approaches to storing viewstate on the server:</p>
<p><a href="http://aspalliance.com/72%5FServer%5FSide%5FViewstate" rel="nofollow">Here is one</a></p>
<p><a href="http://www.clanmonroe.com/Blog/archive/2008/08/05/efficient-server-side-view-state-persistence.aspx" re... | <blockquote>
<p>I am looking for a way to persist an object without having to serialize it.</p>
</blockquote>
<p>Be careful with that. This will have a dramatic impact on the memory use of your site, and memory use is often the biggest impediment to scalability.</p>
|
Testing/Debugging website running on iis 6.0 and 7.0 with an xp development environment? <p>Considering iis 6.0 and above can't run on xp what options have i available?</p>
<p>Remote debugging (using a win 2k3 host) i'm aware of but i might not have the facilities available very easily</p>
| <p>I'm not sure of your exact situation (availability of OS licenses, specifically), but you could consider virtualization. I've used VirtualBox ( <a href="http://www.virtualbox.org/" rel="nofollow">http://www.virtualbox.org/</a> ) and I've heard that MS Virtual PC ( <a href="http://www.microsoft.com/Windows/products/w... |
Query several EAV attributes in separate columns <p>I am facing issues trying to write a query. (this is slightly modified from my previous question)</p>
<p>My tables are laid out as follows:</p>
<pre><code> tblTicketIssues.TicketID
tblTicketIssues.RequesterID
tblPersonnelProfile.PersonnelID
tblPersonnelProfile.F... | <p>I'm not 100% sure that I understand, but I think this satisfies what you're asking for. Note that this was assuming that the database is MySQL, you didn't specify. The syntax of the IF() and CONCAT() may be slightly different if it's something else.</p>
<p><em>EDIT: updated query as per Csharp's "answer" below. <co... |
Slow performance of SqlDataReader <p>I've query executing ~2 secs in MSSMS (returning 25K of rows)</p>
<p>Same query used in .NET (sqlReader) exetuting few minutes!</p>
<p>I've also tried to execute only reader </p>
<p>(commented all code in while loop just leaving reader.Read() ) - still same!</p>
<p>Any idea what... | <p>I would set up a trace in SQL Server Profiler to see what SET options settings the connection is using when connecting from .NET code, and what settings are being used in SSMS. By SET options settings, I mean</p>
<pre><code>ARITHABORT
ANSI_NULLS
CONCAT_NULL_YIELDS_NULL
//etc
</code></pre>
<p>Take a look at <a href... |
How to test if a C# Hashtable contains a specific key/value pair? <p>I'm storing a bunch of supposedly-unique item IDs as a key and the file locations as the value in a hash table while traversing a table. While I am running through it, I need to make sure that they key/location pair is unique or throw an error messag... | <p>Try this:</p>
<pre><code>Hashtable check_for_duplicates = new HashTable();
foreach (object item in items)
{
if (check_for_duplicates.ContainsKey(item["ItemID"]) &&
check_for_duplicates[item["ItemID"]].Equals(item["Path"]))
{
//throw error
}
}
</code></pre>
<p>Also, if you're usi... |
Need to write a ruby script to create a csv file of the data on the website <p>There is a website which gives me the information of pin codes of a particular state for example <a href="http://www.indiapost.gov.in/pin/pinsearch.aspx" rel="nofollow">indian postal website</a>, gives the details when I select the state in ... | <p>You should be interested in the FasterCSV gem</p>
<p><a href="http://fastercsv.rubyforge.org/" rel="nofollow">http://fastercsv.rubyforge.org/</a></p>
<pre><code>gem install fastercsv
</code></pre>
<p>And then, something like that:</p>
<pre><code>require 'fastercsv'
FasterCSV.open("temp.csv", "w") do |csv|
csv ... |
oracle 10g - Monitor large row deletions <p>how can i monitor rows being deleted(say 20 rows)?
consider, i am a dba and monitoring an oracle database.. i have to get an alert if someone deletes more than 20 rows.. i should avoid a trigger since it is costly.. is there any other way around? </p>
<p>how can i parse the ... | <p>What were you hoping to do if such a deletion occurs? Unless you've saved the deleted rows somewhere (which would require a trigger) you can't get them back, nor can you even know what they were.</p>
<p>If deleting rows is a problem and recovery is likely to be needed, don't allow rows to be deleted: add a "deleted... |
Oracle Deadlock when Hibernate application loading data for readonly use <p>We are experiencing an Oracle Deadlock (org.hibernate.util.JDBCExceptionReporter - ORA-00060: deadlock detected while waiting for resource) error. It has been suggested that the issue is with a process that is performing readonly operations us... | <p>Involuntary updates might happen with hibernate when you use setters that manipulate the value they actually set. An example would be a setter for an String attribute that replaces a value of null with "". A likely candidate are also collections. Make sure setters don't replace the contained collection. If you repla... |
What's the advantage of this indirect function call? <p>I found the following code in a library:</p>
<pre><code>class Bar {
public:
bool foo(int i) {
return foo_(i);
}
private:
virtual bool foo_(int i) = 0;
};
</code></pre>
<p>Now I'm wondering: Why would you use this indirection? Could there be any reasons ... | <p>This is the <a href="http://www.gotw.ca/publications/mill18.htm">Non-Virtual Interface Idiom</a> (NVI). That page by Herb Sutter has a good bit of detail about it. However, temper what you read there with what the C++ FAQ Lite says <a href="http://www.parashift.com/c%2B%2B-faq-lite/strange-inheritance.html#faq-23.... |
LastChildFill Not Working When Trying To Dock ItemsControl <p>I've got the following markup in a WPF UserControl: </p>
<pre><code><Border Name="_border" BorderThickness="4" BorderBrush="Blue">
<Canvas Name="_canvas" Background="Black" >
<DockPanel LastChildFill="True">
<Ite... | <p>Whats the size of your DockPanel? Try setting a background on your DockPanel for testing. </p>
<p>I don't think that you problem is with your ItemsControl not stretching to fill your DockPanel, but actually your DockPanel is not stretching to fit inside the Canvas Control. Canvas control and its children will no... |
What's the deal with a leading underscore in PHP class methods? <p>While looking over various PHP libraries I've noticed that a lot of people choose to prefix some class methods with a single underscore, such as</p>
<pre><code>public function _foo()
</code></pre>
<p>...instead of...</p>
<pre><code>public function fo... | <p>It's from the bad old days of Object Oriented PHP (PHP 4). That implementation of OO was pretty bad, and didn't include things like private methods. To compensate, PHP developers prefaced methods that were intended to be private with an underscore. In some older classes you'll see <code>/**private*/ __foo() {</co... |
Sockets Authentication is failing using NegotiateStream <p>I've got a Socket that is connected that I use to get HTTP header responses. If I skip authentication, everything works fine (unless the page requires authentication). But when I step into this code, it always throws an IOException on the AuthenticateAsClient... | <p><a href="http://msdn.microsoft.com/en-us/library/system.net.security.negotiatestream.aspx" rel="nofollow"><code>NegotiateStream</code></a> doesn't perform HTTP authentication:</p>
<blockquote>
<p>On Windows 95/98 systems, Windows NT LAN Manager (NTLM) is the protocol used for authentication. On other platforms th... |
Python: How do you login to a page and view the resulting page in a browser? <p>I've been googling around for quite some time now and can't seem to get this to work. A lot of my searches have pointed me to finding similar problems but they all seem to be related to cookie grabbing/storing. I think I've set that up prop... | <p>First off, when doing cookie-based authentication, you need to have a <a href="http://docs.python.org/library/cookielib.html#cookielib.CookieJar" rel="nofollow"><code>CookieJar</code></a> to store your cookies in, much in the same way that your browser stores its cookies a place where it can find them again.</p>
<p... |
Is it a good idea to let your users change their usernames? <p>I'm back and forth on the idea of letting the users on my site change their usernames, which would be displayed through out the site. On one side I want to give the users flexibility. But on the other, I don't want them to use this feature as a way to hide ... | <p>What do you mean with "do something bad and then change their name"? If you're implying that users can post content, for instance, with their name attached, and then change their name and the name attached to their posts won't change as well, then I think you need to reconsider your (database) architecture and ensur... |
How does gesture recognition work? <p>In a multi-touch environment, how does gesture recognition work? What mathematical methods or algorithms are utilized to recognize or reject data for possible gestures?</p>
<p>I've created some retro-reflective gloves and an IR LED array, coupled with a Wii remote. The Wii remot... | <p>Gesture recognition, as I've seen it anyway, is usually implemented using machine learning techniques similar to image recognition software. <a href="http://www.codeproject.com/KB/recipes/cmgblade.aspx" rel="nofollow">Here's a cool project on codeproject about doing mouse gesture recognition in c#</a>. I'm sure th... |
C# Nested Try Catch statements or methods? <p>Simple best practice question.</p>
<p>Should you nest try catch statements or just use methods.</p>
<p>For instance, if you have a method that opens a file does work and closes the file, you would have the open and close outside the try catch, or rather the close in the f... | <p>In the context of a method that opens a file I would use a using statement vs a try catch. The using statement ensures that Dispose is called if an exception occurs. </p>
<pre><code>using (FileStream fs = new FileStream(file, FileMode.Open))
{
//do stuff
}
</code></pre>
<p>does the same thing as:</p>
<pre><co... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.