instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>From some forum I came to know that Multiple database support is added in Django at lower level, but the higher level apis are not added yet.</p>
<p>Can anyone please tell me how one can achieve multiple database connections in Django.</p>
<p>Does anyone have any idea by when Django will fully/officially support M... | <p>If you simply need multiple connections, you can do something like this:</p>
<pre><code>from django.db import load_backend
myBackend = load_backend('postgresql_psycopg2') # or 'mysql', 'sqlite3', 'oracle'
myConnection = myBackend.DatabaseWrapper({
'DATABASE_HOST': '192.168.1.1',
'DATABASE_NAME': 'my_databas... | <p>I think you will have to resort to "raw sql" .. kinda thing .. <br>
look here: <a href="http://docs.djangoproject.com/en/dev/topics/db/sql/" rel="nofollow noreferrer">http://docs.djangoproject.com/en/dev/topics/db/sql/</a></p>
<p>you need a "connection" to your other database,
if you look at <code>django/db/__init... | 33,638 |
<p>I'm working on a web application that needs to prints silently -- that is without user involvement. What's the best way to accomplish this? It doesn't like it can be done with strictly with Javascript, nor Flash and/or AIR. The closest I've seen involves a Java applet.</p>
<p>I can understand why it would a Bad ... | <p>Here’s what you need to do to enable Firefox immediately print without showing the print preferences dialog box.</p>
<ol>
<li><p>Type about:config at Firefox’s location bar and hit Enter.</p></li>
<li><p>Right click at anywhere on the page and select New > Boolean</p></li>
<li><p>Enter the preference name as print.... | <p>I have to be honest, I am kinda thinking out loud here.. But could it not be done with an applet or some sort (be it Java or whatever) that is given trusted permissions (such as that within the Intranet zone) or something?</p>
<p>May be worth investigating what permissions can be given to each zone?</p>
<p>Follow... | 4,193 |
<p>One of the items in the <a href="http://www.joelonsoftware.com/articles/fog0000000043.html" rel="noreferrer">Joel Test</a> is that a project/company should have a specification.</p>
<p>I'm wondering what makes a spec good. Some companies will write volumes of useless specification that no one ever reads, others wil... | <p>The best spec is one that:</p>
<ol>
<li>Exists</li>
<li>Describes WHAT, not HOW (no solutions)</li>
<li>Can be interpreted in as few ways as possible</li>
<li>Is widely-distributed</li>
<li>Is agreed-upon as being THE spec by all parties involved</li>
<li>Is concise</li>
<li>Is consistent</li>
<li>Is updated regula... | <p>I think writing "Use cases" should save you bunch of pages</p>
| 49,703 |
<p>I'm fairly new to ASP.NET MVC, and I'm having a little trouble with scripts... in particular, I want to use jQuery in most pages, so it makes sense to put it in the master page. However, if I do (from my <code>~/Views/Shared/Site.Master</code>):</p>
<pre><code><script src="../../Scripts/jquery-1.2.6.js" type="te... | <p>I have a AppHelper class with some methods for adding script references: </p>
<pre><code>public static string ReferenceScript(string scriptFile)
{
var filePath = VirtualPathUtility.ToAbsolute("~/Scripts/" + scriptFile);
return "<script type=\"text/javascript\" src=\"" + filePath + "\"></script>"... | <p>Our applications are deployed using virtual directories, and we have had some issues with other answers mentioned here (not resolving the path correctly). One way that worked well, (not the only way mind you), was to use this:</p>
<pre><code><script src="<%=Request.ApplicationPath%>/Web/AppName/JavaScript... | 45,222 |
<p>I am trying to build an OLAP datasource from a bunch of binary files, and our current model just isn't working. We are using SSAS as our analysis / reporting model for our results, but aren't able to get the performance we want out of SQL. </p>
<p>Our main constraints are:</p>
<ol>
<li><p>The database is very la... | <p>If you need a low latency cube (i.e. one showing up-to-date data) the canonical architecture for such things is thus:</p>
<ul>
<li>Incrementally load a fact table with changed data from your source.</li>
<li>Build a partitioned cube with a process that generates new partitions every day or some other suitable perio... | <p>I haven't had any luck yet. We are going the route of either building our own Data Provider and building add-ins for excel to emulate the olap behavior, OR using CLR table-valued functions to emulate our data-sources and build the cube off of that. The one attempt I took at the CLR stuff had horrible performance a... | 16,188 |
<p>I am trying to write a simple networked chat program in Java. I have almost no networking experience. I was wondering what resources I should begin looking at (beside here of course).</p>
<p>Sticking with the core Java API would be best for now.</p>
| <p>I found a great tutorial into networking and java from sun's own website: <a href="http://download.oracle.com/javase/tutorial/networking/TOC.html" rel="noreferrer">http://download.oracle.com/javase/tutorial/networking/TOC.html</a></p>
<p>The socket section even has you write a mini client / server chat demo.</p>
| <p>Google is your friend. Search for "java socket programming tutorial" or something like that and you'll get lots of results, including the one suggested by zxcv as well as these:</p>
<p><a href="http://www.javaworld.com/javaworld/jw-12-1996/jw-12-sockets.html" rel="nofollow noreferrer">http://www.javaworld.com/java... | 12,064 |
<p>I'd like to implement a <a href="http://en.wikipedia.org/wiki/Bloom_filter" rel="noreferrer">bloom filter</a> using MySQL (other a suggested alternative).</p>
<p>The problem is as follows:</p>
<p>Suppose I have a table that stores 8 bit integers, with these following values:</p>
<pre><code>1: 10011010
2: 00110101... | <p>Create a table with int column (use <a href="http://dev.mysql.com/doc/refman/5.0/en/integer-types.html" rel="noreferrer">this link</a> to pick the right int size). Don't store numbers as a sequence of 0 and 1. </p>
<p>For your data it will look like this:</p>
<pre><code>number
154
53
148
38
59
106
</code></pre>
... | <p>For up to 64 bits, you can use a MySQL integer type, like tinyint (8b), int (16b), mediumint (24b) and bigint (64b). Use the unsigned variants.</p>
<p>Above 64b, use the MySQL (VAR)BINARY type. Those are raw byte buffers.
For example BINARY(16) is good for 128 bits.</p>
<p>To prevent table scans you need an index ... | 47,092 |
<p>Lots of people talk about writing tests for their code before they start writing their code. This practice is generally known as Test Driven Development or TDD for short. What benefits do I gain from writing software this way? How do I get started with this practice?</p>
| <p>There are a lot of benefits:</p>
<ul>
<li>You get immediate feedback on if your code is working, so you can find bugs faster</li>
<li>By seeing the test go from red to green, you know that you have both a working regression test, and working code</li>
<li>You gain confidence to refactor existing code, which means y... | <p>In my opinion, the single greatest thing is that it clearly allows you to see if your code does what it is supposed to. This may seem obvious, but it is super easy to run astray of your original goals, as I have found out in the past :p</p>
| 2,630 |
<p>For a stylesheet I'm writing (actually for a set of them, each generating a different output format), I have the need to evaluate whether a certain value is present in a list of values. In this case, the value being tested is taken from an element's attribute. The list it is to be tested against comes from the invoc... | <p>Actually, using XPath string functions is the right way to do it. All you have to make sure is that you test for the delimiters as well:</p>
<pre><code>contains(concat(',' $list, ','), concat(',', $value, ','))
</code></pre>
<p>would return a Boolean value. Or you might use one of these:</p>
<pre><code>substring-... | <p>In addition to the XPath 1.0 solution provided by Tomalak,
<br />
<br />
<strong>Using XPath 2.0</strong> one can tokenize the list of values:</p>
<p> <strong><code>exists(tokenize($list, ',')[. = $value])</code></strong></p>
<p>evaluates to <code>true()</code> if and only if <code>$value</c... | 46,423 |
<p>I want to create a string that spans multiple lines to assign to a Label Caption property. How is this done in Delphi?</p>
| <p>In the System.pas (which automatically gets used) the following is defined:</p>
<pre><code>const
sLineBreak = {$IFDEF LINUX} AnsiChar(#10) {$ENDIF}
{$IFDEF MSWINDOWS} AnsiString(#13#10) {$ENDIF};
</code></pre>
<p>This is from Delphi 2009 (notice the use of AnsiChar and AnsiString). (Line wrap ad... | <p>Sometimes I don't want to clutter up my code space, especially for a static label. To just have it defined with the form, enter the label text on the form, then right click anywhere on the same form. Choose "View as Text". You will now see all of the objects as designed, but as text only. Scroll down or search f... | 31,737 |
<p>I have inherited a monster.</p>
<p>It is masquerading as a .NET 1.1 application processes text files that conform to Healthcare Claim Payment (ANSI 835) standards, but it's a monster. The information being processed relates to healthcare claims, EOBs, and reimbursements. These files consist of records that have a... | <p>I just had some legacy code at work this week that was similar (although not as dire) as what you are describing.</p>
<p>There is no one thing that will get you out of this. The <a href="http://en.wikipedia.org/wiki/Finite_state_machine" rel="noreferrer">state machine</a> might be the final form your code takes, bu... | <p>Judging by the description, a state machine might be the best way to deal with it. Have an enum variable to store the current state, and implement the processing as a loop over the records, with a switch or if statements to select the action to take based on the current state and the input data. You can also easily ... | 13,106 |
<p>In a user defined wizard page, is there a way to capture change or focus events of the controls? I want to provide an immediate feedback on user input in some dropdowns (e.g. a message box)</p>
| <p>Took me some time to work it out, but after being pointed in the right direction by Otherside, I finally got it (works for version 5.2):</p>
<pre><code>[Code]
var
MyCustomPage : TWizardPage;
procedure MyEditField_OnChange(Sender: TObject);
begin
MsgBox('TEST', mbError, MB_OK);
end;
function MyCustomPag... | <p>Since the scripting in innosetup is loosely based on Delphi, the controls should have some events like <code>OnEnter</code> (= control got focus) and <code>OnExit</code> (= control lost focus). You can assign procedures to these events, something like this:
ComboBox.OnExit := ComboBoxExit;</p>
<pre><code>proce... | 16,858 |
<p>What is WCF in simple terms?</p>
<p>It's hard to distill the meaning from <a href="http://en.wikipedia.org/wiki/Windows_Communication_Foundation" rel="noreferrer">the Wikipedia page</a>.</p>
| <p>WCF - <a href="http://msdn.microsoft.com/en-us/library/ms731082.aspx" rel="noreferrer">Windows Communication Framework</a> - is Microsoft's framework to make inter-process communication easier. It let's you do this communication through various means, plain old asmx web services, Remoting, MS Message Queuing, and a ... | <p>WCF is Microsoft's new .NET do-all extensible communications framework meant to replace functionality previously available in <a href="http://en.wikipedia.org/wiki/Distributed_Component_Object_Model" rel="nofollow noreferrer">DCOM</a>, <a href="http://en.wikipedia.org/wiki/.NET_Remoting" rel="nofollow noreferrer">.N... | 6,430 |
<p>I have a solution which contains many class libraries and an ASP .NET website which references those assemblies.</p>
<p>When I build the solution from within the IDE, all assemblies referenced by the website end up in the bin directory. Great!</p>
<p>When I use MsBuild from the command line, all the referenced ass... | <p>I have found various references to this problem scattered around the Net - and I've just come across it myself. Apparently MSBuild on the command line isn't as good at tracing chains of dependencies as the IDE is.</p>
<p>So as I understand it, if A depends on B which depends on C, The command line may not realize ... | <p>If I recall, MSBuild dosen't copy the referenced assemblies.
I've posted a "solution" a while ago:
<a href="http://www.brunofigueiredo.com/post/Issue-Tracker-part-IV-The-Build-Enviroment-using-MSBuild-(or-NAnt).aspx" rel="nofollow noreferrer">http://www.brunofigueiredo.com/post/Issue-Tracker-part-IV-The-Build-Enviro... | 34,260 |
<p>Do you put unit tests in the same project for convenience or do you put them in a separate assembly?</p>
<p>If you put them in a separate assembly like we do, we end up with a number of extra projects in the solution. It's great for unit testing while coding but how do you release the application without all of th... | <p>In my opinion, unit tests should be placed in a separate assembly from production code. Here are just a few cons of placing unit tests in the same assembly or assemblies as production code are:</p>
<ol>
<li>Unit tests get shipped with production code. The only thing shipped with product code is production code.</... | <blockquote>
<p>Do you put unit tests in the same project for convenience or do you put them in a separate assembly?</p>
</blockquote>
<p><strong>No, never, ever do that</strong>. The consumers of your component cannot separate your test code from your production code and therefore, they cannot use it for anything non-... | 45,170 |
<p>I am writing a program in Python that will act as a server and accept data from a client, is it a good idea to impose a hard limit as to the amount of data, if so why?</p>
<p>More info:
So certain chat programs limit the amount of text one can send per send (i.e. per time user presses send) so the question comes do... | <p>Most likely you've seen code which protects against "extra" incoming data. This is often due to the possibility of buffer overruns, where the extra data being copied into memory overruns the pre-allocated array and overwrites executable code with attacker code. Code written in languages like C typically has a lot of... | <p>I don't know what your actual application is, however, setting a hard limit on the total amount of data that a client can send could be useful in reducing your exposure to denial of service attacks, e.g. client connects and sends 100MB of data which could load your application unacceptably.</p>
<p>But it really dep... | 24,927 |
<p>From time to time I browse the web and look for interesting algorithms and datastructures to put into my bag of tricks. A year ago I came across the <a href="http://en.wikipedia.org/wiki/Soft_heap" rel="noreferrer">Soft Heap</a> data-structure and learned about near sorting.</p>
<p>The idea behind this is that it's... | <p>This is a total flying guess, but given the inherent subjectivity of "relevance" measures when sorting search results, I'd venture that it doesn't really matter whether or not they're perfectly sorted. The same could be said for recommendations. If you can somehow arrange that every other part of your algorithm for ... | <p>O(n log n) is already pretty fast. I don't think anyone would ever <em>start out</em> using a near-sort algorithm. You would start out with code that just does a complete sort (since your programming language of choice likely provides a <code>sort</code> function and not a <code>nearsort</code> function), and when y... | 17,596 |
<p>What are the best file permission settings for PHP scripts? Any suggestions on ways to figure out the minimum required permissions?</p>
| <p>You could do this fairly simply with refspecs.</p>
<pre><code>git pull origin
git diff @{1}..
</code></pre>
<p>That will give you a diff of the current branch as it existed before and after the pull. Note that if the pull doesn't actually update the current branch, the diff will give you the wrong results. Another... | <p>If you drop this into your bash profile you'll be able to run grin (git remote incoming) and grout (git remote outgoing) to see diffs of commits that are incoming and outgoing for origin master.</p>
<pre><code>function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/... | 8,611 |
<p>In XNA, how do I load in a texture or mesh from a file without using the content pipeline?</p>
| <p>I believe Texture2D.FromFile(); is what you are looking for.</p>
<p>It does not look like you can do this with a Model though.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.texture2d.fromfile.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/microsof... | <p>If you really want to load an Xna <code>Xna.Framework.Graphics.Model</code> on PC without the content pipeline (eg for user generated content), there is a way. I used SlimDX to load an X file, and avoid the parsing code, the some reflection tricks to instantiate the Model (it is sealed and has a private constructor ... | 12,115 |
<p>In PowerShell I'm reading in a text file. I'm then doing a Foreach-Object over the text file and am only interested in the lines that do NOT contain strings that are in <code>$arrayOfStringsNotInterestedIn</code>.</p>
<p>What is the syntax for this?</p>
<pre><code> Get-Content $filename | Foreach-Object {$_}
</c... | <p>If $arrayofStringsNotInterestedIn is an [array] you should use -notcontains:</p>
<pre><code>Get-Content $FileName | foreach-object { `
if ($arrayofStringsNotInterestedIn -notcontains $_) { $) }
</code></pre>
<p>or better (IMO)</p>
<pre><code>Get-Content $FileName | where { $arrayofStringsNotInterestedIn -notco... | <p>To exclude the lines that contain any of the strings in $arrayOfStringsNotInterestedIn, you should use:</p>
<pre><code>(Get-Content $FileName) -notmatch [String]::Join('|',$arrayofStringsNotInterestedIn)
</code></pre>
<p>The code proposed by Chris only works if $arrayofStringsNotInterestedIn contains the full line... | 10,058 |
<p>What is the regular expression to match strings (in this case, file names) that start with 'Run' and have a filename extension of '.py'?</p>
<p>The regular expression should match any of the following:</p>
<pre><code>RunFoo.py
RunBar.py
Run42.py
</code></pre>
<p>It should not match:</p>
<pre><code>myRunFoo.py
Ru... | <p>For a regular expression, you would use:</p>
<pre><code>re.match(r'Run.*\.py$')
</code></pre>
<p>A quick explanation:</p>
<ul>
<li>. means match any character.</li>
<li>* means match any repetition of the previous character (hence .* means any sequence of chars)</li>
<li>\ is an escape to escape the explicit dot<... | <p>This probably doesn't fully comply with file-naming standards, but here it goes:</p>
<pre><code>/^Run[\w]*?\.py$/
</code></pre>
| 22,415 |
<p>When using IE, you cannot put an absolutely positioned div over a select input element. That's because the select element is considered an ActiveX object and is on top of every HTML element in the page.</p>
<p>I already saw people hiding selects when opening a popup div, that leads to pretty bad user experience hav... | <p>I don't know anything better than an Iframe</p>
<p>But it does occur to me that this could be added in JS by looking for a couple of variables </p>
<ol>
<li>IE 6</li>
<li>A high Z-Index (you tend to have to set a z-index if you are floating a div over)</li>
<li>A box element</li>
</ol>
<p>Then a script that looks... | <p>I don't think there is. I've tried to solve this problem at my job. Hiding the select control was the best we could come up with (being a corporate shop with a captive audience, user experience doesn't usually factor into the PM's decisions). </p>
<p>From what I could gather online when looking for a solution, ther... | 2,949 |
<p>It's a part of larger code base, which forces -Werror on gcc. This warning is generated in a third party code that shouldn't be changed (and I actually know how to fix it), but I can disable specific warnings. This time man gcc failed me, so please, let some gcc master enlighten me. TIA.</p>
| <p>It is the <em>-Wno-unused-value</em> option, see the <a href="http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options" rel="nofollow noreferrer">documentation</a></p>
| <p>Have you tried using a <a href="http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html" rel="nofollow noreferrer">diagnostic pragma</a> directive? These are available in gcc 4.2.1+, I believe.</p>
| 13,664 |
<p>Is anyone else having trouble running Swing applications from IntelliJ IDEA 8 Milestone 1? Even the simplest application of showing an empty JFrame seems to crash the JVM. I don't get a stack trace or anything, it looks like the JVM itself crashes and Windows shows me a pop-up that says the usual "This process is ... | <p>Ask your question directly on the IDEA website. They always react fast and the problem you have is probably either fixed or documented.</p>
| <p>IDEA 8 Milestone 1 is a beta(ish) "based on a new platform". This may have changed the way that swing is handled. Also you are running a beta JDK.</p>
<p>You will probably get more help/submit a bug at the Jetbrain forums unless they are on SO also. <a href="http://www.jetbrains.net/jira/browse/IDEA/" rel="nofollow... | 4,185 |
<p>I have a controller that returns either JSON or partial html depending on if the user is logged in. </p>
<p>Is there anyway to tell the difference once the result has been returned??
What is the best way.</p>
<p>Obviously i have different actions to complete if the response is json or if it is the partial html. Wi... | <p>You could use <a href="http://www.devpro.it/JSON/files/JSON-js.html" rel="nofollow noreferrer">JSON.js</a> to find out if a given string is JSON or not. </p>
<blockquote>
<p><strong>JSON encoder / decoder</strong><br>
This object uses good practices to encode/decode every kind of JSON compatible variable quickl... | <p>I'd say, assuming you have control of the thing returning JSON or partial HTML, that you should change the Content-Type header of the JSON result to something like <code>application/x-format-json</code> or an equally obvious type.</p>
| 40,433 |
<h3>Background</h3>
<p>I work for a large organization which has thousands of MS Access applications floating around. I didn't write any of these - in fact, most of the original authors have long since left the company - but from time to time another Access app lands on my desk for support. I would <em>soooo</em> lov... | <p>You could check out <a href="http://apex.oracle.com/i/index.html" rel="noreferrer">Oracle's Application Express</a>. It's free and it's geared toward Access developers.</p>
<p>It has a migration assistant as well that you run your Access database through, it proccesses the data and the forms, migrates everything t... | <blockquote>
<p>Is there anything that will replace the front end part of MS Access?</p>
</blockquote>
<p>Maybe <a href="http://www.kexi-project.org/" rel="nofollow noreferrer">Kexi</a>?</p>
| 27,374 |
<p>Why am I getting an out of memory exception?</p>
<p>So this dies in C# on the first time through:</p>
<p><strong>splitBitmaps.Add(neededImage.Clone(rectDimensions, neededImage.PixelFormat));</strong> </p>
<p>Where splitBitmaps is a List<BitMap> BUT this works in VB for at least 4 iterations:</p>
<p><strong... | <p>Clone() may also throw an Out of memory exception when the coordinates specified in the Rectangle are outside the bounds of the bitmap. It will not clip them automatically for you.</p>
| <p>Make sure that you're calling .Dispose() properly on your images, otherwise unmanaged resources won't be freed up. I wonder how many images are you actually creating here -- hundreds? Thousands?</p>
| 24,309 |
<p>I see this from time to time and want to know what it is. I did try google, but its filtering out the characters from the search. I have a few books that don't reference it either. </p>
<p>FWIW, I remember in pascal that is was the assignment operator. </p>
<p>Can anybody point me to the MSDN or similar page?</p>
| <p>You can use the := syntax to assign the parameters to a Sub or Function by name, rather than strictly by position. For example:</p>
<pre><code>Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TestRoutine(Y:="TestString", X:=12)
... | <p>VB uses that operator for attribute value assignments:</p>
<p><a href="http://www.ondotnet.com/pub/a/dotnet/excerpt/vbnut_8/index1.html" rel="nofollow noreferrer">http://www.ondotnet.com/pub/a/dotnet/excerpt/vbnut_8/index1.html</a></p>
| 38,843 |
<p>I have see code like this</p>
<pre><code>Dim s as something = new something
Dim s as new something
</code></pre>
<p>what's the difference? is there any?</p>
| <p>A slight difference.</p>
<p>The first allows you to do:</p>
<pre><code>Dim s as ParentType = new InheritedType
</code></pre>
<p>The second doesn't.</p>
<p>The "advantage" of this is <code>s</code> can be a number of different types related to ParentType without it exploding at runtime.</p>
| <p>I believe all you're doing is specifically casting something as something.</p>
| 41,577 |
<p>I need more than the default diff! I have recently purchased "Beyond Compare" and I'd like to integrate it with svn, so its launched when I type:</p>
<p>svn diff foo.c</p>
<p>How do I do this?</p>
| <p>From a <a href="http://www.scootersoftware.com/vbulletin/showthread.php?t=41520" rel="noreferrer">Beyond Compare forum post</a>:</p>
<p>/usr/bin/bcompare_svn:</p>
<pre><code>#!/bin/bash
/usr/bin/bcompare $6 $7 &
exit 0
</code></pre>
<p>The invocation of bcompare is obvious but I had to add "exit 0" so that sv... | <p>I recently added instructions for Subversion on Linux to our <a href="http://www.scootersoftware.com/support.php?zz=kb_vcs.php" rel="nofollow noreferrer">Using Beyond Compare With Version Control Systems</a> web page. Once you follow the steps at the above link it should launch Beyond Compare 3 for Linux when you ru... | 36,111 |
<p>I have a controller action that is being executed by a link that was created using 'Ajax.ActionLink()' the problem is that I can't tell in my action that the request is an AJAX request because <code>Request.IsMvcAjaxRequest()</code> is always returning false.</p>
<p>Does <code>Request.IsMvcAjaxRequest()</code> not ... | <p>There are no form parameters on a delete. Try adding __MVCASYNCPOST=true as route data (query parameter in the url)</p>
| <p>Because "IsMvcAjaxRequest" just returns (request["__MVCASYNCPOST"] == true), and that checks the query string, form post and cookies... it should work with POST,GET,etc.</p>
<p>Try putting a break point in your code behind and making sure it's hitting for the POST, then change to "DELETE" and see if it's hitting yo... | 36,805 |
<p>What's the best way, using SQL, to check the maximum number of connections that is allowed for an Oracle database? In the end, I would like to show the current number of sessions and the total number allowed, e.g. "Currently, 23 out of 80 connections are used".</p>
| <p>There are a few different limits that might come in to play in determining the number of connections an Oracle database supports. The simplest approach would be to use the SESSIONS parameter and V$SESSION, i.e.</p>
<p>The number of sessions the database was configured to allow</p>
<pre><code>SELECT name, value
... | <pre><code>select count(*),sum(decode(status, 'ACTIVE',1,0)) from v$session where type= 'USER'
</code></pre>
| 19,625 |
<p>I am a Winforms and business engine developer who is using asp.net for the first time in over 2 years, and in that time I have noticed a few convention changes.</p>
<p>What is the logic behind the anti-'tables for layout' movement?</p>
<p>Is it to allow css classes to be used to handle layout, and if so, should th... | <p>A few additional points:</p>
<ul>
<li><p>Don't be a fanatic about it. CSS isn't perfect, and there are some things that can be done much easier with tables. So if you need to, put a little table in there. It won't kill you.</p></li>
<li><p>The major "evil" of table-based layouts was the kind of deeply-nested mess t... | <p>Honestly, don't worry that much about using tables. Even some of the best, most semantically correct people advise using tables if it's easier for the flow of the document. Just use what works for - the dissadvantage to using tables isn't all that great.</p>
| 40,416 |
<p>Is there a way to pass null arguments to C# methods (something like null arguments in c++)?</p>
<p>For example:</p>
<p>Is it possible to translate the following c++ function to C# method:</p>
<pre><code>private void Example(int* arg1, int* arg2)
{
if(arg1 == null)
{
//do something
}
if(arg... | <p>Yes. There are two kinds of types in .NET: reference types and value types.</p>
<p>References types (generally classes) are always referred to by references, so they support null without any extra work. This means that if a variable's type is a reference type, the variable is automatically a reference.</p>
<p>Valu... | <p>Starting from C# 2.0, you can use the nullable generic type Nullable, and in C# there is a shorthand notation the type followed by ?</p>
<p>e.g.</p>
<pre><code>private void Example(int? arg1, int? arg2)
{
if(arg1 == null)
{
//do something
}
if(arg2 == null)
{
//do something else... | 34,158 |
<p>I have a project that uses a class library for the business layer functionality (database access, etc.). A web application sits on top of this. I have a web service that I would like to call in the class library. Every time I add a 'service reference' (I am using VS2008) to the class library, everything seems to wor... | <p>You're supposed to use the <code>EmployeeServiceSoapClient</code> to access the service. The Service class itself sits on the server.</p>
| <p>You're supposed to use the <code>EmployeeServiceSoapClient</code> to access the service. The Service class itself sits on the server.</p>
| 46,164 |
<p>By default netbeans stores it's settings in a directory called .netbeans under the user's home directory. Is it possible to change the location of this directory (especially under Windows)?</p>
<p>Thanks to James Schek I now know the answer (change the path in netbeans.conf) but that leads me to another question:
... | <p>yes, edit the netbeans.conf file under %NETBEANS_HOME%\etc.</p>
<p>Edit the line with:
netbeans_default_userdir="${HOME}/.netbeans/6.0"</p>
<p>If you need different "profiles"--i.e. want to run different copies of Netbeans with different home directories, you can pass a new home directory to the launcher. Run "net... | <p>"HOME" is the only variable supported by the IDE. When deploying a custom application using the Netbeans Platform, "APPNAME" is also supported out of the box.</p>
| 14,184 |
<p>I would like to implement a producer/consumer scenario that obeys interfaces that are roughly:</p>
<pre><code>class Consumer {
private:
vector<char> read(size_t n) {
// If the internal buffer has `n` elements, then dequeue them
// Otherwise wait for more data and try again
}
public:
... | <p>This code is not production ready.
No error checking is done on the results of any library calls.</p>
<p>I have wrapped the lock/unlock of the mutex in LockThread so it is exception safe. But that's about it.</p>
<p>In addition if I was doing this seriously I would wrap the mutex and condition variables inside obj... | <p>Glib Asynchronous Queues provide the locking and sleep on reading an empty queue you are looking for. See <a href="http://library.gnome.org/devel/glib/2.20/glib-Asynchronous-Queues.html" rel="nofollow noreferrer">http://library.gnome.org/devel/glib/2.20/glib-Asynchronous-Queues.html</a> You can combine them with gth... | 25,350 |
<p>I want to create a stored procedure with one argument which will return different sets of records depending on the argument. What is the way to do this? Can I call it from plain SQL?</p>
| <p>Here is how to build a function that returns a result set that can be queried as if it were a table:</p>
<pre><code>SQL> create type emp_obj is object (empno number, ename varchar2(10));
2 /
Type created.
SQL> create type emp_tab is table of emp_obj;
2 /
Type created.
SQL> create or replace funct... | <p>If you want to use it in plain SQL, I would let the store procedure fill a table or temp table with the resulting rows (or go for @Tony Andrews approach).<br>
If you want to use @Thilo's solution, you have to loop the cursor using PL/SQL.
Here an example: (I used a procedure instead of a function, like @Thilo did) ... | 12,637 |
<p>I've been wondering about how hard it would be to write some Python code to search a string for the index of a substring of the form <code>${</code><em>expr</em><code>}</code>, for example, where <em>expr</em> is meant to be a Python expression or something resembling one. Given such a thing, one could easily imagi... | <p>I think your best bet is to match for all curly braced entries, and then check against Python itself whether or not it's valid Python, for which <a href="https://docs.python.org/2/library/compiler.html" rel="nofollow noreferrer">compiler</a> would be helpful.</p>
| <p>After posting this, reading the replies so far (thanks everyone!), and thinking about the problem for a while, here is the best approach I've been able to come up with:</p>
<ol>
<li>Find the first <code>${</code>.</li>
<li>Find the next <code>}</code> after that.</li>
<li>Feed whatever's in between to <code>compile... | 25,401 |
<p>I am merging a CVS branch and one of the larger changes is the replacement wherever it occurs of a Singleton pattern with abstract classes that have a static initialisation block and all static methods.</p>
<p>Is this something that's worth keeping since it will require merging a lot of conflicts, what sort of situ... | <p>From a strict runtime performance point of view, the difference is really negligible. The main difference between the two lies down in the fact that the "static" lifecycle is linked to the classloader, whereas for the singleton it's a regular instance lifecycle. Usually it's better to stay away from the ClassLoader ... | <p>Does this discussion help? (I don't know if it's taboo to link to another programming forum, but I'd rather not just quote the whole discussion =) )</p>
<p><a href="http://forums.sun.com/thread.jspa?threadID=5221231&messageID=9898827" rel="nofollow noreferrer">Sun Discussion on this subject</a></p>
<p>The ver... | 4,790 |
<p>Does anyone know how to resize images proportionally using JavaScript?</p>
<p>I have tried to modify the DOM by adding attributes <code>height</code> and <code>width</code> on the fly, but seems did not work on IE6.</p>
| <p>To modify an image proportionally, simply only alter one of the width/height css properties, leave the other set to auto.</p>
<pre><code>image.style.width = '50%'
image.style.height = 'auto'
</code></pre>
<p>This will ensure that its aspect ratio remains the same.</p>
<p>Bear in mind that browsers tend to <em>suc... | <pre><code>function resize_image(image, w, h) {
if (typeof(image) != 'object') image = document.getElementById(image);
if (w == null || w == undefined)
w = (h / image.clientHeight) * image.clientWidth;
if (h == null || h == undefined)
h = (w / image.clientWidth) * image.clientHeight;
... | 20,585 |
<p>When possible.. do you leave parentheses in or out in Ruby? </p>
| <p>From the <a href="https://web.archive.org/web/20100420090330/http://www.pathf.com/blogs/2008/10/elements-of-ruby-style/" rel="noreferrer" title="Elements of Ruby Style">Elements of Ruby Style</a></p>
<blockquote>
<p><strong>Ruby allows you to leave out parenthesis, in general, resist this
temptation.</strong></... | <p>If you've been programming for a long time, you'll probably have an "itch" to add parentheses, and in many cases there are good reasons for this.</p>
<p>The code is easier on the eyes though in my opinion, and I haven't run into a problem yet--if you're going to need parentheses, you'll know it beforehand before yo... | 44,262 |
<p>I've editing this original question as I think I've narrowed down the problem...</p>
<p>I have one view in my site that will not let me put $document.ready within a masterpage contentplaceholder. I've stripped this page to the bare bones and the only thing that is special about it is it has a custom route in global... | <p>I had the same problem and it turned out that when I used a certain route it changed the perceived file hierarchy of the site such as the ../../Content link for the .js file didn't work any more. I fixed it by changing my jquery script reference to look like this:</p>
<pre><code><script src="<%= Url.Content("... | <p>Just stick it somewhere within the content control of your view page in a <code><script ...></code> tag.</p>
<pre><code><asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
<div class="contentItem">
<%!-- yadda --%>
</div>
<sc... | 30,747 |
<p>When choosing a layer height, I know that often you go as fine as your printer will do for better precision, but sometimes you go a little thicker, for speed, for example.</p>
<p>I also see 0.1 mm and 0.2 mm as common thicknesses.</p>
<p>What are my options here? When I'm working on a part where I want t... | <p>You decide which layer height you want based on the quality you desire, but never go over about 75 % of your nozzle diameter, so with your 0.4 mm nozzle never choose layer heights larger than 0.3 mm. The rationale of this rule of thumb is that the filament leaves the nozzle as a tube and needs to be f... | <p>You decide which layer height you want based on the quality you desire, but never go over about 75 % of your nozzle diameter, so with your 0.4 mm nozzle never choose layer heights larger than 0.3 mm. The rationale of this rule of thumb is that the filament leaves the nozzle as a tube and needs to be f... | 1,165 |
<p>How do I make open “read only” the only option within a SharePoint document library?</p>
<p>When using either Word 2003 or 2007 and saving the document as a template or modifying the file properties as “read only” doesn’t prevent modification of the file in a SharePoint document library. Modifying the document lib... | <p>I don't know if you can force read only to be the only option, but you can implement your own event handler to override the ItemUpdating event. Just cancel the update and any changes will be discarded.</p>
<p>Sahil shows a very basic event handler that performs the cancel <a href="http://blah.winsmarts.com/2006-7-... | <p>The event handler works, but I have found a simpler workaround.</p>
<p>If you “Check Out” the file and leave it checked out, no one else has the option to edit the file. This is still not ideal, but for forcing a document to be “read only” it works.</p>
| 11,154 |
<p>I've been able to find details on several self-balancing <code>BST</code>s through several sources, but I haven't found any good descriptions detailing which one is best to use in different situations (or if it really doesn't matter). </p>
<p>I want a <code>BST</code> that is optimal for storing in excess of ten m... | <p><a href="http://en.wikipedia.org/wiki/Red-black_tree" rel="nofollow noreferrer">Red-black</a> is better than AVL for insertion-heavy applications. If you foresee relatively uniform look-up, then Red-black is the way to go. If you foresee a relatively unbalanced look-up where more recently viewed elements are more li... | <blockquote>
<p>[hash tables have] O(1) insertion and search</p>
</blockquote>
<p>I think this is wrong.</p>
<p>First of all, if you limit the keyspace to be finite, you could store the elements in an array and do an O(1) linear scan. Or you could shufflesort the array and then do a linear scan in O(1) expected ti... | 2,456 |
<p>I have 2 components for example (editor.mxml using mx:windows), when I click an edit button, I want to get the current value from the other component's datafield? (datagrid.mxml using mx:window)</p>
<p>I do know how to access the main MXML's datagrid by parentDocument or Application.application method, but stumped ... | <p>You could either do <a href="http://en.wikipedia.org/wiki/Dependency_injection" rel="nofollow noreferrer">dependency injection</a>, that is, give component <code>A</code> a reference to component <code>B</code> so that they can communicate directly (example of tighter coupling,) or have both components communicate t... | <p>This might be more complicated than it deserves, and it smacks of Pattern-Fever, but you could use a mediator class that listens for the CLICK event from the button and knows enough about the other component to query its property. It could even transmit that data using a custom event, which the button listens for.</... | 49,574 |
<p>How to add child rows in datagrid c#.net windows forms?</p>
| <p>I'm not sure if this is what you're asking, but if you want to append rows you're easiest way is to append them to whatever DataSource you're using before you DataBind()</p>
<p>If this wasn't what you're after, please provide more detail.</p>
| <p>Usually you bind the datagrid to a dataset. Could you please clarify what you are looking for so that we can get into more detail?</p>
| 12,765 |
<p><strong>C#6 Update</strong></p>
<p>In <a href="https://msdn.microsoft.com/en-us/magazine/dn802602.aspx" rel="nofollow noreferrer">C#6 <code>?.</code> is now a language feature</a>:</p>
<pre><code>// C#1-5
propertyValue1 = myObject != null ? myObject.StringProperty : null;
// C#6
propertyValue1 = myObject?.String... | <p>We independently came up with the exact same extension method name and implementation: <a href="http://code.logos.com/blog/2008/01/nullpropagating_extension_meth.html" rel="noreferrer">Null-propagating extension method</a>. So we don't think it's confusing or an abuse of extension methods.</p>
<p>I would write your... | <p>Personally, even after all your explanation, I can't remember how the heck this works:</p>
<pre><code>if( obj1.NullCompare( obj2, (x,y) => x.Property == y.Property )
</code></pre>
<p>This could be because I have no C# experience; however, I could read and understand everything else in your code. I prefer to ke... | 14,981 |
<p>In my C++ program (on Windows), I'm allocating a block of memory and can make sure it stays locked (unswapped and contiguous) in physical memory (i.e. using VirtualAllocEx(), MapUserPhysicalPages() etc). </p>
<p>In the context of my process, I can get the VIRTUAL memory address of that block,
<b> but I need to fin... | <p><em>In my C++ program (on Windows), I'm allocating a block of memory and can make sure it stays locked (unswapped and contiguous) in physical memory (i.e. using VirtualAllocEx(), MapUserPhysicalPages() etc).</em></p>
<p>No, you can't really ensure that it stays locked. What if your process crashes, or exits early? ... | <p>Wait, there is more. For the privilege of runnning on your customer's Vista 64 bit, you get expend more time and money to get your kernal mode driver resigned my Microsoft,</p>
| 47,846 |
<p>What tools do you use to find unused/dead code in large java projects? Our product has been in development for some years, and it is getting very hard to manually detect code that is no longer in use. We do however try to delete as much unused code as possible.</p>
<p>Suggestions for general strategies/techniques (... | <p>An Eclipse plugin that works reasonably well is <a href="http://www.ucdetector.org/" rel="noreferrer">Unused Code Detector</a>.</p>
<p>It processes an entire project, or a specific file and shows various unused/dead code methods, as well as suggesting visibility changes (i.e. a public method that could be protected... | <p>Eclipse can show/highlight code that can't be reached. JUnit can show you code coverage, but you'd need some tests and have to decide if the relevant test is missing or the code is really unused. </p>
| 19,655 |
<p>Please pardon my lack of Photoshop skills, but I'm curious what type of strategy Apps like Facebook and AP Mobile News are using for the 'label slider' in their applications. Here's a quick snippet outlining what I'm talking about as I'm sure the name I'm labeling the utility as is being butchered: <a href="http://d... | <p>You'll most likely want to use a UIScrollView, with a UILabel as its content view. Size the label appropriately to your content, and then set the contentSize property of the scrollview to that size. </p>
| <p>I created a similar control, and it's much easier than you think. It's just a UIScrollView with a series of UIButtons added to it. You could use labels instead of buttons - just depends on the feel you want. I think Facebook is probably using labels for theirs. </p>
<p>In any case, you'll probably want to use a ser... | 43,802 |
<p>I am having severe performance issues when compiling a moderately large ASP.Net website in Visual Studio 2008 (targeting .Net 3.5). I know there are some tips & registry hacks for improving compilation performance in VS 2005, are there any for VS 2008? Specifically, it seems that VS 2008 is compiling the whole w... | <ul>
<li><p><strong>Antivirus problems</strong>: Make sure that your Antivirus program excludes your project directories! Make sure that your Microsoft.NET directory inside of your Windows directory is also on the exclusion list.</p></li>
<li><p><strong>IIS vs. "Cassini"</strong> : If you can, use IIS instead of VS's... | <p>I'm guessing this is an ASP.Net Website project and <em>not</em> an ASP.Net Web Application project. You'll get better compile performance from a Web Application project so you might consider converting it.</p>
<p>For a Website project, you can open the Website in Visual Studio, right click the web site project nod... | 36,638 |
<p>Is there a good way to time SQL queries when using Linq to SQL? I really like logging feature, but it would be great if you could somehow also time that query. Any ideas?</p>
| <p>SQL Profiler to get the query and the time, and also Execution Path in Query analyzer to see where the bottlenecks are.</p>
| <p>We use SQL Profiler to test our queries with LLBLGen Pro. </p>
| 10,179 |
<p>I recently tried cleaning my CR-10S Pro heat bed with acetone and it made this white stain on it.</p>
<p>Anyone have any solutions to this?</p>
| <p>If you use a build surface such as PEI, acetone frosts your surface, leaving a white film appearance. If you have no additional surface on a glass or metal bed, it is incomplete cleaning. If incomplete cleaning, you could try isopropyl alcohol (IPA) immediately after acetone, followed immediately by a water based ... | <p>If you use a build surface such as PEI, acetone frosts your surface, leaving a white film appearance. If you have no additional surface on a glass or metal bed, it is incomplete cleaning. If incomplete cleaning, you could try isopropyl alcohol (IPA) immediately after acetone, followed immediately by a water based ... | 1,869 |
<h2>Backstory</h2>
<p>I've had issues in the past with my drive gear "eating" my filament. It seemed that the filament quit extruding for one reason or another and the drive gear would slowly eat away at the side of the filament.</p>
<p>I eventually assumed it was the plastic filament guides causing unnecessary tensi... | <p>For an easy test, try manually pulling the filament through the U-loop of guide tube. How hard is it to pull through? It should only take 1-2 lbs of tension at most. </p>
<p>Then do a "tug test" on the extruder. Start it loading and grab the filament by hand to try to stop it from extruding. The Replicator 1/2/2x e... | <p>The friction inside of the guide tubes is fairly minimal assuming that the lines are straight and there isn't anything else inside them. My guess would be that you may have another issue. Reducing the drag in the guide tubes while it may reduce the problem of clogged nozzle, might just be hiding the symptoms of anot... | 224 |
<p>I was wondering if its possible to inject a thread into a remote app domain running in a separate process. </p>
<p>My guess is that I could do this using the debugging interfaces (ICorDebug) but I was wondering if there is any other way? </p>
| <p>There was recently an announcement of a new facility Mono provides to do just this. See this post on <a href="http://tirania.org/blog/archive/2008/Sep-29.html" rel="nofollow noreferrer">assembly injection</a>. </p>
| <p>Mike Stall has an <a href="http://blogs.msdn.com/jmstall/archive/2006/09/28/managed-create-remote-thread.aspx" rel="nofollow noreferrer">interesting sample</a> on how to use CreateRemoteThread to inject remote threads in managed apps. </p>
<p>This answer is still incomplete, cause I would like to run new code in th... | 22,382 |
<p>In my project I have a class that is inherited by many other classes. We'll call it ClassBase.</p>
<pre><code>public class ClassInheritFromBase : ClassBase
</code></pre>
<p>When ClassBase is being inherited, <a href="http://en.wikipedia.org/wiki/ReSharper" rel="noreferrer">ReSharper</a> throws an "Ambiguous refere... | <p>For those who still have a problem with this, (I still get it from time to time) here's the steps I did to get rid of the ambiguous reference warning in ReSharper.</p>
<ol>
<li>First I went to all my class libraries and made sure that all references to my other class libraries had the <em>Copy Local</em> property s... | <p>I encountered the same problem. The issue I had was caused by a custom build provider (from an open source library I'm using called <a href="http://www.codeplex.com/PageMethods" rel="nofollow noreferrer">PageMethods</a>) and the fact that all my .aspx pages inherit from a BasePage class which lives in the App_Code f... | 23,320 |
<p>How do you generate and analyze a thread dump from a running JBoss instance?</p>
| <p>There is a JBoss-specific method that is slightly more user-friendly:</p>
<p><a href="http://community.jboss.org/wiki/GenerateAThreadDumpWithTheJMXConsole" rel="nofollow noreferrer">http://community.jboss.org/wiki/GenerateAThreadDumpWithTheJMXConsole</a></p>
<p>This is especially useful when you don't have direct ... | <p>Sometimes JBoss locks so much that even jmx-concole doesn't respond.
In such case use kill -3 on Linux and <a href="http://www.latenighthacking.com/projects/2003/sendSignal/" rel="nofollow">SendSignal</a> on Windows.</p>
| 8,448 |
<p>It drives me nuts to hear business proponents using the term realtime for web-based systems. I'm becoming the crazy in the room, chanting, "There is no such thing as realtime on the web! We're in banking, not the rocket launch/ship navigation/airplane autopilot business!"</p>
<p>Anyone have anything better for pe... | <p>In the banking industry most of the time "real time" means the opposite of "end-of-day". </p>
<p>Because there was no such thing as internet/intranet/LANs/WANs in the old days, all balancing is done at "end-of-day". Transactions done in one branch with a certain bank account are oblivious of the transactions done i... | <p>How do you define "real-time" for embedded systems? I would say that a decent definition is "a system which is able to process and respond to inputs faster than the average time between inputs." In other words, a system that will never fall behind in processing compared to the systems which are feeding it data. U... | 7,406 |
<p>I'm adding a new field to a list and view. To add the field to the view, I'm using this code:</p>
<pre><code>view.ViewFields.Add("My New Field");
</code></pre>
<p>However this just tacks it on to the end of the view. How do I add the field to a particular column, or rearrange the field order? view.ViewFields is an... | <p>I've found removing all items from the list and readding them in the order that I'd like works well (although a little drastic). Here is the code I'm using:</p>
<pre><code>string[] fieldNames = new string[] { "Title", "My New Field", "Modified", "Created" };
SPViewFieldCollection viewFields = view.ViewFields;
viewF... | <p>You have to use the follow method to reorder the field</p>
<pre><code> string reorderMethod = @"<?xml version=""1.0"" encoding=""UTF-8""?>
<Method ID=""0,REORDERFIELDS"">
<SetList Scope=""Request"">{0}</SetList>
... | 15,518 |
<p>I've just read up on <code>Thread.IsBackground</code> and if I understand it correctly, when it's set to <code>false</code> the Thread is a foreground thread which means it should stay alive until it has finished working even though the app have been exited out. Now I tested this with a winform app and it works as e... | <p>The <code>Thread.IsBackground</code> property only marks if the thread should block the process from exiting. It doesn't perform any magic to keep the thread alive until some sort of explicit exit.</p>
<p>To quote the <a href="http://msdn.microsoft.com/en-us/library/system.threading.thread.isbackground.aspx" rel="... | <p>IMHO really you should be a lot more explicit about the expected semantics of your application and deliberately <thread>.Join.</p>
| 13,270 |
<p>I seem to recall reading about an Amazon S3-compatible test server that you could run on your own server for unit tests or whatever. However, I've just exhausted my patience looking for this with both Google and AWS. Does such a thing exist? If not, I think I'll write one.</p>
<p>Note: I'm asking about Amazon S3 (t... | <p>Are you thinking of <a href="http://github.com/technoweenie/parkplace" rel="nofollow noreferrer">Park Place</a>?</p>
<p>FYI, its <a href="http://code.whytheluckystiff.net/parkplace/" rel="nofollow noreferrer">old home page</a> is offline now.</p>
| <p>Amazon uses Xen, so you can probably just run your AMI in your own Xen installation. I'd just fire up an instance and run the tests there, though. It doesn't cost much and you should usually be fine with developing locally and infrequently testing it on their system.</p>
| 11,688 |
<p><strong>What Delphi coding standards document(s) do you follow?</strong></p>
<p>Our company is looking at putting some better coding standards in place, to improve our code’s readability, reviewability, and maintainability. We’ve come across CodeGear’s “Object Pascal Style Guide”, but it hasn’t been touched in qui... | <p><strong>Project JEDI Delphi Language Style Guide With JCL Additions</strong></p>
<p>(An extension of CodeGear’s “Object Pascal Style Guide”)</p>
<p><a href="https://wiki.delphi-jedi.org/wiki/Project_JEDI_Delphi_Language_Style_Guide" rel="nofollow noreferrer">https://wiki.delphi-jedi.org/wiki/Project_JEDI_Delphi_La... | <p><strong>CodeGear’s “Hungarian peanut butter”, for naming identifiers</strong></p>
<p><a href="http://dn.codegear.com/article/27983" rel="nofollow noreferrer">http://dn.codegear.com/article/27983</a></p>
| 32,907 |
<p>Whenever I try to backup a database it goes until 90% and gets stuck there until I manually kill (because it doesn't stop if I try to stop it) the msftesql process.</p>
<p>That clearly means that something makes a conflict between the fulltext indexing and the backup process. </p>
<p>So, have you seen anything lik... | <p>The first and obvious debug point is to disable full text indexing and try backing up the database again. If it does backup, then you know that FTS is the problem. If it doesn't, then you have another issue to find.</p>
<p>I would also check both the SQL Logs and the Event Viewer to see if any useful information is... | <p>I have the same problem.
The activity monitor shows that the Backup job has a wait type MSSEARCH</p>
<p>The index is manually populated when run it is hanging for days on end until I force-ably stop it or the service is restarted. it used to take minutes to populate.</p>
| 12,655 |
<p>I'm new to ASP.NET MVC and all tutorials, samples, and the like I seem to find are very basic.</p>
<p>Is it possible (and if yes, a good design) to have routes like so:
.../Organization/10/User/5/Edit
.../Organization/10/User/List</p>
<p>In other words; can the urls mirror your domain model?</p>
| <p>Possible, yes, with a route something like:</p>
<pre><code>"~/Organization/{orgId}/{Controller}/{id}/{action}"
</code></pre>
<p>Whether it is a good design or not I couldn't say for sure, only that it seems rather complicated to me. </p>
<p>If you have multiple User tables, one for each company, it might make som... | <p>"<strong>If you have multiple User tables</strong>, one for each company, it might make some sense."
Why only then? </p>
<p>"~/Organization/10/User/5/Edit"</p>
<p>... gives me the organization context at all times.</p>
<p>I didn't say so in my first question, but I've written an action filter that authorizes acco... | 48,057 |
<p>I have the following table structure</p>
<pre><code>CREATE TABLE `table` (
`id` int(11) NOT NULL auto_increment,
`date_expired` datetime NOT NULL,
`user_id` int(11) NOT NULL,
`foreign_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `date_expired` (`date_expired`,`user_id`,`foreign_id`),
KEY `use... | <p>I believe if you created your unique index as (<code>user_id</code>, <code>date_expired</code>, <code>foreign_id</code>), you'll get the same benefit of having a normal index on <code>user_id</code> with just the unique index. MySQL can use the first columns of any index to pare down the number of rows in the join i... | <p>Having several indexes including one field is not bad at all (essentially, they do index different things). It has a slight impact on write perfomance, but that's the typical trade-off you have with every index in first place.
Having indexes eating up more space than the data itself is not bad if space is cheap. In ... | 37,286 |
<p>PL/Ruby is a loadable procedural language for Postgres that lets you use Ruby to write user defined functions for the database.</p>
<p>Anyone know of an equivalent way of writing user defined functions for MySQL in Ruby?</p>
| <p>Starting from version 5 (I think) Mysql supports <a href="http://dev.mysql.com/doc/refman/5.1/en/stored-routines.html" rel="nofollow noreferrer">stored procedures</a>, but the syntax is restricted to SQL:2003 which is somewhat similar to PL/SQL. </p>
<p>Other languages aren't supported and I'm not aware of any proj... | <p>Mysql as far as I am aware only supports MySQLs own stored procedure language. </p>
<p>I'm a postgresql fan too, and this is something that has always frustrated me about MySQL when I have had no choice but to use it. :(</p>
| 32,026 |
<p>I was reading googlebooks on chrome, where they talk about why they decided to spin up a process to host browser tab, every time you created a new tab.'
So </p>
<p>2 tabs = 2 chrome processes</p>
<p>3 tabs = 3 chrome processes and so on .. right??</p>
<p>But i opened up some 20 or so tabs, but in task manager, i ... | <p>it's being hosted in the first process. open up chrome. you'll see 2 processes (manager and initial tab). then open 10 more tabs, you'll notice the second process's memory jump a lot. then type in google.com or something into the first tab, and you'll see a new process get spawned.</p>
<p>also notice, if you do shi... | <p>Process creation is relatively expensive, certainly compared to thread creation. But the frequency of process creation in Chrome is <em>very</em> slow, so the real issue is the amount of resource overhead vs other techniques.</p>
<p>The Google team figured that the benefits of a separate process model justified th... | 6,439 |
<p>How do I remove items from, or add items to, a select box? I'm running jQuery, should that make the task easier. Below is an example select box.</p>
<pre><code><select name="selectBox" id="selectBox">
<option value="option1">option1</option>
<option value="option2">option2</option... | <p>Remove an option:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>$("#selectBox option[value='option1']").remove();</code></pre>
<pre class="snippet-code-html lang-html ... | <p>I just want to suggest another way to add an <code>option</code>.
Instead of setting the <code>value</code> and <code>text</code> as a string one can also do:</p>
<pre><code>var option = $('<option/>')
.val('option5')
.text('option5');
$('#selectBox').append(option);
</cod... | 49,141 |
<p>I have a server that sends data via a socket, the data is a wav 'file'. I can easily write the data to disk and then play it in WMP, but I have no idea how I can play it as I read it from the socket. Is it possible?</p>
<p>Bonus question: how would I do it if the stream was in mp3 or other format?</p>
<p>This is f... | <p>Because you've said WMP, I'm assuming the question applies to trying to play a wav file on a windows machine. If not, this answer isn't relevant.</p>
<p>What you want to do isn't trivial. There is a good article <a href="http://www.codeproject.com/KB/audio-video/wavefiles.aspx" rel="nofollow noreferrer">here</a> ... | <p>Mark is right about this being a tricky problem. The waveOutXXXX API is ancient (it predates Windows 95) and requires more error-prone coding than you would think. You will have an easier time interacting with the API in C++ than with C#. Just make sure this is something you really want to do.</p>
<p>If your str... | 15,821 |
<p>I am writing a compiler in F# and I want to be able to access the <a href="http://msdn.microsoft.com/en-us/library/ms404384.aspx" rel="nofollow noreferrer">unmanaged metadata COM interfaces</a> in the .net runtime. Before anybody mentions it, <em>Reflection.Emit is not suitable for my purposes</em>, nor do I want to... | <p>I found a possible solution by myself in this MSDN article: <a href="http://msdn.microsoft.com/en-us/library/76e4d2xw.aspx" rel="noreferrer">ClickOnce Deployment and Security</a>.</p>
<h2>ASP.NET Form-Based Authentication</h2>
<p>If you want to control which deployments each user can access, you should <strong>not... | <p>A ClickOnce installer is just a couple installer files sitting out on your web server, right? So then, you can just implement some sort of directory security on those files. You can do this on a couple different levels I believe; for example IIS permissions or (if your users are on your domain) NTFS permissions.</... | 23,745 |
<p>In another <a href="https://stackoverflow.com/questions/242650/is-mutation-testing-useful-in-practice">question</a> I asked if <a href="http://en.wikipedia.org/wiki/Mutation_testing" rel="noreferrer">mutation-testing</a> is useful in practice. As I didn't get any answers that satisfy me, I want to check the current ... | <p>There is also <a href="http://pitest.org" rel="noreferrer" title="pit">PIT</a> which can be hooked into your build via a maven plugin or command line interface. </p>
<p>It provides much nicer reports than the other available tools with combined mutation and line coverage. It also runs considerably faster than the s... | <p>Jester does provide a file for the mutations and they are limited. To some degree, you can add your own mutations to the file.</p>
<p>I've experimented with Jumble and Jester and I found that Jumble provides more mutations and better documentation. Additionally, I've had quick responses from the project owners when... | 30,596 |
<p>Is it possible to set up somehow Microsoft SQL Server to run a stored procedure on regular basis?</p>
| <p>Yes, in MS SQL Server, you can create scheduled jobs. In SQL Management Studio, navigate to the server, then expand the SQL Server Agent item, and finally the Jobs folder to view, edit, add scheduled jobs.</p>
| <p>Using Management Studio - you may create a Job (unter SQL Server Agent)
One Job may include several Steps
from T-SQL scripts up to SSIS Packages</p>
<p>Jeb was faster ;)</p>
| 36,509 |
<p>What kind of performance implications are there to consider when using try-catch statements in php 5? </p>
<p>I've read some old and seemingly conflicting information on this subject on the web before. A lot of the framework I currently have to work with was created on php 4 and lacks many of the niceties of php 5.... | <p>One thing to consider is that the cost of a try block where no exception is thrown is a different question from the cost of actually throwing and catching an exception.</p>
<p>If exceptions are only thrown in failure cases, you almost certainly don't care about performance, since you won't fail very many times per ... | <p>Generally speaking, they're expensive and not worthwhile in PHP.</p>
<p>Since it is a checked expressions language, you MUST catch anything that throws an exception.</p>
<p>When dealing with legacy code that doesn't throw, and new code that does, it only leads to confusion.</p>
<p>Good luck!</p>
| 12,991 |
<p>Has anyone ever seen the storage class <code>auto</code> explicitly used in C/C++? If so, in what situation?</p>
| <p>auto is never useful in current C/C++ because all variables are implicitly auto. It is useful in C++0x, where it can replace the type declaration entirely - if you have a variable with an initial assignment, 'auto' will just make it the type of that assignment value, as in the comments.</p>
| <p>No, it's assumed if you omit the class specifier. The only reasonable uses I can think of would be to call attention to a particular local variable that overrides, say, a global variable with the same name, or as an interview question.</p>
<p>Chances are, you'll confuse the poor programmer who's stuck maintaining ... | 31,481 |
<p>Everybody knows that you should close a connection immediately after you finish using it.</p>
<p>Due to a flaw in my domain object model design, I've had to leave the connection open for the full page life cycle. Essentially, I have a Just In Time property which opens a connection on first call, and then on Page.U... | <p>No, it is not OK.</p>
<p>If your application will ever need to grow or scale, you'll want to fix this issue. By holding that connection open you're reducing your ability to scale. Keep in mind that open connections take up memory on the server, memory on the client, hold open locks, etc.</p>
| <p>page crashes? this is what using and finally are for</p>
<p>that said, for the sake of DB performance (i.e. scaling)* it's best to keep connections open as short a period as possible allowing only that you don't want to open close open close open close for rapidly sequential and predictable work</p>
<p>* I was tol... | 38,788 |
<p>Summary for the impatient:</p>
<p>What I want to know is what you want to have in a new gui language. About the short answers mentioning <code>$your_favorite_one</code>; I assume you mean that, such a language should look like <code>$your_favorite_one</code>. These are not helpful. Resist the temptation.</p>
<p>I'... | <p>Most recent XML GUI language (not only for GUI actually) is called XAML. It has all that candies: styles, layout definition, objects initialization, etc. But it's a <strong>pain</strong> to write more or less large XAML files. Auto-completion helps but the core problem - forest of angle brackets - is not solved. Ano... | <p>You should have specified whether you mean web or rich client, but either way take a look at XAML/WPF. If you're anti-MS, then look at Moonlight, the Mono implementation of SilverLight.</p>
| 14,444 |
<p>Has anyone used <a href="http://pear.php.net/package/Spreadsheet_Excel_Writer/" rel="nofollow noreferrer">Pear: Spreadsheet_Excel_Writer</a>?</p>
<p>The <a href="http://pear.php.net/manual/en/package.fileformats.spreadsheet-excel-writer.intro-format.php" rel="nofollow noreferrer">Formatting Tutorial</a> lists a scr... | <p>Here is some sample code:</p>
<pre><code><?php
require_once 'Spreadsheet/Excel/Writer.php';
$workbook = new Spreadsheet_Excel_Writer('test.xls');
$worksheet =& $workbook->addWorksheet('My first worksheet');
if (PEAR::isError($worksheet)) {
die($worksheet->getMessage());
}
$workbook->close();
?&g... | <p>send() sends cache-control headers and content type headers, but not content.
The content is sendt, as I understand from the code, when $workbook->close() is called.</p>
| 24,258 |
<p>I'm trying to change the background color of a single subplot in a MATLAB figure.</p>
<p>It's clearly feasible since the UI allows it, but I cannot find the function to automate it.</p>
<p>I've looked into <code>whitebg</code>, but it changes the color scheme of the whole figure, not just the current subplot. </p>... | <p>You can use the set command.</p>
<pre><code>set(subplot(2,2,1),'Color','Red')
</code></pre>
<p>That will give you a red background in the subplot location 2,2,1.</p>
| <p>I've not used Matlab in several years, but I think it might well be the whitebg method called after the subplot declaration, similar to the way in which you would set a title.</p>
<pre><code>subplot(3, 2, 4), hist(rand(50)), whitebg('y');
</code></pre>
| 19,068 |
<p>I want to do an HTTP POST that looks like an HMTL form posted from a browser. Specifically, post some text fields and a file field.</p>
<p>Posting text fields is straightforward, there's an example right there in the net/http rdocs, but I can't figure out how to post a file along with it.</p>
<p>Net::HTTP doesn't ... | <p>I like <a href="https://github.com/rest-client/rest-client" rel="noreferrer">RestClient</a>. It encapsulates net/http with cool features like multipart form data:</p>
<pre><code>require 'rest_client'
RestClient.post('http://localhost:3000/foo',
:name_of_file_param => File.new('/path/to/file'))
</code></pre>
... | <p>I had the same problem (need to post to jboss web server). Curb works fine for me, except that it caused ruby to crash (ruby 1.8.7 on ubuntu 8.10) when I use session variables in the code.</p>
<p>I dig into the rest-client docs, could not find indication of multipart support. I tried the rest-client examples above ... | 22,275 |
<p>I'm having trouble with <code>TryUpdateModel()</code>. My form fields are named with a prefix but I am using - as my separator and not the default dot.</p>
<pre><code><input type="text" id="Record-Title" name="Record-Title" />
</code></pre>
<p>When I try to update the model it does not get updated. If i chan... | <p>Another thing to note is that the prefix is to help reflection find the proper field(s) to update. For instance if I have a custom class for my ViewData such as:</p>
<pre><code>public class Customer
{
public string FirstName {get; set;}
public string LastName {get; set;}
}
public class MyCustomViewData
{
... | <p>There is a reason not to use . as ID/Name in HTML bcs it is not standard. For example, the will break if there is a dot in target.</p>
| 45,221 |
<p>I have ran into an odd problem with the ActionLink method in ASP.NET MVC Beta. When using the Lambda overload from the MVC futures I cannot seem to specify a parameter pulled from ViewData.</p>
<p>When I try this:</p>
<pre><code><%= Html.ActionLink<PhotoController>(p => p.Upload(((string)ViewData["grou... | <p>Have you updated your version of the Microsoft.Web.Mvc.dll where the Strongly typed actionlink resides. </p>
<p>Apparently this dll has been updated for the Beta release. The function may have been slightly modified.</p>
<p>I just tried this </p>
<pre><code><%= Html.ActionLink<HomeController>(x=>x.Sea... | <p>Ok, I figured out what my problem was.</p>
<p>Apparently I was not even setting the ViewData slot that I was trying to read from in the view, resulting in it being a null value.</p>
<p>So effectually I was writing:</p>
<pre><code><%= Html.ActionLink<PhotoController>(p => p.Upload(null), "upload new ph... | 26,540 |
<p>I have two arrays of <code>System.Data.DataRow</code> objects which I want to compare. </p>
<p>The rows have two columns A and B. Column A is a key and I want to find out which rows have had their B column changed and which rows have been added or deleted. </p>
<p><strong>How do I do this in PowerShell?</strong></... | <p>I wrote a script to do this a little while back. The script (Compare-QueryResults.ps1) is available <a href="http://podcast.acoupleofadmins.com/media/Scripts/Compare-QueryResults.ps1" rel="nofollow noreferrer">here</a> and you will also need my Run-SQLQuery script (available <a href="http://podcast.acoupleofadmins.... | <p>Do you need two arrays of DataRows? the DataRow object has a RowState property which will give you what you require. See the MSDN Docs: <a href="http://msdn.microsoft.com/en-us/library/system.data.datarow.rowstate.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/</a></p>
| 4,196 |
<p>In C++, what alternatives do I have for exposing a collection, from the point of view of performance and data integrity?</p>
<p>My problem is that I want to return an internal list of data to the caller, but I don't want to generate a copy. Thant leaves me with either returning a reference to the list, or a pointer... | <p><a href="https://stackoverflow.com/questions/44693/in-c-what-alternatives-do-i-have-for-exposing-a-collection-from-the-point-of-vi#44734">RichQ's answer</a> is a reasonable technique, if you're using an array, vector, etc. </p>
<p>If you're using a collection that isn't indexed by ordinal values... or think you <em... | <p>Using const is a reasonable choice.
You may also wish to check out the boost C++ library for their shared pointer implementation. It provides the advantages of pointers i.e. you may have the requirement to return a shared pointer to "null" which a reference would not allow.</p>
<p><a href="http://www.boost.org/doc/... | 6,644 |
<p>I wish to use the Validating event on a label in VB.Net (Visual Studio 2005, .Net Runtime 2.0).</p>
<p>I have two text boxes side by side. These are for a %/% split allocation, such as 80/20, 50/50, etc. So, I have validation on each box to ensure that their values are >= 0 and <= 100. It is my desire to have th... | <p>validation events are for controls that have editable values. labels do not have editable values.</p>
<p>your situation is not uncommon, you have a field-level validation that says 'positive integer' and a business rule that says the sum of values A and B must equal 100%.</p>
<p>one way to handle this is to delay ... | <p>May I ask is this a web or form project?</p>
<p>User's cannot enter any data into a label, so I don't see why they would fire validation.</p>
| 34,943 |
<p>No doubt, it's essential for understanding code to give member variables a prefix so that they can easily be distinguished from "normal" variables.</p>
<p>But what kind of prefix do you use?</p>
<p>I have been working on projects where we used <strong>m_</strong> as prefix, on other projects we used an underscore ... | <blockquote>
<p>No doubt, it's essential for understanding code to give member variables a prefix so that they can easily be distinguished from "normal" variables.</p>
</blockquote>
<p>I dispute this claim. It's not the least bit necessary if you have half-decent syntax highlighting. A good IDE can let you write y... | <p>None if it's not necessary, single underscore otherwise. Applies for python.</p>
| 13,682 |
<p>I want to fade out an element and all its child elements after a delay of a few seconds. but I haven't found a way to specify that an effect should start after a specified time delay.</p>
| <pre><code>setTimeout(function() { $('#foo').fadeOut(); }, 5000);
</code></pre>
<p>The 5000 is five seconds in milliseconds.</p>
| <p>You can avoid using setTimeout by using the fadeTo() method, and setting a 5 second delay on that.</p>
<pre><code>$("#hideAfterFiveSeconds").click(function(){
$(this).fadeTo(5000,1,function(){
$(this).fadeOut("slow");
});
});
</code></pre>
| 31,273 |
<p>As just stated in a recent <a href="https://stackoverflow.com/questions/135759/why-cant-i-inherit-iodirectory">question</a> and <a href="https://stackoverflow.com/questions/135759/why-cant-i-inherit-iodirectory#135772">answer</a>, you can't inherit from a static class. How does one enforce the rules that go along w... | <p>Module == static class</p>
<p>If you just want a class that you can't inherit, use a <code>NotInheritable</code> class; but it won't be static/Shared. You could mark all the methods, properties, and members as <code>Shared</code>, but that's not strictly the same thing as a static class in C# since it's not enforce... | <p>From the CLR point of view, C# static class is just "sealed" and "abstract" class. You can't create an instance, because it is abstract, and you can't inherit from it since it is sealed. The rest is just some compiler magic.</p>
| 16,449 |
<p>What do I need to set up and maintain a local CPAN mirror? What scripts and best practices should I be aware of?</p>
| <p><a href="http://search.cpan.org/perldoc?CPAN::Mini" rel="noreferrer">CPAN::Mini</a> is the way to go. Once you've mirrored CPAN locally, you'll want to set your mirror URL in CPAN.pm or CPANPLUS to the local directory using a "file:" URL like this:</p>
<pre><code>file:///path/to/my/cpan/mirror
</code></pre>
<p>If... | <p>Try <a href="http://search.cpan.org/perldoc/CPAN::Mini" rel="nofollow noreferrer">CPAN::Mini</a>.</p>
| 10,317 |
<p>Is there any difference between</p>
<pre><code> int on_exit(void (*function)(int , void *), void *arg);
</code></pre>
<p>and</p>
<pre><code> int atexit(void (*function)(void));
</code></pre>
<p>other than the fact that the function used by on_exit gets the exit status?</p>
<p>That is, if I don't care about ... | <p>According to <a href="http://www.delorie.com/gnu/docs/glibc/libc_560.html" rel="noreferrer">this link</a> I found, it seems there are a few differences. <code>on_exit</code> will let you pass in an argument that is passed in to the <code>on_exit</code> function when it is called... which might let you set up some p... | <p>@Nathan</p>
<p>First, see if there is another API call to determine exit status... a quick glance and I don't see one, but I am not well versed in the standard C API.</p>
<p>An easy alternative is to have a global variable that stores the exit status... the default being an unknown error cause (for if the program ... | 3,189 |
<p>I need to manipulate 100,000 - 200,000 records.<br>
I am thinking of using LINQ (to SQL) to do this.<br>
I know from experience that filtering dataviews is very slow.<br>
So how quick is LINQ?<br>
<br>
Can you please tell me your experiences and if it is worth using, or would I be better off using SQL stored procedu... | <p>LINQ to SQL translates your query expression into T-SQL, so your query performance should be exactly the same as if you sent that SQL query via ADO.NET. There is a little overhead I guess, to convert the expression tree for your query into the equivalent T-SQL, but my experience is that this is small compared with ... | <p>Normally the manipulation of that many records should happen as close as possible to the db. If it where my task I would look to do it in stored procs. That me personally. Linq is yet another layer of abstraction on top of data access and while it works well for "normal" needs i.e. a few hundred entities sent to the... | 14,123 |
<p>Let's pretend I have the following xaml...</p>
<p></p>
<pre><code><UserControl.Resources>
<local:ViewModel x:Name="viewModel" />
<local:LoadChildrenValueConverter x:Name="valueConverter" />
</UserControl.Resources>
<UserControl.DataContext>
<Binding Source="{StaticReso... | <p>Since you're using a ViewModel to sit between your actual model and your view, I wonder if it's easier just to implement the IValueConverter logic directly in there. Sort of like:</p>
<pre><code>public class ViewModel
{
public ObservableCollection Root { get; set: }
public ObservableCollection Children
... | <p>Sorry guys I am a little confused about what you are trying to do here... Anyway, from the title it sounds as if you want to a property in your value converter to a property in your value converter. Firstly have a look at an article I have written explaining exactly how you can do that:
<a href="http://nick-howard.b... | 48,321 |
<p>Well, it seems simple enough, but I can't find a way to add a caption to an equation.
The caption is needed to explain the variables used in the equation, so some kind of table-like structure to keep it all aligned and pretty would be great.</p>
| <p>The <code>\caption</code> command is restricted to floats: you will need to place the equation in a figure or table environment (or a new kind of floating environment). For example:</p>
<pre><code>\begin{figure}
\[ E = m c^2 \]
\caption{A famous equation}
\end{figure}
</code></pre>
<p>The point of floats is that y... | <p>You may want to look at <a href="http://tug.ctan.org/tex-archive/macros/latex/contrib/float/" rel="nofollow noreferrer"><a href="http://tug.ctan.org/tex-archive/macros/latex/contrib/float/" rel="nofollow noreferrer">http://tug.ctan.org/tex-archive/macros/latex/contrib/float/</a></a> which allows you to define new fl... | 18,011 |
<p>What the difference between <code>Application("some-object")</code> and <code>Cache("some-object")</code> in ASP.NET?</p>
| <p>Application is an application wide, no timeout (except when the pool restarts) dictionary. The cache is a temporary repository for common cache storage.</p>
<p><a href="http://www.eggheadcafe.com/articles/20030405.asp" rel="nofollow noreferrer">This</a> And <a href="http://bytes.com/forum/thread314515.html" rel="n... | <p>Application and cache are both application level storage of item, but difference is that in usage cenario , like cache is more flexible can do much more like scavenges ( removes unimortent item from cache automaticaly) ,but cache on othere side is volatilemeans that it is not sure that data will stay for applicatio... | 16,529 |
<p>I know that that is not a question... erm anyway HERE is the question.</p>
<p>I have inherited a database that has 1(one) table in that looks much like this. Its aim is to record what species are found in the various (200 odd) countries.</p>
<pre><code>ID
Species
Afghanistan
Albania
Algeria
American Samoa
Andorra... | <p>I would use a script to generate all the individual queries, since this is a one-off import process.</p>
<p>Some programs such as Excel are good at mixing different dimensions of data (comparing column names to data inside rows) but relational databases rarely are.</p>
<p>However, you might find that some systems ... | <p>You're probably going to want to create replacement tables in place. The script sort of depends on the scripting language you have available to you, but you should be able to create the country ID table simply by listing the columns of the table you have now. Once you've done that, you can do some string substitutio... | 10,258 |
<p>Well I'm new to OOP in PHP and am trying to write a site with it. The site is a basic flash games site and has categories to track the games. My first step was to create a basic MVC setup and list all the categories. The problem is I don't know how to create an array with all of the categories in it. Can I add t... | <p>Very simply, you're just missing the glue to put it all together. This is often described as the "business logic". What you currently have as your "model" is actually your data storage layer. Your model needs to use this to return to the controller what it needs to give to the view. </p>
<p>Down in the code, you ha... | <p>Like Staticsan said, there's lots of places you can put it, and books written about it. I'd change the constructor so that if you give it no arguments, it does no query. Then I'd use a static method that does its own query of all categories (or some subset) and then assembles an array of Category objects to return... | 43,615 |
<p>I can't seem to grok the concept of "loose coupling." I suppose it doesn't help that the word "loose" usually has a negative connotation, so I always forget that loose coupling is a <em>good</em> thing.</p>
<p>Will somebody please show some "before" and "after" code (or pseudocode) that illustrates this concept?</p... | <p>Consider a simple shopping cart application that uses a <code>CartContents</code> class to keep track of the items in the shopping cart and an <code>Order</code> class for processing a purchase. The <code>Order</code> needs to determine the total value of the contents in the cart, it might do that like so:</p>
<p><s... | <p>Loose coupling, in general, is 2 actors working independently of each other on the same workload. So if you had 2 web servers using the same back-end database, then you would say that those web servers are loosely coupled. Tight coupling would be exemplified by having 2 processors on one web server... those proces... | 28,079 |
<p>I have just built my Anet A8 and it won't print. </p>
<p>I will preheat it (190°C 60°C) and then press "<code>Print File</code>" and select, then it starts for a second, gets to around 11% and stops and shows "<code>Preheat PLA</code>". The PLA is already preheated - it is coming out of the nozzle. </p>
<p>Any hel... | <p>I had a similar problem last week where the thermostat's heat shrink was being melted by the block and the two wires were touching. I fixed this by securing the thermistor and putting a thermal insulator between the block and the wires. I also put a small piece of heat shrink between the wires to insulate them so th... | <p>The Anet A8 files that come preloaded are <code>.stl</code> so if you try to print those it will say printing zero percent and then just switch right back to preheating PLA without any error message. Download a free slicer tool if that's the case.</p>
| 580 |
<p>In our legacy system, we wrote our own VM to execute our internal DSL at run time. The in-house VM was designed to run our internal DSL only. We are in the process of rewriting our legacy application. One of the idea we are considering is, to transform our internal DSL to external DSL (C# or Java) and take advantage... | <p>The internal DSL/VM vs. external DSL/VM decision is the same as all build vs. buy vs. download decisions. The guidelines are clear and the same for all software.</p>
<p>Why support your own VM, when someone else will support Java or Python for you?</p>
<p>Here's some clear guidelines. Note that these are the sam... | <p>It is definitely not an anti-pattern. External DSLs have many advantages compared to the internal ones. Independence from the host language or implementation platform in your case is one of them. Other benefits are better syntax flexibility, possibility to use model driven approches like model transformations, model... | 23,645 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.