instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I looked for the name of a procedure, which applies a tree structure of procedures to a tree structure of data, yielding a tree structure of results - all three trees having the same structure. </p>
<p>Such a procedure might have the signature: </p>
<pre>(map-tree data functree)</pre>
<p>Its return value woul... | <p>I don't have a very good name for the function. I'm pasting my implementation below (I've called it <code>map-traversing</code>; others should suggest a better name). I've made the argument order mirror that of <code>map</code> itself.</p>
<pre><code>(define (map-traversing func data)
(if (list? func)
(map ... | <p>I found that with the follwing definition of map-traversing, you don't need to unquote the functions:</p>
<pre>(define (map-traversing func data)
(if (list? func)
(map map-traversing func data)
(apply (eval func (interaction-environment)) (list data))))</pre>
<p>Note: in my installed version of Guile... | 12,380 |
<p>Does anyone know of an IDE for F# development that does not involve me shelling out $300? I will gladly move to F# VS Express if they ever release one, but spending money to just get started with a new language is not in my budget.</p>
| <p><a href="http://msdn.microsoft.com/en-us/vsx2008/products/bb933751.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/vsx2008/products/bb933751.aspx</a></p>
<p>Visual Studio Shell - Free, and F# supports it out of the box.</p>
<p>(edited)
<a href="http://blogs.msdn.com/dsyme/archive/2008/04/04/tackling-the-f-p... | <p>start a WebsiteSpark microsoft programm. It is free and for three years you will have access to latest version of visual studio professional. Glad I found it three years ago...</p>
<p><a href="http://www.microsoft.com/web/websitespark/" rel="nofollow">here</a> the link</p>
<p>this is the description of my company ... | 11,849 |
<p>What's better practice when defining several methods that return the same shape of data with different filters? Explicit method names or overloaded methods?</p>
<p>For example. If I have some Products and I'm pulling from a database</p>
<p>explicit way:</p>
<pre><code>public List<Product> GetProduct(int pro... | <p>Yes, overloading can easily be overused.</p>
<p>I've found that the key to working out whether an overload is warranted or not is to consider the audience - not the compiler, but the maintenance programmer who will be coming along in weeks/months/years and has to understand what the code is trying to achieve.</p>
... | <p>yes you can overuse it. In your example it would seem like the first and third would probably return a single item, where the second would return several. If that is correct, then I would call the first and third GetProduct and the second GetProducts or GetProductList</p>
<p>if this is not the case and all three ... | 30,840 |
<p>Say I have two lists:</p>
<pre><code>var list1 = new int[] {1, 2, 3};
var list2 = new string[] {"a", "b", "c"};
</code></pre>
<p>Is it possible to write a LINQ statement that will generate the following list:</p>
<pre><code>var result = new []{
new {i = 1, s = "a"},
new {i = 1, s = "b"},
new {i = 1, ... | <pre><code>var result = from l1 in list1
from l2 in list2
select new { i = l1, s = l2};
</code></pre>
| <pre><code>var result = from l1 in list1
from l2 in list2
select new { i = l1, s = l2};
</code></pre>
| 36,835 |
<p>I have this C-code to do multiplications over GF(8):</p>
<pre><code>int32_t GaloisMultiply (int32_t a, int32_t b)
{
int32_t i;
int32_t mask = 0x100;
int32_t y = 0;
for(i=0;i<8;i++)
{
if(b & mask)
{
y ^= a;
}
mask >>= 1;
y <&... | <p>Table-based? <a href="http://www.samiam.org/galois.html" rel="nofollow noreferrer">link</a></p>
<p>And when you are limited to x*x, it's a sparse matrix.</p>
<p>Here's another <a href="http://www.cs.utk.edu/~plank/plank/papers/CS-07-593/" rel="nofollow noreferrer">good paper (and a library)</a></p>
| <p>You could probably write some assembly to do a slightly better job. However, I'd be pretty surprised if this was the bottleneck in your application; have you done any profiling? This function doesn't seem like it's worth optimizing.</p>
| 14,291 |
<p>I have a build server running CruiseControl.NET. It works well for the 7 projects that are configured to run on that server (let's call it server A).</p>
<p>Now I have a new project that I wish to build on a different server (server B), but I want it to appear in the same ccnet dashboard as the existing projects. <... | <p>In <code>dashboard.config</code> (default location is <code>c:\Program Files\CruiseControl.NET\webdashboard\dashboard.config</code>) take a look at the <a href="http://confluence.public.thoughtworks.org/display/CCNET/Servers+Configuration+Block" rel="nofollow noreferrer">Servers Configuration Block</a>:</p>
<pre><c... | <p>Duckworth's answer is the one I found via Google. I found the complete story (identifying all protagonists) as:</p>
<p>Open the dashboard.config file. Its default location is \Program Files\CruiseControl.NET\webdashboard. </p>
<p>At the top of dashboard.config, add the extra server. Eg</p>
<p>
... | 34,101 |
<p>This code works in Firefox, Internet Explorer, not in Safari/Chrome:</p>
<pre><code><head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-ui.js"></script>
<script>
function newDiv() {
var div = $... | <p>the solution i found is to set the element <code>position: absolute !important</code>, :))</p>
| <p>To resolve this problem, you must define WMODE diferent to transparent. I just set the wmode=window and this works fine in all browsers.</p>
| 36,244 |
<p>Do you think there is a big difference in for...in and for loops? What kind of "for" do you prefer to use and why?</p>
<p>Let's say we have an array of associative arrays:</p>
<pre><code>var myArray = [{'key': 'value'}, {'key': 'value1'}];
</code></pre>
<p>So we can iterate:</p>
<pre><code>for (var i = 0; i <... | <p>The choice should be based on the which idiom is best understood.</p>
<p>An array is iterated using:</p>
<pre><code>for (var i = 0; i < a.length; i++)
//do stuff with a[i]
</code></pre>
<p>An object being used as an associative array is iterated using:</p>
<pre><code>for (var key in o)
//do stuff with o[... | <p>Be careful!!!
I am using Chrome 22.0 in Mac OS and I am having problem with the for each syntax.</p>
<p>I do not know if this is a browser issue, javascript issue or some error in the code, but it is VERY strange. Outside of the object it works perfectly.</p>
<pre><code>var MyTest = {
a:string = "a",
b:str... | 30,073 |
<p>Let's say I do something in Java like:</p>
<pre>
<code>
RemoteResponse response = null;
try {
FutureTask task new FutureTask(....);
executor.execute(task);
response = task.get(1000, TimeUnits.MILLISECONDS);
}
catch( TimeoutException te ) {
<b>
.. should I do something special here? ...
.. what hap... | <p>Edit after the question was revised:</p>
<p><code>response</code> is a reference to a <code>RemoteResponse</code> that <code>task</code> is responsible for allocating. The assignment of the return value from a method won't happen if the method threw an exception, so there is no need for special handling of <code>r... | <p>I think the way to look at the problem is that you need to claim the resource outside of the FutureTask, so that when you do decide to cancel it you can force the reclamation of resources.</p>
<p>so:</p>
<pre><code>Resource res = null;
try {
resource = ResourceAquirer.claim()
FutureTask<?> task = new Futu... | 35,279 |
<p>OK, I am not sure if the title it completely accurate, open to suggestions!</p>
<p>I am in the process of creating an ASP.NET custom control, this is something that is still relatively new to me, so please bear with me.</p>
<p>I am thinking about the event model. Since we are not using Web Controls there are no ev... | <p>You might like to try this <a href="http://www.vim.org/scripts/script.php?script_id=1491" rel="noreferrer">improved Javascript syntax highlighter</a> rather than the one that ships with VIMRUNTIME.</p>
| <p>For a quick and dirty fix, sometimes I just scroll up and down and the highlighting readjusts. <kbd>Ctrl</kbd>+<kbd>L</kbd> for a screen redraw can also fix it.</p>
| 8,327 |
<p>I think I know the answer, but I would like to bounce around some ideas.</p>
<p>I would like to pass several (in this instance 2) somewhat different pieces of data to a View. My initial thought is simply to wrap-up the various objects into a containing object and pass them along that way. Then from the View, I'd h... | <p>I find it useful to create additional classes dedicated that are to be presented to the Views. I keep them in a separate namespace called 'Core.Presentation' to keep things organized. Here is an example:</p>
<pre><code>namespace Core.Presentation
{
public class SearchPresentation
{
public IList<... | <p>I've got the same dealie going on. Here's my solution (may not be the best practice, but it works for me).</p>
<p>I created a number of "Grouping" classes:</p>
<pre><code>public class Duo<TFirst,TSecond> { /*...*/ }
public class Trio<TFirst,TSecond, TThird> { /*...*/ }
</code></pre>
<p>and a factory ... | 29,485 |
<p>I just started getting into BizTalk at work and would love to keep using everything I've learned about DDD, TDD, etc. Is this even possible or am I always going to have to use the Visio like editors when creating things like pipelines and orchestrations?</p>
| <p>You can certainly apply a lot of the concepts of TDD and DDD to BizTalk development. </p>
<p>You can design and develop around the concept of domain objects (although in BizTalk and integration development I often find interface objects or contract first design to be a more useful way of thinking - what messages g... | <p>You could use BizUnit to create and reuse generic test cases both in code and excel(for functional scenarios)</p>
<p><a href="http://www.codeplex.com/bizunit" rel="nofollow noreferrer">http://www.codeplex.com/bizunit</a></p>
<p>BizTalk Server 2009 is expected to have more IDE integrated testability.</p>
<p>Cheers... | 36,359 |
<p>I am trying to get started writing scalable, telecom-grade applications with Asterisk and Ruby. I had originally intended to use the Adhearsion framework for this, but it does not have the required maturity and its documentation is severely lacking. AsteriskRuby seems to be a good alternative, as it's well documen... | <p>SipX is really the wrong answer. I've written some extremely complicated VoiceXML on SipX 3.10.2 and it's been all for naught since SipX 4 is dropping SipXVXML for an interface that requires IVRs to be compiled JARs. Top that off with Nortel filing bankruptcy, extremely poor documentation on the open-source version,... | <p>There really aren't any other frameworks out there. There's of course AGI bindings to every language, but as far as full-fledged frameworks for developing telephony applications, we're just not there yet. At least in the open-source world.</p>
| 12,339 |
<p>How do I programmatically reset the Excel <code>Find and Replace</code> dialog box parameters to defaults ("Find what", "Replace with", "Within", "Search", "Look in", "Match case", "Match entire cell contents")?</p>
<p>I am using <code>Application.FindFormat.Clear</code> and <code>Application.ReplaceFormat.Clear</c... | <p>You can use this macro to reset find & replace. Unfortunately, you have to call them both as there are one or two arguments unique to each, so if you want to reset everything, you're stuck. There is no 'reset', so the only way I have found is to execute a fake find & replace using the default parameters.</... | <p>No need to use sendkeys you can easily refer to the values you need to reset the dialog box values.</p>
<pre><code>Sub ResetFindReplace()
'Resets the find/replace dialog box options
Dim r As Range
On Error Resume Next
Set r = Cells.Find(What:="", _
LookIn:=xlFormulas, _
SearchOrder:=xlRows, _
... | 30,151 |
<p>I would like to be able to embed a command line interpreter inside a dockable window in Visual Studio. Is there any nice way to do this?</p>
| <p>See the <a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=VSCmdShell" rel="noreferrer">VS Command shell</a> project</p>
| <p>Checkout <a href="https://marketplace.visualstudio.com/items?itemName=MadsKristensen.OpenCommandLine" rel="nofollow noreferrer">Open Command Line</a> by Mads Kristensen. <strong>note</strong> it doesn't really "embed" the shell in VS, rather it adds a keyboard shortcut to open the shell at the project directory</p>
... | 8,247 |
<p>I want to update/upgrade the standard Leopard install of Sqlite3 to >3.5 to use the new sqlite_xxx_v2 methods from a Cocoa project.</p>
<p>I can't seem to find any information on how to do this. Does anyone have any tips or a site that outlines the update procedure. </p>
<p>Also is 3.5+ supported on the iPhone. I ... | <p>What you want to do is grab the amalgamation sources from <a href="http://sqlite.org/download.html" rel="noreferrer">http://sqlite.org/download.html</a> . Then just compile that into / add it to your project. You don't want to replace the system sqlite- that'll have unintended consequences in other applications. ... | <p>I don't believe i've updated my version, but it's currently at 3.4.2, and i'm able to use the new methods with the current version.</p>
<p>And i'm running 10.5.5 with the latest (public) iPhone SDK.</p>
| 34,823 |
<p>Banging my head against the wall here. I don't want to reinvent the wheel.</p>
<p>The default Flex 3 classs for PopupButton is a combination of two buttons. One is a normal button with label and/or icon, and the second is the arrow which opens the popup. </p>
<p>My struggle here is that I just want a button with a... | <p>Have you tried setting a <a href="http://www.adobe.com/devnet/flex/articles/flex_skins.html" rel="nofollow noreferrer">new skin</a>? Not sure if it would work but it would be far easier than trying to write a new control.</p>
| <p>It's been a while since I did some work with Flex, but here's my idea:
<br/>
Create a new component consisting of a classic button and a list. The component should have two view states. The list should not be visible in the base state, but should become visible when the component enters the other state. The other st... | 18,271 |
<p>I have a daily batch process that involves selecting out a large number of records and formatting up a file to send to an external system. I also need to mark these records as sent so they are not transmitted again tomorrow.</p>
<p>In my naive JDBC way, I would prepare and execute a statement and then begin to loo... | <p>Hibernate does also iterate over the result set so only one row is kept in memory. This is the default. If it to load greedily, you must tell it so.</p>
<p>Reasons to use Hibernate:</p>
<ul>
<li>"Someone" was "creative" with the column names (PRXFC0315.XXFZZCC12)</li>
<li>The DB design is still in flux and/or you ... | <p>If there are possible performance issues then stick with the JDBC code.</p>
<p>There are a number of well known pure SQL optimisations which
which would be very difficult to do in Hibernate.</p>
<p>Only select the columns you use! (No "select *" stuff ).</p>
<p>Keep the SQl as simple as possible. e.g. Dont inclu... | 43,185 |
<p>For example:</p>
<pre><code>me$ FOO="BAR * BAR"
me$ echo $FOO
BAR file1 file2 file3 file4 BAR
</code></pre>
<p>and using the <code>\</code> escape character:</p>
<pre><code>me$ FOO="BAR \* BAR"
me$ echo $FOO
BAR \* BAR
</code></pre>
<p>I'm obviously doing something stupid.</p>
<p>How do I get the output <code>B... | <p>Quoting when setting <code>$FOO</code> is not enough. You need to quote the variable reference as well:</p>
<pre><code>me$ FOO="BAR * BAR"
me$ echo "$FOO"
BAR * BAR
</code></pre>
| <pre><code>echo "$FOO"
</code></pre>
| 12,755 |
<p>I am looking for a way of efficiently specifying a recurring job execution time without having to write an explicit execution time to a datastore. In other words, rather than saying 'job x next runs at 13.00pm on 11.12.08' and then having to update the execution time for the following week once the job has run, I wa... | <p>I have seen cron expressions used widely for doing this, it might work well as an internal representation format. </p>
| <p>I implemented some unattended services (Windows Services written in c#), using cron to manage the scheduling. The pattern is powerful, and flexible. We can create schedules to any time we want, only using the cron expression. Maybe I am wrong, but the only schedule that I think cron doesn't cover is if we want the l... | 44,714 |
<p>I need to grep for lines with bunch of names, say <code>clientLogin=a@yahoo.com</code>, <code>clientLogin=b@gmail.com</code> from a file.txt.</p>
<p>file.txt has junk which is <code>email=a@yahoo.com email=b@gmail.com</code>. I need to filter these out</p>
<p>Once I get these lines I need to grep for gmail and yah... | <p>You're already using groovy, does using a regular expression that gives you your answer work?</p>
<pre><code>def file = new File("file.txt")
file.delete() // clear out old version for multiple runs
file << """
foobar clientLogin=a@yahoo.com baz quux # should match a@yahoo.com
foobar email=a@yahoo.com b... | <p>You need {}'s around the variable expression. That is:</p>
<pre><code> "${l.get(0)}"
</code></pre>
<p>See <a href="http://groovy.codehaus.org/JN1525-Strings" rel="nofollow noreferrer">Groovy String</a> documentation for more information. </p>
<p>Full example:</p>
<pre><code>List l = new ArrayList{a@yahoo.com, ... | 45,638 |
<p>Here is the sample:</p>
<pre><code> Dim TestString As String = "Hello," & Chr(0) & "World"
MsgBox(TestString, , "TestString.Length=" & TestString.Length.ToString)
</code></pre>
<p>Result - Messagebox shows "Hello," with title says TestString.Length=12 </p>
<p>I guess the chr(0) is treated as th... | <p>The sample code in the questioner's example ("SCORE".ToString...) works fine for me in a console application. The VS2005 debugger does not show the string correctly, but it outputs to the console just fine. So, my feeling is either that you think it's incorrect because the debugger wrongly says so or your output s... | <p>chr(0) is null. Are you after a single space chr(32) or just type vblf or after Enter(Return) chr(13) or type vbcrlf</p>
| 21,547 |
<p>I want to implement my own clustering algorithm using this Virtual Earth javascript API: <a href="http://msdn.microsoft.com/en-us/library/cc966716.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/cc966716.aspx</a>
However, the VE engine calls my cluster function once for every shape in the lay... | <p>The CRLF pair is the expected end-of-line (EOL) marker on most internet protocols.</p>
<p>Here, Postel's "Robustness Principle" should apply. Be liberal in what you accept, but strict in what you send. So, be prepared to receive just a LF, but if you're sending data use whatever the relevant standards require.</p... | <p>This is not a language compatibility issue, but either a file issue or a protocol issue. File-wise: Unix uses \n as a carriage return, Windows uses \r\n and I think MacOS used (not sure about now) \r. Many 'cross platform' languages abstract this in a platform dependant variable. Protocol-wise: what the protocol spe... | 32,116 |
<p>Is the jQuery intellisense plugin available for Visual Studio now?</p>
| <p>Yes, it is. <a href="http://blogs.msdn.com/webdevtools/archive/2008/10/28/rich-intellisense-for-jquery.aspx" rel="nofollow noreferrer">Rich Intellisense for JQuery</a>.</p>
| <p>Yes. <a href="http://mwtech.blogspot.com/2009/05/how-to-get-jquery-intellisense-working.html" rel="nofollow noreferrer">This blog</a> taught me how to do it.</p>
| 37,253 |
<p>I have a csv imported into my Hyperion v8.3 bqy file. I have some custom columns and a pivot already created. I just want to refresh the data. In the past, I would hit Process Current and it would direct me to my computer and I could select the csv file to update from. Now it will not do that. It doesn't go to... | <p>It appears that you're using schtasks.exe - it took me longer to figure that out than to find an answer! More details please! :) I found an answer with <a href="http://tinyurl.com/6z6m8j" rel="nofollow noreferrer">a quick google search</a></p>
<p>Try this code:</p>
<pre><code>string args = "/CREATE /RU SYSTEM /... | <p>Put a batch file in a location that does not have spaces.</p>
<p>In the batch file, run the program commands that have spaces.</p>
| 47,037 |
<p>I am trying to get a simple demo started with ActiveMQ that will demonstrate a TCP to TCP route. I am coding the endpoints and routes in a camel context in my activemq.xml configuration file.</p>
<pre><code><camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
<package>or... | <p>I'm a bit confused by your configuration file. What exactly are you trying to do? </p>
<p>You've defined 2 endpoints for using MINA (which won't use ActiveMQ at all); then you are using a route from an ActievMQ queue listener_A to listener_B then listener_B to listener_A (which is a recursive loop).</p>
<p>Maybe i... | <p>More on this:</p>
<p>When the endpoint is defined as a mina tcp connection, it cannot be identified as "activemq::listener_A" </p>
<pre><code><endpoint id="listener_A" uri="mina:tcp://localhost:42000?sync=false&amp;textline=true"/>
</code></pre>
<p>this is wrong:</p>
<pre><code> <from uri="act... | 33,256 |
<p>I believe the following VB.Net code is the equivalent of the proceeding C# code; however the VB.Net test fails - the event handling Lambda is never called.</p>
<p>What is going on?</p>
<p>VB.Net version - fails:</p>
<pre class="lang-vb prettyprint-override"><code><TestFixture()> _
Public Class TestClass
... | <blockquote>
<p><strong>Note:</strong> This relates to older versions of VB.net Prior to Visual Studio 2010 and VB.net 10</p>
</blockquote>
<p>The difference is that in VB.Net a lambda expression must return a value i.e. they must be functions not subs. The lambda expression <code>eventRaised = true</code> is being... | <p>WPF controls that have popups require an instance of the WPF Application Object. In a WPF application, this is automatically created. This is not the case in a WinForm application. For this reason, this object must be created manually. The Application also must be set to remain open until it is shut down through... | 25,078 |
<p>The heart of any good web app is it's offline capability and JavaScript functionality. Currently what tools and wrappers are availability for the desktop web app maker to cross over to the mobile market? What would be the necessary read ups for such a team?</p>
<p>Clarifications:
I am searching for information on h... | <p>I'm not totally sure I understand your question, but you'll probably want to take a look at the <a href="http://developer.apple.com/iphone/" rel="nofollow noreferrer">iPhone Dev Center</a> and the <a href="http://code.google.com/android/" rel="nofollow noreferrer">Google Android SDK</a> to start. <a href="http://na.... | <blockquote>
<p>The heart of any good web app is it's offline capability and JavaScript functionality.</p>
</blockquote>
<p>You are talking about Single Page webapps like GMail right? Then you will probably need a Mashup platform (<a href="http://en.wikipedia.org/wiki/Mashup_(web_application_hybrid)#Mashup_editors" ... | 17,306 |
<p>I'm writing a program that uses <a href="http://msdn.microsoft.com/en-us/library/dd145102(VS.85).aspx" rel="nofollow noreferrer"><code>SetWindowRgn</code></a> to make transparent holes in a window that belongs to another process. (This is done only when the user explicitly requests it.)</p>
<p>The program has to as... | <p>Are you sure your window <em>has</em> a region? Most top-level windows in XP do, simply because the default theme uses them for round corners... but this is still a bad assumption to be making, and may very well not hold once you get to Vista.</p>
<p>If you haven't set a region yet, and the call fails, use a sensib... | <p>You mention that you're trying to get the region of the window of <strong>another process</strong>. Vista tightened up the security of a lot of cross-process Win32 calls. I can't find any documentation one way or the other for <code>GetWindowRgn()</code>, but you could test it simply enough. Make a simple project th... | 17,462 |
<p>Say I have a Student table, it's got an int ID. I have a fixed set of 10 multiple choice questions with 5 possible answers. I have a normalized answer table that has the question id, the Student.answer (1-5) and the Student.ID</p>
<p>I'm trying to write a single query that will return all scores over a certain pe... | <p>If I understand your schema and question correctly, how about something like this:</p>
<pre><code>select student_name, score
from students
join (select student_answers.student_id, count(*) as score
from student_answers, answer_key
group by student_id
where student_answers.question_id = ans... | <p>The architecture you are talking about could become very cumbersome in the long run, and if you need to change the questions it means more changes to the UDF you are using.</p>
<p>I would think you could probably do your analysis in code without necessarily de-normalizing your database. De-normalization could also... | 4,243 |
<p>I'm 3D printing almost 2 years, and I expected to have better result after changing to complete smooth rods with new bearings.</p>
<p>I have a problem with my Z axis giving me inconsistent prints; I already replaced the leadscrews, E3D clone with Bowden tube, I decided to replace all smooth rods on all axis and als... | <p>From the pictures can be seen that you have good lead screws as there is no cyclic anomaly/wobble present at the side. It appears as though the lines at the sides of the print are more or less random X/Y positional inaccurate.</p>
<p>These lines can be caused by various reasons. From what is read you tried to impro... | <p>From the pictures can be seen that you have good lead screws as there is no cyclic anomaly/wobble present at the side. It appears as though the lines at the sides of the print are more or less random X/Y positional inaccurate.</p>
<p>These lines can be caused by various reasons. From what is read you tried to impro... | 1,075 |
<p>I'm planning to write a program in Ruby to analyse some data which has come back from an online questionnaire. There are hundreds of thousands of responses, and each respondent answers about 200 questions. Each question is multiple-choice, so there are a fixed number of possible responses to each.</p>
<p>The intent... | <p>First thing that comes to mind: Storing it in Memory can be absolutely reasonable for processing purposes. Lets say you reserve one byte for each answer, you have a million responses and 200 questions, then you have a 200 MB array. Not small but definitely not memory exhausting on a modern desktop, even with a 32 bi... | <p>I'm not a great database person, so I'll just answer #2:</p>
<p>If you'd really like to save on memory (or foresee a situation where there will be a lot more data) you could take the best of both worlds: Use ruby as essentially a data-mining tool. Have it pull some of the data from the DB, then write the results ... | 17,386 |
<p>I have a rather simple scenario where I have two tables in which I want to add data. They are managed with primary key/foreign key. I want to add new data into TABLE A and then retrieve the Id and insert into TABLE B. </p>
<p>I can certainly do it with a stored procedure, but I'm looking at trying to do it using Li... | <p>Do you have the relationship defined between the 2 tables in the object relational designed? If so, you can have linq take care of assigning the ID property of the second table automatically.</p>
<p>Example...<br/>
Table A – Order<br/>
OrderId<br/>
OrderDate<br/><br/>
Table B – Order Item<br/>
OrderItemId<br/>
Orde... | <p>hi i insert data into three table using this code </p>
<pre><code> Product_Table AddProducttbl = new Product_Table();
Product_Company Companytbl = new Product_Company();
Product_Category Categorytbl = new Product_Category();
// genrate product id's
long Productid = (from p in Acc... | 36,592 |
<p>I want to open a file for reading, the C++ way. I need to be able to do it for:</p>
<ul>
<li><p>text files, which would involve some sort of read line function.</p></li>
<li><p>binary files, which would provide a way to read raw data into a <code>char*</code> buffer.</p></li>
</ul>
| <p>There are three ways to do this, depending on your needs. You could use the old-school C way and call <code>fopen</code>/<code>fread</code>/<code>fclose</code>, or you could use the C++ fstream facilities (<code>ifstream</code>/<code>ofstream</code>), or if you're using MFC, use the <code>CFile</code> class, which p... | <p>fstream are great but I will go a little deeper and tell you about <a href="http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization" rel="nofollow noreferrer">RAII</a>.</p>
<p>The problem with a classic example is that you are forced to close the file by yourself, meaning that you will have to bend your... | 2,943 |
<p>So, in reading this site, it seems that the shop in which I work does a lot of things wrong and some things right. How can I improve the code that I work with from my colleagues? The only thing I can think of is to lead by example - start using Boost, etc. Any other thoughts? </p>
| <p>You probably have to look more closely at what it is your shop does wrong and what they do right. What can you actually change there? <em>What can you change about your own practices that will improve your skills or that of your team?</em> It can be difficult to realize change in an entrenched shop. Try proposin... | <p>Leading by example is always a good thing, though convincing others that your example is better than however they're currently doing it is not so easy. Constructive criticism through code review is probably your best bet for gently suggesting alternative approaches to how your colleagues work. The key point is to c... | 19,394 |
<p>Do bubble sorts have any real world use? Every time I see one mentioned, it's always either:</p>
<ol>
<li>A sorting algorithm to learn with.</li>
<li>An example of a sorting algorithm <em>not</em> to use.</li>
</ol>
| <p>It depends on the way your data is distributed - if you can make some assumptions.</p>
<p>One of the best links I've found to understand when to use a bubble sort - or some other sort, is this - an animated view on sorting algorithms:</p>
<p><a href="http://www.sorting-algorithms.com/" rel="noreferrer">http://www.... | <p>Mostly <em>nothing</em>. Use QuickSort or SelectionSort instead...!</p>
| 34,811 |
<p>How to serve users a dynamically generated ZIP archive in Django?</p>
<p>I'm making a site, where users can choose any combination of available books and download them as ZIP archive. I'm worried that generating such archives for each request would slow my server down to a crawl. I have also heard that Django doesn... | <p>The solution is as follows.</p>
<p>Use Python module <a href="https://docs.python.org/3/library/zipfile.html" rel="noreferrer">zipfile</a> to create zip archive, but as the file specify <a href="https://docs.python.org/3/library/io.html#io.StringIO" rel="noreferrer">StringIO</a> object (ZipFile constructor requires... | <p>Can't you just write a link to a "zip server" or whatnot? Why does the zip archive itself need to be served from Django? A 90's era CGI script to generate a zip and spit it to stdout is really all that's required here, at least as far as I can see.</p>
| 9,299 |
<p>I'm trying to generate synthetic Javascript events in an Internet Explorer extension, and I'm having trouble getting the fromElement property to stick. Here's an excerpt of my code:</p>
<pre><code>MsHtml.IHTMLDocument4 doc4 = ... // the document object
Object o = null;
MsHtml.IHTMLEventObj2 eObj =
(MsHtml.IHT... | <p>A lot of this depends on what you want to do with the data. I assume render it.</p>
<p>Flash probably would be the simplest solution. It's a common enough add-on that just about everyone should have it by now; so you're not running much of a risk for incompatibility.</p>
<p>JavaScript just hasn't been considered m... | <p>You can use Base64 to convert the binary to text and send that to the browser. With IE you can convert it directly to binary, but I'm not sure if you can do it with Firefox and others. I did see jscripts for Base64 enflate/deflate and a script named base64.js which probably does the conversion as well.</p>
<p>Howev... | 44,450 |
<p>An abstract class can only be used as a base class which is extended by some other class, right? The constructor(s) of an abstract class can have the usual access modifiers (public, protected, and private (for internal use)). Which of <code>protected</code> and <code>public</code> is the correct access modifier to ... | <blockquote>
<blockquote>
<p>since the abstract type seems to indicate that technically a public constructor will act very much protected</p>
</blockquote>
<p>This is not correct. An abstract class cannot be directly instatiated by calling its constructor, however, any concrete implementation <em>will inhe... | <blockquote>
<p>since the abstract type seems to indicate that technically a public constructor will act very much protected</p>
</blockquote>
<p>Umm... for abstract classes this constructor scope [public or protected] is not of much difference since the instantiation is not allowed [even if public]. Since it is mea... | 32,604 |
<p>I'm in the process of creating a class that stores metadata about a particular data source. The metadata is structured in a tree, very similar to how XML is structured. The metadata values can be integer, decimal, or string values.</p>
<p>I'm curious if there is a good way in C++ to store variant data for a situa... | <p>As of C++17, there’s <a href="http://en.cppreference.com/w/cpp/utility/variant" rel="noreferrer"><code>std::variant</code></a>.</p>
<p>If you can’t use that yet, you might want <a href="http://www.boost.org/doc/libs/1_36_0/doc/html/variant.html" rel="noreferrer">Boost.Variant</a>. A similar, but distinct, type for ... | <p>Although the question had been answered for a long time, for the record I would like to mention that <a href="http://doc.qt.io/qt-5/qvariant.html" rel="nofollow noreferrer">QVariant</a> in the Qt libraries also does this.</p>
<blockquote>
<p>Because C++ forbids unions from including types that have non-default
const... | 25,634 |
<p>I have a project with literally thousands of image files that aren't being used. The main problem is that they are intermixed with images that are.</p>
<p>Is there a way to get a list of all project artifacts which aren't referenced?</p>
<p><strong>EDIT</strong>: Assuming I don't have access to the web logs... Is... | <p>Basically, no there isn't a straightforward, works-always way. You could build image-references based on user input or other context. So spidering your website means that you have to execute all code paths, otherwise you might throw away stuff that you actually need.</p>
<p>But now for the specific case of Chris, y... | <ul>
<li><p>access your web server logs, parse for GET's of the desired file pattern, unique them, then compare them against your reference list.</p></li>
<li><p>or, look at the file access dates (you may need to turn on this feature if you are sysop)</p></li>
</ul>
| 31,357 |
<p>I've been doing PHP/MySQL websites with shared hosting providers for the last couple years. The day-to-day process is basically:</p>
<ul>
<li>develop in Eclipse, one website per folder</li>
<li>upload via FileZilla, one website per folder</li>
<li>use PHPMyAdmin to create and manage your local and online databases ... | <p>For the most part, what you're doing now will work with an asp.net website.</p>
<p>For your development environment, I don't think you will be limited by using Visual Web Developer 2008 express for what you want to do. Here is a microsoft page that compares every version of visual studio 2008, including Visual Web ... | <p>As far as capabilities of VS Express vs Standard - Standard is still the better tool. It gives you a richer debugging experience, broader support for solutions/projects dependencies among other things.</p>
<p>These things still matter even when doing shared hosting b/c you absolutely need to debug your app (client... | 40,542 |
<p>I was browsing <a href="https://stackoverflow.com/questions/5119/what-are-the-best-rss-feeds-for-programmersdevelopers">this thread</a>, which has good recommendation but a bit too general for me.</p>
<p>So, if anyone has a collection of nice game programming feeds,please share them. :)</p>
<p>(both general and sp... | <p>My first suggestion would be to use a drop-in logging tool like log4net, which will make formatting much more automatic.</p>
<p>If you are going to go the route of two files (and I agree with Craig that a database is probably a better choice,) you can probably save yourself a lot of heartache by having one file tha... | <p>If you are catpuring logging information for future searching and anaylsis perhaps a database would be a better answer. </p>
<p>As for your solution. Flat files do not scale well at all where as a database scale much better. I wouldn't split the files either, that just compounds the scalability issue. If you ha... | 7,348 |
<p>What is the easiest way to match non-ASCII characters in a regex? I would like to match all words individually in an input string, but the language may not be English, so I will need to match things like ü, ö, ß, and ñ. Also, this is in Javascript/jQuery, so any solution will need to apply to that. </p>
| <p>This should do it:</p>
<pre><code>[^\x00-\x7F]+
</code></pre>
<p>It matches any character which is not contained in the <a href="http://en.wikipedia.org/wiki/American_Standard_Code_for_Information_Interchange" rel="noreferrer">ASCII character set</a> (0-127, i.e. 0x0 to 0x7F). </p>
<p>You can do the same thing w... | <p>I had a problem with <strong>\p</strong> working as expected, so I just used a different strategy like:</p>
<pre><code>([^\t]+)\t
</code></pre>
<p>Find anything that is not a tab character until the next tab character... obviously this depends on your search source, but you get the idea. Now I don't have to figure... | 18,078 |
<p>How do I make <a href="http://en.wikipedia.org/wiki/Vi" rel="noreferrer">vi</a>-<a href="http://en.wikipedia.org/wiki/Vim_%28text_editor%29" rel="noreferrer">Vim</a> never use tabs (converting spaces to tabs, bad!), makes the tab key == 4 spaces, and automatically indent code after curly brace blocks like <a href="h... | <p>As has been pointed out in a couple of other answers, the preferred method now is NOT to use smartindent, but instead use the following (in your <a href="https://stackoverflow.com/questions/10921441/where-is-my-vimrc-file"><code>.vimrc</code></a>):</p>
<pre><code>filetype plugin indent on
" show existing tab wi... | <p>Firstly, do not use the <kbd>Tab</kbd> key in Vim for manual indentation. Vim has a pair of commands in insert mode for manually increasing or decreasing the indentation amount. Those commands are <kbd>Ctrl-T</kbd> and <kbd>Ctrl-D</kbd>. These commands observe the values of <code>tabstop</code>, <code>shiftwidth</c... | 29,034 |
<p>We would like to have the FormsCookieName of FormsCookiePath change per instance of our application. We have an application which has multiple instances on 1 server/domainname. Because of this we can only work in 1 application at the same time, since the cookies will overwrite eachother. Same for the Sessions btw.</... | <p>According to <a href="http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.formscookiename.aspx" rel="nofollow noreferrer">MSDN</a>, the FormsAuthentication.FormsCookieName property that stores the cookie name is a read-only property. This property must be read from the web.config.</p>
<... | <p>I had similar situation, I did the following. In the Application_Start, I checked to see if my cookie name needed change. This would occur after a new deployment for all applications where I have the same web.config for all.</p>
<p><pre><code>
protected void Application_Start(object sender, EventArgs e)
{
// de... | 33,179 |
<p>I have a coworker who is planning a database for a new app that will have several tables with over 30 fields each. Is this excessive? Maybe I'm just not enterprisey enough to understand. </p>
<p>Edit: Also, a lot of the fields are option-type sort of things (like on a request form, would you like your widget to be ... | <p>Database tables can legitimately have 30 or more fields in them. What you need to look at is the normalization of the data and whether that normalization makes any sense. It will normally change in the future, as well. But, you want to try to minimize that.</p>
<p>For instance, if you have a table that has addre... | <p>A tell-tale sign is just what you said. He has fields that should in theory be split out into a different table. Another giveaway is the presence of many optional fields.</p>
<p>I'd say that a course in database design is in order for your DB "Expert". And I'd suggest that you brush up on it as well...it can only h... | 27,166 |
<p>I'm trying to provide a link to my company's website from a Windows Form. I want to be well behaved and launch using the user's preferred browser.</p>
<p>What is the best way to open a URL in the user's default browser from a Windows Forms application?</p>
| <p>This <a href="http://support.microsoft.com/kb/320478" rel="noreferrer">article</a> will walk you through it.</p>
<p>Short answer:</p>
<pre><code>ProcessStartInfo sInfo = new ProcessStartInfo("http://mysite.com/");
Process.Start(sInfo);
</code></pre>
| <p>The above approach is perfect, I would like to recommend this approach to where you can pass your parameters.</p>
<pre><code>Process mypr;
mypr = Process.Start("iexplore.exe", "pass the name of website");
</code></pre>
| 8,246 |
<p>I have a very simple mapping function called "BuildEntity" that does the usual boring "left/right" coding required to dump my reader data into my domain object. (shown below) My question is this - If I don't bring back every column in this mapping as is, I get the "System.IndexOutOfRangeException" exception and want... | <p>Also check out this <a href="http://www.madprops.org/blog/another-idbcommand-extension-fill/" rel="noreferrer">extension method I wrote</a> for use on data commands:</p>
<pre><code>public static void Fill<T>(this IDbCommand cmd,
IList<T> list, Func<IDataReader, T> rowConverter)
{
using (va... | <p>Why don't you use LinqToSql - everything you need is done automatically. For the sake of being general you can use any other <a href="http://en.wikipedia.org/wiki/Object-relational_mapping" rel="nofollow noreferrer">ORM tool</a> for .NET</p>
| 4,218 |
<p>Does anywone know when a UnknownMessageReceived event on a WCF ServiceHost will be fired?</p>
<p>I have some code where I capture the Faulted en UnknownMessageReceived event but even when I post a wrong message to a particular service I never get the event.</p>
<p>Jochen</p>
| <p>I ran into this event when I, incorrectly specified an address like this:
<a href="http://localhost:4000/SomeService//mex" rel="nofollow">http://localhost:4000/SomeService//mex</a></p>
<p><strong>Note the double forward slash</strong></p>
<p>The service was hosted in a WPF application. Because of that I also found... | <p>I guess (not sure though) it means that you get (back) a message that is not defined in your contract.</p>
| 26,797 |
<p>I like to read about new and clever algorithms. And I like to think out of the box, so all kinds of algorithms from all fields of computation are welcome.</p>
<p>From time to time I read research papers to keep up with the current research and expand my horizon. I also like to learn new tricks. Unfortunately I tend... | <p>I'll start with something everyone can use: introspective sort. <a href="http://en.wikipedia.org/wiki/Introsort" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Introsort</a> </p>
<p>A new sort algorithms that combines the best of quick, insertion and heap sort. To be exact it's not a new algorithm by itself... | <p>I found this very useful proof that a^n = b^n + c^n but only for n=2.<br>
Unfortunately this comment box is too small to contain it!</p>
| 20,786 |
<p>Is there a way to change the color of the background for a MDIParent windows in MFC (2005)?</p>
<p>I have tried intercepting ON_WM_CTLCOLOR AND ON_WM_ERASEBKGND but neither work. OnEraseBkgnd does work, but then it gets overwritten by the standard WM_CTL color.</p>
<p>Cheers</p>
| <p>The CMDIFrameWnd is actually covered up by another window called the MDIClient window. Here is a Microsoft article on how to subclass this MDIClient window and change the background colour. I just tried it myself and it works great.</p>
<p><a href="http://support.microsoft.com/kb/129471" rel="nofollow noreferrer">h... | <p>Just guessing here, but try handling ON_WM_PAINT.</p>
| 24,373 |
<p>I have a web app which connects to a server using a TCP connection and reads a binary document which it then writes to its response object. In other words it's transferring a file from a backend server using a custom protocol and returning that file to its client through HTTP.</p>
<p>The server sends a status code ... | <p>I would use the <code>OutputStream</code> directly with a general-purpose function. With the <code>Stream</code>, you can control <code>Flush</code>.</p>
<pre><code> public void WriteDocument(HttpResponse response) {
StreamCopy(response.OutputStream, stream_);
response.End();
}
public st... | <p>Not sure how things work in .Net, but in most environments I've worked in Read() returns 0 bytes when the connection is closed. So you'd do something like:</p>
<pre>
char buffer[4096];
int num_read;
while ( num_read = src.Read(sizeof(buffer)) > 0 )
{
dst.Write(buffer, num_read);
}
</pre>
| 13,634 |
<p>I have one aspx page with some controls.
Also i have one DIV which is dynamically populated from AJAX call.
This AJAX call return couple of controls, for example HtmlInputText1 and HtmlInputText2.</p>
<p>When page is submitted, I can get values from this controls through Request.Form.
If possible access to the att... | <p>The data you want the server to know can be set by the javascript within the form.
Then You can process postback data for the target values manually.</p>
<p>You can write some javascript which modify the value of the server control within browser.</p>
<pre><code><script language="javascript" type="text/javascri... | <blockquote>
<p>The data you want the server to know
can be set by the javascript within
the form. Then You can process
postback data for the target values
manually.</p>
</blockquote>
<p>How to make this?</p>
| 30,046 |
<p>Is there something like the Python descriptor protocol implemented in other languages? It seems like a nice way to increase modularity/encapsulation without bloating your containing class' implementation, but I've never heard of a similar thing in any other languages. Is it likely absent from other languages because... | <p>I've not heard of a direct equivalent either. You could probably achieve the same effect with macros, especially in a language like Lisp which has extremely powerful macros.</p>
<p>I wouldn't be at all surprised if other languages start to incorporate something similar because it is so powerful.</p>
| <p>Ruby and C# both easily let you create accessors by specifying getter/setter methods for an attribute, much like in Python. However, this isn't designed to naturally let you write the code for these methods in another class the way that Python allows. In practice, I'm not sure how much this matters, since every ti... | 5,443 |
<p>When I create an Issue Tracking list in SharePoint, I am unable to remove the Categories choice field that it adds by default as part of the Issue content type. I looked in the list definition but I can't find anything explicit about not allowing the column to be deleted. Does anybody know why the Delete button is... | <p>Toni's solution did work, but be careful- this will also remove the category field from EVERY ISSUES TRACKING LIST being used currently and any future ones created.</p>
| <p>I know that I have had a similar issue with field in a variety of fields where once the field is added, it is not possible to remove it. </p>
<p>Sometimes it is possible to create code to delete the field, but in most of the situations I have come across we have had to hide the field to prevent it from appearing.</... | 15,123 |
<p>An instance of class A instantiates a couple of other objects, say for example from class B:</p>
<pre><code>$foo = new B();
</code></pre>
<p>I would like to access A's public class variables from methods within B.</p>
<p>Unless I'm missing something, the only way to do this is to pass the current object to the i... | <p>That looks fine to me, I tend to use a rule of thumb of "would someone maintaining this understand it?" and that's an easily understood solution.</p>
<p>If there's only one "A", you could consider using the registry pattern, see for example <a href="http://www.phppatterns.com/docs/design/the_registry" rel="nofollow... | <p>Similar to what Paul said, if there's only one A, you can implement that as a singleton. You can then pass the instance of A as an argument to the constructor (aggregation), with a setter method (essentially aggregation again), or you can set this relationship directly in the constructor (composition).</p>
<p>Howev... | 8,758 |
<p>I have a read-only database that has cached information which is used to display pages on the site. There are processes that run to generate the database, and those run on a different server. When I need to update the live database, I restore this database to the live server, to a new name and file. Then I drop the ... | <p>Probably what you want to do is take the live database offline with the command:</p>
<pre><code>ALTER DATABASE name SET OFFLINE
</code></pre>
<p>You can read more <a href="http://www.blackwasp.co.uk/SQLOffline.aspx" rel="nofollow noreferrer">here</a>, but it says:</p>
<blockquote>
<p>The above command attempts ... | <p>+1 for Mike Sharek - I like your solution, it's very tidy and prevents users being disconnected abruptly (and very rudely).</p>
<p>Another alternative, if you don't want to sit around waiting for users to log off for hours. You could send an alert to connected clients through an AJAX mechanism you build into the s... | 48,657 |
<p>What is the best full text search alternative to Microsoft SQL? (which works with MS SQL)</p>
<p>I'm looking for something similar to <a href="http://lucene.apache.org/java/docs/index.html" rel="nofollow noreferrer">Lucene</a> and <a href="http://incubator.apache.org/lucene.net/" rel="nofollow noreferrer">Lucene.N... | <p>Take a look at <a href="http://clucene.wiki.sourceforge.net/" rel="nofollow noreferrer">CLucene</a> - It's a well maintained C++ port of java Lucene. It's currently licenced under LGPL and we use it in our commercial application.</p>
<p>Performance is incredible, however you do have to get your head around some of ... | <p>I second Sphinx, but <a href="http://lucene.apache.org/" rel="nofollow noreferrer">Lucene</a> is also not so bad despite the Java. :) If you are not dealing with too much data spread out etc., then also look into MySQL's <a href="http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html" rel="nofollow noreferrer">... | 5,979 |
<p>Is there any good practice related to dynamic_cast error handling (except not using it when you don't have to)? I'm wondering how should I go about NULL and bad_cast it can throw.
Should I check for both? And if I catch bad_cast or detect NULL I probably can't recover anyway...
For now, I'm using assert to check if ... | <p>If the <code>dynamic_cast</code> <em>should</em> succeed, it would be good practice to use <code>boost::polymorphic_downcast</code> instead, which goes a little something like this:</p>
<pre><code>assert(dynamic_cast<T*>(o) == static_cast<T*>(o));
return static_cast<T*>(o);
</code></pre>
<p>This ... | <p>I'd concur with the 'it depends' answer, and also add "Graceful degradation": just because a cast fails somewhere isn't enough reason to let the application fail (and the user lose his/her work, etc.). I'd recommend a combination of asserts and defensive programming:</p>
<pre><code>ptr = dynamic_cast<MyClass>... | 30,566 |
<p>I am porting an existing application to C# and want to improve performance wherever possible. Many existing loop counters and array references are defined as System.UInt32, instead of the Int32 I would have used.</p>
<p>Is there any significant performance difference for using UInt32 vs Int32?</p>
| <p>I don't think there are any performance considerations, other than possible difference between signed and unsigned arithmetic at the processor level but at that point I think the differences are moot.</p>
<p>The bigger difference is in the CLS compliance as the unsigned types are not CLS compliant as not all langua... | <p>Its going to allocate the same amount of memory either way (although the one can store a larger value, as its not saving space for the sign). So I doubt you'll see a 'performance' difference, unless you use large values / negative values that will cause one option or the other to explode. </p>
| 39,443 |
<p>I was wondering if anyone had come across this one before. I have a customer who uses special characters in their product description field. Updating to a MySQL database works fine if we use their HTML equivalents but it fails if the character itself is used (copied from either character map or Word I would assume).... | <p>This suggests a mismatched character set between your database (connection) and actual data.</p>
<p>Most likely, you're using ISO-8859-1 on your site, but MySQL thinks it should be getting UTF-8.</p>
<p><a href="http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html" rel="nofollow noreferrer">http://dev.my... | <p>Have you tried to set collation for the table to utf-8 or something non latin1/ascii.</p>
| 28,859 |
<p>I have a DataGridView which shows the content of a DataTable.</p>
<p>I want to set the backcolor of a row based on the value of a cell in this row.</p>
<p>Note that the cell in question is in a column which is not displayed in the DataGridView (Visible=False).</p>
| <p>If you handle the RowDataBound event you can check the value of the data and modify the attributes of the cell or apply a different style in that event handler.</p>
<pre><code>protected void Page_Load(object sender, EventArgs e)
{
GridView g1 = new GridView();
g1.RowDataBound += new GridViewRowEventHandler(... | <p>Another option would be to use the CellFormatting event.
First option shows accessing the bound data item and is useful if you don't have a column set up for the data in question. Second option works if there is a column whether it is visible or not.</p>
<pre><code> private void dataGridView_CellFormatting(obje... | 23,178 |
<p><strong>TL;DR:</strong> I'm looking to change the steps per mm but I'm not sure what to set it to. Do I decide on a temperature and change the rate based on the percentage for that temp? Or is there a more general setting I can put it to? Or is there a different underlying problem here?</p>
<p>I'm running into an i... | <p>Obviously, your extrusion process is troubled by a lot of pressure. This can be seen from the extensive experiment you conducted with PLA extrusion at different temperatures. Please do note that 230 °C is considered pretty high for PLA! Usually it should be in the range of <a href="https://rigid.ink/blogs/news/3... | <p>So I feel that I solved the problem thanks to a few sources. Thanks to 0scar for his quick response and help.</p>
<p>The problem was two fold. Mechanical problem causing blockage and slicer setting causing ripple.</p>
<ol>
<li>The PTFE tube wasn't pushed all the way in as far as it could go causing too much pressu... | 1,109 |
<p>I've got a css menu like this:</p>
<pre><code><ul>
<li><a>Item1</a></li>
<li><a>Item Two</a></li>
<li><a>Item C</a></li>
<li><a>A Rather Long Menu Item Down Here</a></li>
</ul>
</code></pre>
<p>I want ... | <p>This is remarkably simple: </p>
<pre><code><style>
ul {
float: left;
}
ul li a {
display: block;
white-space: nowrap;
border: 1px solid blue;
}
</style>
<ul>
<li><a>Item1</a></li>
<li><a>Item Two</a></li>
<li><a>... | <p>Certain amount of hacking to make it work in IE6, because width:auto never really worked properly. </p>
<p>I have seen some solutions to this problem using width:1px; overflow:visible;, which might work in this case, but best to do it in a conditional comment so as not to stuff up in "real" browsers, or use the h... | 38,468 |
<p>I am using MS AJAX ASP.NET Components (Calendar Extender) and I'm finding this problem.</p>
<p>Some weekdays are not being displayed....</p>
<p>I uploaded a picture so you can view exactly how it is being displayed...</p>
<p>The one on the right (calnder) in the picture is taken from microsoft's sample.</p>
<p>H... | <p>I have seen enough odd behavior when it comes to using MS "Ajax" objects across different browsers, to recommend not using the Calendar object if it can be avoided. There are enough client side (JS) libraries out there for calendars that are significantly better. </p>
<p>Why not try a <a href="http://marcgrabanski... | <p>You don't need to know much about javascript to use JQuery. It's more simple than Javascript and just a few lines of code you can use JQuery Calendar on your page.</p>
<p>But of course being good needs some efforts.</p>
| 47,727 |
<p>I want to display documents on my website. The server is hosted on a Debian machine. I was thinking I can allow the upload of support documents then use a Linux app or PHP app to convert the doc into PDF and display that in an HTML page. Are there any APIs or binaries that allow me to do this?</p>
| <p>If it is an office document, one option would be to use openoffice in headless mode. See here for a python script that shows how: <a href="http://www.oooninja.com/2008/02/batch-command-line-file-conversion-with.html" rel="nofollow noreferrer">http://www.oooninja.com/2008/02/batch-command-line-file-conversion-with.h... | <p>Pear has a PHP PDF class. See:<br>
<a href="http://pear.php.net/package/File_PDF" rel="nofollow noreferrer">http://pear.php.net/package/File_PDF</a><br>
<a href="http://pear.php.net/package/File_PDF/docs/latest/apidoc/File_PDF/File_PDF.html" rel="nofollow noreferrer">http://pear.php.net/package/File_PDF/docs/latest/... | 49,382 |
<p>I love programming with and for Windows Presentation Framework. Mostly I write browser-like apps using WPF and XAML.</p>
<p>But what really annoys me is the slowness of WPF. A simple page with only a few controls loads fast enough, but as soon as a page is a teeny weeny bit more complex, like containing a lot of da... | <ol>
<li><p><strong>How do you speed up WPF?</strong><br /><br>
Often after using one of the following profiling tools it is obvious what is causing my bottlenecks.</p>
<ul>
<li>If memory is the issue then I virtualize my data.</li>
<li>If render time is the issue then I virtualize the controls or simplify control tem... | <p>can you give more details? </p>
<p>I only noticed a slow performance when I use something like a listview or a grid that has some complexity. The solution is to simplify it. </p>
<p>Other than that I only noticed a slow performance when loading the app for the first time.</p>
<p>HTH</p>
| 27,390 |
<p>Im trying to do a dialog box with jquery. In this dialog box Im going to have terms and conditions. The problem is that the dialog box is only displayed for the FIRST TIME.</p>
<p>This is the code.</p>
<p>JavaScript:</p>
<pre><code>function showTOC()
{
$("#TOC").dialog({
modal: true,
overlay... | <p>Looks like there is an issue with the code you posted. Your function to display the T&C is referencing the wrong div id. You should consider assigning the showTOC function to the onclick attribute once the document is loaded as well:</p>
<pre><code>$(document).ready({
$('a.TOClink').click(function(){
... | <p>This is a little more concise and also allows you to have different dialog values etc based on different click events:</p>
<pre><code>$('#click_link').live("click",function() {
$("#popup").dialog({modal:true, width:500, height:800});
$("#popup").dialog("open");
return false;
});
</code></pre>
| 47,859 |
<p>I'm creating an installer for a website that uses a custom event log source. I would like our WiX based installer to create that event log source during installation.</p>
<p>Does anyone know the best way to do this using the WiX framework.</p>
| <p>Wix has out-of-the-box support for creating event log sources.</p>
<p>Assuming you use Wix 3, you first need to add a reference to WixUtilExtension to either your Votive project or the command line. You can then add an EventSource element under a component :</p>
<pre><code><Wix xmlns="http://schemas.microsoft.c... | <p>Just to save people some time - if you are trying to use the Application log and the .NET messages you can cut paste the below code:</p>
<pre><code><Util:EventSource
xmlns:Util="http://schemas.microsoft.com/wix/UtilExtension"
Name="ROOT Builder"
Log="Application"
EventMessageFile="%SystemRoot%\Microsoft.NET\... | 8,289 |
<p>I put together a class yesterday to do some useful task. I started alpha testing, and at some point realized I was adding alpha test related methods to the class itself. It hit me that they don't belong there. After a bit of head scratching I derived a test class from the base class that has access to the protect... | <p>One of the goals of unit testing is to verify the <i>interface</i> to your classes. This means that, generally speaking, you shouldn't be testing the dirty innards of your class. The unit test is supposed to interact with the public inputs and outputs of your class, and verify that the behaviour is as expected. You ... | <p>Those are good. I have usually also wanted the test class to not only be spearate from the original, but also in a complete different DLL/EXE, as well as testing the "real" compiled class from the "real" DLL/EXE into which it was compiled.</p>
<p>The one additional technique I've found is to re-define the class wi... | 44,455 |
<p>Re the recent question at <a href="https://stackoverflow.com/questions/361481/when-are-modal-dialogs-truly-necessary">when are modal dialogs truly necessary?</a>. WHY are modal dialog boxes evil? Is it because people don't read them anyway? Because they are often implemented so poorly? Something else?</p>
| <p>About half of the answers so far are addressing the flaws of <em>confirmation</em> dialogs, not of <em>modal</em> dialogs. While the vast majority of confirmation dialogs are modal, this does not mean that the two terms are synonymous.</p>
<p>A <em>mod</em>al dialog is one which puts the program into a specific <e... | <p>One of the reasons that I don't like them is because they are showing information in serial(one lot of information at a time) and not parallel(all the information you need to see at once), parallel will allow the user to choose what they want to look at where as in serial you are pretty much forcing them to pick an ... | 47,179 |
<p>We are in the process of upgrading our VS2008 to the new SP1, but noticed a change in the csproj files for something that we can't find information on. Seems that the ProductVersion in the csproj file is changed from:</p>
<pre><code><ProductVersion>9.0.21022</ProductVersion>
</code></pre>
<p>to</p>
<p... | <p>I think it's more likely to be the product version that <em>produced</em> the file rather than saying what it can be consumed by. I'd be very surprised to see the build version make any tangible difference.</p>
| <p>My coworker just got SP1 courtesy of of a ninja update from corporate IT (presumably I'll be getting it after rebooting). My RTM copy doesn't seem to care about the newer version string in all the csproj files.</p>
| 33,203 |
<p>I'm learning C++ and writing little programs as I go along. The following is one such program:</p>
<pre><code>// This program is intended to take any integer and convert to the
// corresponding signed char.
#include <iostream>
int main()
{
signed char sch = 0;
int n = 0;
while(true){
std::cin >... | <p>Basically your <code>cin</code> stream is in a fail state and thus returns immediately when you try to read it. Rewrite your example like this:</p>
<pre><code>#include <iostream>
int main()
{
signed char sch = 0;
int n = 0;
while(std::cin >> n){
sch = n;
std::cout << n << " --... | <p>One problem here is that a <code>char</code> has a size of one byte, and thus can only hold a number between -127 and 128. An <code>int</code> on the other hand, is typically 4 bytes, and can take on much larger values. Second problem is that you are inputting a value that is too large even for an <code>int</code>... | 33,431 |
<p>I have boiled down an issue I'm seeing in one of my applications to an incredibly simple reproduction sample. I need to know if there's something amiss or something I'm missing.</p>
<p>Anyway, below is the code. The behavior is that the code runs and steadily grows in memory until it crashes with an OutOfMemoryExce... | <p>I was able to reproduce your problem using the code you provided. Memory keeps growing because the Canvas objects are never released; a memory profiler indicates that the Dispatcher's ContextLayoutManager is holding on to them all (so that it can invoke OnRenderSizeChanged when necessary).</p>
<p>It seems that a si... | <p><strong>Edit 2:</strong> Obviously not the answer, but was part of the back-and-forth among answers and comments here, so I'm not deleting it.</p>
<p>The GC never gets a chance to collect those objects because your loop and its blocking calls never end, and therefore the message pump and events never get their turn... | 23,375 |
<p>SQL Server 2005.</p>
<p>I'm adding Foreign Key constraints to the database of an application that allegedly didn't need them. Naturally, the data has become unreliable and there are orphaned entries in the foreign key field.</p>
<p>Setup:<br/>
Two tables, TableUser and TableOrder.
TableUser has Primary Key 'UserI... | <p>Here's one way:</p>
<pre><code>select * from TableOrder where UserID not in (select UserID from TableUser);
</code></pre>
<p>There are many different ways to write this sort of query.</p>
| <p>There were no FK Constraints in the tables to begin with. The were used like FK and PK but not coded -- the belief was that they were unnecessary overhead. So we have all the columns, but no coded constraints. When I went to put them in so that they would be enforced, I discovered that there were lots of violatio... | 32,422 |
<p>Sample data:
!!Part|123456,ABCDEF,ABC132!!</p>
<p>The comma delimited list can be any number of any combination of alphas and numbers </p>
<p>I want a regex to match the entries in the comma separated list:</p>
<p>What I have is:
!!PART\|(\w+)(?:,{1}(\w+))*!!</p>
<p>Which seems to do the job, the thing is I want... | <p>You can either use split:</p>
<pre><code>string csv = tag.Substring(7, tag.Length - 9);
string[] values = csv.Split(new char[] { ',' });
</code></pre>
<p>Or a regex:</p>
<pre><code>Regex csvRegex = new Regex(@"!!Part\|(?:(?<value>\w+),?)+!!");
List<string> valuesRegex = new List<string>();
forea... | <p>The following code</p>
<pre><code>string testString = "!!Part|123456,ABCDEF,ABC132!!";
foreach(string component in testString.Split("|!,".ToCharArray(),StringSplitOptions.RemoveEmptyEntries) )
{
Console.WriteLine(component);
}
</code></pre>
<p>will give the following output</p>
<pre><code>Part
123456
ABCDEF
A... | 48,089 |
<p>I am getting the following error when I post back a page from the client-side. I have JavaScript code that modifies an asp:ListBox on the client side.</p>
<p>How do we fix this?</p>
<p>Error details below:</p>
<pre><code>Server Error in '/XXX' Application.
--------------------------------------------------------... | <p>The problem is that ASP.NET does not get to know about this extra or removed listitem.
You got an number of options (listed below):</p>
<ul>
<li>Disable eventvalidation (bad idea, because you lose a little of security that come with very little cost).</li>
<li>Use ASP.NET Ajax UpdatePanel. (Put the listbox in the U... | <p>Check you data of binded your controls. Some invalid data corrupt ValidateEvent.</p>
| 28,336 |
<p>On my current project, I came across our master DB script. Taking a closer look at it, I noticed that all of our original primary keys have a data type of <strong>numeric(38,0)</strong>
We are currently running SQL Server 2005 as our primary DB platform.</p>
<p>For a little context, we support both Oracle and SQL S... | <p>Well, you <em>are</em> spending more data to store numbers that you will never really reach.</p>
<p>bigint goes up to 9,223,372,036,854,775,807 in 8 Bytes</p>
<p>int goes up to 2,147,483,647 in 4 bytes</p>
<p>A NUMERIC(38,0) is going to take, if I am doing the math right, 17 bytes.</p>
<p>Not a huge difference, ... | <p>Barring the storage considerations and some initial confusion from future DBAs, I don't see any reason why NUMERIC(38,0) would be a bad idea. You're allowing for up to 9.99 x 10^38 records in your table, which you will certainly never reach. My quick digging into this didn't turn up any glaring reason not to use it.... | 36,316 |
<p>Using Awk I want to match the <em>entire</em> record using a regular expression. By default the regular expression matching is for parts of a record.</p>
<p>The ideal solution would:</p>
<ul>
<li>Be general for all fields, regardless of the field separator used.</li>
<li>Not treat the entire input as a single fiel... | <p>You just need to add a beginning and end anchor to your regex:</p>
<pre><code>/^[01]*_[01]*$/ { print $0 }
</code></pre>
| <pre><code>$ gawk '/^[01]*_[01]*$/' indata.txt
1010_
</code></pre>
| 45,002 |
<p>I was looking at the Java code for <code>LinkedList</code> and noticed that it made use of a static nested class, <code>Entry</code>.</p>
<pre><code>public class LinkedList<E> ... {
...
private static class Entry<E> { ... }
}
</code></pre>
<p>What is the reason for using a static nested class, rathe... | <p>The Sun page you link to has some key differences between the two:</p>
<blockquote>
<p>A nested class is a member of its enclosing class. Non-static nested classes (inner classes) have access to other members of the enclosing class, even if they are declared private. Static nested classes do not have access to ot... | <p>Adavantage of inner class--</p>
<ol>
<li>one time use</li>
<li>supports and improves encapsulation</li>
<li>readibility </li>
<li>private field access</li>
</ol>
<p>Without existing of outer class inner class will not exist.</p>
<pre><code>class car{
class wheel{
}
}
</code></pre>
<p>There are four type... | 31,600 |
<p>I am wondering any efficient way to hide our Silverlight code. I know there are some obfuscators available but it looks like people can hack that too. Anybody have any success on this front?</p>
| <p>Pragma No-Cache on the page hosting the silverlight application will prevent the the browser from caching the xap, instead it will read it by streaming from the web server. That will make it harder for peeps to get the xap. Obfuscation will make it harder still.</p>
<p>Also make sure the app is hosted in https, h... | <p>You cannot hide (at least not non-trivially) XAP files. But you can obfuscate them. Obfuscation is not a definitive answer, but its a start and can give pretty good protection. </p>
| 14,105 |
<p>I have Visual Studio 2008 and the Windows SDK for Windows Server 2008 and .NET Framework 3.5
installed. I believe that is the latest platform SDK.</p>
<p>I'm trying to build a signed dll to be installed in SxS.
All the tutorials explain to use a tool called pktextract.exe which is part of the SDK, but I can't seem ... | <p>I have a visual Basic program with Visual Studio 2008 that uses an Access 2007 database and was receiving the same error. I found some threads that advised changing the advanced compile configuration to x86 found in the programs properties if you're running a 64 bit system. So far I haven't had any problems with my ... | <p>I've got the same error on a fully updated Windows Vista Family 64bit with a .NET application that I've compiled to 32 bit only - the program is installed in the programx86 folder on 64 bit machines. It fails with this error message even with 2007 access database provider installed, with/wiothout the SP2 of the sam... | 29,516 |
<p>I have two collections which have property <code>Email</code> in both collections. I need to get a list of the items in the first list where <code>Email</code> does not exist in the second list. With SQL I would just use "not in", but I do not know the equivalent in LINQ. How is that done?</p>
<p>So far I have a jo... | <p>I don't know if this will help you but..</p>
<pre><code>NorthwindDataContext dc = new NorthwindDataContext();
dc.Log = Console.Out;
var query =
from c in dc.Customers
where !(from o in dc.Orders
select o.CustomerID)
.Contains(c.CustomerID)
select c;
foreac... | <p>I did not test this with <a href="http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework#LINQ_to_Entities" rel="nofollow">LINQ to Entities</a>:</p>
<pre><code>NorthwindDataContext dc = new NorthwindDataContext();
dc.Log = Console.Out;
var query =
from c in dc.Customers
where !dc.Orders.An... | 22,224 |
<p>I really enjoy having "pretty" URLs (e.g. <code>/Products/Edit/1</code> instead of <code>/products.aspx?productID=1</code>) but I'm at a loss on how to do this for pages that let you search by a large number of variables.</p>
<p>For instance, let's say you have a page that lets a user search for all products of a p... | <p>You can get the "pretty" urls, but not through the prettiest of means..</p>
<p>You can set up your url to be something like:</p>
<pre><code>/Products/Search/Type/{producttype}/Name_{name}/Address_{address}
</code></pre>
<p>Then a <a href="http://www.workingwith.me.uk/articles/scripting/mod_rewrite" rel="nofollow ... | <p>You can find an answer about <strong>Routing in .NET</strong> here:</p>
<p><a href="https://stackoverflow.com/questions/125826/what-is-the-best-method-to-achieve-dynamic-url-rewriting-in-aspnet#126426">What is the best method to achieve dynamic URL Rewriting in ASP.Net?</a></p>
<p>There you can find different reso... | 15,664 |
<p>EDIT: It seems to be something with having the two queues in the same schema.</p>
<p>I’m trying to experiment with queue propagation but I’m not seeing records in the destination queue. But that could easily be because I don’t have all the pieces in place.</p>
<p>Does anyone have a test case they could post? I’ll ... | <p>Perhaps you need to enable it?</p>
<pre><code>DBMS_AQADM.ENABLE_PROPAGATION_SCHEDULE(queue_name => 'Test_Q');
</code></pre>
| <p>You might want to read thru this Tom Kyte thread on AQ:</p>
<p><a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:8760267539329#tom1246632800346467977" rel="nofollow noreferrer">http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:8760267539329#tom1246632800346467977</a></p>... | 26,192 |
<p>How does one dynamically load a new report from an embedded resource? I have created a reporting project that contains a report as an embedded resource. I added a second report file and use the following code to switch reports:</p>
<pre><code>this.reportViewer1.LocalReport.ReportEmbeddedResource = "ReportsApplicati... | <p>The answer: you have to call </p>
<pre><code><ReportViewer>.Reset();
</code></pre>
<p>prior to changing the value of ReportEmbeddedResource or calling LoadReportDefinition.</p>
<p>After you do so, you'll also have to call </p>
<pre><code><ReportViewer>.LocalReport.DataSources.Add( ... );
</code></pre... | <p>a better way to reference your reports is by using the default value of ReportEmbeddedResource, <strong>don't hard code</strong> it just change the name of the report.</p>
<pre><code>//choose which report to load
string reportEmbeddedResource = this.orderReportViewer.LocalReport.ReportEmbeddedResource;
... | 19,711 |
<p>I am working on a project where I search through a large text file (large is relative, file size is about 1 Gig) for a piece of data. I am looking for a token and I want a dollar value immediately after that token. For example,</p>
<p>this is the token 9,999,999.99</p>
<p>So here's is how I am approaching th... | <p>I think you've got the right idea in chunking the file. You may want to read chunks in at line breaks rather than a set number of bytes, though. In your current implementation, if the token lies on a 1000 byte boundary it could get cut in half, preventing you from finding it. The same thing could cause the data t... | <p>If you're going to use chunks, it would be wise to use blocks which are multiples of 512 bytes long, and seek on a 512 byte alignment, because that will tend to be more efficient in accessing the disk (which ultimately will be in 512 byte blocks).</p>
<p>There may be other granularities even better than that, but 5... | 31,262 |
<p>My team is developing a large java application which extensively queries a MySQL database (in different classes and modules).
I'd like to known if there is a pattern that allows me to be notified at compile time if there are queries that refer to a wrong table structure (for instance if I remove or add a field on a... | <p>There's an open-source tool called DODS (Data Object Design Studio) that could do what you want. The DODS tool was originally part of the Enhydra Java application server project, and since the company backing that project went kablooey in 2002, DODS has been hosted and maintained at ObjectWeb. Anyway, it's open-so... | <p>I would say that the simple answer is "no". The more complete answer is "yes, to some degree", depending on your willingness to jump through hoops.</p>
<p>Unless you have a java representation of your database schema you will never be able to get compile time notification if your queries are wrong (these classes ca... | 48,560 |
<p>Was wondering if it is recomended to pass a database connection object around(to other modules) or let the method (in the other module) take care of setting it up. I am leaning toward letting the method set it up as to not have to check the state of the connection before using it, and just having the caller pass an... | <p>Personally I like to use tightly scoped connections; open them late, use them, and close them (in a "using" block, all within the local method). Connection pooling will deal with re-using the connection in most cases, so there is no real overhead in this approach.</p>
<p>The main advantage in passing connections <e... | <p>I would use the web.config</p>
<pre><code><configuration>
<connectionStrings>
<add name="conn1" providerName="System.Data.SqlClient" connectionString="string here" />
<add name="conn2" providerName="System.Data.SqlClient" connectionString="string here" />
</connect... | 31,342 |
<p>I am working on a design spec for a new application that will be heavily workflow driven.</p>
<p>Before I re-invent the wheel, is there a decent lightweight workflow engine that plugs into ASP.NET already around?</p>
<p>Basically, I'm looking for something that handles moving through a defined set of workflow page... | <p>Is the workflow dynamic, or static?</p>
<p>If the workflows are simple, you could roll your own workflow engine.
In certain situations, it can be fairly simple, and just a couple of data tables to handle the rules, processing and state.</p>
<p>Alot of workflow engines are built for large scale processing (credit c... | <p>I don't think there is a workflow engine that will automatically handle state for you, but if you are moving through a set of pages like a process such as checkout on an ecommerce site, perhaps the ASP.NET wizard control could help you?</p>
| 40,768 |
<p>I'd like to know how to - if even possible - reflect what method calls are executed inside the method during execution. I'm especially interested in either external method calls (that is, methods in other classes) or calling some specific method like getDatabaseConnection().</p>
<p>My intention would be to monitor ... | <p><a href="http://www.eclipse.org/aspectj/" rel="nofollow noreferrer">Aspect J</a> will solve your problem.</p>
<p>Try to define a pointcut like this: </p>
<pre><code>pointcut profilling(): execution(public * *(..)) && (
within(com.myPackage..*) ||
</code></pre>
<p>In this way you will catch all... | <p>I'd expect <a href="http://jakarta.apache.org/bcel/index.html" rel="nofollow noreferrer">BCEL</a> to be able to do this. From the web site:</p>
<blockquote>
<p>The Byte Code Engineering Library is
intended to give users a convenient
possibility to analyze, create, and
manipulate (binary) Java class files
... | 25,985 |
<p>Any idea anyone? Is it possible that we specify the name of the form input field?
How to go about doing that?</p>
| <p>More generally, all JSF components have an ID.
If you don't provide one, JSF will create an automatic ID, using the format j<code>_</code>idXXX (<em>XXX</em> is a incremented number).</p>
<p>Some components implement the javax.faces.component.NamingContainer interface, in particular <code><h:form></code>.
Thi... | <p>For most pages which contain a view, form and some components, the clientID will be the colon seperated string contained the form-id and component-id. Example:</p>
<p>
</p>
<p>The input text client ID would be "myForm:myInputText". If you have nested within a subview, then that will be the first thing... | 33,230 |
<p>When I try to build my project I get the following message in the build window :</p>
<p><strong>========== Build: 0 succeeded or up-to-date, 0 failed, 1 skipped ==========</strong></p>
<p>I tried rebuilding , then building again , but it doesn't help . Is there a way to view more detailed messages ? The "skipped" ... | <p>Check with the configuration manager like CMS said and make sure that you have the right platform set. A lot of the time when you use something like the MS Application Blocks the default platform is set to Itanium.</p>
| <p>I generally run into that when the PC is low on resources (RAM), after closing things the build runs fine.</p>
| 47,738 |
<p>What do you think is the best way for obtaining the results of the work of a thread? Imagine a Thread which does some calculations, how do you warn the main program the calculations are done?</p>
<p>You could poll every X milliseconds for some public variable called "job finished" or something by the way, ... | <p>Don't use low-level constructs such as threads, unless you absolutely need the power and flexibility.</p>
<p>You can use a <a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html" rel="noreferrer">ExecutorService</a> such as the <a href="http://java.sun.com/javase/6/docs/api/java/ut... | <p>As noted by saua: use the constructs offered by java.util.concurrent. If you're stuck with a pre 1.5 (or 5.0) JRE, you ,might resort to kind of rolling your own, but you're still better of by using a backport: <a href="http://backport-jsr166.sourceforge.net/" rel="nofollow noreferrer">http://backport-jsr166.sourcefo... | 45,926 |
<p>I have a silverlight 2 beta 2 application that accesses a WCF web service. Because of this, it currently can only use basicHttp binding. The webservice will return fairly large amounts of XML data. This seems fairly wasteful from a bandwidth usage standpoint as the response, if zipped, would be smaller by a facto... | <p>I didn't see a native way for WCF to do compression when doing a WCF project recently. I just used the System.IO.Compression namespace and made a quick compressor. Here's the code i used</p>
<pre><code>public static class CompressedSerializer
{
/// <summary>
/// Decompresses the specified compressed d... | <p>It should also be noted that you may need to add the mime type to <code>applicationHost.config</code> under <code><httpCompression><dynamicTypes></code> section in addition to enabling compression for the site:</p>
<pre><code><add mimeType="application/soap+msbin1" enabled="true" />
</code></pre>
... | 3,129 |
<p>In a C++ project, compilation dependencies can make a software project difficult to maintain. What are some of the best practices for limiting dependencies, both within a module and across modules?</p>
| <ul>
<li><a href="http://en.wikipedia.org/wiki/Forward_declaration" rel="noreferrer">Forward Declarations</a></li>
<li><a href="http://en.wikipedia.org/wiki/Abstract_interface" rel="noreferrer">Abstract Interfaces</a></li>
<li><a href="http://en.wikipedia.org/wiki/Opaque_pointer" rel="noreferrer">The Pimpl Idiom</a></l... | <p>I think you need to be very careful and considerate about this. Generally, you can limit dependencies by separating the code and using abstract interfaces (eg: function pointers or an object equivalent), but separation generally adds fragility. For example, you can call a module through a generic abstract interface ... | 22,848 |
<p>How would you reference the models (Accord, CRV, Prius, etc) in this structure?
Is this a bad structure to be able to extract the makes...then use a make to get the models...then use the model to get the options?</p>
<pre><code>var cars = [
{
"makes" : "Honda",
"models" : [
{'Ac... | <p>The structure:</p>
<pre><code>var cars = [
{ name: 'Honda', models: [
{ name: 'Accord', features: ['2dr', '4dr'] },
{ name: 'CRV', features: ['2dr', 'Hatchback'] },
{ name: 'Pilot', features: ['base', 'superDuper'] }
]},
{ name: 'Toyota', models: [
... | <p>If I were you, I wouldn't lump all your data into one big multidimensional array/object literal mess like that. I'd encapsulate each object and use methods to access the data. It'll mess with your brain a lot less.</p>
| 21,817 |
<p>I have applied a <code>Formatter</code> to a <code>JFormattedTextField</code> using a <code>FormatterFactory</code>, when a user clicks into the text field I want to select the contents. </p>
<p>A focus listener does not work as expected because the formatter gets called, which eventually causes the value to be res... | <p>Quick and dirty workaround is to use
EventQueue.invokeLater from your focusListener.</p>
<pre><code> EventQueue.invokeLater(new Runnable(){
public void run() { yourTextField.selectAll();}
});
</code></pre>
| <p>which jdk are you using - any chance this is a bug in it?</p>
| 20,823 |
<p>What's the best way to identify if a string (is or) might be UTF-8 encoded? The Win32 API <code>IsTextUnicode</code> isn't of much help here. Also, the string will not have an UTF-8 BOM, so that cannot be checked for. And, yes, I know that only characters above the ASCII range are encoded with more than 1 byte.</p>
| <p><a href="http://www.mozilla.org/projects/intl/chardet.html" rel="nofollow noreferrer">chardet</a> character set detection developed by Mozilla used in FireFox. <a href="http://mxr.mozilla.org/mozilla/source/intl/chardet/" rel="nofollow noreferrer">Source code</a></p>
<p><a href="http://jchardet.sourceforge.net/" re... | <p>As an add-on to the previous <a href="https://stackoverflow.com/a/19308773/2215591">answer</a> about the Win32 mlang DetectInputCodepage() API, here's how to call it in C:</p>
<pre><code>#include <Mlang.h>
#include <objbase.h>
#pragma comment(lib, "ole32.lib")
HRESULT hr;
IMultiLanguage2 *pML;
char *ps... | 49,407 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.