input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Looking for an algorithm to spit out a sequence of numbers in a (pseudo) random order <p>Suppose I have a sequence of numbers:
{n, n+1, n+2, ... n + m}</p>
<p>Without storing the numbers ahead of time I want to create a function f(), which given the sequence {1,2,3,...m} will spit out the original set in a random (or ... | <p>There is a simple function that generates a permutation of <code>[0..m-1]</code> for a given <code>m</code>. Just pick a number <code>k</code>, relatively prime to <code>m</code> and let <code>f(i)=(k*i) mod m</code>. This always generates a permutation (no repeats on <code>0<=i<m</code>). It works better if <... |
Managing concurrent projects written in different programming languages <p>I currently have three independent projects on my plate - each requiring development in a different language.</p>
<p>There's a WCF Web Services / Windows Forms project in C# .Net 3.5, a web site in PHP with generous javascript, and maintenance ... | <p>Definitely been there. </p>
<p>While it's frustrating to sometimes get caught up in the incorrect syntax, my guess is that in the long run you'll be a much better developer for having the multi-platform exposure.</p>
<p>The best thing I've found is to try to get blocks of significant time to focus on the project a... |
Why should we use literals in C#? <p>In some C# code I have seen staments like this:</p>
<pre><code>float someFloat = 57f;
</code></pre>
<p>I want to know why we should use literals like <code>f</code> in the above case?. </p>
| <p>Mainly so the compiler knows exactly what we mean - in particular for overload resolution:</p>
<pre><code>Foo(57f);
</code></pre>
<p>should that call <code>Foo(int)</code> / <code>Foo(float)</code> / <code>Foo(decimal)</code> ?</p>
<p>Actually, I don't like remembering things - an alternative is:</p>
<pre><code>... |
Save metafile in C# <p>If I have a wmf or emf image in System.Drawing.Image, is there a way to save the metafile data with c# without rendering it as a bitmap? Calling Image.Save will render it to a bitmap and I want to keep the original data so that it would still be a valid .wmf or .emf format file.</p>
| <p>Despite this MSDN page, it is possible to save a true EMF file. See this question: <a href="http://stackoverflow.com/questions/152729/gdi-c-how-to-save-an-image-as-emf/895204#895204">gdi-c-how-to-save-an-image-as-emf</a></p>
|
troublesome javascript <p>I'm trying to make a little tag list doohickey for adding and removing tags. I have a textbox where the user can enter the tags, separated by commas. and an add button. I would like it for when the user clicks the add button to add a small div to the inside of a div below the box. the small di... | <p>Your first problem is that</p>
<pre><code>$('#tagsbox').text()
</code></pre>
<p>should be</p>
<pre><code>$('#tagsbox').val()
</code></pre>
<p>because #tagsbox is an input field.</p>
<p>There are other issues, like splitting on "," and then trimming rather than splitting on ", " but I think your main problem is ... |
Apache Cocoon JAR configuration - I want to use .class files ! <p>I'm using the Apache Cocoon framework, set up several eons ago for the web app I'm developing.</p>
<p>I don't know if its how cocoon is set up for everyone, or its if some 'special' configuration my company has performed, but this is what happens.</p>
... | <p>I know nothing about Cocoon, but if you can put jars in tomcat/common/lib, then classes should work in tomcat/common/classes (NOT WEB-INF/classes).</p>
<p>Placing stuff into tomcat/common (instead of inside the webapp itself) is kind of weird, but you probably need to change some Cocoon settings (or the place where... |
When to override GetHashCode()? <p>When should we override the <strong>GetHashCode</strong>() method provided by '<strong>Object</strong>' class in '<strong>System</strong>' namespace?</p>
| <p>When you override <code>Equals</code>, basically. When you want to provide a different idea of equality than simple reference equality.</p>
<p>String is a good example of this - two strings are equal (under a simple Equals call) if they represent the same sequence of characters. The hash code reflects this, such th... |
AS3 access dynamic textfield on stage from a class <p>I have this dynamic textfield on stage, and I want to access it from my xmlloader class, so it can display text from my xml file. I just can't figure out a way to do it.</p>
| <p>I found the answer:</p>
<pre><code>MovieClip(root).thetextfieldonstage.text = "yep";
</code></pre>
<p>can call the textfield from class.</p>
|
Zend Framework: Some email users get errors when trying to open PDF attachments? <p>I'm having a strange problem and not sure how to troubleshoot it. I have created a script in one of my Zend Framework controllers that allows an administrator to log in, upload a PDF, and send as an attachment to everyone subscribed to ... | <p>It appears (to me) that in this line of code:</p>
<pre><code>$attachment = $mail->createAttachment($fileContents);
</code></pre>
<p>you likely need to add the additional header information available in the createAttachment method of the Zend_Mail framework::</p>
<pre><code>$attachment = $mail->createAttachm... |
How to exclude one value from a grouping sum, based on a value of another field? <p>How do I exclude one value from a grouping sum, based on a value of another field?</p>
<p>ie I open Report=> Report Properties=>Code and insert my Custom Code, but how would I change the below code to exclude a numeric value of anothe... | <p>I'm assuming you want to exclude a numeric value from a sum where the string value of a cell on the same row includes "Others", and that the function you've supplied is used as the grouping criteria for a table in the report. Apologies if this isn't correct.</p>
<p>It's not going to be possible to do this without u... |
"No default module defined" error in Zend Framework app <p>I am in process of making my bootstrap.php file more organized, but after I put everything into separate static methods, I cannot load any page beyond index controller. E.g.
if I try to open </p>
<p><code>http://localhost/zftutorial/login/index</code></p>
<p>... | <p>Looking at your stack trace the error is *Invalid controller class ("Login_IndexController")*</p>
<p>This suggests that the class Login_IndexController doesn't exist.</p>
<p>You should have a file called IndexController.php in the login module's controller directory. The structure you have at the moment won't work... |
Generics Sub List <p>Check the code.</p>
<pre><code>class DynamicObj : BaseObj {}
class BaseObj {}
class clientCode
{
List<DynamicObj> GetFilteredObjs(List<BaseObj> baseList)
{
// I want to return the sublist of baseList which only have DynamicObj.
List<DynamicObj> dList = ba... | <p>The easiest way is probably to use an iterator block:</p>
<pre><code>public IEnumerable<TTarget> FilteredCast<TSource,TTarget>
(IEnumerable<TSource> source)
where TSource : class
where TTarget : class, TSource
{
foreach (TSource element in source)
{
TTarget converted = ... |
Good text editor for Windows? <p>I'm looking for a text editor, much like TextMate (<a href="http://www.macromates.com" rel="nofollow">www.macromates.com</a>) on Mac, but I want it to have a built-in compiler. </p>
<p>For example, I do not want an IDE like Visual Studio or Eclipse. I'm looking for an editor where I ca... | <p><strong><a href="http://notepad-plus.sourceforge.net/de/site.htm">Notepad++</a></strong></p>
<p>It is based on Scintilla and is available under GPL.</p>
<p>Additionally I recommend downloading the <a href="http://www.mingw.org/wiki/HOWTO%5FInstall%5Fthe%5FMinGW%5FGCC%5FCompiler%5FSuite">MinGW port of GCC</a>.</p>
|
Compare different ways to remove selected items from System.Windows.Forms.ListBox <p>So far I've found 2 ways to delete selected items from a listbox (winform):</p>
<p>1.</p>
<pre><code>ListBox.SelectedObjectCollection tempCollection = new ListBox.SelectedObjectCollection(myListBox);
for (int i = tempCollection.Count... | <p>The first way is written really strangely. It looks strange because it goes backwards. This is so that it doesn't upset the collection of selected items. The selected items collection isn't fully created, it's an Enumerable collection, and items come off it only when you ask for them. You can't use a foreach, b... |
How do I loop backwards from SiteMap.CurrentNode to SiteMap.RootNode <p>I have a simple Sitemap like this from asp:SiteMapDataSource:</p>
<p>Page 1 > Page 2 > Page 3</p>
<p>I would like to create foreach loop in C# that generates it instead for using asp:SiteMapPath because I need to add some exceptions to it. Now I ... | <p>The property you are looking for is <a href="http://msdn.microsoft.com/en-us/library/system.web.sitemapnode.parentnode.aspx" rel="nofollow">SiteMapNode.ParentNode</a></p>
<pre><code>SiteMapNode currentNode = SiteMap.CurrentNode;
SiteMapNode rootNode = SiteMap.RootNode;
Stack<SiteMapNode> nodeStack = new Stack... |
Query interceptor to return true if the entity is in a list of items in ado.net data services <p>I'm using ado.net data services and want to implement row level security in the query interceptor to limit the data to only return data that the user is allowed to see.
The complexity comes in in that the user name for the ... | <p>Apparently this fails because by using the lambda expression events.Any... it's already querying in the initial context (ie. querying on Events straight) and then when you add the events.Any clause it also tries to query on the new context (ie. the nested "from" of Events within OnlineSubscription) so it understanda... |
Why do we not have a virtual constructor in C++? <p>Why does C++ not have a virtual constructor?</p>
| <p>Hear it from the horse's mouth:). </p>
<p>From Bjarne Stroustrup's C++ Style and Technique FAQ
<a href="http://www.stroustrup.com/bs_faq2.html#virtual-ctor">Why don't we have virtual constructors?</a></p>
<blockquote>
<p>A virtual call is a mechanism to get work done given partial
information. In particular, "... |
How to use css within a javascript function <p>I am using jQuery monthly calender, in which every day is a cell, onClick in the cell, I am able to print the alert, but I also want to change the background color of the cell, on which I clicked. But I am not getting the way to call CSS using Javascript. Please help me ou... | <p>In jQuery, you may use the <a href="http://docs.jquery.com/CSS/css#namevalue" rel="nofollow">css method</a> to change the background-color of the cell:</p>
<pre><code>// let's say this is in a loop
$(this).css('background-color', '#f00');
</code></pre>
|
Visual C++: How to get the CPU time? <p>How can I programatically find the CPU time which is displayed in <code>System Idle Process</code> (in Task Manager) using Visual C++?</p>
| <p>What you want is something like this...</p>
<pre><code>NTSTATUS hStatus;
SYSTEM_PERFORMANCE_INFORMATION stSysPerfInfo;
hStatus = NtQuerySystemInformation(SystemPerformanceInformation, &stSysPerfInfo, sizeof(stSysPerfInfo), NULL);
if (hStatus != NO_ERROR)
{
// Do work....
}
</code></pre>
<p>Or ta... |
How to display only parts of several urls into one html file? <p>In the past I was using iframe but it displayed all the webpage urls contents in full.</p>
<p>For example: I have saved the following code in a file named "trial.html" :</p>
<pre><code><iframe src="http://stackoverflow.com/unanswered" width=1100 heig... | <p>Frames are just another viewport, same as your basic browser window, and all a viewport does is provide a place to display documents. Whole documents.</p>
<p>If you want to parse a document, or indeed many documents, to pick and choose sections of them and merge into another document, you'll have to engage a server... |
Renaming the created_at, updated_at columns of ActiveRecord/Rails <p>I want to rename the timestamp columns defined in timestamp.rb .
Can the methods of timestamp.rb be overwritten? And what has to be done in the application that the module with the overwritten methods is used.</p>
| <p>This can be done via just over writing the ActiveRecord::Timestamp module methods. Not actually overwriting the entire module. I need to to accomplish this same goal as I am working with a legacy database. I am on rails 3 and I have started following a methodology of how to monkey patch my code with over writing rai... |
Select Most Recent States From History Table <p>I have inherited a table with a structure something like this:</p>
<pre><code>ID Name Timestamp Data
----------------------------
1 A 40 ...
2 A 30 ...
3 A 20 ...
4 B 40 ...
5 B 20 ... | <p>SQL Server 2005 (onwards):</p>
<pre><code>WITH MostRecentRows AS
(
SELECT ID, Name, Data,
ROW_NUMBER() OVER (PARTITION BY Name ORDER BY TimeStamp DESC) AS 'RowNumber'
FROM MySchema.MyTable
)
SELECT * FROM MostRecentRows
WHERE RowNumber = 1
</code></pre>
|
Transaction across basicHttpBinding <p>we currently have an asmx webservice which exposes a single method to make various updates to a Sql database, wrapped internally in a SqlTransaction.</p>
<p>I am re-writing this service in WCF and we would like to split up the existing method into sub-calls accessed through vario... | <p>It's very rare that you get something for nothing. The chief difference between <strong>basic</strong>HttpBinding and <strong>ws</strong>HttpBinding is that the latter supports the <strong>WS-*</strong> protocols.</p>
<p>basicHttpBinding gives you what you had with ASMX, more or less. "transactions" would be <em>mu... |
How to handle serialization changes in .NET 2.0 <p>.NET 2.0 introduced VTS (Version Tolerant Serialization,
<a href="http://msdn.microsoft.com/en-us/library/ms229752" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms229752</a>(VS.80).aspx )</p>
<p>A simple test project reveals that the default behavior in 2.0 ... | <p>In general, people want to be able to at least deserialize old data, regardless of changes to the class design. Unfortunately, BinaryFormatter (being field based) is very brittle here - even switching to automatically implemented properties <a href="http://marcgravell.blogspot.com/2009/03/obfuscation-serialization-a... |
What is the key difference between a 'Debug' and a 'Release' build in .NET? <p><strong>Duplicate of:</strong> <a href="http://stackoverflow.com/questions/90871/debug-vs-release-in-net">Debug VS Release in .net</a></p>
<p>Why there are 'Debug' and 'Release' modes on build in dot net application?</p>
<p>What is the maj... | <p>A short answer is that code built in 'Release' mode will be optimised for speed or size and also will have all the information used for debugging removed</p>
|
How Delphi 2009 converts Delphi 7 projects re build configurations <p>I'm moving frequently between D7 and D2009 with library code that works with both.</p>
<p>For ease of going both ways, I'm routinely deleting all the D2009 additional files that get created, eg: *.dproj etc, such that on entry to D2009 I'm only ever... | <p>I've just come across this exact problem.</p>
<p>In my <a href="http://melander.dk/delphi/dragdrop" rel="nofollow" title="Drag and Drop Component Suite">Drag/Drop components</a>, although I support Delphi 5 through Delphi 2010, I only distribute the dof files. I do this to avoid having to keep the dof and dproj fil... |
MySQL vs SQL Server 2005/2008 performance <p>I intend to start developing an ASP.NET application and I am wondering which database to use. Performance is very important and the database should be able to handle without issues a database of about 50GB. I am wondering however, if a SQL Server license is worth paying for.... | <p>MySQL traditionally is very fast if you are doing a lot of reads. For example in a web site there is probably a 100 to 1 read write ratio so MySQL works well. If you are planning a high transaction database then head straight to MSSQL. If money is no issue head straight to MSSQL anyway because it is a better produc... |
Iterate over choices in CheckboxSelectMultiple <p>I have a CheckboxSelectMultiple field, why can't I iterate over the single choices?</p>
<p>This doesn't work:</p>
<pre><code> {%for choice in form.travels.choices%}
{{choice}}
{%endfor%}
</code></pre>
<p>Even specifying <code>{{choice.0}}</code> doesn't help, ... | <p>Inside the template, the <code>travels</code> field as actually an instance of <code>BoundField</code> (which is a Django object that binds together the field and its value for rendering). This means the properties are somewhat different.</p>
<p>To iterate over the choices as a tuple:</p>
<pre><code>{% for choice ... |
Force garbage collection/compaction with malloc() <p>I have a C++ program that benchmarks various algorithms on input arrays of different length. It looks more or less like this:</p>
<pre><code># (1)
for k in range(4..20):
# (2)
input = generate 2**k random points
for variant in variants:
benchmark the follo... | <p>If you want the test runs to start in the same heap states, you can run them in their own processes created by fork().</p>
|
How do I do a search on my website <p>I wanted to add a search feature on a website that would allow users to search the whole website. </p>
<p>The site has around 20 tables and i wanted the search to search through all 20 tables. </p>
<p>Any one can point me into what sort of mysql queries I need to build?</p>
| <p>First of all, what about adding <a href="http://www.google.com/services/custom.html" rel="nofollow">custom Google websearch</a> to your site?</p>
<p>The hard way: You should propably do a query for each of your tables and <code>LIMIT</code> (with <code>LIKE</code> on text columns or use full text indexing if your d... |
indicating libgloss machine when building newlib for bespoke platform <p>I'm compiling newlib for a bespoke PowerPC platform with no OS. Reading information on the net I realise I need to implement stub functions in a <code><newplatform></code> subdirectory of libgloss.</p>
<p>My confusion is to how this is goin... | <p>I ported newlib and GCC myself too. And i remember i didn't have to do much stuff to make newlib work (porting GCC, gas and libbfd was most of the work). </p>
<p>Just had to tweak some files about floating point numbers, turn off some POSIX/SomeOtherStandard flags that made it not use some more sophisticated functi... |
Persistent data structures in Java <p>Does anyone know a library or some at least some research on creating and using persistent data structures in Java? I don't refer to persistence as long term storage but persistence in terms of immutability (see <a href="http://en.wikipedia.org/wiki/Persistent%5Fdata%5Fstructure">W... | <p>Builders will make your code too verbose to be usable. In practice, almost all immutable data structures I've seen pass in state through the constructor. For what its worth, here are a nice series of posts describing immutable data structures in C# (which should convert readily into Java):</p>
<ul>
<li><a href="htt... |
C# crash when loading C++ dll <p>My program is written in C# NET 2.0,it's using external functions from a dll written in C++ using Microsoft Visual Studio 2008 SP1.
If I remove the dll from the directory the program is placed,the program crashes at the moment it should use the dll.That's normal.</p>
<p>But the users t... | <p>Its most likely the wrong runtime. Make sure you are distributing the correct one. These will always work on your dev box because the runtimes are in the path. For testing software, I use a windows xp virtual machine. I set up the virtual machine as a completely fresh install, install the components I know that I ne... |
Trim first two characters from year of GETDATE() <p>I am trying to create a WHERE clause that says </p>
<pre><code>WHERE column_1 = TRIM(LEADING '20' FROM(DATEPART(year, GETDATE())))
</code></pre>
<p>Basically <code>column_1</code> contains the fiscal year but the fiscal year is in the database as 8 or 9 not 2008 or... | <p>Rather than trim, use modulus:</p>
<pre><code>...
WHERE column_1 = (YEAR(GETDATE()) % 100)
</code></pre>
|
Do I need to change anything programmatically to leverage the integrated pipeline in IIS7? <p>Do I need to change anything programmatically to leverage the integrated pipeline in IIS7? </p>
<p>If so, what's the best way to degrade gracefully and remain functional on IIS6?</p>
<p>Thanks!</p>
| <p>No, the setting is in IIS when selecting application pool (integrated mode).
I recently upgraded from IIs 6.0 to IIS 7.0. The application runs fine on both IIS 6.0 and 7.0. </p>
|
Is there a standard definition of what constitutes a version(revision) change <p>I am currently in bureaucratic hell at my company and need to define what constitutes the different levels of software change to our test programs. We have a rough practice that we follow internally, but I am looking for a standard (if it... | <p>A good practice is to use 3 level revision numbers:</p>
<p>x.y.z</p>
<p>x is the major
y is the minor
z are bug fixes</p>
<p>The important thing is that two different software versions with the same x should have binary compatibility. A software version with a y greater than another, but the same x may add featur... |
Passing the "enter key" event to flash player in an ATL Window? <p>I have a Flash player (flash9.ocx) embedded in an ATL window and have coded functionality into the swf to respond to the return/enter key being pressed.
Works fine from the standalone swf player but as soon as its played from within my embedded player i... | <p>I'm not VC++ developer, but I use Flash a lot.</p>
<p>Though not sure, it seems that the embedded player doesn't have the focus. Make sure you've got this part covered on the Flash side of things:</p>
<ul>
<li>the stage exists ( you movie is properly initialized)</li>
<li>you set the KeyboardEvent listener to the ... |
java SWT: how can I draw a widget to an offscreen buffer <p>I would like to draw the contents of a StyledText widget in to an Image; this will then provide a convenient way to stick the image into a Table cell.</p>
<p>Any suggestions about the best way to go about this?</p>
| <p>Why do you want to create an image? </p>
<p>You could just render the the StyledText-widget in the table cell. If you have a lot of items and it is a performance problem you could create a virtual table by using SWT.VIRTUAL. If you're using JFace check out <a href="http://help.eclipse.org/stable/nftopic/org.eclipse... |
ASP.NET DataSet vs Business Objects / ORM <p>I'm thinking through data access for an ASP.NET application. Coming from a company that uses a lot of Windows applications with Client Data sets there is a natural dendancy towards a DataSet approach for dealing with data.</p>
<p>I'm more keen on a Business Object approach ... | <p>You are smart to be thinking of designing a Data Layer in your app. In an ASP.NET application this will help you standardize and pretty dramatically simplify your data access. You <em>will</em> need to learn how to create and use ObjectDataSources but this is quite straightforward. </p>
<p>The other advantage of... |
The difference between + and & for joining strings in VB.NET <p>What is the difference between <code>+</code> and <code>&</code> for joining strings in VB.NET?</p>
| <p>There's no difference if both operands are strings. However, if one operand is a string, and one is a number, then you run into problems, see the code below.</p>
<pre><code>"abc" + "def" = "abcdef"
"abc" & "def" = "abcdef"
"111" + "222" = "111222"
"111" & "222" = "111222"
"111" & 222 = "111222"
"111" + ... |
database use with ExtendScript (for Adobe Illustrator) <p>I want to refactor a VB program into ExtendScript to automate some drawing in Adobe Illustrator CS4, but have a requirement to read from a database. Is it possible to read from a database using ExtendScript? How?</p>
| <p>Illustrator scripting engine doesn't provided any mechanism to read external data directly, but you have several ways to do this...</p>
<ol>
<li>Write an external program which connecting database to generate VB script, and use Illustrator to exec the 'generated' script, which is the old way I have done.</li>
<li>T... |
OO Design - do you use public properties or private fields internally? <p>I'm working in C# 2.0, but this would apply to most object oriented languages. When I create classes with public properties that wrap private fields, I switch back & forth between whether I should use the property or field internally. Of cour... | <p>Basically, because you can implement your validation and other logic in the property, you should access through the property unless you have a specific reason not to.</p>
<p>It helps with consistency within your object, because that way you know that the values of your private fields have gone through whatever rigo... |
Getting started with subversion <p><strong>Duplicate of..:</strong></p>
<ul>
<li><a href="http://stackoverflow.com/questions/2658/version-control-getting-started">Version Control. Getting startedâ¦</a></li>
<li><a href="http://stackoverflow.com/questions/35670/how-do-I-begin-using-svn">How do I begin using SVN?</a></... | <p>Get your developers to read the free online <a href="http://svnbook.red-bean.com/" rel="nofollow">Red-Bean Book</a>. It's excellent, and covers all aspects of the process, including probably the best description of branching you'll find anywhere.</p>
|
How to crop an image using C#? <p>How can I write an application that will crop images in C#?</p>
| <p>Check out this link: <a href="http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing">http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing</a></p>
<pre><code>private static Image cropImage(Image img, Rectangle cropArea)
{
... |
Python: Reference to a class from a string? <p>How to use a string containing a class name to reference a class itself?<br />
See this (not working) exemple...</p>
<pre><code>class WrapperClass:
def display_var(self):
#FIXME: self.__class_name__.__name__ is a string
print self.__class__.__name__.th... | <blockquote>
<p>How to use a string containing a class name to reference a class itself?</p>
</blockquote>
<p>Classes aren't special, they're just values contained in variables. If you've said:</p>
<pre><code>class X(object): pass
</code></pre>
<p>in global scope, then the variable âXâ will be a reference to t... |
Delphi - Using the TApplicationEvents OnShortCut event to detect Alt+C key presses <p>I am using TApplicationEvents OnShortCut event to get application keyboard short cuts in a Delphi program.</p>
<p>Using the following code:</p>
<pre><code>procedure TForm1.ApplicationEvents1ShortCut(var Msg: TWMKey; var Handled: Boo... | <p>Like so:</p>
<pre><code>procedure TForm1.ApplicationEvents1ShortCut(var Msg: TWMKey;
var Handled: Boolean);
begin
if (Msg.CharCode = Ord('C'))
and (HiWord(Msg.KeyData) and KF_ALTDOWN <> 0)
then begin
ShowMessage('Alt+C pressed!') ;
Handled := TRUE;
end;
end;
</code></pre>
<p>Please note t... |
Does it make sense that there may be more than one class that conforms to the UIApplicationDelegate protocol in an iPhone App? <p>I think I've understood what that Delegate is supposed to do. If a class conforms to that protocol, it tells the underlying system: "Hey man, I am the UIApplication object's delegate! Tell m... | <p>While you could implement multiple classes that conform to the UIApplicationDelegate protocol only one, the first, would receive these messages.</p>
<p>Implementing a protocol to create a delegate is only one part of the equation. That delegate then has to be registered with the code that's generating the messages ... |
C# LINQ to SQL: Refactoring this Generic GetByID method <p>I wrote the following method.</p>
<pre><code>public T GetByID(int id)
{
var dbcontext = DB;
var table = dbcontext.GetTable<T>();
return table.ToList().SingleOrDefault(e => Convert.ToInt16(e.GetType().GetProperties().First().GetValue(e, nul... | <p>What you need is to build an expression tree that <a href="http://en.wikipedia.org/wiki/Language_Integrated_Query#LINQ_to_SQL">LINQ to SQL</a> can understand. Assuming your "id" property is always named "id":</p>
<pre><code>public virtual T GetById<T>(short id)
{
var itemParameter = Expression.P... |
Can the "Application Error" dialog box be disabled? <p>I am using Hudson as a continuous integration server to test C/C++ code. Unfortunatly, I have a bug somewhere that causes memory corruption, so on some Windows machines I will sometimes get a "Application Error" dialog box explaining that an instruction referenced... | <ol>
<li>Use "Disable error reporting", as Mr. Gently suggests. See also <a href="http://www.pcworld.com/article/108734/window%5Ftips%5Fxp%5Ferror%5Fmessagesyou%5Fdecide%5Fwhat%5Fto%5Freport.html">this PC World article</a>.</li>
<li>If you happen to have MS Visual Studio on your build machine, it will catch Applicatio... |
Java reflection - access protected field <p>How can I access an inherited protected field from an object by reflection?</p>
| <p>Two issues you may be having issues with - the field might not be accessible normally (private), and it's not in the class you are looking at, but somewhere up the hierarchy.</p>
<p>Something like this would work even with those issues:</p>
<pre><code>public class SomeExample {
public static void main(String[] ... |
How do I programmatically tell if a client machine has the Microsoft.Jet.OLEDB.4.0 as a valid provider? <p>I need to export data into an Access database. My code works, but it works with the assumption the client machine has the Microsoft.Jet.OLEDB.4.0 as a valid provider.</p>
<p>I want to test to see if this is true... | <p>You could simply check for the existence of</p>
<pre><code>HKEY_CLASSES_ROOT\CLSID\{dee35070-506b-11cf-b1aa-00aa00b8de95}
</code></pre>
<p>which is the CLSID of Microsoft.Jet.OLEDB.4.0.</p>
|
How to get a user's client IP address in ASP.NET? <p>We have <code>Request.UserHostAddress</code> to get the IP address in ASP.NET, but this is usually the user's ISP's IP address, not exactly the user's machine IP address who for example clicked a link. How can I get the real IP Address?</p>
<p>For example, in a Stac... | <p>Often you will want to know the IP address of someone visiting your website. While ASP.NET has several ways to do this one of the best ways we've seen is by using the "HTTP_X_FORWARDED_FOR" of the ServerVariables collection.</p>
<p>Here's why...</p>
<p>Sometimes your visitors are behind either a proxy server or a ... |
Another Safari width issue with CSS <p>I am making this web site <a href="http://www.christopherbier.com/gbg/locations.html" rel="nofollow">http://www.christopherbier.com/gbg/locations.html</a></p>
<p>In safari on mac the content div is larger in width than it is in other browsers. It overlaps the right side bar bit. ... | <p>I don't have a mac so can't see, but a few points:</p>
<blockquote>
<blockquote>
<p>your xhtml is not valid. center> doesn't exist anyomre (and by the looks of things isn't actually needed in the design anyway), also you shoudl specify the dimensions of any the header image in px.</p>
<p>don't know w... |
ASP.NET MaskedEditExtender & TextBox: Cannot enter zero, workarounds? Solutions? <p>I'm trying to enter a 0 into a Textbox hooked into a MaskedEditExtender. My mask is set for a NUMBER(13,2) with 9999999999999.99 as my Decimal mask.</p>
<p>The problem is that the user HAS to enter a number. The value can be 0. I've te... | <p>Generally use this property, if its 0 then user shud not even need to enter anything</p>
<blockquote>
<p>AutoCompleteValue - Default character
to use when AutoComplete is enabled</p>
</blockquote>
|
How to save a Java FloatBuffer (or any Buffer) to a file <p>I have a FloatBuffer of known size and just want to dump the data to a file (in binary) for inspection outside my app. What's the easiest way to do this?</p>
| <p>UPDATE FOR BINARY OUTPUT:</p>
<pre><code>// There are dependencies on how you create your floatbuffer for this to work
// I suggest starting with a byte buffer and using asFloatBuffer() when
// you need it as floats.
// ByteBuffer b = ByteBuffer.allocate(somesize);
// FloatBuffer fb = b.asFloatBuffer();
// There wi... |
Using StructureMap to cache a named instance <p>I'm having difficulty figuring out how to have StructureMap cache a non-default instance. I can cache the default instance with code like this</p>
<pre><code>ForRequestedType<ISession>()
.CacheBy(InstanceScope.HttpContext)
.TheDefault.Is.Co... | <p>this was as close as I was able to get quickly</p>
<pre><code>ForRequestedType<IInterface>()
.AddInstances(x => x
.OfConcreteType<Implementation>()
.WithName("foo"))
.CacheBy(InstanceScope.HttpContext);
</code></pre>
|
WCF on PocketPC, not connecting to host machine <p>I'm working with a PocketPC vm for development over here.</p>
<p>I can get the virtual device to connect to the internet, but I can't get it to connect to a web service on my local (host) machine.</p>
<p>I've tried the machine name and my IP address, different ports,... | <p>I have not had the specific issue. But, the best way I've found to deal with these issues when using WCF is to <a href="http://msdn.microsoft.com/en-us/library/ms733025.aspx" rel="nofollow">enable tracing</a> and see what the error messages are.</p>
|
Unit testing against large databases <p>I would like to ask about your suggestions concerning unit testing against large databases.</p>
<p>I want to write unit tests for an application which is mostly implemented in T-SQL so mocking the database is not an option.
The database is quite large (approx. 10GB) so restorin... | <p>I'm not sure I entirely agree with your assumption that you cannot restore the database after a test run. While I definitely agree that some tests should be run on a full-size, multi-TB database, I don't see why you can't run most of your tests on a much, much smaller test database. Are there constraints that need... |
SQL Query: How do you combine count function result into a select query? <pre><code>select distinct Franchise.FranchiseName, Franchise.Initials, Franchise.StoreNo, AccountCancellation_Process.Store_Num
FROM FranchiseData
INNER JOIN AccountCancellation_Process
on FranchiseData.StoreNo = AccountCancellation_Process.Stor... | <p>Like this I think is what you want.
I created two table value correlated subqueries to get the data based on the stored number in the inner join table. Then I join them based on the store number. That way the distinct will work. But you might also be able to do the counts in the select part with using just correl... |
jQuery Selectors <p>I'm finding it difficult to find examples of using jQuery, so my bad for asking such a simple question. I've got this ul:</p>
<pre><code><ul id="navLinks">
<li class="selected" id="homeNavLink"></li>
<li id="aboutNavLink"></li>
<li id="contactNavLink"&g... | <p>You don't have to do <code>.each</code> - functions like <a href="http://docs.jquery.com/Removeclass" rel="nofollow"><code>removeClass</code></a> can work on a set of elements just fine.</p>
<pre><code>function changeNavLink(selectedId) {
$("#navLinks li").removeClass('selected')
.filter('#... |
spymemcached (Java Memcached Client) <p>Is there a way to collect the memcached stats using this API (<strong>spymemcached</strong>)?</p>
<p>I know there are tools like cacti to collect information on Memcached Server. But I would like to collect, say, memory usage by each item I have put into the server--the total no... | <p><a href="http://dustin.github.com/java-memcached-client/apidocs/net/spy/memcached/MemcachedClient.html#getStats%28%29" rel="nofollow">getStats()</a></p>
|
File from SOAP, how to save? <p>I am working with a client on getting a gzip from their webservice. I am able to get a response with my following call:</p>
<pre><code>$response = $client->call('branchzipdata', $param);
$filename = "test.gzip";
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($fi... | <p>(Edited based on the comments)</p>
<p>If the return value is base64-encoded, you need to base64-decode it before you write it to the file. Alternatively you could write it out to a file which you then base64-decode to <em>another</em> file before trying to open it, but that seems a bit pointless compared with just ... |
Expanding this Regular Expressions to remove all special characters <p>How can I expand this to remove any special characters e.g. <code>:</code> <code>;</code> <code>,</code> etc. but still do what it does now which is remove <code><div></code> tags:</p>
<pre><code>string BBCSplit = Regex.Replace(BBC, @"<(.|... | <pre><code>string BBCSplit = Regex.Replace(BBC, @"<(.|\n)*?>|[:;]", string.Empty);
</code></pre>
<p>By careful if the "special" characters you want to remove include '"", ']', etc.--you'll need to put a '\' before them.</p>
|
How to load an image server-side in ASP.NET? <p>I'm trying to load an image that is in the root dir of my project:</p>
<pre><code>Dim b As Bitmap = New Bitmap("img.bmp")
</code></pre>
<p>but it doesn't seem to find the file.</p>
<p>I've tried various combinations like ~img.gif, /img.gif, \img.gif, ~/img.gif etc, but... | <p>Have you tried:</p>
<pre><code>Dim b As Bitmap = New Bitmap(HttpContext.Current.Server.MapPath("~/img.bmp"))
</code></pre>
|
Why are methods in Ruby documentation preceded by a hash sign? <p>This is something that has been bugging me for a while. When I see any Ruby method printed in text, it usually appears as:</p>
<pre><code>Class#method
</code></pre>
<p>or </p>
<pre><code>#method
</code></pre>
<p>Now, I would use:</p>
<pre><code>Cla... | <p>Note that the convention is:</p>
<pre><code>Class#method
</code></pre>
<p>rather than</p>
<pre><code>object#method
</code></pre>
<p>In code you would have <code>object.method</code>, if <code>object</code> was an instance of <code>class</code>. The <code>#</code> convention is not used in code.</p>
<p>From <a h... |
If I have a direct reference to a google app engine Property object, how do I get() or set() upon it? <p>Assume I have a Model class called Bird and a instance of Bird called pigeon. I know I can get all the Properties of Pigeon (or bird) using</p>
<pre><code>properties = pigeon.properties() #Note, Bird.properties() w... | <p>I played around with <a href="http://con.appspot.com" rel="nofollow">App Engine Console</a>, which is great for testing and experimenting. It looks to me like you want to use <code>__set__</code>, with the first argument being your model instance, and the second being the new value. Next you need to <code>put()</c... |
Interface exposes type A, but implementation requires type B (subclass of A) <p>I have a system which I've been wrestling with for a while. Essentially, it uses a lot of abstraction to deal with the fact that later extension is not just expected, but necessary. One place this is required is data access. The system gene... | <p>I'm not sure if this is what you want, but it seems to me you could try doing it with generics:</p>
<pre><code>public interface Observation<T> where T : UniqueKey
{
T Key { get; }
}
public interface ObservationDataSource<T> where T : UniqueKey
{
Observation<T> GetObservationByUniqueKey(T ... |
How do I export Readonly variables with mod_perl? <p>I'm trying to make it easier to follow some <a href="http://oreilly.com/catalog/9780596001735/" rel="nofollow">Perl Best Practices</a> by creating a <code>Constants</code> module that exports several of the scalars used throughout the book. One in particular, <code>... | <p>I'm the author of the Readonly module. The next version of Readonly will provide support for mod_perl, specifically because of this problem.</p>
<p>I know this doesn't solve your problem <em>now</em>, but... well, I'm working on it :-)</p>
<p>-- Eric</p>
|
strange problem with java.net.URL and java.net.URLConnection <p>I'm trying to download an image from a url.
The process I wrote works for everyone except for ONE content provider that we're dealing with.</p>
<p>When I access their JPGs via Firefox, everything looks kosher (happy Passover, btw). However, when I use my ... | <p>Maybe the site is just using some kind of protection to prevent others from hotlinking their images or to disallow mass downloads.</p>
<p>They usually check either the HTTP referrer (it must be from their own domain), or the user agent (must be a browser, not a download manager). Set both and try it again.</p>
|
ThreadA and ThreadB both call WaitOne() in that order on the same AutoResetEvent - when the event is set, why does ThreadB get released instead of ThreadA? <p>I ran a test to find out what happens when you set an AutoResetEvent on which mutiple threads are waiting:</p>
<pre><code> private static void Test()
{
... | <p>IIRC, which thread is released by an auto-reset event is unspecified. As everyone else mentioned, you want a manual reset event if you want to broadcast a condition. If you want to release an exact number (say exactly 3 of n), then you probably want to use a semaphore.</p>
<p>If you really want to dig into why the ... |
How Do You Dynamically Graph/Chart Interval Data w/ OpenOffice Calc? <p>I'm interested in creating one or more spreadsheet graphs of interval metered data. The raw data is recorded as a continuously increasing value (i.e. total bytes, user logins, website hits) and date. Each sample measurement date will happen at a no... | <p>While you maybe can use spreadsheets for this, I think this is better done with tools specifically made for such graphing. If you search for "graph network traffic" or "graph disk temperature" you should get loads of results with different solutions.</p>
<p>For monitoring network cards/routers <a href="http://oss.o... |
getting a view controller to disappear <p>I'm trying out a multiple view application, but I can't seem to get the first view controller to go away when I bring in the new view controller. I'm laying the second (coming) view controller at index 0, and it's just placing it in the background. I thought the [going.view ... | <p>First a little refactoring:</p>
<pre><code>coming = (answer ? boyController : girlController);
</code></pre>
<p>You can delete <code>going</code> and <code>transition</code>, as they're only used once. Then, to actually do the animation, you need to put everything in the context of an animation block.</p>
<pre><c... |
PHP arrow operator closing tags <p>I am writing a php app on the websever I set up at my house. It is a fedora10 machine, running php5 and mysql. I have code like this:</p>
<pre><code><?php echo $var->function(); ?>
</code></pre>
<p>But for some reason the -> is closing the php tag, so the output has 'func... | <p>I dont think that you have mod_php enabled in your apache config file, or else you would never see the php code in the output. <a href="http://dan.drydog.com/apache2php.html" rel="nofollow">Here is a good tutorial</a> on setting up php 5 in apache.</p>
|
Is The Web's version of MVC different than traditional MVC? <p>I've done a fair amount of work on MVC on the web, and we're learning about it in my OOP class. I'm seeing some differences, and I can't tell whether that's because the Web's version of the MVC pattern is different than the traditional one, or whether I mis... | <p>In a non-web interface the controller handles the inputs from things like the keyboard and mouse, choosing which views to render and what changes to make in the model based on those inputs. The view and model can be more closely related because the view can register callbacks directly with the model entities to be ... |
Are Windows Logo (TM) Certified applications harder to write in Java? <p>Third party vendors using our software as a component view Windows Logo Certification as an important selection criteria. 90% of the requirements are easy to adhere to given the flexibility in deploying Java programs. Some immediate difficulties... | <p>For the look and feel, call this at the beggining of your <code>main()</code> function:</p>
<pre><code> log.info("Setting java look and feel");
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
log.warn("Could not set system look and feel",... |
Add new attribute (element) to JSON object using JavaScript <p>How do I add new attribute (element) to JSON object using JavaScript?</p>
| <p>JSON stands for JavaScript Object Notation. A JSON object is really a string that has yet to be turned into the object it represents.</p>
<p>To add a property to an existing object in JS you could do the following.</p>
<pre><code>object["property"] = value;
</code></pre>
<p>or </p>
<pre><code>object.property =... |
daemon threads in an app container <p>I read in <a href="http://www.igniterealtime.org/community/message/189500" rel="nofollow">a post</a> to the Smack forum recently that </p>
<blockquote>
<p>Starting daemon threads in a Java EE server is a big no no</p>
</blockquote>
<p>Basically Smack's XMPPConnection starts one... | <p>Yes, XMPPConnection creates two threads--one for listening/reading and one for writing. But these only live as long as the XMPPConnection instance, which I assume is not forever. </p>
<blockquote>
<p>"Starting daemon threads in a Java EE server is a big no no"</p>
</blockquote>
<p>Are you writing spec complian... |
Need ad-hoc reporting component <p>We need some simple ad-hoc reporting solution for our ASP.NET web-site.</p>
<p>Just an ability to build a query with user friendly interface, then show the result of this query in some table and maybe export it to Excel or print.</p>
<p>The solution must be quite easy for end users ... | <p><a href="http://devtools.korzh.com/eq/dotnet/">EasyQuery.NET</a> may suit your needs.
It is proprietary but they have free version as well.</p>
|
How do I find the smallest item in an array? <p>I have an array, and need to find the index of the smallest item, using Java or C, without altering the content or ordering of the array.</p>
<p>For example, with the input:</p>
<pre><code>a = [2, 2, 2, 3, 3, 4, 3]
</code></pre>
<p>0 should be returned.</p>
<p>I am un... | <blockquote>
<p>It should return me the array position of the smallest number.</p>
</blockquote>
<p>Simply iterate through the array, keeping track of whether a particular index has a smaller value than the smallest one encountered so far.</p>
<p>In pseudocode:</p>
<pre><code>j = 0
for i = 1 ... arr.length:
if ... |
ASP.NET MVC retrieving route to controller, action and parameters <p>In ASP.NET MVC how can I generate a URL to a specific controller and action along with other parameters. The RedirectToAction allows me to redirect, but I would like to retrieve this URL instead from within my controller.</p>
<p>I tried using:</p>
<... | <p>What do your routes look like? The standard route expects an id as the third parameter. If you haven't changed your routes, try using:</p>
<pre><code>Url.Action( "Page", "Administrator", New With { id = _currentPage } )
</code></pre>
|
How does the DiggBar work? <p>How does the DiggBar work? </p>
<p>I'm trying to make an ASP.NET MVC DiggBar clone just for learning purposes and does anyone have a suggestion on how to specify the url of the content for the lower frame? How would you go about constructing that in MVC?</p>
<p>Also, I know that it is ... | <p>The basic <code>html</code> is:</p>
<pre><code><html>
<head>
<style type="text/css">
#toolbar {position: fixed; top: 0; height: 40px; width: 100%; ... }
#page {width: 100%; height: 100%;}
</style>
</head>
<div id="toolbar">
All your toolbar stuff here.
</div>
... |
"Administer Web Site" equivalent for IIS deployment <p>During development, i can easily manage my users/roles/smtp etc using the "Administer Web Site" or "ASP.net configuration "command in Visual Studio. Once the site is deployed to a IIS server, How can i get the same functionality (user and role management).</p>
<p>... | <p>The IIS admin tools will be available on the production server as well. <a href="http://blogs.neudesic.com/blogs/phil%5Fscott/archive/2006/07/04/187.aspx" rel="nofollow">Here is a blog post</a> on the ASP.NET config. web site.</p>
<p>Edit for comment:</p>
<p>I don't think you can just copy the exe over. I think ... |
SqlConnectionStringBuilder form in .net C# <p>I am wondering how I can add DATA LINK form to my WIN application.
You know those forms where Users can choose on witch SQL server they going to connect
and what type of security they going to use and on wht database. </p>
<p>Something like on this picture
<img src="http:... | <p>You can do it through some COM Introp...but then you have to pull in a bunch of Interop assemblies into your project which can be a drag. This code will show the dialog using reflection instead.</p>
<pre><code>public static string ShowDialog( IWin32Window owner,
string connectionSt... |
Should I call my validation script in the prebuild section of my ccnet.config? <p>I have a ccnet.config section which I had implemented for a demo purpose. So I have a simple validation check which is done before my build is being triggered. So if the validation passes then my build starts of successfully.So validation... | <p>The prebuild section is executed before the source is updated, so you probably want to call your bat file in the tasks section instead. </p>
<p>I would make the vbs/bat file do the comparing/validating as well as the counting, then you just have to exit with an errorlevel > 0 to indicate that the build should fail.... |
Resized images not smooth in flex <p>I am loading images in flex 3.0 , but when they are resized they look grainy and distortered . Can i give some sort of effect or dsomething to fix this .thanks </p>
| <p><a href="http://blog.flexmonkeypatches.com/2007/02/05/scaling-an-image-with-smoothing/" rel="nofollow">Try this site. Flex Monkey Patches</a></p>
|
The deserializer has no knowlege of any type that maps to this contract <p>I'm trying to serialize and deserialize a tree of Node objects. My abstract "Node" class as well as other abstract and concrete classes that derive from it are defined in my "Informa" project. In addition, I've created a static class in Informa ... | <blockquote>
<p>All classes that derive from Node,
including Building, have the
[KnownType(typeof(type t))] attribute
applied to them.</p>
</blockquote>
<p><code>KnownType</code> is usually applied to the <em>base</em> type - i.e.</p>
<pre><code>[DataContract, KnownType(typeof(Building)), ...]
abstract class ... |
problem with mvc beginform <p>I have two dropdowns in my form.
Selected values from this dropdowns should be send to the proper route.
One is called "category" and second is called "status".
When I send my form I don't get expected:</p>
<p>Home/List/category/status adress</p>
<p>but something like this:</p>
<p>Home/... | <p>If you have parameters appended as a query string this means they don't have a place in the route so you have to setup a route for them. Somewhere in your route you need to have a place for them to fall.</p>
<p>You would need to add a route or change the default one to look like this...</p>
<pre><code>routes.MapR... |
Is there ever a good reason to use Insertion Sort? <p>For general-purpose sorting, the answer appears to be no, as quick sort, merge sort and heap sort tend to perform better in the average- and worst-case scenarios. However, insertion sort appears to excel at incremental sorting, that is, adding elements to a list one... | <p>From <a href="http://www.sorting-algorithms.com/insertion-sort" rel="nofollow">http://www.sorting-algorithms.com/insertion-sort</a>:</p>
<blockquote>
<p>Although it is one of the elementary sorting algorithms with
O(n<sup>2</sup>) worst-case time, insertion sort
is the algorithm of choice either when
the da... |
Is ASP.NET MVC 1.0 Futures beta/preview code? <p>I understand that the "1.0" in "ASP.NET MVC 1.0 Futures" means that it is the ASP.NET MVC Futures built against the ASP.NET MVC 1.0 RTW (final/release to web). What I'd like to know is whether the Futures code is solid enough to treat as 1.0 / gold quality?</p>
<p>We're... | <p>It is the official release, not the beta. However, like any Microsoft product, 2.0 will always better if you can wait, but as far as your question concerned, it's the full release.</p>
|
Good Java community and resource <p>I've just started learning Java as part of my uni course, and am so far really liking it. I did a quick search to try and find a Java Community online, but haven't really had any luck. I was looking for something along the lines of gotoandlearn.com and www.kirupa.com like the flash c... | <p>You can try javaranch.com. It is one of most active Java community on Internet.</p>
|
Which SOAP XML object serialization library for Java would you recommend? <p>Which Java SOAP XML object serialization library would you recommend for <strong>Java object exchange</strong> with other platforms / languages (.NET, Delphi)?</p>
<p>Communication scenarios could look like this:</p>
<ul>
<li>Java object wri... | <p>I prefer JAX-WS (with JAXB 2.1 databinding) over the other liberaries I've used (JAX-RPC, Axis 1 and 2, but not XFire). The JAXB 2 databinding uses generics, which makes for a pleasant mapping of properties with a maxoccurs > 1. JAX-WS itself is reasonably well documented and provides a reasonably good API. The meth... |
Create Weak Multimap with Google Collections <p>Is there an equivalent to the nice MapMaker for MultiMaps?
currently i create the cache like this:</p>
<pre><code> public static Map<Session,List<Person>> personCache = new MapMaker().weakKeys().makeMap();
</code></pre>
<p>the whole point of MultiMap is ... | <p>Unfortunately not. Yet. Could you file a MultimapMaker feature request in our issues db?
<a href="http://google-collections.googlecode.com" rel="nofollow">http://google-collections.googlecode.com</a></p>
|
Why doesnât url rewrite work in server <p>In asp.net 3.5, I'm rewriting the url</p>
<pre><code> http://www.dotoobeta/blogs/1108
</code></pre>
<p>to the following</p>
<pre><code> http://www.dotoobeta/blogs/blogs.aspx
</code></pre>
<p>I am using the <code>UrlRewritingNet.UrlRewriter.dll</code> and it works fi... | <p>Perhaps your server is not configured to route requests like <a href="http://www.dotoobeta/blogs/1108" rel="nofollow">http://www.dotoobeta/blogs/1108</a> through ASP.NET pipeline. If you have IIS 6 or higher on the server, you can configure wildcard handler and handle everything via ASP.NET. Don't forget to uncheck ... |
Is double-checked locking safe in Ruby? <p>This <a href="http://en.wikipedia.org/wiki/Double%5Fchecked%5Flocking%5Fpattern" rel="nofollow">article</a> states that double-checked locking is unsafe on certain language/hardware combinations when a shared variable can be updated with a reference to an object that is only p... | <p>Which implementation of Ruby? Ruby 1.8, 1.9, and JRuby have quite different threading implementations so it may be impossible to say.</p>
<p>I don't have the answer for your question, but it appears that you might be trying to write fast concurrent code in Ruby. My experiences with Ruby 1.8 is that this isn't a r... |
Show YouTube video in a Drupal Section <p>Thanks to <a href="http://stackoverflow.com/questions/736755/multiple-sections-in-content-block-for-drupal">the help of SOers</a>, now I can create a few sections in a Drupal page using <a href="http://drupal.org/project/panels" rel="nofollow">Panels module</a>. I want to embed... | <p>Paste the "embed" code directly into the node body and set the Input format to be Filtered HTML. No need for any additional modules.</p>
|
send form data as web service in symfony <p>I am making a restrictive portal to a WiFi network using symfony, and I want to send a form as web service to other sites that want to use this portal. How should I solve this? I realize I could go the SOAP/WSDL route, but since symfony is already RESTful, it seems to me I co... | <p>to call restfull service somewhere you simply call its URL and read result. Do you have any example of what exactly is not working? Does "other" service support restfull calls? :) I hope so. </p>
<p>Calling rest service is really as easy as opening a website with some parameters in URL. So I am wondering what shoul... |
C/C++: Array size at run time w/o dynamic allocation is allowed? <p>I've been using C++ for a few years, and today I don't know if this is a mere brainfart or what, but how can this be perfectly legal:</p>
<pre><code>int main(int argc, char **argv)
{
size_t size;
cin >> size;
int array[size];
for... | <p>This is valid in C99. </p>
<p>C99 standard supports variable sized arrays on the stack. Probably your compiler has chosen to support this construct too.</p>
<p>Note that this is different from <code>malloc</code> and <code>new</code>. <code>gcc</code> allocates the array on the stack, just like it does with <code>... |
LINQ: How to perform an update like UPDATE <T> SET Update(<T>, <T>) SELECT FROM clause in LINQ? <p>I want to update and insert some records based on a csv I read. The insert is not a problem, but how to update a bunch of data in a single statement? I have not clear how to join them.</p>
<pre><code>Update Item
Set
Na... | <p>I'm making the assumption that TextFile is an in memory collection of objects that you've read from the CSV file and Items is a Table in the data context from your database. In that case I don't think you will be able to do an actual join without first fetching all of the items from the database into an in memory c... |
Why prefer Properties to public variables? <p>Other being able to sanity check values in a setter is there a more underlying reason to prefer properties to public variables?</p>
| <p>We've had this subject before but I can't find anything now.</p>
<p>In brief: your needs might change: where there's no sanity check now, one might be required in the future. However, if you change your public fields to properties, this breaks binary compatiblity: every client who uses your code/library would have ... |
Exporting a web from to MS word <p>IS it possible to export a web page contents to MS word? If yes give some links to refer.</p>
| <p>^A ^C ^V ^S ?</p>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.