instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>The <a href="http://en.wikipedia.org/wiki/Law_Of_Demeter" rel="noreferrer">wikipedia article</a> about <a href="http://c2.com/cgi/wiki?LawOfDemeter" rel="noreferrer">Law of Demeter</a> says:</p> <blockquote> <p>The law can be stated simply as "use only one dot".</p> </blockquote> <p>However a <a href="http://web...
<p>Well, the short definition of the law shortens it too much. The real "law" (in reality advice on good API design) basically says: Only access objects you created yourself, or were passed to you as an argument. Do not access objects indirectly through other objects. Methods of fluent interfaces often return the objec...
<p>There's no problem with your example. After all, you're rotating, watermarking, etc... always the same image. I believe you're talking to a Pipeline object all the while, so as long as your code only depends on the class of the Pipeline, you're not violating LoD.</p>
9,312
<h2>Syntax</h2> <ul> <li><a href="https://stackoverflow.com/questions/182630/jquery-tips-and-tricks/2218129#2218129">Shorthand for the ready-event</a> by roosteronacid</li> <li><a href="https://stackoverflow.com/questions/182630/jquery-tips-and-tricks/2218135#2218135">Line breaks and chainability</a> by roosteronacid<...
<p><strong>Creating an HTML Element and keeping a reference</strong></p> <pre><code>var newDiv = $("&lt;div /&gt;"); newDiv.attr("id", "myNewDiv").appendTo("body"); /* Now whenever I want to append the new div I created, I can just reference it from the "newDiv" variable */ </code></pre> <p><br /> <strong>Check...
<p><strong>No-conflict mode</strong></p> <pre><code>jQuery.noConflict(); </code></pre> <blockquote> <p>"Run this function to give control of the <code>$</code> variable back to whichever library first implemented it. This helps to make sure that jQuery doesn't conflict with the <code>$</code> object of other librar...
22,073
<p>Please one library per answer so that people can vote for the individually.</p>
<p><a href="http://code.google.com/p/calendardateselect/" rel="nofollow noreferrer">Calendar Date Select</a></p>
<p><a href="http://developer.yahoo.com/yui/calendar/" rel="nofollow noreferrer">Yahoo! UI Library: Calendar</a></p> <blockquote> <p>"The Calendar component is a UI control that enables users to choose one or more dates from a graphical calendar presented in a single month or multi month interface. Calendars ...
25,440
<p>I am using a Flashforge Creator Dual Extrusion 3D Printer with RepG (<a href="http://replicat.org/" rel="nofollow noreferrer">ReplicatorG</a>), and tonight a print completely detached from the build plate.</p> <p>I reset everything and watched it closely. It is a simple abs print at 230/110 degrees.</p> <p>A few...
<p>Check your slicer settings. Some slicers allow the temperature to change at a specified layer. You may have programmed the slic3r to turn off the bed after the first (or maybe zeroth) layer.</p> <p>You call also examine the G-code for M140, M144, and M190 commands.</p> <p>Of course, the usual intermittent ele...
<p>Preheating the bed is a commonly used approach to shorten the time to print. I'll explain; it actually does not shorten the physical print time itself, but before you start a print there is always stuff to do like inserting the SD-card or loading the model in the print server, while you do that, the bed will be heat...
973
<p>How do I accomplish text wrapping of table fields in SSRS Report, and proper landscaping when rendering the report to PDF format?</p>
<p>Setting the CanGrow property to True will allow wrapping, and the text box will get as big as it needs to vertically to contain all the characters in its value.</p> <p>To ensure the proper landscaping of PDF exports, set the PageSize of the report object accordingly (setting Width=11" x Height=8.5" will make a land...
<p>To ensure line breaks are inserted correctly, use</p> <pre><code>=Replace(Fields!MyField.Value, vbLf, Environment.NewLine) </code></pre> <p>Set CanGrow = True.</p>
39,276
<p>I'm working on a project that currently has zero users but we would like to scale up to potentially hundreds. Currently we are running on a MySQL database with AMFPHP interacting with Flex. We used Flex because of its robust graphic features (important to this project) and because the initial developer (not me) al...
<p>Short answer, Yes. There are already many prime-time Apps using Flex as their UI development platform. If you go to the Adobe site they showcase quite a few.</p> <p>Speaking personally, I chose Flex for two reasons, first was that, although you probably can do much of what Flex does in HTML or with an appropriate...
<p>Flex + AIR is probably as good a tool as Visual Basic was; it may be a better tool for having a much more flexible programming language and having free development tools, but keep the limitations in mind....</p> <p>The main limitation I've seen from working with it is documentation. There seems to be not enough doc...
40,859
<p>I'm one of the people involved in the <a href="http://testanything.org/wiki/index.php/TAP_at_IETF:_Notes" rel="noreferrer">Test Anything Protocol (TAP) IETF group</a> (if interested, feel free to join the mailing list). Many programming languages are starting to adopt TAP as their primary testing protocol and they ...
<p>It must be very, very easy to write a test, and equally easy to run them. That, to me, is the single most important feature of a testing harness. If someone has to fire up a GUI or jump through a bunch of hoops to write a test, they won't use it.</p>
<p>I use TAP as output protocol for a set of simple C++ test methods, and have seen the following shortcomings:</p> <ul> <li>test steps cannot be put into groups (there's only the grouping into several test scripts; but for running all tests in our software, I need at least one more level of grouping, so that a single...
11,699
<p>I have a TSqlDataSet which has a blob field, I need to get the data of this blob field in the BeforeUpdateRecord event of the provider and execute an update command, I've tried this:</p> <pre><code>Cmd := TSQLQuery.Create(nil); try Cmd.SQLConnection := SQLConnection; Cmd.CommandText := 'UPDATE MYTABLE SET IMAGE...
<p>Answering my own question, the correct way to do it is the following:</p> <pre><code>const SQL = 'UPDATE MYTABLE SET IMAGE = :PIMAGE WHERE ID = :PID;'; var Params: TParams; begin Params := TParams.Create(nil); try Params.CreateParam(ftBlob, 'PIMAGE', ptInput).AsBlob := DeltaDS.FieldByName('IMAGE').NewVa...
<p>Have you tried testing with another driver (e.g. ODBC)? It's possible that the error is not in your code. This approach (changing data providers/drivers) has helped me with some confusing problems that turned out not to be mine.</p>
42,215
<p>I'm looking at ways to deploy a Ruby on Rails app (running on JRuby) to a Tomcat instance for testing.</p> <p>The tomcat instance is running on a Solaris server that I can SSH to. I've looked at using Capistrano, but there doesn't seem to be a lot out there about using it to deploy to Tomcat, or even about running ...
<p>I am running a Rails project using JRuby and deploying to a Tomcat server. I have chosen to deploy with Capistrano because it automates just about everything. I had to make a few minor modifications to Capistrano's deployment lifecycle in order to get it to run on Tomcat:</p> <p>Step 1: I created a warble task to b...
<p>There's a few Capistrano recipes for deploying to Tomcat -- I built one into a gem called <a href="http://rubygems.org/gems/capistrano-tomcat" rel="nofollow">capistrano-tomcat</a>. It takes a WAR you've built (probably with <a href="http://caldersphere.rubyforge.org/warbler/" rel="nofollow">Warbler</a>) and deploys ...
17,782
<p>I'm documenting the procedure for a full redeploy on my development server. Small staff, using Basic authentication (over SSL, of course) with an htpasswd file backend.</p> <p>Is it safe to transfer the .htpasswd file as-is?</p> <p>The Operating Systems will potentially differ, but the software on top (ie. Apache...
<p>It's safe to transfer the htpasswd file no matter what architectures you are on. It is a text file. The only case in which you might need to do some conversions is to deal with line endings if you were moving between Unix and Windows, but between Linux/Unix boxes, no problems.</p>
<p>If you use the same apache version you shouldn't have any problems just copying the .htpasswd files: They just contain the hashes that people's passwords are being compared with and the hashing is always the same (or it wouldn't work on any machine ;))</p>
32,963
<p>What function can I use in Excel VBA to slice an array?</p>
<blockquote> <p><strong>Application.WorksheetFunction.Index(array, row, column)</strong></p> </blockquote> <p>If you specify a zero value for row or column, then you'll get the entire column or row that is specified.</p> <p>Example:</p> <blockquote> <p>Application.WorksheetFunction.Index(array, 0, 3)</p> </block...
<p>You can use a combination of the Rows, Columns, Offset and Resize properties to get a subset of a range.</p> <p>For example if you have a range that is 5 columns by 3 rows:</p> <pre><code>Set rng = Range("A1:E3") </code></pre> <p>You can get any subset by appropriately combining the above properties. For example...
21,120
<p>I have the following XML document:</p> <pre><code>&lt;projects&gt; &lt;project&gt; &lt;name&gt;Shockwave&lt;/name&gt; &lt;language&gt;Ruby&lt;/language&gt; &lt;owner&gt;Brian May&lt;/owner&gt; &lt;state&gt;New&lt;/state&gt; &lt;startDate&gt;31/10/2008 0:00:00&lt;/startDate&gt; &lt;/project&g...
<p>Found an XML transform stylesheet <a href="https://web.archive.org/web/20160624174014/http://wenzlaff.de/xmltocsv.html" rel="nofollow noreferrer">here</a> (wayback machine link, site itself is in german)</p> <p>The stylesheet added here could be helpful:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="h...
<p>This <code>CsvEscape</code> function is XSLT 1.0 and escapes column values <code>,</code>, <code>&quot;</code>, and newlines like <a href="https://www.rfc-editor.org/rfc/rfc4180" rel="nofollow noreferrer">RFC 4180</a> or Excel. It makes use of the fact that you can recursively call XSLT templates:</p> <ul> <li>The t...
47,694
<p>About 2 years ago I dropped windows from my home PC and switched 100% to linux (fedora, then ubuntu) - The missus wasn't too happy but she got used to it and learned a thing or two. Then about 6 months ago I got myself a shiny new Macbook and since moving to OSX have never looked back; Unfortunately I've not been su...
<p>Operating System is just a tool, if you are building cross platform applications (or web applications[it depends only your target web browser]) and you can use whatever operating system you like , you can install windows xp in virtual machine on your osx for using IE for example, <strong>but</strong> if your company...
<p>As a software developer I pretty much live in my text editor and shell. In the jobs where I've been forced to use windows I install emacs and cygwin and I'm off to the races. </p> <p>I don't focus on the periphery -- control panels, window managers, etc -- I focus on what I really use 90+% of the time and don't swe...
28,384
<p>I've written a small hello world test app in Silverlight which i want to host on a Linux/Apache2 server. I want the data to come from MySQL (or some other linux compatible db) so that I can databind to things in the db.</p> <p>I've managed to get it working by using the <a href="http://www.mysql.com/products/connec...
<p>The easiest way to do what you want (having read through your edits now :)) will be to expose services that can be consumed. The pattern that Microsoft is REALLY pushing right now is to expose WCF services, but the truth is that your Silverlight client can use WCF to consume a lot of different types of services.</p...
<p>You can get data from MySQL by using Web Services.</p> <p>Walkthrough:</p> <p>Step 1: Create Web Services</p> <p>Step 2: Add Service Reference to Silverlight</p> <p><hr /> <b>Step 1: Create Web Services</b></p> <p>Add a new Silverlight project.</p> <p><img src="https://i.stack.imgur.com/ccdis.png" alt="Add a n...
12,531
<p>Given a list of locations such as</p> <pre class="lang-html prettyprint-override"><code> &lt;td&gt;El Cerrito, CA&lt;/td&gt; &lt;td&gt;Corvallis, OR&lt;/td&gt; &lt;td&gt;Morganton, NC&lt;/td&gt; &lt;td&gt;New York, NY&lt;/td&gt; &lt;td&gt;San Diego, CA&lt;/td&gt; </code></pre> <p>What's the easies...
<p>I'm assuming you have the basics for Maps in your code already with your API Key.</p> <pre><code>&lt;head&gt; &lt;script type="text/javascript" href="http://maps.google.com/maps? file=api&amp;v=2&amp;key=xxxxx"&gt; function createMap() { var map = new GMap2(document.getElementById("map")); ...
<p>I guess more information would be needed to really give you an answer, but over at Django Pluggables there is a <a href="http://djangoplugables.com/projects/django-googlemap/" rel="nofollow noreferrer">django-googlemap plugin</a> that might be of help.</p> <p><strong>Edit:</strong> Adam has a much better answer. Wh...
3,606
<p>I'd like know what people think about using RAISERROR in stored procedures to pass back user messages (i.e. business related messages, not error messages) to the application. </p> <p>Some of the senior developers in my firm have been using this method and catching the SqlException in our C# code to pick up the mes...
<p>I've done this, but it was usually to pass along business "error" messages, essentially a data configuration had to be in place that couldn't be enforced with standard FK constraints for whatever reason.</p> <p>If they are actually "errors", I don't have much of a problem with it. If it's inserting a record and us...
<p>If it can't be checked/caught earlier it might be difficult to do anything else. </p> <p>I've had to write a raiseerror in a procedure I wrote and used as a constraint on inserting/updating a table because it was the 'last stop' for the data and I had to check it there. </p> <p>I think in general if you are gett...
11,381
<p>I am told that good developers can spot/utilize the difference between <code>Null</code> and <code>False</code> and <code>0</code> and all the other good "nothing" entities.<br> What <em>is</em> the difference, specifically in PHP? Does it have something to do with <code>===</code>?</p>
<h2>It's language specific, but in PHP :</h2> <p><strong><code>Null</code></strong> means "<strong>nothing</strong>". The var has not been initialized.</p> <p><strong><code>False</code></strong> means "<strong>not true in a boolean context</strong>". Used to explicitly show you are dealing with logical issues.</p> <...
<p>The issues with falsyness comes from the PHP history. The problem targets the not well defined scalar type.</p> <pre><code>'*' == true -&gt; true (string match) '*' === true -&gt; false (numberic match) (int)'*' == true -&gt; false (string)'*' == true -&gt; true </code></pre> <p>PHP7 strictness is a step forward,...
16,630
<p>We are currently testing a Java Swing application for it's performance. I wonder if there is a good tool to automate this?</p>
<p>A few years ago I used <a href="http://jakarta.apache.org/jmeter/" rel="nofollow noreferrer">JMeter</a> for such a task. I generally enjoyed using it, though I never did much research on what else is available and I don't know if it's still actively developed.</p>
<p>The Pragmatic Programmers also came out with a <a href="https://rads.stackoverflow.com/amzn/click/com/1934356182" rel="nofollow noreferrer" rel="nofollow noreferrer">book</a> on using Ruby to do GUI testing.</p> <p>In particular, they give extensive examples using JRuby to test a swing app. </p> <p>The testing th...
11,813
<p>I've seen people doing things like this in their HTML:</p> <pre><code>&lt;!--[if IE]&gt; &lt;link rel="stylesheet" href="ie.css" type="text/css" /&gt; &lt;![endif]--&gt; </code></pre> <p>Does this work across all modern browsers and is there a list of browser types that will work with that kind of if statement?<...
<p>This works across all browsers because anything except IE sees <code>&lt;!--IGNORED COMMENT--&gt;</code>. Only IE reads the comment if it contains a conditional clause. Have a look at <a href="http://www.quirksmode.org/css/condcom.html" rel="noreferrer">this article</a></p> <p>You can also specify which version of ...
<p>Further to Ross' answer, you can only target the Internet Explorer rendering engine with conditional comments; there is no similar construct for other browsers. For example, you can't write conditional comments that target Firefox, but are ignored by Internet Explorer. </p> <p>The way I achieve the same effect as y...
6,814
<p>Is there some way to do multi-threading in JavaScript?</p>
<p>See <a href="http://caniuse.com/#search=worker" rel="nofollow noreferrer">http://caniuse.com/#search=worker</a> for the most up-to-date support info.</p> <p>The following was the state of support circa 2009.</p> <hr /> <p>The words you want to google for are <a href="http://www.google.com/search?q=JavaScript+worker+...
<p>With HTML5 <a href="https://www.w3.org/TR/workers/" rel="nofollow noreferrer">specification</a> you do not need to write too much JS for the same or find some hacks.</p> <p>One of the feature introduced in HTML5 is <a href="http://www.w3schools.com/html/html5_webworkers.asp" rel="nofollow noreferrer">Web Workers</a...
4,988
<p>How can I set a custom background color of a button? </p> <p>Interface Builder doesn't seem to have an interface to do this. </p> <p>Is it only available programmatically? If so, can you provide an example, please?</p>
<p>I found that I needed to use a stretchable image to accomplish this. Apple's UICatalog example has one or more colored buttons that are drawn in this fashion. You could use their template image and recolor it to suit your button needs.</p> <p>I'm not sure about doing this in Interface Builder, but I was able to c...
<p>May be I misunderstood your question, but does below not work for you?</p> <p><img src="https://i.stack.imgur.com/I7i5W.png" alt=""></p>
48,727
<p>I'm using RichFaces per a client requirement, but the markup it (and the stock JSF controls) generates is an awful mess of nested tables. Are there any control libraries out there that generate nicer markup? AJAX support is a huge plus!</p>
<p>There is ICEFaces which provides more semantic support than RichFaces .Also you can try Nitobi suite which also provides similar kinda solution.If you are not satisfied with any of these I suggest try to write your own part extending the Sun faces</p>
<p>Short answer: No I have not yet found one. Your options include using less complicated controls and know what html the standard controls emit. Thing like h:panelGrid render as a table. There is nothing stopping you writing your own rendering family which produces more standards compliment html, but this would be a b...
8,896
<p>Our rails app is designed as a single code base linking to multiple client databases. Based on the subdomain the app determines which db to connect to.</p> <p>We use liquid templates to customise the presentation for each client. We are unable to customise the generic 'We're Sorry, somethign went wrong..' message f...
<p>For catching exceptions in Rails 2, <code>rescue_from</code> controller method is a great way to specify actions which handle various cases.</p> <pre><code>class ApplicationController &lt; ActionController::Base rescue_from MyAppError, :with =&gt; :show_errors def show_errors render :action =&gt; "..." e...
<p>It's not clear if you're trying to do inline error messaging or new page error messaging, but if you want to improve the text around inline error messaging, <a href="http://www.softiesonrails.com/2008/4/23/better-messages-for-activerecord-validation-errors" rel="nofollow noreferrer">this post</a> provides good infor...
12,633
<p>Are there any other IDEs worth my time for Lotus Notes development? We're doing mostly LotusScript development and would kill for features of Eclipse or Visual Studio, like "Show Declaration". I know there's <a href="http://www.ibm.com/developerworks/lotus/library/notes-eclipse/" rel="nofollow noreferrer">an Eclipse...
<p>Lotus Notes has moved to the Eclipse platform in version 8. You can run the client in 2 different modes, basic mode which is the version we all know or on the Eclipse platform (know as the standard). The IDE is also moving to eclipse, version 8.5 beta 2 is currently available with the new Eclipse based IDE. Bear in ...
<p>Teamstudio sell a number of tools to assist your Lotus Notes development, and it looks like they can do some of the things you want, but it doesn't look like they can be assembled into an IDE.</p> <p><a href="http://www.teamstudio.com/products/product-index.html" rel="nofollow noreferrer">http://www.teamstudio.com/...
16,117
<p>I am just getting started with flex and am using the SDK (not Flex Builder). I was wondering what's the best way to compile a mxml file from an ant build script. </p>
<p>The Flex SDK ships with a set of ant tasks. More info at:</p> <p><a href="http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html" rel="noreferrer">http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html</a></p> <p>Here is an example of compiling Flex SWCs with ant:</p> <p><a href=...
<p>If you're open to Maven, try the flex-compiler-mojo plugin:</p> <p><a href="http://code.google.com/p/flex-mojos/" rel="nofollow noreferrer">http://code.google.com/p/flex-mojos/</a></p> <p>Christiaan</p>
10,368
<p>Currently I monitoring a particular file with a simple shell one-liner:</p> <pre><code>filesize=$(ls -lah somefile | awk '{print $5}') </code></pre> <p>I'm aware that Perl has some nice modules to deal with Excel files so the idea is to, let's say, run that check daily, perhaps with cron, and write the result on ...
<p>You can check the size of the file using the -s operator.</p> <pre> use strict; use warnings; use File::Slurp qw(read_file write_file); use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; use Spreadsheet::WriteExcel; my $file = 'path_to_file'; my $size_file = 'path_to_file_keeping_the_siz...
<p>The module you should be using is <a href="http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel/lib/Spreadsheet/WriteExcel.pm" rel="nofollow noreferrer">Spreadsheet::WriteExcel</a>.</p>
9,717
<p>Has anyone ever used the <a href="https://www.dofactory.com/net/bridge-design-pattern" rel="nofollow noreferrer">Bridge pattern</a> in a real world application? If so, how did you use it? Is it me, or is it just the <a href="https://www.dofactory.com/net/adapter-design-pattern" rel="nofollow noreferrer">Adapter patt...
<p>The Bridge pattern is an application of the old advice, "prefer composition over inheritance". It becomes handy when you must subclass different times in ways that are orthogonal with one another. Say you must implement a hierarchy of colored shapes. You wouldn't subclass Shape with Rectangle and Circle and then sub...
<pre><code>Bridge design pattern we can easily understand helping of service and dao layer. Dao layer -&gt; create common interface for dao layer -&gt; public interface Dao&lt;T&gt;{ void save(T t); } public class AccountDao&lt;Account&gt; implement Dao&lt;Account&gt;{ public void save(Account){ } } public LoginDao&lt...
41,344
<p>i am creating a system. What i want to know is if a msg is unsupported what should it do? should i throw saying unsupported msg? should i return 0 or -1? or should i set an errno (base->errno_). Some messages i wouldnt care if there was an error (such as setBorderColour). Others i would (addText or perhaps save if i...
<p>Generally if it's C++, prefer exceptions unless performance is critical or unless you may be running in an environment (e.g. an embedded platform) that does not support exceptions. Exceptions are by far the best choice for debugging because they are very noticeable when they occur and are ignored. Further, exception...
<p>Personally when it comes to output graphics, I feel a silent fail is fine. It just makes your picture wrong.</p> <p>Graphical errors are super easy to spot anyways.</p>
39,572
<p>Is it legal to more or less "copy" (or euphemistically, be very "inspired by") the idea and UI of a copyrighted program? This question popped in my mind when looking at "<a href="http://culturedcode.com/things/" rel="noreferrer">Things</a>" which is a Mac-only program.</p> <p>How legal would it be for someone to ma...
<p>Specific elements of a design can be copyrighted. Apple won the "trashcan" icon, but effectively nothing else during the Microsoft/Apple lawsuit over a look and feel. As long as the code is entirely your own, the graphics are your own (and yes, copying too closely a <em>specific</em> graphic element like the trashca...
<p>I think in general the answer is no, it would not be illegal. Apple tried to sue Microsoft for stealing the "look and feel" of Mac OS, and lost... There are lots of linux programs, which copy the UI of similar windows programs almost exactly...</p>
30,896
<p>I need to call into a Win32 API to get a series of strings, and I would like to return an array of those strings to JavaScript. This is for script that runs on local machine for administration scripts, not for the web browser.</p> <p>My IDL file for the COM object has the interface that I am calling into as:</p> <...
<p>If i recall correctly, you'll need to wrap the <code>SAFEARRAY</code> in a <code>VARIANT</code> in order for it to get through, and then use a <a href="http://msdn.microsoft.com/en-us/library/y39d47w8(VS.85).aspx" rel="noreferrer">VBArray object</a> to unpack it on the JS side of things:</p> <pre><code>HRESULT GetA...
<p><a href="https://stackoverflow.com/questions/45169/how-do-i-return-an-array-of-strings-from-an-activex-object-to-jscript#45211">Shog9</a> is correct. COM scripting requires that all outputs be VARIANTS. </p> <p>In fact, it also requires that all the <strong>INPUTs</strong> be VARIANTS as well -- see the nasty detai...
6,698
<p>Until this morning, I have had Apache 2.0 running as a service using a local account which was configured with appropriate permissions. Sometime yesterday, someone must have changed something, and now Apache 2.0 won't start as a service under this account.</p> <p>I made the account an Administrator temporarily, and...
<p>I have discovered the problem. After establishing the connection and the message listener the service went into a loop with Thread.Sleep(500). Dumb. I refactored the service to start everything up in OnStart and dispose of it in OnStop.</p> <p>Since doing that, everything is running perfectly.</p> <p>Classic ID...
<p>we have just come across exactly the same issue using a .Net service talking to ActiveMQ, but ours locks up after only about 10-20 messages being delivered.</p> <p>Have tried it with and without the spring framework and it's slightly better without (unless I'm imagining things).</p> <p>Would you mind checking over...
33,833
<p>Added: Working with SQL Server 2000 and 2005, so has to work on both. Also, value_rk is not a number/integer (Error: Operand data type uniqueidentifier is invalid for min operator)</p> <p>Is there a way to do a single column "DISTINCT" match when I don't care about the other columns returned? Example:</p> <pre><c...
<p>this might work:</p> <pre><code>SELECT DISTINCT a.value, a.attribute_definition_id, (SELECT TOP 1 value_rk FROM attribute_values WHERE value = a.value) as value_rk FROM attribute_values as a ORDER BY attribute_definition_id </code></pre> <p>.. not tested.</p>
<p>Less elegant than I would like---- it's essentially what you're doing, just in pure SQL--- but it works and can all be done in SQL.</p> <pre> DECLARE @mytable TABLE(mykey NVARCHAR(512), myVal NVARCHAR(512)) DECLARE @keyVal NVARCHAR(512) DECLARE @depVal NVARCHAR(512) DECLARE myCursor CURSOR for SELECT DISTINCT(v...
31,285
<p>I am interested in references to designs which use a customized support instead of the slicer's default normal/tree support.</p> <p>The background is this: I am making a hubcap with a 3D logo. I do not want to place the logo on the print bed because the logo will become very messy. So, I place the rim of the hubcap ...
<p>Your question may be closed for being somewhat vague and outside the scope of the SE, but consider to view <a href="https://www.youtube.com/watch?v=RPijCjz9G1w" rel="nofollow noreferrer">Maker's Muse video</a> about creating alternatives to slicer-generated supports.</p> <p>The video suggests creating primitives in ...
<p>In this situation I probably wouldn't use supports at all.</p> <p>I'd put something round on the bed that fits the space instead.</p>
2,191
<p>We are developing a C# application for a web-service client. This will run on Windows XP PC's.</p> <p>One of the fields returned by the web service is a DateTime field. The server returns a field in GMT format i.e. with a "Z" at the end.</p> <p>However, we found that .NET seems to do some kind of implicit conversi...
<p>For strings such as <code>2012-09-19 01:27:30.000</code>, <code>DateTime.Parse</code> cannot tell what time zone the date and time are from.</p> <p><code>DateTime</code> has a <em>Kind</em> property, which can have one of three time zone options:</p> <ul> <li>Unspecified</li> <li>Local</li> <li>Utc</li> </ul> <p>...
<p>This code block uses universal time to convert current DateTime object then converts it back to local DateTime. Works perfect for me I hope it helps!</p> <pre><code>CreatedDate.ToUniversalTime().ToLocalTime(); </code></pre>
21,709
<p>I'm trying to format a column in a <code>&lt;table/&gt;</code> using a <code>&lt;col/&gt;</code> element. I can set <code>background-color</code>, <code>width</code>, etc., but can't set the <code>font-weight</code>. Why doesn't it work?</p> <pre><code>&lt;table&gt; &lt;col style="font-weight:bold; background-c...
<p>As far as I know, you can only format the following using CSS on the <code>&lt;col&gt;</code> element: </p> <ul> <li>background-color</li> <li>border</li> <li>width</li> <li>visibility</li> </ul> <p>This <a href="http://www.quirksmode.org/css/columns.html" rel="noreferrer">page</a> has more info.</p> <p>Herb is r...
<p>A <code>col</code> tag must be inside of a <code>colgroup</code> tag, This may be something to do with the problem.</p>
19,077
<p>related to:</p> <ul> <li><a href="https://stackoverflow.com/questions/21265/">comparing ieee floats and doubles for equality</a></li> <li><a href="https://stackoverflow.com/questions/328475/">Should we compare floating point numbers for equality against a <em>relative</em> error</a></li> <li><a href="https://stacko...
<p>Since D has 80-bit reals built in (as far as I can tell), why would you not just use the standard approach of comparing with an epsilon value. This can be a fixed value if you know the rough range in advance, such as US currency:</p> <pre><code>if (abs (a - b) &lt; 1e-6) // effectively equal </code></pre> <p>or an...
<p>My current solution is</p> <pre><code>bool Near(real a, real b, int count = 5) { // Returns the number of mantissa bits which are equal in x and y. int i = std.math.feqrel!(real)(a,b); return i + count &gt;= real.mant_dig; } </code></pre> <p>It gives the number of miss-matched bits in the inputs. I'm n...
46,278
<p>I'm using Visual Studio icon library (VS2008ImageLibrary), there are some BMP files with a pink background. How can I make the pink background become transparent? What software can I use to do this? Any free one? </p> <p>Thanks</p>
<p>I used IrfanView's batch conversion tool. It's still some work, because you have to click the pink area on every single icon instead of just specifying pink as transparent color, but it worked. It would be easy to write a simple conversion tool using GDI+ though, which I considered as well.</p> <p>Note that even th...
<p>While I don't know the modern .NET answer to your question, it's worth noting the historical reason for these bitmaps with magenta backgrounds:</p> <p>Back in the Win32-only days, there were some Common Controls (like the Toolbar, and ListView) that took these bitmaps and a colour to be treated as transparent, and ...
29,244
<p>I'm taking a look at how the model system in django works and I noticed something that I don't understand.</p> <p>I know that you create an empty <code>__init__.py</code> file to specify that the current directory is a package. And that you can set some variable in <code>__init__.py</code> so that import * works p...
<p>All imports in <code>__init__.py</code> are made available when you import the package (directory) that contains it.</p> <p>Example:</p> <p><code>./dir/__init__.py</code>:</p> <pre><code>import something </code></pre> <p><code>./test.py</code>:</p> <pre><code>import dir # can now use dir.something </code></pre>...
<blockquote> <p>&quot;We recommend not putting much code in an <code>__init__.py</code> file, though. Programmers do not expect actual logic to happen in this file, and much like with <code>from x import *</code>, it can trip them up if they are looking for the declaration of a particular piece of code and can't find i...
14,496
<p>Dear stack overflow community,</p> <p>I've been given the task of overhauling a couple of websites for a large corporation I'm working for, as well as developing an internal intranet site for content management and document storage within the organization.</p> <p>My "problem" is this: They want me to use a framewo...
<p>If you like Python, and you want a web framework, I wouldn't go past Django. It's simple, powerful, and runs plenty of enterprise-level sites.</p> <p>A few of the bigger sites using Django are <a href="http://www.lawrence.com/" rel="nofollow noreferrer">Lawrence.com</a>, <a href="http://www.curse.com/" rel="nofoll...
<blockquote> <p>CMS for a medium-big company is not about Software. It is about proccesses and policies.</p> </blockquote> <p>Very true! </p> <p>Association with prestigious names is not necessarily an indicator of pleasing end results. </p> <p>I like Sony products, yes, but on the various occasions on which I hav...
29,904
<p>Is there a difference between the two examples below for beginning a Perl script? If so, when would I use one over the other?</p> <p>example 1:</p> <pre><code>#!/usr/bin/perl use warnings; </code></pre> <p>example 2:</p> <pre><code>#!/usr/bin/perl -w </code></pre>
<p>Using the switch will enable all warnings in <strong>all</strong> modules used by your program. Using the pragma you enable it only in that specific module (or script). Ideally, you use warnings in all your modules, but often that's not the case. Using the switch can get you a lot of warnings when you use a third pa...
<p>In addition to enabling/disabling specific assertions using the pragma, you can also promote some or all warnings to errors:</p> <pre><code>use strict; use warnings FATAL =&gt; 'all', NONFATAL =&gt; 'exec'; </code></pre>
27,362
<p>There is a select dropdown and I want to add &quot;No selection&quot; item to the list which should give me 'null' when submitted. I'm using SimpleFormController derived controller.</p> <pre><code>protected Map referenceData(HttpServletRequest httpServletRequest, Object o, Errors errors) throws Exception { Map&l...
<p>One option:</p> <pre class="lang-html prettyprint-override"><code>&lt;form:select path="country" title="country" &gt; &lt;form:option value=""&gt;&amp;nbsp;&lt;/form:option&gt; &lt;form:options items="${countryList}" /&gt; &lt;/form:select&gt; </code></pre>
<p>I don't think you should need a property editor for this. If the "blank" option is first in the list, and the tag that outputs the list doesn't mark any of them as selected, then the browser should select the first, "blank" one automatically.</p> <p>When you submit the form, try and work it so that the "blank" val...
19,650
<p>Given an array of <strong>n</strong> Objects, let's say it is an <strong>array of strings</strong>, and it has the following values:</p> <pre><code>foo[0] = "a"; foo[1] = "cc"; foo[2] = "a"; foo[3] = "dd"; </code></pre> <p>What do I have to do to delete/remove all the strings/objects equal to <strong>"a"</strong> ...
<p>[If you want some ready-to-use code, please scroll to my "Edit3" (after the cut). The rest is here for posterity.]</p> <p>To flesh out <a href="https://stackoverflow.com/a/112507/13">Dustman's idea</a>:</p> <pre><code>List&lt;String&gt; list = new ArrayList&lt;String&gt;(Arrays.asList(array)); list.removeAll(Array...
<p>Assign null to the array locations.</p>
13,756
<p>I'm writing a little web-based utility for my brother who needs to merge columns in a CSV file. I know things like this surely exist somewhere, but a large part of this is that is a fun little exercise.</p> <p>Anyways, I'm trying to figure out the best/neatest way to present the part of the UI where he reorders the...
<p>Basic steps:</p> <ol> <li>Grab the list of columns to be merged as an array of &lt;li&gt;'s. <ul> <li>If you're merging two already-merged columns (or one of the colums is already merged), extract each column in the group. In your structure, you'd want to make "Column 1" have its own &lt;li&gt; without the child ...
<p>I'd say to stick with using tables for tabular data, unordered lists don't seem to suit the content as much.</p>
40,327
<p>I have an Open Source app and I currently only post the binary for the Windows build. At this point Linux users have to get the source and compile it. Is there a standard way for posting a Linux binary? </p> <p>My app is in c / c++ and compiled with gcc, the only external Linux code I use is X Windows and CUPS.</p>...
<p>The most common way would be to package it in a <a href="http://en.wikipedia.org/wiki/RPM_Package_Manager" rel="nofollow noreferrer">.rpm file</a> for <a href="http://www.redhat.com/" rel="nofollow noreferrer">RedHat</a>-based distros like <a href="http://fedoraproject.org/" rel="nofollow noreferrer">Fedora</a>, or ...
<p>I only use precompiled binaries from my distribution - never from other hand. If you can afford it just roll a tarball and add some buildscript so that people can build your project. To publish it add it to sites like: <a href="http://www.freshmeat.net" rel="nofollow noreferrer">Freshmeat</a></p>
15,815
<p>I have a question about Slic3r software.</p> <p>I would like to subtract two parts. For example, I have an STL model, when I right click on the part, I can select <strong>Settings...</strong>, and in the <strong>Settings</strong> window, I can select modifier and I can select slab.with selecting proper thickness. N...
<p>Given my limited familiarity with all the CAD tools that exist, I would fall back to something that I know does binary operations on volumes -- openScad.</p> <p>One can create two objects, one from each of the two STL files, and subtract one from the other. One can also compute intersections, unions, and other ope...
<p>I am assuming your trying to perforate, hollow or cut your design in a specific shape that is the same as the inner 3D object or vice versa? </p> <p>Do this with 3Ds max its just really easy there for such operations.</p> <p>Please load into Autodesk 3Ds max and perform Boolean.</p> <p>This is the link on how to ...
937
<p>Various programs can do stuff only when you haven't used the computer for a while (eg screensaver, Google Desktop indexing, etc).</p> <p>How do they know when it has been inactive? Is there some function in Windows that tells you how long it has been inactive, or do you have to use some kind of keyboard/mouse hook ...
<p>EDIT: changed answer, providing text and detail behind Shy's answer (which should be and was accepted). Feel free to merge and delete this one.</p> <p><a href="http://pinvoke.net/default.aspx/user32/GetLastInputInfo.html" rel="nofollow noreferrer">GetLastInputInfo</a> Function The GetLastInputInfo function retriev...
<p>The keyboard and mouse hooks are what I find to be most valuable. The class below can be inserted and you just have to figure out what you want to do with the information about key and mouse updates. </p> <pre><code>using System; using System.Runtime.InteropServices; using System.Threading; using System.Windows.F...
24,885
<p>Once again one of those: "Is there an easier built-in way of doing things instead of my helper method?"</p> <p>So it's easy to get the underlying type from a nullable type, but how do I get the nullable version of a .NET type?</p> <p>So I have</p> <pre><code>typeof(int) typeof(DateTime) System.Type t = something;...
<p>Here is the code I use:</p> <pre><code>Type GetNullableType(Type type) { // Use Nullable.GetUnderlyingType() to remove the Nullable&lt;T&gt; wrapper if type is already nullable. type = Nullable.GetUnderlyingType(type) ?? type; // avoid type becoming null if (type.IsValueType) return typeof(Nulla...
<p>There isn't anything built in that I know of, as the <code>int?</code>, etc. is just syntactic sugar for <code>Nullable&lt;T&gt;</code>; and isn't given special treatment beyond that. It's especially unlikely given you're attempting to obtain this from the type information of a given type. Typically that always nece...
13,351
<p>Two ways to normalize a Vector3 object; by calling Vector3.Normalize() and the other by normalizing from scratch:</p> <pre><code>class Tester { static Vector3 NormalizeVector(Vector3 v) { float l = v.Length(); return new Vector3(v.X / l, v.Y / l, v.Z / l); } public static void Main(...
<p>Look how they implemented it (e.g. in asm).</p> <p>Maybe they wanted to be faster and produced something like:</p> <pre><code> l = 1 / v.length(); return new Vector3(v.X * l, v.Y * l, v.Z * l); </code></pre> <p>to trade 2 divisions against 3 multiplications (because they thought mults were faster than divs (whi...
<p>Don't care about this. There's always some error involved when using floats. If you're curious, try changing to double and see if this still happens.</p>
41,831
<p>I would like to write some data to a file in Ruby. What is the best way to do that?</p>
<pre><code>File.open("a_file", "w") do |f| f.write "some data" end </code></pre> <p>You can also use <code>f &lt;&lt; "some data"</code> or <code>f.puts "some data"</code> according to personal taste/necessity to have newlines. Change the <code>"w"</code> to <code>"a"</code> if you want to append to the file inste...
<pre><code>filey = File.new("/path/to/the/file", APPEND) filey.puts "stuff to write" </code></pre>
18,171
<p>I hope I haven't painted myself into a corner. I've gotten what seems to be most of the way through implementing a Makefile and I can't get the last bit to work. I hope someone here can suggest a technique to do what I'm trying to do.</p> <p>I have what I'll call "bills of materials" in version controlled files i...
<p>Make is very bad at being able to detect actual file changes, as opposed to just updated timestamps. </p> <p>It sounds to me that the root of the problem is that the bom-checkout always modifies the timestamp of the bom, causing the dependencies to be regenerated. I would probably try to solve this problem instead ...
<p>I'm not a make expert, but I would try have $(BOMS) depend on $(SIGS), and making the $(SIGS) target execute the if/else rules that you currently have under the $(BOMS) target.</p> <pre><code>$(DEP) : $(SIGS) ... recreate dependency $(BOMS) : $(SIGS) ...checkout TAG=$(VER) $@ $(SIGS) : ...if $(subst .bo...
9,705
<p>Can you specialize a template method within a template class without specializing the class template parameter?</p> <p>Please note that the specialization is on the <em>value</em> of the template parameter, not its type.</p> <p>This seems to compile under Visual Studio 2008 SP1 complier, but not GCC 4.2.4.</p> <p...
<p>It is not supported in the standard (and it is apparently a known bug with Visual Studio that you <em>can</em> do it).</p> <p>The standard doesn't allow an inner template (member function <em>or</em> class) to be specialized without the outer template being specialized as well. One of the reasons for this is that ...
<p>I've never heard of that being possible; it would make sense to me if it was <em>not</em> supported by all compilers. So here is an idea for a workaround:</p> <p>Implement a template function outside of your class which takes the same action as the method. Then you can specialize this function, and it call it fro...
9,005
<p>I'm trying to create a POST request, unfortunately the body of the POST never seems to be sent.</p> <p>Below is the code that I'm using. The code is invoked when a user clicks on a link, not a form "submit" button. It runs without error, invokes the servlet that is being called but, as I mentioned earlier, the bo...
<p>These are the kind of situations where Firebug and Firefox are really helpful. I suggest you install Firebug if you don't have it and check the request that is being sent.</p> <p>You also definitely need to stick to <code>parameters</code> instead of <code>requestBody</code>.</p> <p>This:</p> <pre><code>new Ajax....
<p>When I hit this problem the solution was to remove <code>contentType</code> from <code>Ajax.Request</code> options. </p> <p>In <a href="https://stackoverflow.com/a/216074/1483">answer</a> by <a href="https://stackoverflow.com/users/16417/paolo-bergantino">Paolo Bergantino</a> <code>contentType</code> is not defined...
26,562
<p>What's the best way to parse fragments of HTML in C#?</p> <p>For context, I've inherited an application that uses a great deal of composite controls, which is fine, but a good deal of the controls are rendered using a long sequence of literal controls, which is fairly terrifying. I'm trying to get the application i...
<p>Have a look at the <a href="http://www.codeplex.com/htmlagilitypack" rel="nofollow noreferrer">HTMLAgility</a> pack. It's very compatible with the .NET XmlDocument class, but it much more forgiving about HTML that's not clean/valid XHTML.</p>
<p>You can also look into <a href="http://tidy.sourceforge.net/" rel="nofollow noreferrer">HTML Tidy</a> for HTML parsing/cleanup. I don't think they have specific .NET libraries, but you might be able to run the binary via command-line, or IKVM the java libraries.</p>
31,138
<p>I've switched computers a few times recently, and somewhere along the way I lost my .emacs. I'm trying to build it up again, but while I'm at it, I thought I'd pick up other good configurations that other people use.</p> <p>So, if you use Emacs, what's in <i>your</i> .emacs?</p> <p>Mine is pretty barren right now...
<p>Use the <a href="http://dotfiles.org/.emacs" rel="nofollow noreferrer">ultimate dotfiles site</a>. Add your '.emacs' here. Read the '.emacs' of others.</p>
<p>One line to amend the load path One line to load my init library One line to load my emacs init files</p> <p>Of course, the "emacs init files" are quite numerous, one per specific thing, loaded in a deterministic order.</p>
18,617
<p>I have a list of input words separated by comma. I want to sort these words by alphabetical and length. How can I do this without using the built-in sorting functions?</p>
<p>Good question!! Sorting is probably the most important concept to learn as an up-and-coming computer scientist.</p> <p>There are actually lots of different algorithms for sorting a list.</p> <p>When you break all of those algorithms down, the most fundamental operation is the comparison of two items in the list, d...
<p>If you don't want to use build-in-functions, you have to create one by your self. I would recommend <em>Bubble sort</em> or some similar algorithm. Bubble sort is not an effective algoritm, but it get the works done, and is easy to understand.</p> <p>You will find much good reading on <a href="http://en.wikipedia.o...
42,499
<p>I have a large codebase without Javadoc, and I want to run a program to write a skeleton with the basic Javadoc information (e.g., for each method's parameter write @param...), so I just have to fill the gaps left.</p> <p>Anyone know a good solution for this?</p> <p><strong>Edit:</strong></p> <p>JAutodoc is what ...
<p>The <a href="http://jautodoc.sourceforge.net/" rel="noreferrer">JAutodoc</a> plugin for eclipse does exactly what you need, but with a package granularity : </p> <p>right click on a package, select "Add javadoc for members..." and the skeleton will be added.</p> <p>There are numerous interesting options : template...
<p>If you right-click in the source of a file in Eclipse, it has a Javadoc generation option under the source menu.</p>
4,941
<p>I'm trying TripleDES Encryption with ECB mode. My code looks like that:</p> <pre><code>public static string EncryptDES(string InputText) { byte[] key = new byte[] { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,...
<p>My bad ! I found my problem Instead of using <code>alg.CreateEncryptor()</code> I was using <code>alg.CreateDecyptor()</code>.</p> <p>A copy paste issue. :(</p> <p>Thanks for help, guys</p>
<p>It sounds like your encryption method is using a different key/salt combo than the decryption method and it can't decrypt the data.</p> <p>During debugging it might be benefical to convert your key &amp; salt to readable strings and waste the cycle's converting them to bytes.. at least for readability.</p>
38,935
<p>Sorry, I'm new in 3D printing and modeling and I need help.</p> <p>I bought a 3D model with a hollow part of the body that doesn't print on my printer normally (with very high resolution (layer is 0.12 mm, the nozzle is 0.4 mm) because the walls are very thin). I tried to make it as a solid in MeshMixer or ZBrush, ...
<p>The model clearly contains an enclosed surface, which is directed to the inside - in other words, it was modeled to contain a volume of air.</p> <p>Those surfaces need to be removed to print the body solid. To do this, you could check if those surfaces constitute a separate shell for meshmixer. If yes, you can just ...
<p>This is a problem with the model, you need to make sure that the model isn't hollow. You might be able to get around this though if you use scaffolding, it might recognize the overhand hand build supports for your print inside of your print, you just might have to mess around with the scaffolding settings a bit.</p>...
1,938
<p>i have created a workflow activity that do give the item creater of a specific list full control on the item and set everyone else to read only access (permission) </p> <p>someone told me that doing it this way (if i have a lot of users) the performance will go down dramatically </p> <p>is that correct ?!!</p> <p...
<p>Performance degradation will happen when you use large ACLs for each list item. Just make sure that item-level permissions basically have the minimum entries. For example:</p> <ul> <li>The user that has permissions to edit that item</li> <li>A single security group that contains all the users with only Reader permi...
<p>Yes, you might solve this with workflows but that might be a bit clumsy and it might slow your server.</p> <p>The better option is to use List Settings > Advanced Settings > Item-level Permissions. </p> <p>This feature is not available for Document and Form Libraries.</p>
11,097
<p>trying to get a side project hobby going to keep me motivated from my 9-5 job on C# and was looking at Boo. some ?'s</p> <ul> <li>what has your experience being with Boo?</li> <li>what kind of apps/projects have you done with Boo or </li> <li>what is Boo capable of?</li> </ul> <p>Guess being the web world, would l...
<p>My personal experiences with Boo were from about 18 months back, and I've not followed it actively since then, <strong>so keep that in mind wrt to what I say</strong>. It is a <em>cool</em> language. But it is also experimental. What this means in practical terms:</p> <ul> <li>You can do cool things w/ the langu...
<p>You should have a look at some of Boo's interesting <a href="http://boo.codehaus.org/Language+Features" rel="nofollow noreferrer">language features</a>.</p>
25,303
<p>I don't understand where the extra bits are coming from in <a href="http://en.wikipedia.org/wiki/S-box" rel="nofollow noreferrer">this article</a> about s-boxes. Why doesn't the s-box take in the same number of bits for input as output?</p>
<p>It is the way s-boxes work. They can be m * n ==> m bit input , n bit output. For example, in the <a href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard" rel="nofollow noreferrer">AES</a> S-box the number of bits in input is equal to the number of bits in output.</p> <p>In <a href="http://en.wikipedia...
<p>What extra bits? They are going from 6 to 4.</p> <p>EDIT: Whoops! I'm an idiot. This is kinda like a 2nd grade multiplication table. They strip the outer bits off of the 6-bit block to be encypted, and leave the middle 4. Just like a table for an arithmatic operation, they go down one side, and find the outer b...
4,378
<p>I use the Boost Test framework for my C++ code but there are two problems with it that are probably common to all C++ test frameworks:</p> <ul> <li>There is no way to create automatic test stubs (by extracting public functions from selected classes for example).</li> <li>You cannot run a single test - you have to r...
<p>I've just pushed my own framework, <a href="http://www.levelofindirection.com/journal/2010/12/28/unit-testing-in-c-and-objective-c-just-got-easier.html" rel="noreferrer">CATCH</a>, out there. It's still under development but I believe it already surpasses most other frameworks. Different people have different criter...
<p>Eclipse/JUnit is a solid package for java, and there are C++ extensions/equivalents for both. It can do what you're talking about. Of course, you'd have to change IDEs...</p>
11,337
<p>Is it possible to load child entities in a <strong><em>single</em></strong> query without using DataLoadOptions?</p> <p>I am using one data context per request in an asp.net web application and trying to get around the linq to sql limitation of not being able to change dataloadoptions once a query has been executed...
<p>If you don't mind the link to the data context, as you say you don't, you could write a stored procedure that returns multiple results that map to your objects. <a href="http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/10/05/linq-to-sql-stored-procedures-with-multiple-results-imultipleresults.aspx" rel="nofol...
<p>Use Include...</p> <p>var q = from u in context.Users.Include("address")...</p> <p>Would cause the address child object to be populated as well.</p>
29,497
<p>I have a large c# solution file (~100 projects), and I am trying to improve build times. I think that "Copy Local" is wasteful in many cases for us, but I am wondering about best practices.</p> <p>In our .sln, we have application A depending on assembly B which depends on assembly C. In our case, there are dozens...
<p>In a previous project I worked with one big solution with project references and bumped into a performance problem as well. The solution was three fold:</p> <ol> <li><p>Always set the Copy Local property to false and enforce this via a custom msbuild step</p></li> <li><p>Set the output directory for each project to...
<p>Usually, you only need to Copy Local if you want your project using the DLL that is in your Bin vs. what is somewhere else (the GAC, other projects, etc.)</p> <p>I would tend to agree with the other folks that you should also try, if at all possible, to break up that solution.</p> <p>You can also use Configuration...
35,509
<p>If a class defined an annotation, is it somehow possible to force its subclass to define the same annotation?</p> <p>For instance, we have a simple class/subclass pair that share the <code>@Author @interface.</code> What I'd like to do is force each further subclass to define the same <code>@Author</code> annotatio...
<p>You can do that with JSR 269, at compile time. See : <a href="http://today.java.net/pub/a/today/2006/06/29/validate-java-ee-annotations-with-annotation-processors.html#pluggable-annotation-processing-api" rel="nofollow noreferrer">http://today.java.net/pub/a/today/2006/06/29/validate-java-ee-annotations-with-annotat...
<p>I am quite sure that this is impossible to do at compile time.</p> <p>However, this is an obvious task for a "unit"-test. If you have conventions like this that you would like enforced, but which can be difficult or impossible to check with the compiler, "unit"-tests are a simple way to check them.</p> <p>Another ...
12,098
<p>How do I implement some logic that will allow me to reproduce on Windows the functionality that I have on Linux with the <code>fork()</code> system call, using Python?</p> <p>I'm specifically trying to execute a method on the SAPI Com component, while continuing the other logic in the main thread without blocking o...
<p>Use the python <a href="http://docs.python.org/library/multiprocessing.html" rel="noreferrer">multiprocessing module</a> which will work everywhere.</p> <p>Here is a <a href="http://www.ibm.com/developerworks/aix/library/au-multiprocessing/" rel="noreferrer">IBM developerWords article</a> that shows how to convert ...
<p>Possibly a version of spawn() for python? <a href="http://en.wikipedia.org/wiki/Spawn_(operating_system)" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Spawn_(operating_system)</a></p>
4,337
<p>Is there a tool that will find for me all the css classes that I am referencing in my HTML that don't actually exist?</p> <p>ie. if I have &lt;ul class="topnav" /&gt; in my HTML and the topnav class doesn't exist in any of the referenced CSS files.</p> <p>This is similar to <a href="https://stackoverflow.com/quest...
<p>You can put this JavaScript in the page that can perform this task for you:</p> <pre><code>function forItems(a, f) { for (var i = 0; i &lt; a.length; i++) f(a.item(i)) } function classExists(className) { var pattern = new RegExp('\\.' + className + '\\b'), found = false try { forItems(document.styleShee...
<p><a href="http://www.jetbrains.com/idea/features/html_css_editor.html" rel="nofollow noreferrer" title="IntelliJ Idea">IntelliJ Idea</a> tool does that as well. </p>
10,462
<p>I am building web client for CodeCentral web service from CodeGear web site.</p> <p>I need to restrict number of items return by Search operation of CodeGear web service, say it, 10 per page. This way I can minimize loading of my web page.</p> <p>I just don't know how to do it. Any ideas?</p>
<p>Sorry, I don't know the answer off hand.</p> <p>I would suggest you contact John Kaster of CodeGear. He would know all the ins and outs of that. I haven't seen him posting here. Usually the email is [first initial][last name]@codegear.com. You might also try posting in the <a href="https://forums.codegear.com/f...
<p>You're right. The search form on the CodeCentral page lists the maximum number of entries as an option (the "Show" option), but does not allow you to select the option. And trying various obvious parameter values doesn't work.</p> <p>I haven't tried it, but what might help you is if you research the CodeCentral Exp...
39,622
<p>So, I know that try/catch does add some overhead and therefore isn't a good way of controlling process flow, but where does this overhead come from and what is its actual impact?</p>
<p>I'm not an expert in language implementations (so take this with a grain of salt), but I think one of the biggest costs is unwinding the stack and storing it for the stack trace. I suspect this happens only when the exception is thrown (but I don't know), and if so, this would be decently sized hidden cost every ti...
<p>Let us analyse one of the biggest possible costs of a try/catch block when used where it shouldn't need to be used:</p> <pre><code>int x; try { x = int.Parse("1234"); } catch { return; } // some more code here... </code></pre> <p>And here's the one without try/catch:</p> <pre><code>int x; if (int.TryParse...
7,553
<p>I'm trying to recreate the iPhone flick / scroll event in a window using JavaScript.</p> <p>Starting with JQuery, I'm measuring the mouse's acceleration and offset during click - drag - release events using a timer:</p> <pre><code>var MouseY = { init: function(context) { var self = this; self....
<p>Hit up this link for the full explanation of one approach that seems to be what you're looking for.</p> <p><a href="http://www.faqts.com/knowledge_base/view.phtml/aid/14742/fid/53" rel="nofollow noreferrer">http://www.faqts.com/knowledge_base/view.phtml/aid/14742/fid/53</a></p> <p>Here's an excerpt:</p> <blockquo...
<p>You might be interested in the jQuery plugin named overscroll: <a href="http://www.azoffdesign.com/overscroll" rel="nofollow noreferrer">http://www.azoffdesign.com/overscroll</a> (<a href="https://github.com/azoff/Overscroll" rel="nofollow noreferrer">GitHub page</a>)</p>
49,782
<p>I currently have 2 <code>BufferedReader</code>s initialized on the same text file. When I'm done reading the text file with the first <code>BufferedReader</code>, I use the second one to make another pass through the file from the top. Multiple passes through the same file are necessary.</p> <p>I know about <code>r...
<p>What's the disadvantage of just creating a new <code>BufferedReader</code> to read from the top? I'd expect the operating system to cache the file if it's small enough.</p> <p>If you're concerned about performance, have you proved it to be a bottleneck? I'd just do the simplest thing and not worry about it until yo...
<p>"The whole business about mark() and reset() in BufferedReader smacks of poor design."</p> <p>why don't you extend this class and have it do a mark() in the constructor() and then do a seek(0) in topOfFile() method.</p> <p>BR,<br> ~A</p>
32,880
<p>I just moved over to the Visual Basic team here at work.</p> <p>What is the equivalent keyword to <code>break</code> in Visual Basic, that is, to exit a loop early but not the method?</p>
<p>In both Visual Basic 6.0 and <a href="http://en.wikipedia.org/wiki/Visual_Basic_.NET" rel="noreferrer">VB.NET</a> you would use:</p> <ul> <li><code>Exit For</code> to break from For loop</li> <li><code>Wend</code> to break from While loop</li> <li><code>Exit Do</code> to break from Do loop</li> </ul> <p>depending ...
<p><code>Exit</code> [construct], and intelisense will tell you which one(s) are valid in a particular place.</p>
2,761
<p>Is there a Java equivalent to .NET's App.Config?</p> <p>If not is there a standard way to keep you application settings, so that they can be changed after an app has been distributed?</p>
<p>For WebApps, web.xml can be used to store application settings.</p> <p>Other than that, you can use the <a href="http://java.sun.com/javase/6/docs/api/java/util/Properties.html" rel="noreferrer">Properties</a> class to read and write properties files.</p> <p>You may also want to look at the <a href="http://java.su...
<p>The simple way is to simply have a properties file, e.g., myapp.properties, with all your settings in. It's not a very advanced way to do settings but it suffices, or you can have your own XML based setup, or get them from a database, etc.</p>
26,121
<p>I have a situation where I need to process large (many GB's) amounts of data as such:</p> <ol> <li>build a large string by appending many smaller (C char*) strings</li> <li>trim the string</li> <li>convert the string into a C++ const std::string for processing (read only)</li> <li>repeat</li> </ol> <p>The data in ...
<p>You can't actually form a std::string without copying the data. A stringstream would probably reuse the memory from pass to pass (though I think the standard is silent on whether it actually has to), but it still wouldn't avoid the copying.</p> <p>A common approach to this sort of problem is to write the code which...
<p>In this case, might it be better to process the char* directly, instead of assigning it to a std::string.</p>
47,182
<p>I'm unsure whether the following code would ensure all conditions given in Comparator's Javadoc. </p> <pre><code>class TotalOrder&lt;T&gt; implements Comparator&lt;T&gt; { public boolean compare(T o1, T o2) { if (o1 == o2 || equal(o1, o2)) return 0; int h1 = System.identityHashCode(o1); ...
<blockquote> <p>Hey, look at what I found!</p> <p><a href="http://gafter.blogspot.com/2007/03/compact-object-comparator.html" rel="nofollow noreferrer">http://gafter.blogspot.com/2007/03/compact-object-comparator.html</a></p> </blockquote> <p>Oh yes, I forgot about the IdentityHashMap (Java 6 and above only). J...
<p>I'm not really sure about the <code>System.identityHashCode(Object)</code>. That's pretty much what the <strong>==</strong> is used for. You might rather want to use the <code>Object.hashCode()</code> - it's more in parallel with <code>Object.equals(Object)</code>.</p>
4,797
<p>Even though Silverlight2 is still in it's infancy, can anyone recommend a book to get started with? One that has more of a developer focus than a designer one? </p>
<p>I have this one pre-ordered: "Programming Silverlight 2" by Jesse Liberty and Tim Heuer. The authors are both employed by Microsoft working on Silverlight 2, and their blogs are great, so I expect the book (to be released after RTM) to be up to date.</p>
<p>I'm currently working my way through <a href="https://rads.stackoverflow.com/amzn/click/com/073562528X" rel="nofollow noreferrer" rel="nofollow noreferrer">Introducing Microsoft Silverlight 2</a>, so far so good. </p> <p>It's a typical Microsoft book serving up the <strong>koolaid</strong>, but gives a good introd...
8,585
<p>Our 404 error logs show a lot of /SysVol http requests on our Windows Web Server 2008 for our website. It only has a webserver role and I believe that SysVol requests are meant for Domain Controllers? What's causing this and what would be the best solution to deal with these 404 requests?</p> <p>I'm using code that...
<p>Well, some css code to see how you currently set your bullet images would be useful ;-)</p> <p>Instead of actually setting the 'list-style-image' property, I've had far more consistent results with setting a background-image property for the li element. You can then control the positioning with pixel accuracy. Reme...
<p>You can use something like this in your css...</p> <pre><code>#content li{ list-style-image: url(../images/bullet.gif); } </code></pre>
26,779
<p>I need to create an <code>XmlDocument</code> with a root element containing multiple namespaces. Am using C# 2.0 or 3.0</p> <p>Here is my code:</p> <pre><code>XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("JOBS", "http://www.example.com"); doc.AppendChild(root); XmlElement job = doc.Cr...
<p>The following will generate the desired output that you requested above:</p> <pre><code>XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("JOBS"); root.SetAttribute("xmlns:JOBS", "http://www.example.com"); root.SetAttribute("xmlns:JOB", "http://www.example.com"); doc.AppendChild(root); XmlE...
<p>try to add the namespace attribute to the root element:</p> <pre><code> XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("JOBS", "http://www.example.com"); root.SetAttribute("xmlns:JOB", "http://www.example.com"); doc.AppendChild(root); XmlElement j...
42,961
<p>Im trying to craft a regex that only returns <code>&lt;link&gt;</code> tag hrefs</p> <p>Why does this regex return all hrefs including &lt;a hrefs?</p> <pre><code>(?&amp;lt;=&amp;lt;link\s+.*?)href\s*=\s*[\'\&quot;][^\'\&quot;]+ </code></pre> <pre class="lang-html prettyprint-override"><code>&lt;link rel=&quot;style...
<p>Either</p> <pre><code>/(?&lt;=&lt;link\b[^&lt;&gt;]*?)\bhref=\s*=\s*(?:"[^"]*"|'[^']'|\S+)/ </code></pre> <p>or</p> <pre><code>/&lt;link\b[^&lt;&gt;]*?\b(href=\s*=\s*(?:"[^"]*"|'[^']'|\S+))/ </code></pre> <p>The main difference is <code>[^&lt;&gt;]*?</code> instead of <code>.*?</code>. This is because you don't ...
<pre><code>/(?&lt;=&lt;link\s+.*?)href\s*=\s*[\'\"][^\'\"]+[^&gt;]*&gt;/ </code></pre> <p>i'm a little shaky on the back-references myself, so I left that in there. This regex though:</p> <pre><code>/(&lt;link\s+.*?)href\s*=\s*[\'\"][^\'\"]+[^&gt;]*&gt;/ </code></pre> <p>...works in my Javascript test.</p>
33,672
<p>Which is better to do client side or server side validation?</p> <p>In our situation we are using </p> <ul> <li>jQuery and MVC. </li> <li>JSON data to pass between our View and Controller. </li> </ul> <p>A lot of the validation I do is validating data as users enter it. For example I use the the <code>keypress<...
<p>As others have said, you should do both. Here's why:</p> <h2>Client Side</h2> <p>You want to validate input on the client side first because you can give <strong>better feedback to the average user</strong>. For example, if they enter an invalid email address and move to the next field, you can show an error messa...
<p>If you are doing light validation, it is best to do it on the client. It will save the network traffic which will help your server perform better. If if it complicated validation that involves pulling data from a database or something, like passwords, then it best to do it on the server where the data can be secur...
19,613
<p>Is it possible to change the hostname in Windows 2003 from the command line with out-of-the-box tools?</p>
<p>The previously mentioned <code>wmic</code> command is the way to go, as it is installed by default in recent versions of Windows. </p> <p>Here is my small improvement to generalize it, by retrieving the current name from the environment:</p> <pre class="lang-dos prettyprint-override"><code>wmic computersystem whe...
<p>If you are looking to do this from Windows 10 IoT, then there is a built in command you can use:</p> <p><code>setcomputername [newname]</code></p> <p>Unfortunately, this command does <em>not exist</em> in the full build of Windows 10.</p>
7,868
<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" rel="noreferrer">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 progr...
<p>There's also the <a href="http://www.developerfusion.com/tools/" rel="nofollow noreferrer">free online converters up at developerfusion</a> :)</p>
46,313
<p>Situation:</p> <ul> <li>text: a string</li> <li>R: a regex that matches part of the string. This might be expensive to calculate. </li> </ul> <p>I want to both delete the R-matches from the text, and see what they actually contain. Currently, I do this like:</p> <pre><code>import re ab_re = re.compile("[ab]"...
<pre><code>import re r = re.compile("[ab]") text = "abcdedfe falijbijie bbbb laifsjelifjl" matches = [] replaced = [] pos = 0 for m in r.finditer(text): matches.append(m.group(0)) replaced.append(text[pos:m.start()]) pos = m.end() replaced.append(text[pos:]) print matches print ''.join(replaced) </code><...
<p>You could use split with capturing parantheses. If you do, then the text of all groups in the pattern are also returned as part of the resulting list (from <a href="http://www.python.org/doc/2.5.2/lib/node46.html" rel="nofollow noreferrer">python doc</a>).</p> <p>So the code would be </p> <pre><code>import re ab_...
25,087
<p>I have a tabpanel with a calendar control on the 4th tab but when I select a date, the postback causes the tabpanel to return to the first tab instead of the 4th that it came from. Is there a way to get it to return to the tab that the calendar control is on and not revert back to the first tab ?</p> <p>I know sett...
<p>The <a href="http://www.ecma-international.org/publications/standards/Ecma-334.htm" rel="nofollow noreferrer">C# specification</a> states on p.305 (17.4.4)</p> <blockquote> <p>The initial value of a field, whether it be a static field or an instance field, is the default value (§12.2) of the field’s type. It is...
<p>Yes, you can really trust .NET to initialize fields to their default values. There are basically no repercussions for doing it explicitly. (One small caveat here: if you initialize static fields explicitly, then anyone running the type initializer a second time via reflection will end up re-initializing those fields...
33,680
<p>we have users in each region of the world. I would like to create an environment picker that shows up a map on the form and has a link for each region. So if i was in NY i would click NY and would get the NY environment. Any ideas of doing this dynamically in winforms as opposed to having a static map image.</p>
<p>I may be misreading the question, but it sounds like you want something akin to how the old-school <a href="http://blogs.msdn.com/oldnewthing/archive/2006/10/27/880411.aspx" rel="nofollow noreferrer">Windows time zone picker</a> worked. The rest of this is based on that assumption, so if I'm wrong, feel free to disr...
<p>Have you tried using MapPoint and its API? You'd probably want to use their web service. Just google "mappoint api" for some examples and documentation.</p>
24,281
<p>How can I set the font used by the FLVPlaybackCaptioning component for subtitles? Using the style property of the textarea does nothing, and using a TextFormat makes the text go blank, even though the font had been embedded.</p>
<p>It seems the font, as well as the other properties of the text, are specified in the XML file where the subtitles are read (this is from the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlaybackCaptioning.html" rel="nofollow noreferrer">documentation</a>):</p> <pre><code>&lt;?xml v...
<p>//Create a listener for your FLVPlaybackCaptioning instance, listening for the creation of the textfield/target eg.</p> <pre><code>myFLVPlybkcap.addEventListener(CaptionTargetEvent.CAPTION_TARGET_CREATED, captionTargetCreatedHandler); </code></pre> <p>//Then when that occurs, set the 'defaultTextFormat' of the tex...
25,560
<p>Is it even possible?</p> <p>So far, I found that we can buy TypeMock to mock the SharePoint objects and then use any free Mocking framework (<a href="http://code.google.com/p/moq/" rel="nofollow noreferrer">Moq</a>?) to do the rest of the job.</p> <p>What do you think?</p> <p>It seams that without TypeMock, it's ...
<p>I haven't used it yet, but I am anxious to try this product: <a href="http://www.typemock.com/sharepointpage.php" rel="nofollow noreferrer">TypeMock for SharePoint</a></p> <p>Video introduction here on the <a href="http://www.typemock.com/Multimedia.html" rel="nofollow noreferrer">multimedia page (#5)</a></p> <p>H...
<p>Currenlty typemock Isolator is the only framework that can fake or <a href="http://www.typemock.com/sharepointpage.php" rel="nofollow noreferrer">mock SharePoint</a>. That's because it can create mock objects that have private constructors or are sealed, like most SharePoint objects are.</p>
47,161
<p>Recently, I started maintaining a web application which unfortunately works only with IE 6. Most of the issues are related to CSS.</p> <p>Is there any tool which can help me standardize the CSS classes to work with <strong>both</strong> <strong>IE 6 and IE 7</strong>? I understand I have to go through standards but...
<p>Try out <a href="http://www.webdesignerdepot.com/2009/03/microsoft-announces-superpreview-for-ie-browser-testing/" rel="nofollow noreferrer">SuperPreview</a> or the <a href="http://www.istartedsomething.com/20090318/expression-web-superpreview-cross-browser-testing/" rel="nofollow noreferrer">whole package</a> (Expr...
<p>Sometimes you need to introduce a little hack for IE6 and IE7 like removing double margin and I use the following pure CSS code</p> <pre><code>css-selector { code for all browsers } *html css-selector {code for IE6 browser } *+html css-selector {code for IE7 browser } </code></pre> <p>it is not a tool that you ...
36,059
<p>What I want is system which is logging methods called by users and their returning values if they have. For example a user logs in and he/she is surfing on my web app. then naturally he/she clicks on somethings and so he/she fires up some event method whatever then my log system must log this method name and time st...
<p>Well, the <em>simplest</em> way is just to add all the logging statements to your code, using a logging framework such as <a href="http://logging.apache.org/log4net/index.html" rel="nofollow noreferrer">Log4Net</a>. If you want a more automatic way of doing this, you might want to look into <a href="http://www.sharp...
<p>you can attach your write logic class to events triggered from parts of code. using events driven architecture is a good pattern </p>
46,304
<p>I would like to show the user with a spinner, that something is done in background but do not know how this works in a batchfile.</p> <p>Does anyone have a clue?</p>
<p>This can actually be done quite easily with pure native commands, you just have to know how to use the more tricky of them. No use of external tools like VBScript or nasty side effects like clearing the screen are necessary.</p> <p>What you're looking for is the equivalent of the bash "<code>echo -n</code>" command...
<pre><code>:LOOP ECHOX -n &quot;~r%Processing...&quot; IF %CTR% EQU 4 SET /A CTR=0 IF %CTR%==0 (set /p DOT=³)&lt;NUL IF %CTR%==1 (set /p DOT=/)&lt;NUL IF %CTR%==2 (set /p DOT=Ä)&lt;NUL IF %CTR%==3 (set /p DOT=\)&lt;NUL ECHOX -n &quot;~r&quot; SET /A CTR+=1 SET /A TCT+=1 IF %TCT% GTR %MAX_COUNT% GOTO...
48,045
<p>I am new to Hibernate and attempting to run a java/spring example that retrieves data from a table in MS SqlServer. Everytime I try to run the program, the data source loads ok. But when spring tries to load the session facotry it gets the following error:</p> <pre><code>Exception in thread "main" org.springframew...
<p>You are missing a JAR file containing the JTA API classes. You probably have one already when you downloaded Hibernate. It should be called something like:</p> <pre><code>jta-1.1.jar </code></pre> <p>Hope this helps.</p>
<p>In case you are using maven, use <a href="https://mvnrepository.com/artifact/javax.transaction/jta/1.1" rel="nofollow noreferrer">this</a>,</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;javax.transaction&lt;/groupId&gt; &lt;artifactId&gt;jta&lt;/artifactId&gt; &lt;version&gt;1.1&lt;/version&gt; &lt;/...
33,745
<p>How much do you rely on database transactions? </p> <p>Do you prefer small or large transaction scopes ? </p> <p>Do you prefer client side transaction handling (e.g. TransactionScope in .NET) over server side transactions or vice-versa? </p> <p>What about nested transactions? </p> <p>Do you have some tips...
<p>I always wrap a transaction in a using statement.</p> <pre><code>using(IDbTransaction transaction ) { // logic goes here. transaction.Commit(); } </code></pre> <p>Once the transaction moves out of scope, it is disposed. If the transaction is still active, it is rolled back. This behaviour fail-safes you from ac...
<p>As Sara Chipps said, transaction is overkill for high traffic applications. So we should avoid it as much as possible. In other words, we use a <a href="http://queue.acm.org/detail.cfm?id=1394128" rel="nofollow noreferrer">BASE architecture</a> rather than ACID. Ebay is a typical case. Distributed transaction is not...
6,069
<p>I'm looking for a solution to map one or all of the following Flickr, twitter, vimeo, by exif, keywords or whatever to google maps. I'm trying to show a map of my location from updating social sites.</p>
<p>If each of the services you want <a href="http://georss.org/" rel="nofollow noreferrer">supports GeoRSS</a>, then you can actually build such a map with zero coding whatsoever! This is because Google Maps supports mapping a GeoRSS feed directly. All you have to do is type the URL of the RSS feed with the GeoRSS dat...
<p>There's a nice greasemonkey <a href="http://txfx.net/2005/05/17/flickr-google-maps-geobloggers/" rel="nofollow noreferrer">script</a> to ease geotagging on Flickr.</p>
13,781
<p>What does the term <b>referential transparency</b> mean? I've heard it described as "it means you can replace equals with equals" but this seems like an inadequate explanation.</p>
<p>The term "referential transparency" comes from <a href="https://en.wikipedia.org/wiki/Analytical_philosophy" rel="noreferrer">analytical philosophy</a>, the branch of philosophy that analyzes natural language constructs, statements and arguments based on the methods of logic and mathematics. In other words, it is th...
<p>Referential transparency can be simply stated as:</p> <ul> <li>An expression always evaluating to the same result in any context <a href="https://wiki.haskell.org/Referential_transparency" rel="nofollow noreferrer">[1]</a>,</li> <li>A function, if given the same parameters twice, must produce the same result twice ...
25,891
<p>I have added uc in contentplace holder of master page but how do you instantiate the user control in master page .cs file to make it visible when the master page loads</p>
<p>If you add it to a ContentPlaceHolder, and a child page adds content to that ContentPlaceHolder - you're user control will no longer appear. IOW, the controls you add are only the <em>default</em>.</p> <p>Just add it outside of the ContentPlaceHolder if you want it always visible.</p>
<p>I'm not positive but I think you need to use the Page.LoadControl() to officially load a user control to a page at run time.</p>
43,535
<p>How can you find out the number of active users when you're using a StateServer? Also is it possible to query the StateServer and retrieve the contents in the Session State? </p> <p>I know that this is all possible if you use SqlServer for a backing store, but I want them to be in memory.</p>
<p>The number of active <em>sessions</em> in the State Server can be viewed with a Performance Counter on the server running the State Server easily. This does not directly equate to active users (due to session timeout time)</p> <p>The counter for active sessions is: "Asp.net" - "State Server Sessions Active"</p> <p...
<p>Tracking the number of users would need to be done at the application level, not the session level.</p> <p>You should be able to see what is currently in the session with the following:</p> <pre><code>StringBuilder builder = new StringBuilder(); foreach ( String key in Session.Contents ) { builder.AppendFormat...
30,884
<p>We have a set of applications that were developed for the ASCII character set. Now, we're trying to install it in Iceland, and are running into problems where the Icelandic characters are getting screwed up.</p> <p>We are working through our issues, but I was wondering: Is there a good "guide" out there for writi...
<p>This looks like a comprehensive quick guide:<br> <a href="http://www.cl.cam.ac.uk/~mgk25/unicode.html" rel="nofollow noreferrer">http://www.cl.cam.ac.uk/~mgk25/unicode.html</a></p>
<p>You may want to use wide characters (wchar_t instead of char and std::wstring instead of std::string). This doesn't automatically solve 100% of your problems, but is good first step.</p> <p>Also use string functions which are Unicode-aware (refer to documentation). If something manipulates wide chars or string it g...
16,264
<p>Specifically, in VS 2008, I want to connect to a data source that you can have by right-clicking on the automatically-generated App_Data folder (an .mdf "database"). Seems easy, and it is once you know how.</p>
<p>So here's the answer from MSDN:</p> <blockquote> <p>Choos[e] "Add New Data Source" from the Data menu.[And follow the connection wizard]</p> </blockquote> <p>Very easy, except that I have no Data menu. If you don't have a Data menu, do the following:</p> <ul> <li>Click on Tools >> Connect to Database...</li> ...
<p>In your Login.aspx.cs (the code behind file for your login page in the submit button click event) add</p> <pre><code>string constr = @"Data Source=(LocalDB)\v11.0; AttachDbFilename=|DataDirectory|\myData.mdf; Integrated Security=True; Connect Timeout=30;"; using (SqlConnection conn = new SqlConnection(constr)) stri...
20,865
<p>I am using a List Control to display a representation of elements within a vector. When the list is clicked on another control shows information about that element. The index of the element is currently determined by its index in the control, however if I wish to sort or filter the results this will no longer work.<...
<p>Frankly - tying data (the position in your data vector) to the presentation of the data in the list control (the position in the list ctrl) is something I would stay away from.</p> <p>In MFC each control has a "Data" DWORD member variable - when coding in MFC I Always called "SetItemData" for each item added and pa...
<p>To use a virtual list control, set the LVS_OWNERDATA style. You then need to handle the LVN_GETDISPINFO notification message (which is sent via WM_NOTIFY).</p> <p>If you do this, you are entirely responsible for the data, including the order in which it is shown. Therefore it is up to you to handle sorting and so f...
22,694
<p>How do you solve the problem with soft hyphens on your web pages? In a text there can be long words which you might want to line break with a hyphen. But you do not want the hyphen to show if the whole word is on the same line.</p> <p>According to comments on <a href="http://www.thefutureoftheweb.com/blog/breaking-...
<p><del>Unfortunately, <code>&amp;shy</code>'s support is so inconsistent between browsers that it can't really be used.</del></p> <p><del>QuirksMode is right -- there's no good way to use soft hyphens in HTML right now. See what you can do to go without them.</del></p> <p>2013 edit: <a href="http://www.quirksmode.or...
<p>Sometimes web browsers seems to be more forgiving if you use the Unicode string <code>&amp;#173;</code> rather than the <code>&amp;shy;</code> entity.</p>
28,006