instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I have a .NET TCP Client that sends high volumes of messages to a (.NET async) TCP server.</p> <p>I need to keep sending messages to the server but I run out of ports on the client due to TIME_WAIT. </p> <p>How can a program continually and reliably send messages without using all of the available ports?</p> <p>...
<p>You can keep the socket open if your server and client are aware of the format of the data. You're closing the socket so that the server can "see" that the client is "done".</p> <p>If you have some protocol, then the server can "know" when it's finished receiving a block of data.</p> <p>You can look for an End-of-...
<p>When coded like that it doesn't work.</p> <p>The server only receives the first message.</p> <p>When I open and close the socket then the server works but I run out of client ports.</p> <p>I'm guessing it's the design of my server that is causing me to have to code the client like that.</p> <p>So how does one co...
19,120
<p>Today I read <a href="http://rogeralsing.com/2008/12/07/genetic-programming-evolution-of-mona-lisa/" rel="noreferrer">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="noreferrer">Mona Lisa</a> using only 50 semi transparent polygons.</p> <...
<p>There is some debate as to whether Roger's Mona Lisa program is <a href="http://en.wikipedia.org/wiki/Genetic_programming" rel="noreferrer">Genetic Programming</a> at all. It seems to be closer to a (1 + 1) <a href="http://en.wikipedia.org/wiki/Evolution_strategy" rel="noreferrer">Evolution Strategy</a>. Both tech...
<p>I have some projects using Genetic Algorithms. GA are ideal for optimization problems, when you cannot develop a fully sequential, exact algorithm do solve a problem. For example: what's the best combination of a car characteristcs to make it faster and at the same time more economic?</p> <p>At the moment I'm devel...
46,329
<p>I have an application (an IP conferencing service) that I need to scale. It has quite a few independent components/applications, written in different languages (mainly C++ and PHP, some Perl). Currently a single installation runs on 5 machines, with 1-2 components sharing a single box. The configuration of each box ...
<p>I'd go for virtualization. That way you can have various similar configuration machines, and distribute load among them as needed, even if you keep modules in separate VMs.</p>
<p>You need to determine where the highest load or bottle neck will be it will be difficult to properly plan this without.</p> <p>I would second looking at virtualization. It makes your app: Quick to deploy Easy to backup On event of failure quick to restore</p>
20,976
<p>It's clear that a search performance of the generic <code>HashSet&lt;T&gt;</code> class is higher than of the generic <code>List&lt;T&gt;</code> class. Just compare the hash-based key with the linear approach in the <code>List&lt;T&gt;</code> class.</p> <p>However calculating a hash key may itself take some CPU cyc...
<p>A lot of people are saying that once you get to the size where speed is actually a concern that <code>HashSet&lt;T&gt;</code> will always beat <code>List&lt;T&gt;</code>, but that depends on what you are doing.</p> <p>Let's say you have a <code>List&lt;T&gt;</code> that will only ever have on average 5 items in it. ...
<p>Depends on a lot of factors... List implementation, CPU architecture, JVM, loop semantics, complexity of equals method, etc... By the time the list gets big enough to effectively benchmark (1000+ elements), Hash-based binary lookups beat linear searches hands-down, and the difference only scales up from there. </p> ...
18,176
<p>I have an application written using VS2005 in C# targeting the Compact Framework 2.0 SP2. As part of the solution, I have CAB deploy project which deploys to the device without a problem. What I can't do is create a shortcut to my application on the devices desktop.</p> <p>I have spent several hours reading various...
<p>A Windows CE shortcut (CE of any version or flavor, including WinMo) uses a ASCII-text based file. They are in the form:</p> <p>{XX}#{PATH}</p> <p>Where:</p> <ul> <li>XX = the number of the characters in the path, to include the number a # sign</li> <li>PATH = fully qualified path to the file to run</li> </ul> ...
<p>I assume that you're working with a "Smart Device CAB Project"? I don't think this project creates shortcuts in the correct manner for Windows CE 4.2. I think you can download an SDK from Microsoft that after installation will show you something like "Windows CE CAB Project" as a project option.</p> <p>I think yo...
17,536
<p>What are the 'headline' basic design rules for FDM? </p> <p>Which topics for design principles do you recommend to someone who has purchased an FDM machine and wants to understand what is practical? In other words, where is the place to start when you don't yet know what questions to ask?</p> <p><a href="https:/...
<p>Designing a part for 3D printing often doesn't seem to have many special considerations, but I have learned the hard way, that there are some things to do differently. This is just a list of things to that one should keep in mind <em><strong>in addition to basic principles of design</strong></em><sup>1</sup> when de...
<p>In a <a href="https://drive.google.com/file/d/1p62P1ZvTwCKK0TGZL7FKhxg-lZQLMe3Q/view?usp=sharing" rel="nofollow noreferrer">presentation</a>(pdf) that I've used as an introduction to 3D printing, I listed out the following points:</p> <ul> <li>Structures have to be built-up from the build platform, with only about ...
1,012
<p>I've been asked to measure the performance of a fortran program that solves differential equations on a multi-CPU system. My employer insists that I measure FLOP/s (Floating operations per second) and compare the results with benchmarks (<a href="http://www.netlib.org/linpack/" rel="noreferrer">LINPACK</a>) but I am...
<p>It's a pretty decent measure of performance, as long as you understand exactly what it measures.</p> <p>FLOPS is, as the name implies FLoating point OPerations per Second, exactly what constitutes a FLOP might vary by CPU. (Some CPU's can perform addition and multiplication as one operation, others can't, for examp...
<p>Your employer is right.<br/> The only way to measure effectiveness of your Fortran program (or of any other program, btw) is to test it against standard benchmarks, if they exist.</p> <p>And, about FLOPs, it stands for "floating point operations per second" - see the <a href="http://en.wikipedia.org/wiki/FLOPS" re...
42,657
<p>Is there a good method or tool to level the bed of 3D printers? I find myself making small adjustments a lot and it's mostly just trial-and-error. A normal bubble level is of limited help and trying to figure out if the head is the thickness of a sheet of paper from the bed in all corners is beyond the capability of...
<p>There are several ways.</p> <p>1) Simplest is the business card/paper method.</p> <p>This video shows how simple it is: <a href="https://www.youtube.com/watch?v=5bzAE5-QgUY" rel="noreferrer">Leveling the platform</a></p> <p>You should feel the same amount of resistance between the hotend and the bed on all sides....
<p>If you don't have an auto-leveling build plate or a depth gauge attachment for your X-Axis, you're pretty much stuck with the "piece of paper" method. To perform this easier, try shifting the paper as you adjust the bed. As soon as the paper becomes difficult to move (the nozzle is touching now), back off the build ...
183
<p>I have a class storing the name of a WS method to call and the type and value of the only parameter that service receives (it will be a collection of parameters but lets keep it simple for the example):</p> <pre><code>public class MethodCall { public string Method { get; set; } public Type ParType { get; set; }...
<p>The <code>readonly</code> keyword is used to declare a member variable a constant, but allows the value to be calculated at runtime. This differs from a constant declared with the <code>const</code> modifier, which must have its value set at compile time. Using <code>readonly</code> you can set the value of the fi...
<p>There can be a performance benefit in WPF, as it removes the need for expensive DependencyProperties. This can be especially useful with collections</p>
34,948
<p>I want to do this using the <code>Math.Round</code> function</p>
<p>Here's some examples:</p> <pre><code>decimal a = 1.994444M; Math.Round(a, 2); //returns 1.99 decimal b = 1.995555M; Math.Round(b, 2); //returns 2.00 </code></pre> <p>You might also want to look at bankers rounding / round-to-even with the following overload:</p> <pre><code>Math.Round(a, 2, MidpointRounding.ToE...
<pre><code> public double RoundDown(double number, int decimalPlaces) { return Math.Floor(number * Math.Pow(10, decimalPlaces)) / Math.Pow(10, decimalPlaces); } </code></pre>
32,065
<p>Is there a documented max to the length of the string data you can use in the send method of an <code>XMLHttpRequest</code> for the major browser implementations?</p> <p>I am running into an issue with a JavaScript <code>XMLHttpRequest</code> Post failing in FireFox 3 when the data is over approx 3k. I was assuming...
<p>I believe the maximum length depends not only on the browser, but also on the web server. For example, the Apache HTTP server has a <a href="http://httpd.apache.org/docs/2.0/mod/core.html#limitrequestbody" rel="noreferrer">LimitRequestBody directive</a> which allows anywhere from 0 bytes to 2GB worth of data.</p>
<p>The configuration for Nginx must be done at the <a href="http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size" rel="nofollow noreferrer">client_max_body_size</a> and ca be set to any value i.e. 20m for 20MiB or set to 0 to disable it.</p> <pre><code>vim /etc/nginx/nginx.conf </code></pre> <...
15,169
<p>Is a GUID unique 100% of the time?</p> <p>Will it stay unique over multiple threads?</p>
<blockquote> <p>While each generated GUID is not guaranteed to be unique, the total number of unique keys (2<sup>128</sup> or 3.4×10<sup>38</sup>) is so large that the probability of the same number being generated twice is very small. For example, consider the observable universe, which contains about 5×10<sup>22</sup...
<p>Enough GUIDs to assign one to each and every hypothetical grain of sand on every hypothetical planet around each and every star in the visible universe.</p> <p>Enough so that if every computer in the world generates 1000 GUIDs a second for 200 years, there might (MIGHT) be a collision.</p> <p>Given the number of cur...
6,093
<p>I need to do the following for hundreds of files: Append the name of the file (which may contain spaces) to the end of each line in the file.</p> <p>It seems to me there should be some way to do this:</p> <pre><code>sed -e 's/$/FILENAME/' * </code></pre> <p>where <code>FILENAME</code> represents the name of the c...
<p>I'm sure there are other ways to do it, I'd use perl:</p> <pre><code>perl -p -i -e 's/$/$ARGV/;' * </code></pre>
<p>In BASH, I'd do something to the effect of:</p> <pre><code>for f in *; do echo $f &gt;&gt; $f; done </code></pre>
39,884
<p>When I installed Windows Server 2008 I didn't have the (activation) key. Now that I have it I can't find where to enter it. Anybody know?</p>
<p>Go to Control Panel\System and then under Windows Activation click "Change Product Key".</p>
<p>I know in Vista this is done from the system control panel. I would check there in Server 2008.</p>
10,302
<p>Is there a max length for an array in C++?</p> <p>Is it a C++ limit or does it depend on my machine? Is it tweakable? Does it depend on the type the array is made of?</p> <p>Can I break that limit somehow or do I have to search for a better way of storing information? And what should be the simplest way?</p> <p>W...
<p>There are two limits, both not enforced by C++ but rather by the hardware.</p> <p>The first limit (should never be reached) is set by the restrictions of the size type used to describe an index in the array (and the size thereof). It is given by the maximum value the system's <code>std::size_t</code> can take. This...
<p>As has already been pointed out, array size is limited by your hardware and your OS (man ulimit). Your software though, may only be limited by your creativity. For example, can you store your "array" on disk? Do you really need long long ints? Do you really need a dense array? Do you even need an array at all?<...
26,590
<p>I'm still kinda new in ASP.NET and recently I found out about SubSonic, which I started to use. Now it seems funny and such a waste of time (and nerves) when I look back into times when I was developing without SubSonic and jQuery. And there probably are a lot of libraries and frameworks that speeds up development. ...
<p>What I like to use, at the moment:</p> <ul> <li>NHibernate</li> <li>Autofac</li> <li>ASP.NET MVC</li> <li>jQuery</li> </ul>
<p>I only started liking to make websites once I started using the <a href="http://weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framework.aspx" rel="nofollow noreferrer">MVC Framework</a> If you're not already doing this, be sure to check <a href="http://blog.wekeroad.com/blog/" rel="nofollow noreferrer">Rob ...
20,186
<p>I have an sp with the following pseudo code... </p> <pre><code> BEGIN TRANSACTION set @errorLocation='Deleting Permissions' DELETE [tblUsrPermissions] WHERE lngUserID = @lngUserID if @@error&gt;0 begin goto roll_back ...
<p>use raiserror to thorw your error to the client. note that depending on the severity of the erorr your raiserror message might never be hit. so for more complete answer provide the original error you get and where do you get it.</p>
<p>If you are using SqlServer 2005 or greater put your code inside <a href="http://msdn.microsoft.com/en-us/library/ms175976.aspx" rel="nofollow noreferrer">TRY block</a> and then call <a href="http://msdn.microsoft.com/en-us/library/ms178592.aspx" rel="nofollow noreferrer">RAISERROR</a> in the catch block</p>
35,456
<p>Is there an easy way to iterate over an associative array of this structure in PHP:</p> <p>The array <code>$searches</code> has a numbered index, with between 4 and 5 associative parts. So I not only need to iterate over <code>$searches[0]</code> through <code>$searches[n]</code>, but also <code>$searches[0]["part0...
<p>Nest two <a href="http://php.net/foreach" rel="noreferrer"><code>foreach</code> loops</a>:</p> <pre><code>foreach ($array as $i =&gt; $values) { print "$i {\n"; foreach ($values as $key =&gt; $value) { print " $key =&gt; $value\n"; } print "}\n"; } </code></pre>
<p>Can you just loop over all of the "part[n]" items and use isset to see if they actually exist or not?</p>
4,559
<p>I have a page with a <code>document.onkeydown</code> event handler, and I'm loading it inside an iframe in another page. I have to click inside the iframe to get the content page to start "listening". </p> <p>Is there some way I can use JavaScript in the outer page to set the focus to the inner page so I don't have...
<p>I had a similar problem with the jQuery Thickbox (a lightbox-style dialog widget). The way I fixed my problem is as follows:</p> <pre><code>function setFocusThickboxIframe() { var iframe = $("#TB_iframeContent")[0]; iframe.contentWindow.focus(); } $(document).ready(function(){ $("#id_cmd_open").click(fu...
<p>This is something that worked for me, although it smells a bit wrong:</p> <pre><code>var iframe = ... var doc = iframe.contentDocument; var i = doc.createElement('input'); i.style.display = 'none'; doc.body.appendChild(i); i.focus(); doc.body.removeChild(i); </code></pre> <p>hmmm. it also scrolls to the bottom o...
48,190
<p>I am using pseudo-code here, but this is in JavaScript. With the most efficient algorithm possible I am trying to find the high and low given an array of positive whole numbers. This is what I came up with, but I don't think it is probably best, and was just wondering if anyone has any other suggestions.</p> <pre><...
<p>initialise the high and low to be the first element. makes a lot more sense than picking an arbitrarily "high" or "low" number.</p> <pre><code>var myArray = [...], low = myArray[0], high = myArray[0] ; // start looping at index 1 for (var i = 1, l = myArray.length; i &lt; l; ++i) { if (myArray[i] &gt; h...
<p>In python:</p> <pre><code>&gt;&gt;&gt; seq = [1, 2, 3, 4, 5, 6, 7] &gt;&gt;&gt; max(seq) 7 &gt;&gt;&gt; min(seq) 1 </code></pre>
26,709
<p>Background: We have an old (but business-critical) SQL Server database with an MS Access ADP front-end; this was originally upsized to SQL Server from a series of Access databases.</p> <p>This database tracks hazardous materials for our customers, and stores a large number of images. These images are inserted from ...
<p>Take the *.bas file from here <a href="http://www.access-im-unternehmen.de/index1.php?BeitragID=337&amp;id=300" rel="nofollow noreferrer">http:http://stackoverflow.com/Content/img/wmd/ul.png//www.access-im-unternehmen.de/index1.php?BeitragID=337&amp;id=300</a> (unfortunately it is German).</p> <p>It uses the GDI+ l...
<p>I think the reason your database becomes so bloated, is that the JPGs are also stored as bitmaps inside the "OLE object" structure, or so I've seen, depending on the method the JPEG was inserted.</p> <p>This is not optimal, but: for every image in the database, I would programmatically create a dummy .doc containin...
13,966
<p>Just wondering what little scripts/programs people here have written that helps one with his or her everyday life (aka not work related).</p> <p>Anything goes, groundbreaking or not. For me right now, it's a small python script to calculate running pace given distance and time elapsed.</p>
<p>My <code>o</code> key fell off on my laptop; so I wrote a program that replaces two <code>0</code> keystrokes within 200 MS of each other as an <code>o</code>, two <code>0</code> keystrokes within 700 MS of each other as a <code>0</code> and ignore the rest; so I could use my laptop before I get around to replacing ...
<p><br> For those of us who don't remember where we are on unix, or which SID we are using. <br> Pop this in your .profile.</p> <pre><code>&lt;br&gt;function CD &lt;br&gt;{ &lt;br&gt; unalias cd &lt;br&gt; command cd "$@" &amp;&amp; PS1="\${ORACLE_SID}:$(hostname):$PWD&gt; " &lt;br&gt; alias cd=CD &lt;br&gt;} &l...
22,805
<p>I have a table <code>y</code> Which has two columns <code>a</code> and <code>b</code></p> <p>Entries are:</p> <pre><code>a b 1 2 1 3 1 4 0 5 0 2 0 4 </code></pre> <p>I want to get 2,3,4 if I search column <code>a</code> for 1, and 5,2,4 if I search column <code>a</code>.</p> <p>So, if I searc...
<p>I think I have it:</p> <pre><code>SELECT b FROM y where a=if(@value IN (select a from y group by a),@value,0); </code></pre> <p>It checks if @value exists in the table, if not, then it uses 0 as a default. @value can be a php value too.</p> <p>Hope it helps :)</p>
<p>You can do all this in a single stored procedure with a single parameter.</p> <p>I have to run out, but I'll try to write one up for you and add it here as soon as I get back from my errand.</p>
13,364
<p>I have several static factory patterns in my PHP library. However, memory footprint is getting out of hand and we want to reduce the number of files required during execution time. Here is an example of where we are today:</p> <pre><code>require_once('Car.php'); require_once('Truck.php'); abstract class Auto { ...
<p>The Autoload facility is often seen as Evil, but it works at these task quite nicely. </p> <p>If you can get a good filesystem &lt;-> classname mapping so you can, when given a class to provide, find it, then it will save you overhead and only load classes when needed. </p> <p>It works for static classes too, so o...
<p>The point of the require_once function is that no matter the scope, you won't include a file twice and redefine a class causing a PHP error. So no worries about memory leaks, if the require_once is hit, the class def goes in the global symbol table only one time.</p> <p>But aside from that, yeah use autoloader.</p>...
33,448
<p>If it said "oneword", then I could write "#oneword", but what do I write when there is a space in the word?</p>
<p>If it contains spaces, it is not legal HTML. You shouldn't expect this to work. Here is the relevant section of the <a href="http://www.w3.org/TR/html401/types.html#type-name" rel="noreferrer">HTML 4.01</a> specification.</p> <p>[EDIT] As others have noted, you can get around this by assigning one or more class na...
<p>If you make websites with IDEs like Artisteer, you can see a working <code>id="two words"</code> which becomes a class</p> <pre><code>.two{ } .words{ } </code></pre> <p>I don't know if this is a good practice, but it works.</p>
31,084
<p>What is the best way to get the names of all of the tables in a specific database on SQL Server?</p>
<p>SQL Server 2000, 2005, 2008, 2012, 2014, 2016, 2017 or 2019:</p> <pre><code>SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' </code></pre> <p>To show only tables from a particular database</p> <pre><code>SELECT TABLE_NAME FROM [&lt;DATABASE_NAME&gt;].INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE ...
<p>To remove tables added by replication and any other table Microsoft adds run this:</p> <pre><code>SELECT s.NAME SchemaName, t.NAME TableName FROM [dbname].SYS.tables t INNER JOIN [dbname].SYS.SCHEMAS s ON t.SCHEMA_ID = s.SCHEMA_ID WHERE t.is_ms_shipped=0 and type_desc = 'USER_TABLE' ORDER BY s.NAME, t.NAME </code></...
21,146
<p>Say I need some very special multiplication operator. It may be implemented in following macro:</p> <pre><code>macro @&lt;&lt;!(op1, op2) { &lt;[ ( $op1 * $op2 ) ]&gt; } </code></pre> <p>And I can use it like</p> <pre><code>def val = 2 &lt;&lt;! 3 </code></pre> <p>And its work.</p> <p>But what I really want...
<p>Straight from the compiler source code:</p> <pre><code>namespace Nemerle.English { [assembly: Nemerle.Internal.OperatorAttribute ("Nemerle.English", "and", false, 160, 161)] [assembly: Nemerle.Internal.OperatorAttribute ("Nemerle.English", "or", false, 150, 151)] [assembly: Nemerle.Internal.OperatorAttribute ...
<p>As usually, I found answer sooner than comunity respond :) So, solution is to simply use special assemply level attribute which specifies the macro as binary operator:</p> <pre><code>namespace TestMacroLib { [assembly: Nemerle.Internal.OperatorAttribute ("TestMacroLib", "multiply", false, 160, 161)] public macr...
27,608
<p>This is an extension of a question I had yesterday.</p> <p>I am trying to make a little php calculator that will show how much people can save on their phone bills if they switch to VoIP, and how much they can save with each service.</p> <p>I have a form that will spit out the right amount for a monthly bill here:...
<p>At least for GNU make, try the implicit variable <code><a href="http://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html#index-CFLAGS-885" rel="noreferrer">CFLAGS</a></code>, as in:</p> <pre><code>CFLAGS=-I/directory/to/add </code></pre>
<p>At least for GNU make, try the implicit variable <code><a href="http://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html#index-CFLAGS-885" rel="noreferrer">CFLAGS</a></code>, as in:</p> <pre><code>CFLAGS=-I/directory/to/add </code></pre>
44,375
<p>I have Flex Builder 3 installed on two Windows machines and the same project on both of them. On one computer, the CSS styles I defined are shown in design view; on the other computer they are not applied. Is there any reason why it might not work on one?</p>
<p>It would be much 'better' to just do (cons x y). </p> <p>But to <strong>answer the question</strong>, there is nothing wrong with doing that :) (except making it a tad slower).</p>
<p>Why not just</p> <pre><code>(cons x y) </code></pre> <p>By the way, I tried to run your code in CLISP and it didn't work as expected. Since I'm not a big fan of the loop macro here's how you might accomplish the same thing recursively:</p> <pre><code>(defun genint (stop) (if (= stop 1) '(1) (append (genin...
12,698
<p>I am involved in writing a little internal SharePoint portal for our company. I thought it would be a 'quick win' to get create a web part that would display the user's unread mail count, and possibly a list of today's calendar tasks. However, I have had a hunt around for information to do with OWA web services stuf...
<p>A few months ago I have done this using CDO Library with C# .NET Windows Service.Example code was like this</p> <pre><code> MAPI.Folder inboxFolder = Inbox; MAPI.Messages messages = (Messages) inboxFolder.Messages; MAPI.MessageFilter filter = (MessageFilter) messages.Filter; ...
<p>A few months ago I have done this using CDO Library with C# .NET Windows Service.Example code was like this</p> <pre><code> MAPI.Folder inboxFolder = Inbox; MAPI.Messages messages = (Messages) inboxFolder.Messages; MAPI.MessageFilter filter = (MessageFilter) messages.Filter; ...
48,946
<p>Working with python interactively, it's sometimes necessary to display a result which is some arbitrarily complex data structure (like lists with embedded lists, etc.) The default way to display them is just one massive linear dump which just wraps over and over and you have to parse carefully to read it.</p> <p>Is...
<pre><code>from pprint import pprint a = [0, 1, ['a', 'b', 'c'], 2, 3, 4] pprint(a) </code></pre> <p>Note that for a short list like my example, pprint will in fact print it all on one line. However, for more complex structures it does a pretty good job of pretty printing data.</p>
<p>Another good option is to use <a href="http://ipython.scipy.org/moin/" rel="nofollow noreferrer">IPython</a>, which is an interactive environment with a lot of extra features, including automatic pretty printing, tab-completion of methods, easy shell access, and a lot more. It's also very easy to install. </p> <p...
11,725
<p>Is there any setting in Visual Studio 2008 to group/organize tabs? For example, I'd prefer to have all code-behind files open in a tab next to its .aspx page if that page is open and vice versa. Dragging tabs around really kills my productivity.</p>
<p>Jonathan,</p> <p><a href="http://www.tabsstudio.com" rel="nofollow noreferrer">Tabs Studio</a> (developed by me) add-in can automatically group .aspx and .aspx.cs windows in one tab.</p>
<p>There is no setting for this, but take a look at the documentation for writing visual studio add-ins. This would be a pretty simple one to set up.</p>
15,836
<p>I've got a VB.NET module that reads from a resource file to display text in the correct language. Here's my problem - this code is shared between a web application and a non-web application, In the web application, I'm using System.Web.HttpContext to determine the user's preferred language, but now my Windows app wo...
<p>If you reference the System.Web assembly, you should then be given access to HttpContext.Current, which is a reference to the currently running web app's HttpContext object. If the application is a normal Win32 app, this reference should be a null pointer. Thus in C# you would use: <code> if (HttpContext.Current ...
<p>You can add System.Web.dll to your application and then use HttpContext. The problem is that there isn´t a HttpContext in you win application, so you should use a web service or WCF to communicate between the two applications.</p>
36,403
<p>I have a row of buttons, which all create a pdf file which I want to open in a new tab. This way the button page stays on top, and the pdf's open to get printed. To prevent clicking a button twice I disable the button, like this (I use python):</p> <pre><code>&lt;input type='submit' value='Factureren' name='submitb...
<p>It is easy: a disabled submit button do not submit a form in IE. Consider to restructure your code:</p> <ul> <li>Use a regular button, disable it, and call form.submit() from its handler.</li> <li>Do not disable the button in its "onclick", but save it, and do it in form's onsubmit.</li> </ul>
<p>Maybe try to attach the handler to the onsubmit event of the form instead of the click of the button? That would also then work if the user pressed ENTER instead of clicking your button.</p>
42,356
<p>In the application there is a dialog where only numeric string entries are valid. Therefore I would like to set the numeric keyboard layout.</p> <p>Does anyone know how to simulate key press on the keyboard or any other method to change the keyboard layout?</p> <p>Thanks!</p>
<p>You don't need to.</p> <p>Just like full windows, you can set the edit control to be numeric input only. You can either do it <a href="http://msdn.microsoft.com/en-us/library/bb761655(VS.85).aspx" rel="nofollow noreferrer">manually</a> or in the dialog editor in the properites for the edit control.</p> <p>The SIP...
<p>You can use the InputModeEditor:</p> <pre><code>InputModeEditor.SetInputMode(textBox1,InputMode.Numeric); </code></pre>
36,432
<p>Does anybody have an overview of what things should be calibrated (and in what order) for a certain 3d printer or after changing the printing material?</p> <p>I only know about:</p> <ul> <li>calibrating the extruder steps per mm, e.g. <a href="https://www.youtube.com/watch?v=YUPfBJz3I6Y" rel="nofollow noreferrer">...
<p>How to Calibrate. Oh man that is a good 2-3 page long blog post.. So I will try to give you the bullet point section. </p> <p>High level</p> <ul> <li>Mechanical </li> <li>Firmware </li> <li>Software</li> <li>repeat</li> </ul> <p>Mechanical Level everything. Bed. The X axis. Make sure there is no binding, etc. Als...
<p>Recalibrating your machine for the new filament diameter is a good idea. Filament diameters vary slightly between manufacturers. </p>
478
<p><a href="http://en.wikipedia.org/wiki/Total_functional_programming" rel="noreferrer">Wikipedia</a> has this to say:</p> <blockquote> <p>Total functional programming (also known as strong functional programming, to be contrasted with ordinary, or weak functional programming) is a programming paradigm whi...
<p>If I understood that correctly, Total Functional Programming means just that: Programming with Total Functions. If I remember my math courses correctly, a Total Function is a function which is defined over its entire domain, a Partial Function is one which has "holes" in its definition.</p> <p>Now, if you have a fu...
<p>Charity is another language that guarantees termination:<br> <a href="http://pll.cpsc.ucalgary.ca/charity1/www/home.html" rel="noreferrer">http://pll.cpsc.ucalgary.ca/charity1/www/home.html</a> </p> <p>Hume is a language with 4 levels. The outer level is Turing complete and the innermost layer guarantees terminati...
17,514
<p>I'm constructing a simple form in ERB but the HTML produced by the text_field tag makes the <em>for</em> attribute in the label tag invalid.</p> <pre><code>&lt;div&gt; &lt;p&gt;&lt;%= label_tag "email[name]", "Name" %&gt;&lt;/p&gt; &lt;%= text_field :email, :name, :class =&gt; "text_field" %&gt; &lt;/div&gt; </...
<p>My favourite is using the -stdio option</p> <p>Either:</p> <pre><code>sas -stdio </code></pre> <p>Then start typing. Or ...</p> <pre><code>echo "proc options; run;" | sas -stdio </code></pre>
<p>Never having used sas, what I might try is something like:</p> <pre><code>echo &lt;insert sas code here&gt; | sas --execute-file - </code></pre> <p>Oftentimes applications will let you specify '-' as a file to have it read from STDIN. And 'echo' just prints its arguments out, and the | connects them together.</p>
33,923
<p>Is there a way to programmatically interface with iTunes to add new playlists or smart views?</p> <p>For example, say I download 10 new mp3 files from a website, is there a way of programmatically adding this list of mp3s to a new playlist called "New Album xx"? A new smart view could be okay too if this is easier...
<p>Apple does offer a COM-based SDK for automating iTunes with Windows. It's not the greatest (for example, I think you have to make sure iTunes.exe is running in a desktop session and several commands can cause dialogs to popup and block your automation), but it does let you do things like create new play lists and ad...
<p>Assuming you are on a Mac... I think you can do this with AppleScript, this <a href="http://dougscripts.com/itunes/scripts/scripts06.php" rel="nofollow noreferrer">link</a> might be useful</p>
27,782
<p>I have two or three i18n files in my struts application. I am able to switch between these by setting the <code>Global.LOCALE_KEY</code> variable in the session.</p> <p>Is there a way to set a default locale for the application (probably in the struts-config.xml file, I guess) ? Is the session the only place to set...
<p>In your web.xml you can define a context-param:</p> <pre><code>&lt;context-param&gt; &lt;param-name&gt;LOCALE&lt;/param-name&gt; &lt;param-value&gt;en-GB&lt;/param-value&gt; &lt;/context-param&gt; </code></pre> <p>Then up front in your webapp:</p> <pre><code>java.util.Enumeration&lt;String&gt; setout = se...
<p>Hm, I finally solved this one by writing Java code instead of using struts-config.xml.</p> <p>I created a context listener to set the value of a static field in the Struts class.</p> <p>See this question: <a href="https://stackoverflow.com/questions/158336/is-there-a-way-to-run-a-methodclass-only-on-tomcat-startup...
44,688
<p>What is the preferred way to insert strings that can contain both single and double quotes (",') into MySql using DBI? For example, <code>$val1</code> and <code>$val2</code> can contain quotes:</p> <pre><code>my $dbh = DBI-&gt;connect( ... ); my $sql = "insert into tbl_name(col_one,col_two) values($val1, $val2)"; ...
<p>Use a bound query using </p> <pre><code>$sth = $dbh-&gt;prepare("insert into tbl_name(col_one,col_two) values(?,?)"); $sth-&gt;execute($val1, $val2); </code></pre> <p>If you use bound variables, everything is escaped for you.</p> <p>Update: Changed my example to correspond with the example edited into the questio...
<p>Use the <code>quote()</code> method. It will intelligently handle the quoting for you. Example from the <a href="http://search.cpan.org/~timb/DBI/DBI.pm#quote" rel="nofollow noreferrer">docs</a>:</p> <pre><code>$sql = sprintf "SELECT foo FROM bar WHERE baz = %s", $dbh-&gt;quote("Don't"); </code></pre> ...
36,127
<p>Math skills are becoming more and more essential, and I wonder where is a good place to brush up on some basics before moving on to some more CompSci specific stuff?</p> <p>A site with lots of video's as well as practice exercises would be a double win but I can't seem to find one.</p>
<p>It depends on your math level. You should start by revising what you should know till that moment and then go further to algorithm mathmatics, geometry (transforms and etc), statistics and more.</p> <p>There are tons of places on the internet were you can learn:</p> <p><a href="http://www.math.cornell.edu/Courses/...
<p>A lot of the universities will actually publish their lecture materials online. So all you really need to do is find a suitable subject and then read the lecture materials and do the associated work. If you were really sneaky you could probably also go to the tutorials to get help :P</p>
14,544
<p>How do you programmatically obtain a picture of a .Net control?</p>
<p>There's a method on every control called <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.drawtobitmap.aspx" rel="noreferrer">DrawToBitmap</a>. You don't need to p/invoke to do this.</p> <pre><code>Control c = new TextBox(); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(c.Width...
<p>if it's not on the control you're trying to do, you can usually cast it to the base Control class and call the DrawToBitmap method there.</p>
33,367
<p>Just want to know what is better way to get start developing faccebook app?Any tutorial recommnedation?And which is better to start up -php or rails?</p>
<p>From my experience, there is a much better support focus on PHP than on anything else. That said, there'd be no point learning PHP just to take advantage of the superior support.</p> <p>Two other general points:</p> <ol> <li>The official support community is really awful. The community has no expert voices and the...
<p>Use the <a href="http://developers.facebook.com/get_started.php?tab=tutorial" rel="nofollow noreferrer">Get Started tutorial</a> on <a href="http://developers.facebook.com" rel="nofollow noreferrer">developers.facebook.com</a>. This will suggest you use the sample code button which will give you some PHP to list yo...
10,758
<p>I just came across this idiom in some open-source Python, and I choked on my drink.</p> <p>Rather than:</p> <pre><code>if isUp: return "Up" else: return "Down" </code></pre> <p>or even:</p> <pre><code>return "Up" if isUp else "Down" </code></pre> <p>the code read:</p> <pre><code>return isUp and "Up" or...
<p>The "a and b or c" idiom was the canonical way to express the ternary arithmetic if in Python, before <a href="http://www.python.org/dev/peps/pep-0308/" rel="nofollow noreferrer">PEP 308</a> was written and implemented. This idiom fails the "b" answer is false itself; to support the general case, you could write</p>...
<p>No, it is not.</p> <p>I had a somehow <a href="https://stackoverflow.com/questions/331767">similar question</a> the other day. </p> <p>if the construct </p> <pre><code>val if cond else alt </code></pre> <p>Was not very welcome ( at least by the SO community ) and the preferred one was:</p> <pre><code>if cond: ...
44,982
<p>I am reviewing a big java application to see if there are any performance bottlenecks. The real problem is that I cannot pinpoint the performance issues to any single module. The whole application is slow as such.</p> <p>Is there some tool/technique I can use to help me out in this?</p>
<p>Try using a profiler on your running code. It should help you identify the bottlenecks. Try <a href="http://www.ej-technologies.com/products/jprofiler/overview.html" rel="noreferrer">jprofiler</a> or <a href="http://www.netbeans.org/features/java/profiler.html" rel="noreferrer">Netbeans profiler</a></p>
<p>For testing/development purposes, you can download Oracle JRockit Mission Control for free from <a href="http://www.oracle.com/technology/software/products/jrockit/index.html" rel="nofollow noreferrer">this</a> site. (Requires Login, but accounts can be set up with any email adress)</p> <p>Docs <a href="http://www....
5,876
<p>Can anyone tell me how to display all the selected value of my multi value parameter in SSRS report. When giving <code>parameter.value</code> option it gives error.</p>
<p>You can use the "Join" function to create a single string out of the array of labels, like this:</p> <pre><code>=Join(Parameters!Product.Label, ",") </code></pre>
<p>Hopefully someone else finds this useful:</p> <p>Using the Join is the best way to use a multi-value parameter. But what if you want to have an efficient 'Select All'? If there are 100s+ then the query will be very inefficient.</p> <p>To solve this instead of using a SQL Query as is, change it to using an expressi...
38,496
<p>I'm trying to find a way to &quot;pretty print&quot; a JavaScript data structure in a human-readable form for debugging.</p> <p>I have a rather big and complicated data structure being stored in JS and I need to write some code to manipulate it. In order to work out what I'm doing and where I'm going wrong, what I r...
<p>Use <a href="https://github.com/douglascrockford/JSON-js/blob/master/json2.js" rel="noreferrer"><strong>Crockford's JSON.stringify</strong></a> like this:</p> <pre><code>var myArray = ['e', {pluribus: 'unum'}]; var text = JSON.stringify(myArray, null, '\t'); //you can specify a number instead of '\t' and that many ...
<p><a href="http://wrongnotes.blogspot.com/2007/09/flexjson-15-is-live.html" rel="nofollow noreferrer">flexjson</a> includes a prettyPrint() function that might give you what you want.</p>
15,834
<p>How should widgets in GWT inform other widgets to refresh themselfs or perform some other action. </p> <p>Should I use sinkEvent / onBrowserEvent? And if so is there a way to create custom Events?</p>
<p>I have solved this problem using the <a href="http://en.wikipedia.org/wiki/Observer_pattern" rel="nofollow noreferrer">Observer Pattern</a> and a central <a href="http://en.wikipedia.org/wiki/Model-view-controller" rel="nofollow noreferrer">Controller</a>. The central controller is the only class that has knowledge ...
<p>So here is my (sample) implementation, first let's create a new event:</p> <pre><code>import java.util.EventObject; import com.google.gwt.user.client.ui.Widget; public class NotificationEvent extends EventObject { public NotificationEvent(String data) { super(data); } } </code></pre> <p>Then we cr...
10,881
<p>We use Eclipse for our Java development, and we've got Maven compiling our JSPs into servlets to be used in our embedded Jetty instance. This means that to run the project from Eclipse, I have to include ./target/jsp-source as a source folder, which works great. The warnings that show up for that generated code are ...
<p>Just use a Working Set. Details about how to do it here: <a href="https://stackoverflow.com/questions/783902/excluding-disabling-validation-in-eclipse">Excluding Unfixables from Eclipse Problem View</a></p> <p>And here: <a href="http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.platform.doc.user/concepts/...
<p>A working set works well with multiple projects. I suggest you try using one.</p>
28,495
<p>I am working on a web application (J2EE) and I would like to know the options that are available for handling a double post from the browser.</p> <p>The solutions that I have seen and used in the past are all client-side:</p> <ul> <li>Disable the submit button as soon as the user clicks it.</li> <li>Follow a POST-...
<p>Its hard to implement an idiot-proof solution (as they are alway improving the idiots). <strong><em>No matter what you do, the client side can be manipulated or perform incorrectly.</em></strong></p> <p><strong>Your solution has got to be server side to be reliable and secure.</strong> That said, one approach is ...
<p>I'd use a timestamp and compare values with your server side code. If two timestamps are close enough and have the same IP address, ignore the second form submission. </p>
15,829
<p>Is it a problem if you use the global keyword on variables you don't end up using? Compare:</p> <pre><code>function foo() { global $fu; global $bah; if (something()) { $fu-&gt;doSomething(); } else { $bah-&gt;doSomething(); } } function bar() { if (something()) { glo...
<p>If there is, it won't be (humanly) measurable, unless you are literally calling this function millions of times. And even if it was a recursive function with that property, I still wouldn't use your second method for the maintainability aspects you already brought up.</p> <p><strong>Edit:</strong> For arguments sak...
<p>Global variables are generally considered very bad style. I would claim that whenever you need to use the global keyword, or a static class property (And thus, including the infamous Singleton), you should seriously reconsider what you're doing. It may be slightly more work to avoid globals, but it's a huge bonus to...
21,880
<p>When I look at a directory in Windows Explorer, I can see a ProductName and ProductVersion property for the DLL's in that directory.</p> <p>I need to export this DLL list with ProductName and ProductVersion into a text file.</p> <p>If I do <code>c:\&gt;dir *.dll &gt; test.log</code>, the test.log does not have the...
<p>Using VBScript you could do the following:</p> <pre><code>Set objShell = CreateObject ("Shell.Application") Set objFolder = objShell.Namespace ("C:\Scripts") Set objFSO = CreateObject("Scripting.FileSystemObject") Dim arrHeaders(40) For i = 0 to 40 arrHeaders(i) = objFolder.GetDetailsOf (objFolder.Items, i) Ne...
<p>I cannot speak to this software at all, but this appears to do what you're looking for:</p> <p><a href="http://www.softpedia.com/get/Programming/Other-Programming-Files/STRFINFO.shtml" rel="nofollow noreferrer">http://www.softpedia.com/get/Programming/Other-Programming-Files/STRFINFO.shtml</a></p> <pre><code>SYNTA...
43,011
<p>Given some JS code like that one here:</p> <pre><code> for (var i = 0; i &lt; document.getElementsByName('scale_select').length; i++) { document.getElementsByName('scale_select')[i].onclick = vSetScale; } </code></pre> <p>Would the code be faster if we put the result of getElementsByName into a variable bef...
<p>Definitely. The memory required to store that would only be a pointer to a DOM object and that's <strong><em>significantly</em></strong> less painful than doing a DOM search each time you need to use something!</p> <p>Idealish code:</p> <pre><code>var scale_select = document.getElementsByName('scale_select'); for ...
<p>I think so. Everytime it loops, the engine needs to re-evaluate the document.getElementsByName statement. </p> <p>On the other hand, if the the value is saved in a variable, than it allready has the value.</p>
14,018
<p>I'm writing a simple CMS.</p> <p>I want to be able to load a View, having it included inside a master page, and then scan the HTML so that I can replace some custom tags (like {{blog}} with my own blog output) and then serve it up to the browser.</p> <p>How can I get access to the HTML from the ViewResult in order...
<p>Sounds like you want to write an <code>ActionFilterAttribute</code>. This attribute has the following methods:</p> <ul> <li><strong>OnActionExecuting</strong> - called just before the decorated action is executed</li> <li><strong>OnActionExecuted</strong> - called after the action method is called, but before the ...
<p>That's going to be tricky because the ViewResult writes its response directly to the Response.Stream. So you'll probably have to deal with the Response.Filter property to output the ViewResult to a MemoryStream so you can manipulate the content before returning a ContentResult. All this would happen in OnResultExecu...
24,831
<p>I am using ruby on rails with a MySQL backend. I have a table called notes and here is the migration I use to create it:</p> <pre><code>def self.up create_table(:notes, :options =&gt; 'ENGINE=MyISAM') do |t| t.string :title t.text :body t.timestamps end execute "alter table notes ADD FULLTEXT(t...
<p>I'm just guessing here, but the documentation states: </p> <blockquote> <p>A natural language search interprets the search string as a phrase in natural human language (a phrase in free text). There are no special operators. The stopword list applies. In addition, words that are present in 50% or more...
<p>While this probably does not answer your specific question, I would just go ahead and use <a href="http://rm.jkraemer.net/projects/show/aaf" rel="nofollow noreferrer">Ferret</a> or <a href="http://acts-as-solr.rubyforge.org/" rel="nofollow noreferrer">Solr</a> as the search engine, especially if lots of text is invo...
48,530
<p>I have some C++ source code with templates maybe like this - doxygen runs without errors but none of the documentation is added to the output, what is going on?</p> <pre><code>/// /// A class /// class A { /// /// A typedef /// typedef B&lt;C&lt;D&gt;&gt; SomeTypedefOfTemplates; }; </code></pre>
<p>Yeah, so what is going on is the template instantiation is bogus. The ">>" like that is ambiguous and is meant to be a compile time error. You couldn't see it because maybe your compiler (VC++) let it slip by but I guess doxygen was stricter on that. Add a space like shown.</p> <pre><code>/// /// A class /// class ...
<p>Yeah, so what is going on is the template instantiation is bogus. The ">>" like that is ambiguous and is meant to be a compile time error. You couldn't see it because maybe your compiler (VC++) let it slip by but I guess doxygen was stricter on that. Add a space like shown.</p> <pre><code>/// /// A class /// class ...
25,781
<p>I want to build an application that will allow my customers to send marketing information by e-mail. This will be a carefully monitored tool used for legitimate bulk mailing only. It's going to have all of the necessary 'unsubscribe' functionality etc.</p> <p>The solution will be built using VB.NET.</p> <p>My ques...
<p>First off get a component to do the heavy lifting. I would recommend: <a href="http://www.aspnetemail.com" rel="nofollow noreferrer">aspnetmail</a></p> <p>Then setting up bulkmailing is as easy as downloading some example code. <br> <a href="http://www.aspnetemail.com/samples/webmailer.aspx" rel="nofollow noreferr...
<p>The question is not precise enough but I will attempt to answer it anyway. There are a few factors limiting you're options. The best "way" is really up to your circumstances. What deadline are you working against? </p> <p>Implementing a large, low-level, multi-threaded mail-sending system will take a lot of time ...
39,471
<p>It's very easy to mark an image file to become an embedded resource however how does one access the image thereafter. Please can I have some example code?</p>
<p>The most direct method:</p> <pre><code>YourProjectsBaseNamespace.Properties.Resources.YourImageResourceName </code></pre>
<pre><code>//Get the names of the embedded resource files; List&lt;string&gt; resources = new List&lt;string&gt;(AssemblyBuilder.GetExecutingAssembly().GetManifestResourceNames()); //Get the stream StreamReader sr = new StreamReader( AssemblyBuilder.GetExecutingAssembly().GetManifestResourceStream( ...
18,641
<p>My first question on StackOverflow...</p> <p>Does anybody know a way of viewing the reference/documentation manual of a language through CodeBlocks? Specifically for C/C++.</p> <p>Example:<br> Say I want to look up the reference for strncpy(). In a very old Borland system (which we use at school) I would write the...
<p>Yes, it is possible. I'm not sure about the help files themselves though.</p> <p>The procedure seems to be documented <a href="http://wiki.codeblocks.org/index.php?title=Using_devhelp_as_a_help_viewer" rel="noreferrer">here.</a></p> <p>from the forums.</p> <p>Re: F1 - help and function reference « Reply #1 on: S...
<p>(BTW, do you mean <a href="http://en.wikipedia.org/wiki/Codeblocks" rel="nofollow noreferrer">Code::Blocks</a>)</p> <p>Having never used that, I can say anything definite, but have you tried selecting the term and pressing F1?</p>
44,362
<p>I've had been hearing about test driven development for a couple years now, and I never really paid too much attention to it from a practical level until recently when I started getting more interested in the .NET MVC. I've been playing around a lot with the <a href="http://www.codeplex.com/mvcsamples/SourceControl/...
<p>You can still test last. It's okay. We'll forgive you.</p> <p>Learn how the unit test tools work in your current language.</p> <p>Start writing unit tests for whatever you're working on now.</p> <p>Eventually, you can move to code-a-little-test-a-little. Then test-a-little-code-a-little.</p> <p>Pure test <em>...
<p>In addition to what S.Lott says, look at how MVC Storefront is structured.</p> <p>How do they handle testing with data that comes from a database? How do they handle testing that the Controller operates correctly? How do they handle when a class has other dependencies?</p> <p>Looking at how TDD requires you to str...
41,133
<p>What are the implications of including a set of visual components released under a <a href="http://www.mozilla.org/MPL/MPL-1.1.html" rel="nofollow noreferrer">Mozilla Public License</a> in a commercial application.</p> <p>Do I have any obligations?</p>
<p>I've found pretty good analysis on MPL (and others) by Frank Hecker here:</p> <p><a href="http://hecker.org/writings/setting-up-shop" rel="nofollow noreferrer">http://hecker.org/writings/setting-up-shop</a> (search for "Mozilla Public License")</p> <p>This pretty much sums it up:</p> <blockquote> <p>For MozPL-e...
<p>The only problem is if you modify the components you must release them under Mozilla Public License as well</p>
21,961
<p>has anybody managed to get Djangos <a href="http://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/" rel="nofollow noreferrer">site map framework</a> to run on Google App Engine?</p> <p>I receive the following exception:</p> <p>ImproperlyConfigured at /sitemap.xml</p> <p>You haven't set the DATABASE_ENGINE set...
<p>I'm not familiar with GAE, but I may have a solution to your problem. Check out the Sitemap Framework docs @ <a href="http://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/" rel="nofollow noreferrer">http://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/</a></p> <p>Look at both the <em>Simple Example</em> a...
<p>Does not work on GAE. Star the issue here.</p> <p><a href="http://code.google.com/p/google-app-engine-django/issues/detail?id=102&amp;q=sitemaps" rel="nofollow noreferrer">http://code.google.com/p/google-app-engine-django/issues/detail?id=102&amp;q=sitemaps</a></p>
25,618
<p>I use RegexBuddy while working with regular expressions. From its library I copied the regular expression to match URLs. I tested successfully within RegexBuddy. However, when I copied it as Java <code>String</code> flavor and pasted it into Java code, it does not work. The following class prints <code>false</code>:...
<p>Try the following regex string instead. Your test was probably done in a case-sensitive manner. I have added the lowercase alphas as well as a proper string beginning placeholder.</p> <pre><code>String regex = "^(https?|ftp|file)://[-a-zA-Z0-9+&amp;@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&amp;@#/%=~_|]"; </code></pre> <p>This...
<p>When using regular expressions from RegexBuddy's library, make sure to use the same matching modes in your own code as the regex from the library. If you generate a source code snippet on the Use tab, RegexBuddy will automatically set the correct matching options in the source code snippet. If you copy/paste the r...
19,743
<p>I have a btnSave_Click() function in my code-behind. If a user clicks the save button (image) I created, it calls this function:</p> <pre><code>protected void btnSave_Click(object sender, EventArgs e) { this.saveForm(); txtMessages.Text = "Save Complete"; } </code></pre> <p>The saveForm() function obviously saves ...
<p>This is a synchronous method. It's going to wait until the saveForm() method has returned (exited) it's completion before it can move on.</p>
<p>It will only show "Save Complete" once the previous operation is complete.</p> <p>I typically put these types of messages in a statusbar. But it really depends on your application and UI.</p>
21,094
<p>Recently I had to move one of my web applications to a new hosting provider. The mail and web service is still held on the old hosting site however, when I try to send an email from the new server,I get an error; </p> <p>"The server rejected one or more recipient addresses. The server response was:</p> <pre><code>...
<p>i'm not sure how C# would handle the specifics (sockets?), but basically you just want to make a connection to your new POP server. here's a sample POP transaction:</p> <pre><code>$ telnet new-pop-server.com 110 Connected to new-pop-server.com. Escape character is '^]'. +OK USER &lt;username&gt; +OK PASS &lt;passw...
<p>They greylist you because you connect from your new provider, right? Doesn't the new provider have a SMTP which allows connections from the servers IP-range?</p> <p>Another approach is to do the MX-lookup yourself, and connect directly to the authoritive SMTP-server for which address you're sending email to. Howeve...
35,756
<p>In designing any desktop applications, are there any general rules on how much memory should the application uses?</p> <p>For heavy-weight applications, those can be easily understood or at least profiled such as Firefox or Google Chrome. But for smaller utilities or line-of-business application, how much is an acc...
<p>There is no absolute answer for this. It depends on too many variables.</p> <p>Here are some trade-offs for consideration:</p> <ul> <li>What device/platform are you developing for?</li> <li>Do you expect your user to use this software as the main purpose for their computer (example maybe you are developing some k...
<p>This depends on your target PC hardware. If your application uses too much memory then it will be slow while windows pages. TEST! Try both options in your compromise, and some in between if it makes sense. Run the tests on a typical machine that your users would use and with a sensible number of other applicatio...
37,380
<p>I have a WPF app with many list based controls in a window, which all are bound to different CollectionViews.</p> <p>At the window level is there a way to get the current selected item for the currently in focus list based control? I know I can do this with some fairly trivial code by looking for the in focus elem...
<p>I don't think that there is a property like you specify, but as an alternative you could register a ClassHandler for the ListBox.SelectionChanged event in your Window class:</p> <pre><code>EventManager.RegisterClassHandler(typeof(ListBox), ListBox.SelectionChanged, new SelectionChangedEventHandler(this.OnListBo...
<p>I haven't tried this, but you could try using a MultiBinding with a converter to get to the correct item:</p> <pre><code>&lt;MultiBinding Converter="{StaticResource coalesce}"&gt; &lt;MultiBinding.Bindings&gt; &lt;MultiBinding Converter="{StaticResource nullIfFalse}"&gt; &lt;MultiBinding.Bin...
11,918
<p>I am trying to apply styles to HTML tags dynamically by reading in the value of certain HTML attributes and applying a class name based on their values. For instance, if I have:</p> <pre><code>&lt;p height="30"&gt; </code></pre> <p>I want to apply a <code>class="h30"</code> to that paragraph so that I can style it...
<p>I would highly recommend using something like jquery where adding classes is trivial:</p> <pre><code>$("#someId").addClass("newClass"); </code></pre> <p>so in your case:</p> <pre><code>$("p[height='30']").addClass("h30"); </code></pre> <p>so this selects all paragraph tags where the height attribute is 30 and ad...
<p>Attributes are just properties (usually). So just try:</p> <pre><code>for (e in ...) { if (e.height == 30) { e.className = "h30"; } } </code></pre> <p>Or use something like jquery to simplify this kind of stuff.</p>
7,693
<p>I have a ListBox that has a style defined for ListBoxItems. Inside this style, I have some labels and a button. One that button, I want to define a click event that can be handled on my page (or any page that uses that style). How do I create an event handler on my WPF page to handle the event from my ListBoxItem...
<p>Take a look at <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.routedcommand.aspx" rel="noreferrer">RoutedCommand</a>s.</p> <p>Define your command in myclass somewhere as follows:</p> <pre><code> public static readonly RoutedCommand Login = new RoutedCommand(); </code></pre> <p>Now define...
<p>You could create a user control (.ascx) to house the listbox. Then add a public event for the page.</p> <pre><code>Public Event btnRemove() </code></pre> <p>Then on the button click event in the usercontrol</p> <pre><code>RaiseEvent btnRemove() </code></pre> <p>You can also pass objects through the event just li...
4,774
<p>I got into a mini-argument with my boss recently regarding "project failure." After three years, our project to migrate a codebase to a new platform (a project I was on for 1.5 years, but my team lead was on for only a few months) went live. He, along with senior management of both my company and the client (I'm one...
<p>I think, most of the time, we developers forget this we all do is, after all, about bussiness.</p> <p>From that point of view a project is not a failure while the client is willing to pay for it. It all depends on the client, some clients have more patience and understand better the risks of software development, o...
<p>I suppose how successful the project is depends on who the client is. If the client were the company directors and they are happy, then the project was successful regardless of the failures along the way.</p>
5,791
<p>I'm trying to create a use-once HTTP server to handle a single callback and need help with finding a free TCP port in Ruby.</p> <p>This is the skeleton of what I'm doing:</p> <pre><code>require 'socket' t = STDIN.read port = 8081 while s = TCPServer.new('127.0.0.1', port).accept puts s.gets s.print "HTTP/1.1 2...
<p>Pass 0 in for the port number. This will cause the system to pick a port for you out of the ephemeral port range. Once you create the server, you can ask it for its addr, which will contain the port that the server is bound to.</p> <pre><code>server = TCPServer.new('127.0.0.1', 0) port = server.addr[1] </code></p...
<p>I guess you could try all ports > 5000 (for example) in sequence. But how will you communicate to the client program what port you are listening to? It seems simpler to decide on a port, and then make it easily configurable, if you need to move your script between different enviroments.</p> <p>For HTTP, the standar...
24,461
<p>Between <a href="http://developer.yahoo.com/yui/compressor/" rel="nofollow noreferrer">Yahoo! UI Compressor</a>, <a href="http://dean.edwards.name/packer/" rel="nofollow noreferrer">Dean Edwards Packer</a> and <a href="http://www.crockford.com/javascript/jsmin.html" rel="nofollow noreferrer">jsmin</a>, which produce...
<p>A great way to compare the best compressors is <a href="http://compressorrater.thruhere.net/" rel="nofollow noreferrer">The JavaScript CompressorRater</a> by Arthur Blake.</p> <p>What you're usually interested in is the size after compressing with GZIP (you should configure your web server to perform the compressio...
<p>As a Mootools user, I notice that Mootools has replaced Dean Edwards' Packer by YUI Compressor. I also remember there was a discussion on Ajaxian.com where Julien (Compressor author) pointed out the areas where YUI Compressor did better. I used Compressor and have never seen any problem, but I have never studied t...
47,086
<p>Is it good practice to have a class constructor that uses default parameters, or should I use separate overloaded constructors? For example:</p> <pre><code>// Use this... class foo { private: std::string name_; unsigned int age_; public: foo(const std::string&amp; name = "", const unsigned int age = ...
<p>Definitely a matter of style. I prefer constructors with default parameters, so long as the parameters make sense. Classes in the standard use them as well, which speaks in their favor.</p> <p>One thing to watch out for is if you have defaults for all but one parameter, your class can be implicitly converted from...
<p>Matter of style, but as Matt said, definitely consider marking constructors with default arguments which would allow implicit conversion as 'explicit' to avoid unintended automatic conversion. It's not a requirement (and may not be preferable if you're making a wrapper class which you want to implicitly convert to),...
22,737
<p>I have a few questions about whether or not it would be best to not use indexing.</p> <p>BACKGROUND: My records have a timestamp attribute, and the records will be inserted in order of their timestamps (i.e., inserted chronologically).</p> <p>QUESTIONS:</p> <ol> <li><p>If I DON'T use indexing is it typical for th...
<p>In my experience, yes, the database will insert stuff in the chronological order, especially if you never delete anything. However, it is not guaranteed, and it's a really bad idea to try to rely on behaviour that is not guaranteed.</p> <p>Also, the query planner isn't going to know this fact, so any query you do ...
<p>I'm jbu, the post creator.</p> <p>Thanks for everyone's fast input.</p> <p>To address further questions: </p> <p>Yes I have static data - I will not be deleting. </p> <p>I am testing a few different databases : Sybase SQL Anywhere, Oracle Berkeley DB, H2, Firebird, SQLite, and possibly a few others.</p> <p>To ...
29,915
<p>In C++, I code this way:</p> <pre><code>//foo.h class cBar { void foobar(); } </code></pre> <hr> <pre><code>//foo.cpp void cBar::foobar() { //Code } </code></pre> <p>I tried to do this on PHP but the parser would complain. PHP's documentation also doesn't help. Can this be done in PHP?</p>
<p>No. You need to including all your function definitions inside the class block. If defining your functions in a separate structure makes you feel better you could use an interface.</p> <pre><code>interface iBar { function foobar(); } class cBar implements iBar { function foobar() { //Code ...
<p>The language doesn't really provide this feature but if you <em>really</em> want it, you can install the <a href="http://pecl.php.net/package/classkit" rel="nofollow noreferrer">ClassKit</a> extension which will let you do some dynamic class modifications at run-time.</p>
41,388
<p>According to the VS 2008 properties for a GridView:</p> <ul> <li>DataBound fires after the control has been databound.</li> <li>RowDataBound fires after a row has been databound.</li> </ul> <p>If I want to manipulate the text in a header column, does it matter if I use the DataBound or RowDataBound because I can a...
<p>DataBound happens after all RowDataBound events are done firing, and therefore only fires once for the control. If you only have one thing to do, put it in the DataBound method. If it's something that needs to happen on an arbitrary row, do it in RowDataBound.</p>
<p><strong>RowDataBound</strong> event fires after the datafield that is rows in the backend's table bound with the datarows in the gridview.</p> <p>Now we have all the data available in a grid (front end). We can manipulate or customize our grid on the basis of that data in <strong>RowDataBound</strong> event.</p> <...
36,690
<p>On Windows Mobile (but I guess it's the same on Windows) in a native C++ app, how would I go about setting a SYSTEMTIME structure correctly? Assuming I have </p> <pre><code>int year, month, dayOfMonth, hour, minute, second; </code></pre> <p>I obviously should set the wHour, wYear, etc members of the SYSTEMTIME str...
<p>You could fill in the fields you know, then convert to variant time and back.</p> <p>That might fill in the missing data.</p>
<p>Hmm...</p> <p>Maybe first construct a FILETIME and then call FileTimeToSystemTime?</p> <p>Info on FILETIME<br> <a href="http://msdn.microsoft.com/en-us/library/ms724284(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms724284(VS.85).aspx</a></p> <p>Or, first contruct a VARIANT of VT...
36,487
<p>I've got a <code>DateTime?</code> that I'm trying to insert into a field using a <code>DbParameter</code>. I'm creating the parameter like so:</p> <pre><code>DbParameter datePrm = updateStmt.CreateParameter(); datePrm.ParameterName = "@change_date"; </code></pre> <p>And then I want to put the value of the <code>Da...
<p>Ah ha! I found an even more efficient solution than @Trebz's!</p> <pre><code>datePrm.Value = nullableDate ?? (object)DBNull.Value; </code></pre>
<p>The way that I do it, is I have a static utility class that just goes through and checks to see if the parameter value is null, then i set the value to do DBNull. I just do that before i call the Execute.</p>
26,927
<p>Suppose I have a bunch of varchar(6000) fields in a table and want to change those to text fields. What are the ramifications of the stored procedures whose arguments are of type varchar(6000). Does each stored procedure also need those argument data types changed?</p>
<p>Text fields are <a href="http://msdn.microsoft.com/en-us/library/ms187993.aspx" rel="nofollow noreferrer">deprecated</a> in SQL Server 2005 and above. You should use varchar(MAX), if possible. If you expect to have more than 6000 characters passed in the arguments to your stored procedures, you will need to change...
<p>The reason for text field usage is that all of the varchar(6000) fields in one row exceed the max row length. Text fields just store a pointer in the row thus not exceeding the SQL Server max row length of 8000 something. ATM the database cannot be normalized. The data is not manipulated by the stored procedures ...
27,677
<p>I'd like to automate importing cert(s) on a Windows CE device. Pushing the certs down to the devices is not a problem, but once they are there I cannot determine how to import them without using the UI.</p> <p>(I'm currently using Avalanche Mobility Center)</p>
<p>Another way to push certificates onto windows mobile devices is to use Windows Mobile Device Provisioning.</p> <p><a href="http://msdn.microsoft.com/en-us/magazine/cc500581.aspx" rel="nofollow noreferrer">MSDN Provisioning Mobile Devices Article</a></p> <p>For examples of certificate provisioning, in any of the Wi...
<p>You need to execute the certificate from the command line. The easiest way to figure out what is happening is to go in to the .cert extension in Windows ME and see what command gets executed when a double click happens.</p>
36,544
<p>I have a large CSV file and I want to execute a stored procedure for each line.</p> <p>What is the best way to execute a stored procedure from PowerShell?</p>
<p>This answer was pulled from <a href="http://www.databasejournal.com/features/mssql/article.php/3683181" rel="noreferrer">http://www.databasejournal.com/features/mssql/article.php/3683181</a></p> <p>This same example can be used for any adhoc queries. Let us execute the stored procedure “sp_helpdb” as shown below.</...
<p>I include <code>invoke-sqlcmd2.ps1</code> and <code>write-datatable.ps1</code> from <a href="http://blogs.technet.com/b/heyscriptingguy/archive/2010/11/01/use-powershell-to-collect-server-data-and-write-to-sql.aspx" rel="nofollow">http://blogs.technet.com/b/heyscriptingguy/archive/2010/11/01/use-powershell-to-collec...
10,907
<p>I'm writing a php script where I call </p> <pre><code>$lines = file('base_list.txt'); </code></pre> <p>to break a file up into an array. The file has over 100,000 lines in it, which should be 100,000 elements in the array, but when I run </p> <pre><code>print_r($lines); exit; </code></pre> <p>the array only cont...
<p>Darryl Hein,</p> <p>Yeah, there isn't anything in the error logs. I even increased error reporting and still nothing relevant to print_r().</p> <p>In response to Jay: I ran </p> <pre><code>echo count($lines); </code></pre> <p>and I get a result of 105,546 but still print_r() only displays 7280. </p> <p>Taking R...
<p>I'm gonna agree with Cory. I'm thinking your PHP is probably configured default memory of 8MB, which 4MB x 2 is already more. The reason for the x2 is because you have to load the file, then to create the array you need to have the file in memory again. I'm just guessing, but that would make sense. </p> <p>Are you ...
20,652
<p>I have some HTML menus, which I show completely when a user clicks on the head of these menus. I would like to hide these elements when the user clicks outside the menus' area.</p> <p>Is something like this possible with jQuery?</p> <pre><code>$("#menuscontainer").clickOutsideThisElement(function() { // Hide t...
<blockquote> <p>Note: Using <code>stopPropagation</code> is something that should be avoided as it breaks normal event flow in the DOM. See <a href="https://css-tricks.com/dangers-stopping-event-propagation/" rel="noreferrer">this CSS Tricks article</a> for more information. Consider using <a href="https://stackoverflo...
<pre><code> &lt;div class="feedbackCont" onblur="hidefeedback();"&gt; &lt;div class="feedbackb" onclick="showfeedback();" &gt;&lt;/div&gt; &lt;div class="feedbackhide" tabindex="1"&gt; &lt;/div&gt; &lt;/div&gt; function hidefeedback(){ $j(".feedbackhide").hide(); } function showfeedback(){ $j...
18,456
<p>I have a VS2005 windows service where I have the need to use 'useUnsafeHeaderParsing' as per documentation from MSDN.</p> <p>As this is a library used within my windows service, I do not have a web.config to add httpwebrequest element and set useUnsafeHeaderParsing to true.</p> <p>How would I go about achieving th...
<p>You can enable unsafeHeaderParsing programmatically if you wish - here's a function I included in <a href="http://qdfeed.codeplex.com/" rel="noreferrer">Quick and Dirty Feed Parser</a> for turning that on - it's similar to some of the ones you linked to in your question:</p> <pre><code>private static bool SetUseUns...
<p>I'm not sure what the trouble is. </p> <p>You don't use a web.config with a windows service, you use App.config (this gets moved into the deployment directory when you compile and renamed to .config</p> <p>I have used this setting in my App.Config for windows forms applications, web applications and many windows s...
30,094
<p>I was under the impression that I could run it on any machine, but a guy from our hosting company is saying that the csr has to be generated on the server hosting the site.</p> <p>Can anyone clear this one up for me?</p> <p>Thanks.</p>
<p>The bottom line is you do not need to generate CSRs on the server hosting an SSL certificate. A CSR is a CSR and you could actually generate it using something like OpenSSL and then import both the key and certificate once it is created into the keystore. The problem is that they probably don't understand now to get...
<p>It's not entirely accurate. What does need to happen is the chain of key -> csr -> cert all needs to happen within the same keystore file. It is difficult to move key/cert in and out of the original keystore.</p>
30,705
<p>I want to split a command line like string in single string parameters. How look the regular expression for it. The problem are that the parameters can be quoted. For example like:</p> <p>"param 1" param2 "param 3"</p> <p>should result in:</p> <p>param 1, param2, param 3</p>
<p>I tend to use regexlib for this kind of problem. If you go to: <a href="http://regexlib.com/" rel="noreferrer">http://regexlib.com/</a> and search for "command line" you'll find three results which look like they are trying to solve this or similar problems - should be a good start.</p> <p>This may work: <a href="...
<p>(reading your question again, just prior to posting I note you say command line LIKE string, thus this information may not be useful to you, but as I have written it I will post anyway - please disregard if I have missunderstood your question.)</p> <p>If you clarify your question I will try to help but from the gen...
23,993
<p>In ASP.NET MVC is there an equivalent of the Html.ActionLink helper for Img tags? </p> <p>I have a controller action that outputs a dynamically generated JPEG and I wanted to use the same Lambda expressions to link to it as I do HREFs using ActionLink.</p> <p>Alternatively, a helper that just gives the URL to a ro...
<p>You can use the URL.Action method</p> <pre><code>&lt;a href="&lt;%= Url.Action("Create") %&gt;"&gt;&lt;img src="../../Content/Images/add_48.png" /&gt;&lt;/a&gt; </code></pre>
<p>I tried to put the output of the <strong>Html.Image</strong> into my <strong>Html.ImageLink</strong> helper.</p> <pre><code>@(new HtmlString(Html.ActionLink(Html.Image("image.gif").ToString(), "myAction", "MyController").ToString().Replace("&amp;lt;", "&lt;").Replace("&amp;gt;", "&gt;"))) </code></pre> <p>The prob...
25,868
<p>I need a C# profiler.</p> <p>Although I'm not averse to paying for one, something which is free or at least with a trial version would be ideal since it takes time to raise a purchase order.</p> <p>Any recommendations?</p>
<p>You can try the following:</p> <ul> <li><a href="http://nprof.sourceforge.net/Site/Description.html" rel="noreferrer">nprof</a> (free but kinda old)</li> <li><a href="http://sourceforge.net/projects/profilesharp/" rel="noreferrer">ProfileSharp</a> (open source)</li> <li><a href="http://memprofiler.com/" rel="norefe...
<p>I found the <a href="http://memprofiler.com/" rel="nofollow noreferrer">.NET Memory Profiler</a> yesterday, and I must say that I'm very impressed by it.<br> I'm going to order my license today.</p>
3,185
<p>CAML is hard to learn, and dificult to use, is there a better way to get results from MOSS, besides using CAML queries? And not referring to the Web Services, which are slower, or the object model, which again is slower. </p>
<p>Essentially, yes, you need to at least be able to read and understand CAML. However you can probably get out of writing it. I've used these tools:</p> <p>U2U CAML Query Builder by U2U - <a href="http://www.u2u.be/res/Tools/CamlQueryBuilder.aspx" rel="nofollow noreferrer">download</a> and <a href="http://www.u2u.be/...
<p>I depends on what you want to do.<br> You can also use the MOSS search engine to search for documents.</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms544561.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms544561.aspx</a></p>
44,716
<p><a href="https://stackoverflow.com/questions/71955/when-choosing-an-orm-is-linq-to-sql-or-linq-to-entities-better-than-nhibernate#71974">This answer says</a> that Linq is targeted at a slightly different group of developers than NHibernate, Castle, etc.</p> <p>Being rather new to C#, nevermind all the DB stuff surr...
<p>When you say Castle I assume you mean Castle Active Record?</p> <p>The difference is NHibernate is an OR/M and is aimed at developers who want to focus on the domain rather than the database. With linq to sql, your database is pre-existing and you're relationships and some of programming will be driven by how your ...
<p>LINQ is just a set of new C# features: extension methods, lambda expressions, object initializers, anonymous types, etc.</p> <p>"LINQ to SQL" on the other hand is something you can compare other SQL wrappers.</p>
10,831
<p>What is the Java equivalent of PHP's <code>$_POST</code>? After searching the web for an hour, I'm still nowhere closer.</p>
<p>Your <code>HttpServletRequest</code> object has a <code>getParameter(String paramName)</code> method that can be used to get parameter values. <a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getParameter(java.lang.String)" rel="noreferrer">http://java.sun.com/javaee/5/docs/api/javax...
<p>For getting all post parameters there is Map which contains request param name as key and param value as key.</p> <pre><code>Map params = servReq.getParameterMap(); </code></pre> <p>And to get parameters with known name normal</p> <pre><code>String userId=servReq.getParameter("user_id"); </code></pre>
2,718
<p>I'd like to be able to pass a SecureString (a cached passphrase) to a child process in C# (.Net 3.5), but I don't know what the most secure way is to do it. If I were to convert the SecureString back to a regular string and pass it as a command-line argument, for example, then I <em>think</em> the value may be prone...
<p>In general you should define your threat model before worrying about more exotic attacks. In this case: are you worried that somebody shuts down the computer and does a forensic analysis of the harddrive? Application memory can also be swapped out, so the simple fact that <em>one</em> process has it in memory, makes...
<p>Unless your child process also understands how to work with SecureString I don't think there is a way to pass it directly. For example, the Process.Start() method has two overloads that take a SecureString so the risk of the actual string value being sniffed is minimized (it's still possible since somewhere along th...
6,886
<p>I see a lot of IoC frameworks for .Net and Java. Does anyone know why there are no equivalent frameworks for Smalltalk. This is more a philosophy question than anything else. I'm wondering if there is something in the Smalltalk way of doing things that precludes the necessity of having an IoC framework.</p>
<p><a href="http://en.wikipedia.org/wiki/Model_view_controller" rel="nofollow noreferrer">MVC</a> was invented on Smalltalk and is arguably the original <a href="http://en.wikipedia.org/wiki/Inversion_of_control" rel="nofollow noreferrer">Inversion of Control</a> framework. While somewhat more lightweight than its jav...
<p>I think that IOC or the Dependency Injection pattern solves a problem that doesn't really exist in the Smalltalk environment. Smalltalk is an untyped dynamic language and uses message passing to communicate. This makes for objects that are loosely coupled by nature at the language level. Any object can send a mes...
30,227
<p>I have an assembly containing very thorough XML-based documentation, which is used through Sandcastle to generate the help-files for the product. We also use the output XML files for providing proper Intellisense in Visual Studio when programmers use the assembly obviously.</p> <p>In order to do this, it seems we h...
<p>Unfortunately you will need to supply both as Visual Studio only knows to look at XML documents for Intellisense.</p>
<p>Am i missing something? I always comment as usual (using 3 slashes or 3 tick marks (vb)), use the built in xml tags and when i use the assembly i get the intellisense - i rarely use an extrernal xml file. </p>
24,527
<p>I would have thought this would be an easy one to Google, but I've been unsucessful.</p> <p>I want to assign a variable the value out of an attribute (easy so far) then use that variable to select another node based on the value of that attribute.</p> <p>Example:</p> <pre><code>&lt;xsl:variable name="myId" select...
<p>Ok, I finally figured it out. Silly problem really, I simply needed to leave out the quotes and the braces. One of those times when I <em>thought</em> that I'd already tried that. :D Oh, and I mistyped @myId in the first example, the code was actually $myId.</p> <pre><code>&lt;xsl:variable name="myId" select="@...
<p>You seem to have got confused with use of a variable (which is just $variable) and Attribute Value Templates, which allow you to put any XPath expression in some attributes, e.g. </p> <pre><code>&lt;newElement Id="{@Id}"/&gt; </code></pre> <p>They can obviously be combined, so you can include a variable in an Attr...
2,730
<p>I am working with a set of data that I have converted to a list of dictionaries</p> <p>For example one item in my list is </p> <pre><code>{'reportDate': u'R20070501', 'idnum': u'1078099', 'columnLabel': u'2005', 'actionDate': u'C20070627', 'data': u'76,000', 'rowLabel': u'Sales of Bananas'} </code></pre> <p>Per ...
<p>So what's wrong with pickle? If you structure your data as a list of dicts, then everything should work as you want it to (if I understand your problem).</p> <pre><code>&gt;&gt;&gt; import pickle &gt;&gt;&gt; d1 = {1:'one', 2:'two', 3:'three'} &gt;&gt;&gt; d2 = {1:'eleven', 2:'twelve', 3:'thirteen'} &gt;&gt;&gt; d...
<p>Python does not retain order in dictionaries.<br> However, there is the <a href="http://docs.python.org/2/library/collections.html?highlight=collections#ordereddict-objects" rel="nofollow noreferrer">OrderedDict</a> class in the <em>collections</em> module.</p> <p>Another option would be to use a list of tuples:</p...
41,195
<p>I have a little dilemma that maybe you can help me sort out. </p> <p>I've been working today in modifying ASP.NET's Membership to add a level of indirection. Basically, ASP.NET's Membership supports Users and Roles, leaving all authorization rules to be based on whether a user belongs to a Role or not. </p> <p>Wha...
<p>I feel the best combination of DRYness and forcing the contract is as follows (in pseudocode):</p> <pre><code>class Base { public final constructor(name) { constructor(name, null) end public abstract constructor(name, description); } </code></pre> <p>or, alternatively:</p> <pre><code>class Base { pub...
<p>To answer the first part of your post, check out AzMan (Authorization Manager), which, incidentally, is built into windows. It has the capability to specify operations which can be recombined into roles or assigned directly to users.</p> <p><a href="http://msdn.microsoft.com/en-us/magazine/cc300469.aspx" rel="nofo...
5,518
<p>I've set an external tool (sablecc) in eclipse (3.4) that generates a bunch of classes in the current project. I need to run this tool and regenerate these classes fairly frequently. This means that every time I want to run sablecc, I have to manually delete the packages/classes that sablecc creates in order to ensu...
<p>Not sure if I understand your point right, I suppose you need to delete old classes before running sablecc because some of them would not be eventually created in new run.</p> <p>It is probably best to write short <a href="http://ant.apache.org/" rel="nofollow noreferrer">Ant</a> build.xml with the target, which fi...
<p>You can tell Eclipse to refresh the workspace (or parts of it) after an external tool has been run. This should force Eclipse to detect any new/deleted classes.</p>
10,103
<p>Ladies and Gents,</p> <p>My best friends and I do a "Secret Santa" type gift exchange every year, this year I've been trying to think of a couple of ways to make it interesting. There are six of us involved and I want to design a small program that allows the six of us to rank their preferred gift-recipients from 1...
<p>The Gale-Shapley algorithm (for the Stable Marriage problem) applies only when each person has a ranked list of all other participants -- you may or may not be able to convert your problem to that form (make everyone rank <em>everyone</em>). </p> <p>Also, note that the thing it is optimizing for is something differ...
<p>For each person, create two virtual people, a "giver" and a "receiver". Now match the set of givers against the set of receivers using the Gale Shapley Algorithm. Runs in O(n^2) time.</p> <p><a href="http://en.wikipedia.org/wiki/Stable_marriage_problem" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Stable_...
45,551