input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
How do I find the name of the calling function? <p>I have been using PRETTY_FUNCTION to output the current function name, however I have reimplemented some functions and would like to find out which functions are calling them.</p>
<p>In C++ how can I get the function name of the calling routine?</p>
| <p>Here is a solution you can often use. It has the advantage of requiring no changes to the actual function code (<em>no adding calls to stackwalk functions, changing parameters to pass in function names, or linking to extra libraries.</em>). To get it working, you simply need to use a bit of preprocessor magic:</p>... |
How do I replace an Int property with an Enum in Entity Framework? <p>I have an entity class that has a property with an underlying db column of datatype Int, however in reality I want this property to be an Enum. Is there any way to specify that this property returns an Enum?</p>
| <p>Indirectly, like <a href="http://weblogs.asp.net/alexeyzakharov/archive/2008/09/18/enum-in-ado-net-entity-framework-v1.aspx" rel="nofollow">so</a>.</p>
<p>Personally, I leave the storage int public (for example as <code>DbFoo</code>, where the enum property is <code>Foo</code>) - that way I can still write lambdas ... |
ActiveX component can't create object (comReport) <p>I am trying to print a pdf report and it is not printing and giving this error.
Error Type:
ComReport (0x800A01AD)
ActiveX component can't create object</p>
<p>I have registered the ComReport.dll with my OS.</p>
<p>This works fine on our developemtn and production... | <p>Maybe it is a missing reference.
You can use "Depends.exe" (Shipped with Visual Studio) to determine missing libraries.</p>
|
How can I detect a ThreadAbortException in a finally block? (.NET) <p>I have some critical logic in a finally block (with an empty try block), because I want to guarantee that the code gets executed even if the thread is aborted. However, I'd also like to detect the ThreadAbortException. I've found that wrapping my cri... | <p>This is a curious problem.</p>
<p>The code you posted <em>should</em> work. It seems there's some kind of optimization going on that decides not to call your catch handler.</p>
<p>So, I wanted to detect the exception with this:</p>
<pre><code>bool threadAborted = true;
try {
try { }
finally { /* critical code... |
What is a line of code? <p>I realize there's no definitely "right" answer to this question, but when people talk about lines of code, what do they mean? In C++ for example, do you count blank lines? comments? lines with just an open or close brace?</p>
<p>I know some people use LoC as a productivity measure, and I'm ... | <p>No, there is no standard convention, and every tool that counts them will be slightly different.</p>
<p>This may make you ask, "Why then would I ever use LOC as a productivity measure?" and the answer is, because it doesn't really matter how you count a line of code, as long as you count them consistently you can ... |
Easiest way to get a common base class from a collection of types <p>I'm building a custom property grid that displays the properties of items in a collection. What I want to do is show only the properties in the grid that are common amongst each item. I am assuming the best way to do this would be to find the the comm... | <p>You can do this with a method that keeps checking for common base classes. I wrote up this, quickly, using the BaseClass feature of the Type class. You don't have to use an array, a list or other IEnumerable can work with small modifications to this. </p>
<p>I tested it with:</p>
<pre><code>static void Main(string... |
Facebook sharer, pass in a comment? <p>Is it possible to post a description/comment variable to the facebook sharer url? It's only possible for url and title as far as I can figure out.</p>
| <p>The parameters that you can pass to the actual <code>sharer.php</code> are "u" and "t" which are <code>url</code> and <code>title</code>. You can add <code>meta</code> tags to your page to get more info to appear in the sharer. To quote the <a href="http://www.facebook.com/share_partners.php" rel="nofollow">docs</... |
Prevent creation of class whose member functions are all static <p>All the member variables and member functions in my class ClassA are static. </p>
<p>If a user is trying (by mistake) to create an object of this class, he receives a warning: "ClassA, local variable never referenced", because all the functions are sta... | <p>Instead of using a class with all static methods, you may be better off making the methods free-standing functions in a separate namespace. The call syntax would be the same:</p>
<p><code>namespace::function()</code> instead of <code>classname::function()</code></p>
<p>and you don't need to deal with someone tryin... |
How do I make LINQ to XML and HTML work together? <p>I have an html table </p>
<pre><code> <table border="0" width="100%">
<tr class="headerbg">
<th width="5%">
No
</th>
<th width="30%">
Name
</th&... | <p>You can actually use an HTML table as a data source for OLE DB:</p>
<p><a href="http://connectionstrings.com/html-table" rel="nofollow">http://connectionstrings.com/html-table</a></p>
<p>Full Disclosure: I haven't actually tried this - but I'm guessing it'll be much easier than trying to parse XML out of HTML.</p>... |
Open-source IDE's with Git support <p>I'm having trouble finding an open-source IDE with support for Git. Are there any that you could point me to or recommend?</p>
| <p>There's an <a href="http://www.eclipse.org/egit/" rel="nofollow">Eclipse plugin in progress</a>.</p>
|
.NET Web Service Best Practice for multiple developers <p>We have a large ASP.NET project consisting of several hundred reports. We are in the process of moving all the SQL Queries (running against an Oracle Database) into three web services. The web services are categorized by command, selections and report queries.... | <p>This problem would seem to be quite independent of the purpose of the software. The issue here is that you have a small, finite number of files that multiple developers will be working with on a daily basis. I do not have experience with Serena ChangeMan software nor TFS other than playing around with it. I do ha... |
Is storing an array of objects in ASP.NET viewstate the best solution for this? <p>I'm wondering if storing the data in viewstate is a good idea for this given problem.
He's a simplified example of what I am trying to achieve, firstly we have a Repeater control:</p>
<pre><code><asp:Repeater id="Repeater1" runat="se... | <p>Are you persisting the entire list from the database in the viewstate or just the uncommitted additions?</p>
<p>If it's just the additions, then this is a fine use of viewstate.</p>
<p>If the list from the DB isn't very large or volatile, then I guess that'd be OK, too.</p>
|
How does OpenID authentication work? <p>I am a little curious to know about how OpenID authentication works.</p>
<p>Is there any difference between OpenID authentication and the authentication which sites use exclusively for themselves?</p>
| <h2>What is OpenID?</h2>
<blockquote>
<p>OpenID is an open, <strong>decentralized</strong>, <strong>free</strong> framework for user-centric digital identity. OpenID takes advantage of already existing internet technology (URI, HTTP, SSL, Diffie-Hellman) and realizes that people are already creating identities for t... |
How do I do a join in SQL based on table name? <p>Ok, so we have a bunch of tables that are named like this:</p>
<pre><code>training_data_001
training_data_002
training_data_003
training_data_004
training_data_005
</code></pre>
<p>And then to find those we look at a field in another table, let's just call it master.t... | <p>You can only use dynamic SQL to read master.training_type to build a string that you then execute using <code>EXEC (@stringvar)</code></p>
|
Large MySQL tables <p>For a web application I'm developing, I need to store a large number of records. Each record will consist of a primary key and a single (short-ish) string value. I expect to have about 100GB storage available and would like to be able to use it all.</p>
<p>The records will be inserted, deleted an... | <p>Whatever solution you use, since you say your database will be write-heavy you need to make sure the whole table doesn't get locked on writes. This rules out MyISAM, which some have suggested. MyISAM will lock the table on an update,delete or insert. That means any client who wants to read from the table will hav... |
How do I pass pointers to a DLL using Win32:API? <p>I am trying to passing in 3 pointers to a DLL function. I have:</p>
<pre>
{
$code=1;
$len=100;
$str=" " x $len;
$function = new Win32::API(DLLNAME,'dllfunction','PPP','V');
$function->Call($code,$str,$len);
}
</pre>
<p>The DLL is defined as <code>void dllfunctio... | <p>AH!! I figured it out.</p>
<p>The problem was this </p>
<blockquote>
<ol>
<li>And optionally you can specify the calling convention, this defaults to '__stdcall', alternatively you can specify '_cdecl'.</li>
</ol>
</blockquote>
<p>The dll function was exported with extern "C" __declspec(dllexport) so I figu... |
SQL join: where clause vs. on clause <p>After reading it, this is <em>not</em> a duplicate of <a href="http://stackoverflow.com/questions/44917/explicit-vs-implicit-sql-joins">Explicit vs Implicit SQL Joins</a>.
The answer may be related (or even the same) but the <strong>question</strong> is different.</p>
<p><hr /><... | <p>They are not the same thing.</p>
<p>Consider these queries:</p>
<pre><code>SELECT *
FROM Orders
LEFT JOIN OrderLines ON OrderLines.OrderID=Orders.ID
WHERE Orders.ID = 12345
</code></pre>
<p>and</p>
<pre><code>SELECT *
FROM Orders
LEFT JOIN OrderLines ON OrderLines.OrderID=Orders.ID
AND Orders.ID = 12345
</c... |
In Javascript, what is the difference between indexOf() and search()? <p>Being fairly new to Javascript, I'm unable to discern when to use each of these.</p>
<p>Can anyone help clarify this for me?</p>
| <p>If you require a regular expression, use <code>search()</code>. Otherwise, <code>indexOf()</code> is going to be faster.</p>
|
How to determine if two nodes are connected? <p>I'm concerned that this might be working on an NP-Complete problem. I'm hoping someone can give me an answer as to whether it is or not. And I'm looking for more of an answer than just yes or no. I'd like to know why. If you can say,"This is basically this problem 'x' whi... | <p>Your description seems to indicate that you are just interested in whether two nodes are connected, not finding the shortest path.</p>
<p>Finding if two nodes are connected is relatively easy:</p>
<pre><code>Create two sets of nodes: toDoSet and doneSet
Add the source node to the toDoSet
while (toDoSet is not em... |
Adding a SOAP header to a SOAPpy request <p>Does anyone know how to do this? I need to add a header of the form:</p>
<p>
value1
value2
</p>
| <p>As the question is phrased, it's hard to guess what the intention (or even the intended semantics) is. For setting headers, try the following:</p>
<pre><code>import SOAPpy
headers = SOAPpy.Types.headerType()
headers.value1 = value2
</code></pre>
<p>or</p>
<pre><code>[...]
headers.foo = value1
headers.bar = value2... |
Transitions and setting up Layers/Scenes in cocos2d iPhone <p>I am looking to setup a transition between two levels(after one level is complete, use one of cocos2d's slick transition to transition into the next level). In my GameLayer implementation, I have methods setup to do things like [self buildLevel: 3] to build... | <p>For those who might care, here's what I ended up doing:</p>
<pre><code>GameScene * gs = [GameScene node];
[[Director sharedDirector] runScene: gs];
[[Director sharedDirector] replaceScene: [ShrinkGrowTransition transitionWithDuration:0.5 scene: gs]];
</code></pre>
<p>This was done within the GameLayer implementati... |
Preventing automatic change of default-directory <p>As per <a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/File-Names.html">the Emacs docs</a>, every time you open a file, Emacs changes <code>default-directory</code> to the directory containing that file. </p>
<p>Then, if the cursor is in that buffe... | <p>You could try using something like this:</p>
<pre><code>(add-hook 'find-file-hook
(lambda ()
(setq default-directory command-line-default-directory)))
</code></pre>
|
Create a colored bubble/circle programmatically in ObjectiveC and Cocoa <p>Can anyone guide me in the correct way to build a colored bubble/circle programmatically?</p>
<p>I can't use images as I need it to be able to be any color depending on user interaction.</p>
<p>My thought was maybe to make a white circle image... | <p>There are a couple steps to drawing something in Cocoa.</p>
<p>First you need a path that will be used to define the object that you are going to be drawing. Take a look here <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaDrawingGuide/Paths/Paths.html#//apple_ref/doc/uid/TP400... |
Number of arrangements <p>Suppose we have <em>n</em> elements, <em>a</em><sub>1</sub>, <em>a</em><sub>2</sub>, ..., <em>a</em><sub>n</sub>, arranged in a circle. That is, <em>a</em><sub>2</sub> is between <em>a</em><sub>1</sub> and <em>a</em><sub>3</sub>, <em>a</em><sub>3</sub> is between <em>a</em><sub>2</sub> and <em... | <p>Let's first ask the question "how many 0-1 sequences of length n are there with no two consecutive 1s?" Let the answer be A(n). We have A(0)=1 (the empty sequence), A(1) = 2 ("0" and "1"), and A(2)=3 ("00", "01" and "10" but not "11").</p>
<p>To make it easier to write a recurrence, we'll compute A(n) as the sum of... |
How do I keep an NSPathControl updated with the path of the selected cell in an NSBrowser <p>I need to keep an NSPathControl updated with the currently selected path in an NSBrowser, but I'm having trouble figuring out a way of getting notifications when the path has changed from the NSBrowser. The ideal way to do this... | <p>Courtesy of Rob Keniger over at <a href="http://cocoadev.com/forums/comments.php?DiscussionID=600&page=1#Item_1">Cocoa Dev</a>:</p>
<blockquote>
<p>Have you looked at the SimpleBrowser
example in /Developer/Examples? It
shows how to get the current selection
when it is changed by the user,
basically b... |
Using an epsilon value to determine if a ball in a game is not moving? <p>I have balls bouncing around and each time they collide their speed vector is reduced by the Coefficient of Restitution.</p>
<p>Right now my balls CoR for my balls is .80 . So after many bounces my balls have "stopped" rolling because their spee... | <p>A reasonable value for epsilon is going to depend on the constraints of your system. If you are representing the ball graphically, then your epsilon might correspond to, say, a velocity of .1 pixels a second (ensuring that your notion of stopping matches the user's experience of the screen objects stopping). If yo... |
Adobe Flex/AIR: Scrolling a sub-component, not the whole window <p>I'm developing an application with Adobe Flex and AIR, and I've been banging my head against the wall trying to figure out how to solve a scrolling issue.</p>
<p>The basic structure of my main application window (simplified greatly) is this:</p>
<pre>... | <p>An HBox or a VBox will try as hard as possible to display its content without scroll bars. This forces a parent container (often all the way up to the main Application) to be the one that must scroll if the content is too large to fit in the available bounds.</p>
<p>Behind the scenes, the HBox or VBox is setting th... |
Displaying foreign key relationships in Oracle 9i <p>Is there a command in oracle 9i that displays the foreign keys of a table and also the table that those foreign keys reference?</p>
<p>I was searching, did not find anything but i found an equivalent command that works with MySql which is SHOW CREATE TABLE </p>
<p>... | <p>Here's another answer: The <code>dbms_metadata</code> package has a function that can return the DDL for a table definition.</p>
<pre><code>SELECT dbms_metadata.get_ddl('TABLE', '<table>', '<schema>') FROM dual;
</code></pre>
<p>This package has apparently been available since Oracle 9.2</p>
<p><a hr... |
Use "references" for multiple items of same type <p>So I'm teaching myself Ruby on Rails, with a PHP background. I've written a sloppy, proof-of-concept PHP application called "<a href="http://rezich.com/storybored" rel="nofollow">2NDP.</a>" I want to re-create this in Ruby on Rails (but more basic, more clean, and wit... | <p>Rather then having four seperate columns, a separate joining table might be more appropriate. For example:</p>
<p>Pages -> LinkedPages -> Pages</p>
<p>Then you can create a <a href="http://wiki.rubyonrails.org/rails/pages/Beginner+Howto+on+has_many+:through" rel="nofollow">has_many through</a> relationship.</p>
<... |
Should Class Helpers be used in developing new code? <p>Delphi 8 introduced Class Helpers for the purposes of mapping the VCL/RTL to the .NET object hierarchy. They allow injecting methods into an existing class without overriding the the class or modifying the original. Later versions of Delphi found class helpers i... | <p>Depends what you mean by "new code". </p>
<p>They aren't really relevant for classes you are newly developing, so in that case, no, they probably shouldn't be used. </p>
<p>But even in a brand new project, you may still need to modify an existing class that you can't change in other ways (vcl class, third-party cl... |
Formatting double as string in C# <p>I have a Double which could have a value from around 0.000001 to 1,000,000,000.000</p>
<p>I wish to format this number as a string but conditionally depending on its size. So if it's very small I want to format it with something like:</p>
<pre><code>String.Format("{0:.000000000}",... | <p>Use Math.Log10 of the absolute value of the double to figure out how many 0's you need either left (if positive) or right (if negative) of the decimal place. Choose the format string based on this value. You'll need handle zero values separately.</p>
<pre><code>string s;
double epislon = 0.0000001; // or however ... |
Is it possible to avoid a wakeup-waiting race using only POSIX semaphores? Is it benign? <p>I'd like to use POSIX semaphores to manage atomic get and put from a file representing a queue. I want the flexibility of having something named in the filesystem, so that completely unrelated processes can share a queue. I th... | <p>Since there are no other answers I will follow up with what I've learned:</p>
<ul>
<li>Pthreads will not work with my application because I have processes without a common ancestor which need to share an atomic queue.</li>
<li>Posix semaphores <em>are</em> subject to the wakeup-waiting race, but because unlike clas... |
C# vs Java generics <p>I have heard that the Java implementation of Generics is not as good as the C# implementation. In that the syntax looks similar, what is it that is substandard about the Java implementation, or is it a religious point of view?</p>
| <p><a href="http://www.jprl.com/Blog/archive/development/2007/Aug-31.html">streloksi's link</a> does a great job of breaking down the differences. The quick and dirty summary though is ...</p>
<p>In terms of syntax and usage. The syntax is roughly the same between the languages. A few quirks here and there (most no... |
Defining const values in C <p>I have a C project where all code is organized in <code>*.c</code>/<code>*.h</code> file pairs, and I need to define a constant value in one file, which will be however also be used in other files. How should I declare and define this value?</p>
<p>Should it be as <code>static const ...</... | <p>The rule I follow is to only declare things in H files and define them in C files. You can declare and define in a single C file, assuming it will only be used in that file.</p>
<p>By declaration, I mean notify the compiler of its existence but don't allocate space for it. This includes "#define"s, "typedef"s, "ext... |
Downloading the gzip file and Uncompressing to retrieve Content using IPHONE SDK on iphone and ipod touch devices <p>I had the following questions related to downloading the file from the server.</p>
<p>a) Is it possible to download directly the GZIP (Compressed)file to the iphone device using IPHONE SDK.
b) If the co... | <p>Not at all sure about this, but if its http encoded with gzip, then that may well be auto-unzipped for you - as part of the http protocol - a guess and would need to be tested. Also may not be appropriate for your situation.</p>
|
Convert VB.NET --> C# Projects <p>Can anyone recommend a good application that could be used to convert VB.NET projects to C#, without having to do too much manual work?</p>
<p>We've used Reflector to do small libraries manually, but some of the larger projects will be too slow and complex to do this manually.</p>
| <p>You can use Lutz Roeders Reflector (<a href="http://www.red-gate.com/products/reflector">http://www.red-gate.com/products/reflector</a>) which can decompile whole Assemblies into Visual Studio projects. This way you can convert from ANY .NET Langauge into one of the supported languages of this program (C#.VB.NET,MC+... |
How to set WPF's Grid.RowDefinitions via Style <p>I'm using a couple of <code>Grid</code>s to format multiple <code>GridViewColumn.CellTemplate</code>s:</p>
<pre><code><ListView SharedSizeScope="true">
<ListView.View>
<GridView>
<GridViewColumn>
<GridViewColumn.CellTempla... | <p>Grid doesn't support control templates (info taken from <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/731bf94e-0881-49e1-a35a-99a2e2ca647f/">here</a> and, indirectly, from <a href="http://social.expression.microsoft.com/Forums/en-US/wpf/thread/51448155-637c-469d-856b-ff81552fe980/">here</a>).</p>... |
What are the typical use cases of Genetic Programming? <p>Today I read <a href="http://rogeralsing.com/2008/12/07/genetic-programming-evolution-of-mona-lisa/" rel="nofollow">this blog entry by Roger Alsing</a> about how to paint a replica of the <a href="http://en.wikipedia.org/wiki/Mona_Lisa" rel="nofollow">Mona Lisa<... | <p>There is some debate as to whether Roger's Mona Lisa program is <a href="http://en.wikipedia.org/wiki/Genetic_programming">Genetic Programming</a> at all. It seems to be closer to a (1 + 1) <a href="http://en.wikipedia.org/wiki/Evolution_strategy">Evolution Strategy</a>. Both techniques are examples of the broader... |
Event log messages get overrriden by another event log <p>I create event logs for asp.net projects error logging. I do it by adding a key in regedit, and then a sub-key.<br />
Sometimes, I create a new key and sub-key, and instead of getting a new, empty event log, I see in the event viewer that it's showing me the log... | <p>You probably want to use the <a href="http://msdn.microsoft.com/en-us/library/2awhba7a.aspx" rel="nofollow">EventLog.CreateEventSource</a> API to do this - it should take care of any details for you.</p>
<p>A quick read thru the docs seems to show that the 1st 8 characters are checked for uniqueness...perhaps that'... |
Rails: Blocking an user using routes.rb <p>I have a special url which I would want only few people to have access to. I have a list of super users stored as an array in the app.yml. How can I use this array in :requirements section of a specific route in the routes.rb file to allow only those super users access to this... | <p>No, you can't. <code>:requirements</code> are related to route parameters only.</p>
<p>Which is, in my opinion, a good thing. It's a well known convention to have authentication logic in controllers.</p>
|
Sorting an Array of Objects in PHP In a Specific Order <p>I have two arrays in PHP. The first array ($author_array) is comprised of user_ids in a particular order, like so: (8, 1, 6)</p>
<p>The second array ($user_results) is comprised of an array of objects like so:</p>
<pre><code>Array
(
[0] => stdClass Obje... | <p>Use <a href="http://php.net/uksort">usort</a> and provide a custom comparison function which uses the position of the key in your "ordering" array to determine the sort order, e.g. something like:</p>
<pre><code>function cmp($a, $b)
{
global $author_array;
$pos1=array_search ($a->ID, $author_array);
$... |
How to sort the data in alphanumeric values <p>I have these values: <code>d1, d45, d79, d33, d100</code></p>
<p>I want to sort these variables in ascending order from my table.</p>
<p>What is the query to get the output as:</p>
<pre><code>d1
d33
d45
d79
d100
</code></pre>
| <p>What you want is called a "natural sort". For Microsoft SQL Server 2005, see <a href="http://stackoverflow.com/questions/34509/natural-human-alpha-numeric-sort-in-microsoft-sql-2005">this question</a>. For other languages, see (for example) <a href="http://stackoverflow.com/questions/127913/sorting-strings-is-much-h... |
Virtual Directory in ASP.NET project <p>In our web application we have a directory which resides outside of the project. On IIS that's no problem to do, but can I do that also in my project in Visual Studio? </p>
<p><strong>Edit:</strong> My project is running on File System, and not on Local IIS</p>
| <p>If you click <code>File|Open|Website</code> and then click on the <code>Local IIS</code> button on the left-hand side of the dialog, then navigate to your project file and open from there you should find the virtual directories are included in Solution Explorer.</p>
|
Codenamed Products and Visual Studio <p>Are there any practices regarding using codenames of products in Visual Studio projects and solutions? In that typically, namespaces, assembly names, binary outputs, et al need to be renamed once a product name is chosen: is there any way to deal with this?</p>
| <p>In one place I worked we'd choose an unrelated and inoffensive, and typically systematic name for any given project.. Jupiter, Orca, Feynman whatever... and stick with that namespace forevermore.</p>
<p>Because as you've seen what the marketing/client/board chooses to call a product (hell, even what version number ... |
C++ HTML template framework, templatizing library, HTML generator library <p>I am looking for template/generator libraries for C++ that are similar to eg. Ruby's Erb, Haml, PHP's Smarty, etc.</p>
<p>It would be great if I it would sport some basic features like loops, if/else, int conversion to strings, etc.</p>
<p>P... | <p>A quick review of the mentioned project.</p>
<p><a href="http://rgrz.tumblr.com/post/13808947359/review-of-html-template-engines-in-c-language">http://rgrz.tumblr.com/post/13808947359/review-of-html-template-engines-in-c-language</a></p>
<h2>ClearSilver</h2>
<ul>
<li>Site: <a href="http://www.clearsilver.net">htt... |
Is returning early from a function more elegant than an if statement? <p>Myself and a colleague have a dispute about which of the following is more elegant. I won't say who's who, so it is impartial. Which is more elegant?</p>
<pre><code>public function set hitZone(target:DisplayObject):void
{
if(_... | <p>In most cases, returning early reduces the complexity and makes the code more readable.</p>
<p>It's also one of the techniques applied in <a href="http://ssdl-wiki.cs.technion.ac.il/wiki/index.php/Spartan%5Fprogramming">Spartan programming</a>:</p>
<blockquote>
<p><strong>Minimal use of Control</strong></p>
... |
Symbian C++ STOMP library <p>I want my S60 Application to utilize the Stomp protocol.</p>
<p>Although it would be fairly simple to implement myself (but nothing is ever as simple as I hope with Symbian) - I am wondering if anyone has any experience in this already.</p>
<p>It seems a Stomp library exists in almost eve... | <p>In case this is still relevant - I've just finished my implementation of a STOMP client for Symbian, fully using the Active Scheduler framework. We're going to release it as opensource once I get something set up on Google Code.</p>
<p>As Adam says - the implementation needed to be purely within the Symbian framewo... |
ASP.NET MVC public alternative to UrlHelper.GenerateUrl <p>I want to embed a link to a controller action in my page so I can use it from javascript. Something like</p>
<pre><code>var pollAction = '/Mycontroller/CheckStatus'
</code></pre>
<p>Now I am happy to hardcode it, but it would be really nice if there were a me... | <p>Have you tried something along these lines?</p>
<pre><code>var pollAction = '<%=Url.Action("CheckStatus", "MyController") %>';
</code></pre>
|
The best way to store class instances to a file/database <p>What is the best way to store instances of a class to file/database?</p>
<p>We have a base class called Command and loads of derived classes.
Users create instances of these classes by adding commands to a graphical designer
where they can configure them. (Se... | <p>Are you trying to save the data in tables? or as blob/clob data? Since you mention files, I assume the latter: any of the standard .NET serializers should be fine - they all support inheritance etc. I'd consider for <code>DataContractSerializer</code>, as this combines the field-level support (like <code>BinaryForma... |
Caching HTML output with PHP <p>I would like to create a cache for my php pages on my site. I did find too many solutions but what I want is a script which can generate an HTML page from my database ex:</p>
<p>I have a page for categories which grabs all the categories from the DB, so the script should be able to gene... | <p>check ob_start() function</p>
<pre><code>ob_start();
echo 'some_output';
$content = ob_get_contents();
ob_end_clean();
echo 'Content generated :'.$content;
</code></pre>
|
What is Microsoft OSLO? <p>Is it a DSL generation tool or natural query language?</p>
| <p>âOsloâ is the codename for Microsoftâs forthcoming modeling platform. Modeling is used across a wide range of domains and allows more people to participate in application design and allows developers to write applications at a much higher level of abstraction. âOsloâ consists of:</p>
<ul>
<li>A tool that ... |
How can I display Arabic data in Crystal Reports? <p>I am using Crystal Reports 10. The reports are obtaining data from an Oracle 10G database. We have some data in Arabic. When I try to display the Arabic data it is showing as ?.</p>
<p>Any ideas on what I can do to display this correctly?</p>
| <p>I've never used crystal reports and my oracle knowledge is limited, however I've done some work in Arabic. Things to look out for.</p>
<p>Does the Database have the arabic locale installed can it display right to left text.</p>
<p>Under windows check the languages settings and check that the option to include supp... |
How is Domain Driven Design different from just using a specification? <p>I read that Domain Driven Design is about concentrating on the problem domain instead of concentrating on the software. They say that it is easier to solve the complexities of the problem domain than the complexities of the software, because afte... | <p>Domain-driven design is more about establishing a common model of the world (and an associated common language) that both you and the domain experts can use.</p>
<p>In theory this means that developers can write code that reads like a description of the problem domain, and domain experts can look over developers' s... |
How do you test for the existence of a user in SQL Server? <p>I'd like to drop a user in a SQL Server script but I'll need to test for existence first or I'll get script errors. When dropping tables or stored procs, I check the sysobjects table like so:</p>
<pre><code>IF EXISTS (
SELECT *
FROM sysobjects
... | <p>SSMS scripts it in the following way:</p>
<p>For SQL 2005/2008:</p>
<pre><code>IF EXISTS (SELECT * FROM sys.database_principals WHERE name = N'username')
DROP USER [username]
</code></pre>
<p>For SQL 2000:</p>
<pre><code>IF EXISTS (SELECT * FROM dbo.sysusers WHERE name = N'username')
EXEC dbo.sp_revokedbaccess... |
Have ReSharper keep 'using System;' when optimizing usings <p>I was wondering if there is some option to keep ReSharper from removing just the <code>using System;</code> directive? Perhaps this is configurable somewhere?</p>
<p>Also, is there a way to have ReSharper sort the remaining directives just as Visual Studio ... | <p>Yes, there is such an option: ReSharper->Languages->C#->Namespace Imports. You can add namespaces,that should not be removed, as well as namespaces, that should always be imported.</p>
|
How to find out the TabSelection <p>I have using the following code for developing tabs.</p>
<pre><code>$(document).ready(function() {
$('#container-1').tabs();
}
....
<div id="container-1">
<ul>
<li><a href="#fragment-1"><span>Home</span></a></li>
... | <p>Set the id of the <em>Home</em> tab span element:</p>
<pre><code><li><a href="#fragment-1"><span id="home">Home</span></a></li>
</code></pre>
<p>And add the click handler to it somewhere:</p>
<pre><code>$("#home").click(function()
{
alert("Home tab is selected!");
});
</co... |
How to compute the nth root of a very big integer <p>I need a way to compute the nth root of a long integer in Python. </p>
<p>I tried <code>pow(m, 1.0/n)</code>, but it doesn't work:</p>
<blockquote>
<p>OverflowError: long int too large to convert to float</p>
</blockquote>
<p>Any ideas?</p>
<p>By long integer I... | <p>If it's a REALLY big number. You could use a binary search.</p>
<pre><code>def find_invpow(x,n):
"""Finds the integer component of the n'th root of x,
an integer such that y ** n <= x < (y + 1) ** n.
"""
high = 1
while high ** n <= x:
high *= 2
low = high/2
while low <... |
How to wait in bash for several subprocesses to finish and return exit code !=0 when any subprocess ends with code !=0? <p>How to wait in a bash script for several subprocesses spawned from that script to finish and return exit code !=0 when any of the subprocesses ends with code !=0 ?</p>
<p>Simple script:</p>
<pre>... | <p><code>wait</code> also (optionally) takes the PID of the process to wait for, and with $! you get the PID of the last command launched in background.
Modify the loop to store the PID of each spawned sub-process into an array, and then loop again waiting on each PID.</p>
|
How to write a unix filter that outputs only a line every N lines <p>Suppose to feed the filter standard input with these line:</p>
<pre><code>line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10
</code></pre>
<p>It would be nicer if someone tell me how to write a script that prints only every 4 l... | <pre><code>$ yes | cat -n | head -10 | awk 'NR % 4 == 1'
1 y
5 y
9 y
</code></pre>
<p>That is, your answer is "<code>awk 'NR % 4 == 1'</code>".</p>
|
Designing Address validation for app <p>I am planning to design an address validation for users registering in my app. Possibly validating by zipcode and state.</p>
<p>Any idea how to handle addresses from around the globe?</p>
<p>Do i need to insert all the zipcodes in the database and then validate the address. Any... | <p>Since there is no international standard for zip codes and a list of all zip codes in the world would be out of date before you were finished putting it together, I suggest a smaller approach:</p>
<p>Identify the countries that you will have to handle most and develop seperate validation rules for each of them. Mak... |
Build dependency tree from csproj files <p>I'm currently using msbuild for a solution of over 600 projects. </p>
<p>Imagine I change the code for 1 library that is used by 10 projects. Instead of providing all 600 projects to msbuild and let it compile all of them and figure out the dependencys. I was wondering if ... | <p>Have you tried <a href="http://www.drewnoakes.com/code/dependancyanalyser/" rel="nofollow">.NET assembly dependency analyser</a>?. </p>
<p>It is open source, and the graph output in <a href="http://www.graphviz.org/doc/info/lang.html" rel="nofollow">dot script</a> might be what you need. An example from the site:</... |
Regular Expression to Extract HTML Body Content <p>I am looking for a regex statement that will let me extract the HTML content from just between the body tags from a XHTML document.</p>
<p>The XHTML that I need to parse will be very simple files, I do not have to worry about JavaScript content or <code><![CDATA[</... | <p>Would this work ?</p>
<pre><code>((?:.(?!<body[^>]*>))+.<body[^>]*>)|(</body\>.+)
</code></pre>
<p>Of course, you need to add the necessary <code>\s</code> in order to take into account <code>< body ...></code> (element with spaces), as in:</p>
<pre><code>((?:.(?!<\s*body[^>]*... |
CSS Positioning, want to make content's width fixed when window is resized <p>I have a div with two nested divs inside, the (float:left) one is the menu bar, and the right (float:right) should display whatever content the page has, it works fine when the window is at a maximum, but when i resize it the content is colla... | <p>This should do it (container is the parent div containing that 2 divs):</p>
<pre><code>.container {
width: 1024px;
display: block;
}
</code></pre>
|
LINQ to SQL object versioning <p>I'm trying to create a LINQ to SQL class that represents the "latest" version of itself.</p>
<p>Right now, the table that this entity represents has a single auto-incrementing ID, and I was thinking that I would add a version number to the primary key. I've never done anything like thi... | <p>If you can avoid keeping a history, do. It's a pain.</p>
<p>If a complete history is unavoidable (regulated financial and medical data or the like), consider adding history tables. Use a trigger to 'version' into the history tables. That way, you're not dependent on your application to ensure a version is recorded ... |
C# Extracting a name from a string <p>I want to extract 'James\, Brown' from the string below but I don't always know what the name will be. The comma is causing me some difficuly so what would you suggest to extract James\, Brown?</p>
<p>OU=James\, Brown,OU=Test,DC=Internal,DC=Net</p>
<p>Thanks</p>
| <p>A regex is likely your best approach</p>
<pre><code>static string ParseName(string arg) {
var regex = new Regex(@"^OU=([a-zA-Z\\]+\,\s+[a-zA-Z\\]+)\,.*$");
var match = regex.Match(arg);
return match.Groups[1].Value;
}
</code></pre>
|
A good library for converting PDF to TIFF? <p>I need a Java library to convert PDFs to TIFF images. The PDFs are faxes, and I will be converting to TIFF so that I can then do barcode recognition on the image. Can anyone recommend a good library (free or $$) for conversion from PDF to TIFF? </p>
| <p>I can't recommend any code library, but it's easy to use GhostScript to convert PDF into bitmap formats. I've personally used the script below (which also uses the netpbm utilties) to convert the <em>first</em> page of a PDF into a JPEG thumbnail:</p>
<pre><code>#!/bin/sh
/opt/local/bin/gs -q -dLastPage=1 -dNOPAU... |
Select object when a property equals Max with NHibernate <p>We have a query that selects rows depending on the value of another, ie. the max. I don't think that really makes much sense, so here is the query:</p>
<pre><code>var deatched = DetachedCriteria.For<Enquiry>("e2")
.SetProjection(Projections.Alias(Pr... | <p>For aggregations it is better to use SQL and not HQL.Use Nhibernate just for main Entities and their relations (very maintainable design) .Stored procedures are a better place to these aggregations and functions because they are data dependent and not object dependent</p>
|
OOP design question - keeping track of many similar things <p>I'm designing a Data Access layer for an C#/ASP.net application and I have a question regarding the treatment of parameters in sql queries.</p>
<p>At the moment, when a query needs a dynamically set parameter for the Where clause I have to (1) define a vari... | <p>My favorite way to do this is to set up an object data source and then in your table adapter you can add queries for all of the different queries you want to perform with the different parameters you need for your various selects. This gives you the ability to ignore the actual parameters and just use the class to ... |
Obfuscating a .NET Web application <p>Is it possible to obfuscate a .NET web application? I tried to use the Dotofuscator tool that comes with Visual Studio 2005 and I was able to obfuscate the dlls of a precompiled web site, but when I deployed the soultion to an IIS server, I could not the pages of the application.</... | <p>Just bear in mind that is you obfuscate an application that uses reflection, it can cause issues.</p>
<p>I personally don't see the need to obfuscate, as <strong>people who <em>really</em> want to see your code, will get their hands on it with effort, regardless if you obfuscate it or not</strong>.</p>
|
Pexpect, running ssh-copy-id is hanging when trying to spawn a second process <p>I'm doing a Python script where I need to spawn several ssh-copy-id processes, and they need for me to type in a password, so i'm using PExpect.</p>
<p>I have basically this:</p>
<pre><code>child = pexpect.spawn('command')
child.expect('... | <p>Fortunately or not, but OpenSSH client seems to be very picky about passwords and where they come from.</p>
<p>You may try using <a href="http://www.lag.net/paramiko/" rel="nofollow">Paramiko</a> Python SSH2 library. Here's a simple <a href="http://www.lag.net/pipermail/paramiko/2006-January/000180.html" rel="nofol... |
C++ Functors - and their uses <p>I keep hearing a lot about functors in C++. Can someone give me an overview as to what they are and in what cases they would be useful?</p>
| <p>A functor is pretty much just a class which defines the operator(). That lets you create objects which "look like" a function:</p>
<pre><code>// this is a functor
struct add_x {
add_x(int x) : x(x) {}
int operator()(int y) const { return x + y; }
private:
int x;
};
// Now you can use it like this:
add_x add... |
Using a user defined parameter in vba <p>I have an access database that ouptuts a query to an excel file. The query uses a date parameter to run. This parameter is chosen by the user. I would like to use the parameter in the filename of the export. How can I accomplish that with the minimum amount of code.</p>
<p>... | <p>You have to take responsibility for asking for the parameter. I like using global parameters that I can get/set via global functions - this way they can be set anywhere and the queries can have access to them as well.</p>
<p><strong>Just need a couple subs/functions in module:</strong></p>
<pre><code>Some Module
... |
How to clone a jQuery Listen plugin event? <p>I have some <code><tr></code> elements on my page with a <code>click()</code> event attached to an image that sits inside each one. I use this code</p>
<pre><code>$(this).clone(true).appendTo("table#foo");
</code></pre>
<p>to do the following:</p>
<ul>
<li>copy tho... | <p>Ariel Flesler, creator of the listen() plugin, gave me this advice via email:</p>
<p><em>"I think this can be solved in another way. The idea of Listen (and
event delegation) is to actually avoid all the copying of events for
new elements."</em></p>
<p><em>"You could simply do:"</em></p>
<pre><code>$('table#foo')... |
Memory Mapped Files .NET <p>I have a project and it needs to access a large amount of proprietary data in ASP.NET. This was done on the Linux/PHP by loading the data in shared memory. I was wondering if trying to use Memory Mapped Files would be the way to go, or if there is a better way with better .NET support. I ... | <p>I know this is a bit late, but the .NET 4.0 framework now supports memory-mapped files out of the box:</p>
<p><a href="http://blogs.msdn.com/salvapatuel/archive/2009/06/08/working-with-memory-mapped-files-in-net-4.aspx">http://blogs.msdn.com/salvapatuel/archive/2009/06/08/working-with-memory-mapped-files-in-net-4.a... |
ASP.NET/C# - Detect File Size from Other Server? <p>I'm trying to find the file size of a file on a server. The following code I got from <a href="http://www.thejackol.com/2005/06/11/aspnet-get-file-size/" rel="nofollow">this guy</a> accomplishes that for your own server:</p>
<pre><code>string MyFile = "~/photos/mymug... | <p>You can use the <code>WebRequest</code> class to issue an HTTP request to the server and read the <code>Content-Length</code> header (you could probably use HTTP <code>HEAD</code> method to accomplish it). However, not all Web servers respond with a <code>Content-Length</code> header. In those cases, you have to rec... |
Can configuration data be encrypted from an installation process? <p>I am developing a .NET (2.0) WinForms utility that connects to a SQL Server 2005 database. I have found reference material, such as <a href="http://stackoverflow.com/questions/42833/how-do-i-avoid-having-the-database-password-stored-in-plaintext-in-so... | <p>The main problem with encrypted configuration is protecting the key used to decrypt the configuration settings.</p>
<p>With a server application, you can do this by restricting access to the server. A client WinForms app will need to have access to the key while running as the current user, therefore the user will... |
Load FreeMarker templates from database <p>I would like to store my FreeMarker templates in a database table that looks something like:</p>
<pre><code>template_name | template_content
---------------------------------
hello |Hello ${user}
goodbye |So long ${user}
</code></pre>
<p>When a request is recei... | <p>We use a StringTemplateLoader to load our tempates which we got from the db (as Dan Vinton suggested)</p>
<p>Here is an example:</p>
<pre><code>StringTemplateLoader stringLoader = new StringTemplateLoader();
String firstTemplate = "firstTemplate";
stringLoader.putTemplate(firstTemplate, freemarkerTemplate);
// It'... |
Bypass IE "The webpage you are viewing..." pop up <p>Is there a way to bypass the following IE popup box:</p>
<blockquote>
<p>The webapge you are viewing is trying
to close the window. Do you want to
close this window? Yes|No</p>
</blockquote>
<p>This is occurring when I add window.close() to the onclick event ... | <h1>In the opened popup write following</h1>
<pre><code>var objWin = window.self;
objWin.open('','_self','');
objWin.close();
</code></pre>
|
How do I call .NET code (C#/vb.net) from vbScript? <p>I imagine I can compile a C# DLL and then expose it as a COM object so that it can be CreateObject'd from VBscript. I'm just not sure the steps involved in doing this...</p>
| <p>It can be very simple to do this. But there are a lot of places where it's not so simple. It depends a lot on what your class needs to be able to do, and how you intend to deploy it.</p>
<p>Some issues to consider:</p>
<ul>
<li>Your class has to have a parameterless constructor.</li>
<li>It can't expose static m... |
.NET - How to build themes for big CSS files <p>I am in charge of providing a theme functionality for a site using a big CSS file (thousands of elements) I've just inherited.
Basically we want to allow the user to be able to change the colors on the screen.</p>
<p>Every CSS element, besides color definition also have ... | <p>You only have to duplicate the color attributes so if you have </p>
<pre><code>a:hover
{
text-decoration:none;
color:Black;
display:block
}
</code></pre>
<p>in your css file in your theme you only need:</p>
<pre><code>a:hover
{
color:Red;
}
</code></pre>
<p>Now in your page you want to make sure... |
reporting services anonymous access to reports <p>I can't create a NT account for everyone that need access to the reports.
Does anyone know or have a link to the info to allow anonymous access to reporting services reports ?</p>
<p>Thanks</p>
| <p>Thanks, I had tried it before but was failing, tried again and worked fine, must have missed something the first time around.</p>
<p>The steps are very simple:</p>
<ol>
<li>Standard install of SSRS 2005
(Integrated authentication) </li>
<li>In
IIS, duplicate the ReportingServices
virtual directory and name it Publ... |
Spring Integration 1.0 RC2: Streaming file content? <p>I've been trying to find information on this, but due to the immaturity of the Spring Integration framework I haven't had much luck.</p>
<p>Here is my desired work flow:</p>
<ol>
<li><p>New files are placed in an 'Incoming' directory</p></li>
<li><p>Files are pic... | <p>This is a very interesting use case that I'm sorry I missed for such a long time. It's definitely worth creating an issue for. At the moment we have support in Spring Integration for picking up the files and sending <em>references to them</em> around. There is also some rudimentary support for converting the files t... |
Sorting multiple keys with Unix sort <p>I have potentially large files that need to be sorted by 1-n keys. Some of these keys might be numeric and some of them might not be. This is a fixed-width columnar file so there are no delimiters.</p>
<p>Is there a good way to do this with Unix sort? With one key it is as si... | <p>Take care though:</p>
<p>If you want to sort the file primarily by field 3, and secondarily by field 2 you don't want this:</p>
<pre><code>sort -k 3 -k 2 < inputfile
</code></pre>
<p>you want this instead:</p>
<pre><code>sort -k 3,3 -k 2,2 < inputfile
</code></pre>
<p>The first one sorts the file by the s... |
Is const_cast safe? <p>I can't find much information on const_cast. The only info I could find (on Stack Overflow) is:</p>
<blockquote>
<p>The const_cast<>() is used to add/remove const(ness) (or volatile-ness) of a variable.</p>
</blockquote>
<p>This makes me nervous. Could using a const_cast cause unexpected... | <p><code>const_cast</code> is safe only if you're casting a variable that was originally non-<code>const</code>. For example, if you have a function that takes a parameter of a <code>const char *</code>, and you pass in a modifiable <code>char *</code>, it's safe to <code>const_cast</code> that parameter back to a <co... |
Who's Using Cairngorm 2.2 with Imported Web Services? <p>I'm very new to Cairngorm, so apologies for what's probably a simple question:</p>
<p>I'm working with a number of WCF services imported into Flex Builder 3 (via Data > Manage Web Services), and I'm wondering how to expose those services to the ServiceLocator in... | <p>I'm working on an app right now where Services.mxml is driving me nuts... calls are just not being made. I've read the blog posts that describe solutions to this issue but it's a recurring, nagging problem so I want to find a more reliable approach. I believe that you could simply replace the code in your Delegate w... |
ASP.net AJAX: textbox readonly state <p>I currently have a button called Edit and a text box call blah on a ajax updatepanel. is it possible to set the asp.net's textbox Readonly via trigger? </p>
| <p>Yes it is possible.</p>
<p>Assuming the trigger is the edit button's onclick handler, put the code there...</p>
|
What's a good way to debug unit tests written with multiple [Row] attributes? <p>When I run the following test in Gallio's Icarus it passes, but when I step into it using TestDriven.NET (Test With->Debugger), it fails because the parameters are not set according to the Row attributes.</p>
<p>I was expecting that the m... | <p>Hmm... did you install TestDriven.Net BEFORE installing Gallio?</p>
<p>If not, then the Gallio extensions for TestDriven.Net will not be installed. In that case, TestDriven.Net might run the test in "ad-hoc" mode with default values for its parameters.</p>
<p>It should be pretty to tell whether this is the case. ... |
Replacing a word with another word zero or more times in javascript using regular expressions <p>I have a word : [lesserthen] , that I need to replace with < zero or more times in a string. I'm using the String.replace method to do so. But the word is only replaced one time in the string, I need to be replaced mor... | <p>Try using an actual regex (with "g" option) in the replace instead of a search string, for example:</p>
<pre><code>wordReplaced = wordReplaced.replace(/\[lesserthen\]/g,"<");
</code></pre>
|
C# Round Value of a Textbox <p>I have a small calculator that I am creating in C# (Sharp Develop). The user enters two values and the code returns the third. I am having trouble rounding the third value once it is returned. I have been through a couple of forums and the msdn site and I understand the code that is poste... | <p>Use <a href="http://msdn.microsoft.com/en-us/library/system.math.round.aspx" rel="nofollow">Math.Round</a>. Or, since you're going into a string, you could use either the <a href="http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx" rel="nofollow">Standard Numeric Format Strings</a>, or the <a href="http://msdn.mi... |
A small question about python's variable scope <p>I am a beginner of python and have a question, very confusing for me.
If I define a function first but within the function I have to use a variable which is defined in another function below, can I do it like this? Or how can I import the return things of another functi... | <p>The scope of functions <code>hello</code> and <code>hi</code> are entirely different. They do not have any variables in common.</p>
<p>Note that the result of calling <code>hi(x,y)</code> is some object. You save that object with the name <code>good</code> in the function <code>hello</code>.</p>
<p>The variable ... |
Why do IE and Firefox render the same image differently, how can I prevent it? <p><img src="http://farm4.static.flickr.com/3199/3099078396_a3c4924c81_o.gif" alt="alt text" /></p>
<p>On the left you will notice the google logo rendered by IE, I drew a black line at the top and bottom of the G which extends into the FF ... | <p>I just created a composite image of screenshots of the Google image in IE, Firefox & Chrome and they're all in perfect register (top 2 images at 30% opacity).</p>
<p>I believe it has to be a custom zoom you've got set in one of your browsers. Check IE's zoom at the right of the status bar, for example. </p>
<p... |
How to analyse a HTTP dump? <p>I have a file that apparently contains some sort of dump of a keep-alive HTTP conversation, i.e. multiple GET requests and responses including headers, containing an HTML page and some images. However, there is some binary junk in between - maybe it's a dump on the TCP or even IP level (I... | <p>Use <a href="http://www.wireshark.org/" rel="nofollow">Wireshark</a>.</p>
<p>Look into the file format for its dumps and convert your dump to it. Its very simple. Its called the <a href="http://wiki.wireshark.org/Development/LibpcapFileFormat" rel="nofollow">pcap file format</a>. Then you can open it in Wireshark n... |
What happens when you select a non-existing file for upload in an HTML form? <p>On Internet Explorer, the standard HTML file upload form also allows for direct input of the file name (instead of using the file selector dialog). This makes it possible to enter non-existing files. On other browsers (which do not let you ... | <p>I think I figured it out.</p>
<p>First of all, it seems to make a difference whether it is just the file that does not exist, or the whole path is incorrect. If only the file is missing, apparently a POST does take place.</p>
<p>At least in the case I mentioned (FCKEditor's image upload dialog on WinXP and IE6), t... |
Moq tests using ExpectSet() with It.Is<T>() aren't behaving as... expected <p>I've isolated the behaviour into the following test case. I'd be grateful to anyone who can tell me how to expect/verify a property set for a <code>List<T></code> property - it appears there's something going on inside <code>It.Is<T&... | <p>The second parameter of ExpectSet() is the value you're expecting. You can't use <code>It.Is<T></code> in this case as there's no overload that takes a predicate - though it would be nice ;) Here's a (simplified) excerpt from your sample, illustrating the use of a value:</p>
<pre><code>var mockView = new Mock... |
Best practices to test Asp.net MVC applications <p>Whats the best practice to test an Asp.net MVC application?</p>
| <p>Choose your testing framework - I recommend <a href="http://www.codeplex.com/" rel="nofollow" title="xUnit.net">xUnit.net</a>.</p>
<p>Decouple your classes using interfaces and use constructor injection in your controllers to satisfy dependencies. In your tests, pass mocks to your controllers using a mocking framew... |
Have you come across any reason for three levels of indirection? <p>Just flicking through one of my favourite books (Ellen Ullman's The Bug) and there is a small bit where one programmer confronts another over three levels of indirection:</p>
<pre><code>***object_array = ***winarray;
</code></pre>
<p>I get the idea o... | <p>Sure<br />
4 dimensional arrays.<br />
It doesn't take too much for an application for such an array either. Say some sort of lookup table. I've had lookup tables of 8 and more dimensions.</p>
|
jQuery: Can I do $('.superset').$('.within') instead of $('.within', $('.superset'))? <p>Can jQuery be extended so that I can use the above syntax?</p>
<p>I can't figure out how to prototype whatever it is $() returns, so that I can call $().$()</p>
<p>Thanks.</p>
| <p>you can use <a href="http://docs.jquery.com/Traversing/find" rel="nofollow"><code>find()</code></a></p>
<p>eg: <code>$('.superset').find('.within');</code></p>
<p>or much simpler, <code>$('.superset .within');</code></p>
|
Space-Efficient Data Structure for Storing a Word List? <p>Is there anything better than a <a href="http://en.wikipedia.org/wiki/Trie" rel="nofollow">Trie</a> for this situation?</p>
<ul>
<li>Storing a list of ~100k English words</li>
<li>Needs to use minimal memory</li>
<li>Lookups need to be reasonable, but don't ha... | <p>One structure I saw for minimizing space in a spelling dictionary was to encode each word as:</p>
<ul>
<li>the number of characters (a byte) in common with the last; and</li>
<li>the new ending.</li>
</ul>
<p>So the word list</p>
<pre><code>HERE would encode as THIS
sanctimonious ... |
ASP.NET MVC Upgrade to Beta: IControllerFactory is defined in an assembly that is not referenced <p>I'm currently in the process of updating a site from preview 2 of ASP.NET MVC to the Beta release. I'm down to my last compile error with no solution in site after an exhaustive search. I have some code in Global.asax.cs... | <p>PublicKeyToken=null doesn't seem right...</p>
<p><strong>Edit:</strong> I was right, the PublicKeyToken should be "31bf3856ad364e35". It sounds like they're linked against a private build of System.Web.Mvc.dll that isn't signed.</p>
|
Alternate background colors for list items <p>I have a list, and each item is linked, is there a way I can alternate the background colors for each item?</p>
<pre><code><ul>
<li><a href="link">Link 1</a></li>
<li><a href="link">Link 2</a></li>
<li>... | <p>How about some lovely CSS3?</p>
<pre><code>li { background: green; }
li:nth-child(odd) { background: red; }
</code></pre>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.