instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Is it possible to call a constructor from another (within the same class, not from a subclass)? If yes how? And what could be the best way to call another constructor (if there are several ways to do it)?</p>
| <p>Yes, it is possible:</p>
<pre><code>public class Foo {
private int x;
public Foo() {
this(1);
}
public Foo(int x) {
this.x = x;
}
}
</code></pre>
<p>To chain to a particular superclass constructor instead of one in the same class, use <code>super</code> instead of <code>this</... | <p>Originally from an anser by Mirko Klemm, slightly modified to address the question:</p>
<p>Just for completeness: There is also the <a href="https://stackoverflow.com/questions/3987428/what-is-an-initialization-block">Instance initialization block</a> that gets executed always and before any other constructor is ca... | 36,198 |
<p>A simple problem: If i use escape characters for a property such as</p>
<pre><code><mx:Image id="img" toolTip="\\foo{\\bar}"
</code></pre>
<p>It wont validate toolTip and therefore not compile.</p>
<p>What is the solution ?</p>
| <p>You can use ActionScipt for example in a creationComplete event handler and assign you tooltip and you won't have the same constraints as in MXML.</p>
<p>But you also can avoid these constraints in MXML by using CDATA:</p>
<pre><code><mx:Image id="img" source="foo.jpg" width="50" height="50">
<mx:toolTip&... | <p>You can use HTML format for special chars.<code><mx:Image id="img" toolTip="&#092;foo&#123;&#092;bar&#125;"/></code></p>
| 42,497 |
<p>So I'm trying to get rid of my std::vector's by using boost::ptr_vector. Now I'm trying to remove an element from one, and have the removed element deleted as well. The most obvious thing to me was to do:</p>
<pre><code>class A
{ int m; };
boost::ptr_vector<A> vec;
A* a = new A;
vec.push_back(a);
vec.erase(a... | <p>Well you can do that with a std::vector either.</p>
<p>In both cases erase takes an iterator as a parameter.<br>
So before you can erase something from a vector (or a ptr_vector) you need to locate it.</p>
<p>Also note that the ptr_vector treats its content as if you have stored an object not a pointer. So any sea... | <p>You need to use the member erase_if method with a suitable predicate. There's no need to delete the pointer, the container has ownership.</p>
<pre><code>struct delete_a {
bool operator()(boost::ptr_vector<A>::value_type inA) {
return inA == a;
}
}
vec.erase_if(delete_a());
</code></pre>
<p>(n... | 46,418 |
<p>Let's say I click a button on a web page to initiate a submit request. Then I suddenly realize that some data I have provided is wrong and that if it gets submitted, then I will face unwanted consequences (something like a shopping request where I may be forced to pay up for this incorrect request).</p>
<p>So I fra... | <p>A Web Page load from a browser is usually a 4 step process (not considering redirections):</p>
<ol>
<li>Browser sends HTTP Request, when the Server is available</li>
<li>Server executes code (for dynamic pages)</li>
<li>Server sends the HTTP Response (usually HTML)</li>
<li>Browser renders HTML, and asks for other ... | <p>Your submit in important scenarios should have two stages. Verify and submit. If the final submit goes though, you commit any tranactions. I cant think of any other way really to avoid that situation, other than allowing your user to undo his actions after a commit. for example The order example, after the order is ... | 16,711 |
<p>According to what I have found so far, I can use the following code:</p>
<pre>
LocalSessionFactoryBean sessionFactory = (LocalSessionFactoryBean)super.getApplicationContext().getBean("&sessionFactory");
System.out.println(sessionFactory.getConfiguration().buildSettings().getJdbcBatchSize());
</pre>
<p>but ... | <p>Try the following (I can't test it since I don't use Spring):</p>
<pre><code>System.out.println(sessionFactory.getConfiguration().getProperty("hibernate.jdbc.batch_size"))
</code></pre>
| <p>On the versions of Hibernate that I've checked, getConfiguration is not a public method of SessionFactory. In a few desperate cases, I've cast a Session or SessionFactory into its underlying implementation to get at some values that weren't publicly available. In this case that would be:</p>
<pre><code>((SessionF... | 13,150 |
<p>I have some code that generates image of a pie chart. It's a general purpose class, so any number of slices can be given as input. Now I have problem picking good colors for the slices. Is there some algorithm that is good at that?</p>
<p>Colors need to follow some rules:</p>
<ul>
<li>they need to look nice</li>
<li... | <p>I solved it as follows:</p>
<ol>
<li>Choose a <strong>base color</strong>.</li>
<li>Calculate its <strong>hue</strong> (<code>baseHue</code>).</li>
<li>Create a color with the same saturation and luminosity, with its hue calculated as:<pre>
hue = baseHue + ((240 / pieces) * piece % 240
</pre></li>
</ol>
<p>In C#... | <p>I found this pseudocode formula that might help. You could start with a set to seed it.</p>
<p>Colour Difference Formula</p>
<p>The following is the formula suggested by the W3C to determine the difference between two colours.</p>
<p>(maximum (Red value 1, Red value 2) - minimum (Red value 1, Red value 2)) + (max... | 29,316 |
<p>I have an existing bare git repository located in /home/myaccount/git/project. I am currently using it over ssh from my local machine without any problems. I want to add a second user on the server which only shall access to this git repository (maybe move the repo outside my account folder?). How? Using latest vers... | <p>Have him create a ssh keypair and send you the public key.</p>
<p>Add the public key to your <code>~/.ssh/authorized_keys</code> file, and add the <code>command="..."</code> option to limit it to the git-shell - see <a href="http://kitenet.net/~joey/blog/entry/locking_down_ssh_authorized_keys/" rel="noreferrer">thi... | <p>You will also probably want to have both of those users in the same user group, and to make sure you have group-write privileges on the repository.</p>
| 47,029 |
<p>This is what I currently have:</p>
<pre><code>CREATE OR REPLACE TRIGGER MYTRIGGER
AFTER INSERT ON SOMETABLE
FOR EACH ROW
DECLARE
v_emplid varchar2(10);
BEGIN
SELECT
personnum into v_emplid
FROM PERSON
WHERE PERSONID = :new.EMPLOYEEID;
dbms_output.put(v_emplid);
/* INSERT INTO SOMEOTHERTABLE USING ... | <p>1) There must be something else to your example because that sure seems to work for me</p>
<pre><code>SQL> create table someTable( employeeid number );
Table created.
SQL> create table person( personid number, personnum varchar2(10) );
Table created.
SQL> ed
Wrote file afiedt.buf
1 CREATE OR REPLAC... | <p>I would not use a select statment in a trigger ever. Insert into the table rather than a select into. Once the table already exists select into does not work in most databases.</p>
| 24,777 |
<p>This is something that's been bothering me a while and there just has to be a solution to this. Every time I call ShellExecute to open an external file (be it a document, executable or a URL) this causes a very long lockup in my program before ShellExecute spawns the new process and returns. Does anyone know how to ... | <p>I don't know what is causing it, but Mark Russinovich (of sysinternal's fame) has a really great blog where he explains how to debug these kinds of things. A good one to look at for you would be <a href="http://blogs.technet.com/markrussinovich/archive/2006/11/27/532465.aspx" rel="nofollow noreferrer">The Case of th... | <p>I don't know what is causing it, but Mark Russinovich (of sysinternal's fame) has a really great blog where he explains how to debug these kinds of things. A good one to look at for you would be <a href="http://blogs.technet.com/markrussinovich/archive/2006/11/27/532465.aspx" rel="nofollow noreferrer">The Case of th... | 21,393 |
<p>Where is the setting in Visual Studio 2003 to set the include path for individual projects? I know about the VC Directories option in Tools>Options but that is machine specific and won't help when I hand this off to other developers. </p>
| <p><img src="https://www.lemurproject.org/images/VS_Net_AdditionalIncludes.jpg" alt="alt text"></p>
| <p>Strangely I don't see that option. I ended up opening the vcproj file in jedit and writing it in. </p>
<p><a href="http://img88.imageshack.us/img88/1128/idontknowmanln2.jpg" rel="nofollow noreferrer">idontknow http://img88.imageshack.us/img88/1128/idontknowmanln2.jpg</a></p>
| 24,909 |
<p>I'm trying to get something very subtle to work, it looks pretty awful right now. I'm trying to paint the background of a TGroupBox which I have overloaded the paint function of so that the corners are show through to their parent object. I've got a bunch of nested group boxes that look very decent without XPThemes... | <p>I'm trying to duplicate this problem with the following steps:</p>
<p>1 - Set theme to Windows XP default</p>
<p>2 - Drop a TGroupBox on an empty form (align = alNone)</p>
<p>3 - Drop two TGroupBoxes inside the first one, with align = alBottom and align = alClient</p>
<p>But visually it looks just fine for me.</... | <p>Ha, that was lame, I just needed to not set <code>ParentBackground := false</code> in my constructor and paint the interior of the group box when appropriate. </p>
| 18,658 |
<p>I want to use this pure HTML/CSS template for my ASP.NET website:</p>
<p><a href="http://sub3.tanguay.de" rel="nofollow noreferrer">http://sub3.tanguay.de</a></p>
<p>I copy it inside my Default.aspx page, inside the FORM element, but the form messes up the layout:</p>
<p><a href="http://sub2.tanguay.de" rel="nofo... | <p>1) try removing the background-color attribute from the form class:</p>
<pre><code>form {
margin:10px; padding: 0;
border: 1px solid #f2f2f2;
background-color: #FAFAFA; /* remove this */
}
</code></pre>
<p>2) you cannot nest forms, but the searchform is contained inside the ASP.Net form, and ASP.Net r... | <p>1) try removing the background-color attribute from the form class:</p>
<pre><code>form {
margin:10px; padding: 0;
border: 1px solid #f2f2f2;
background-color: #FAFAFA; /* remove this */
}
</code></pre>
<p>2) you cannot nest forms, but the searchform is contained inside the ASP.Net form, and ASP.Net r... | 40,765 |
<p>I'm reading about wiring up the electronic components to my Prusa i3 using an Arduino Mega 2650 and Ramps 1.4.</p>
<p>I have step sticks, a heated bed, and a <a href="http://rads.stackoverflow.com/amzn/click/B007KG0ZYI" rel="noreferrer">Switching Power Supply 12v Dc 30a 360w</a> (more details on that later when I ... | <ul>
<li><p>Polarity matters, sometimes. Be especially mindful of the wires from your power supply to the board, as getting those the wrong way around will definitely cause damage. Heated beds and extruders are not polarity sensitive, and can go in either way. Fans are polarized, but will probably survive if you get th... | <p>Adding to the other answers:</p>
<ul>
<li>ALWAYS power-off the printer completely and make sure it is not receiving any power from any source (could be receiving power from USB after you turned the power supply off).</li>
<li>Avoid loose wires, and before powering the printer on make sure every wire is connected in... | 123 |
<p>This has always bugged me. When I ssh or telnet to a Unix server (whatever flavour) it always manages to guess correctly the terminal type I am logging in from and so the keyboard always acts 'normally' ... i.e. the backspace key works. </p>
<p>But then when I have successfully logged in, it often guesses incorrect... | <p>I think you mean backspace properly works when you are inputting your username and password, then it stops working after you've logged in. </p>
<p>Most likely stty is being set to something else in ~/.profile or /etc/profile (or another script that executes on login). </p>
<p>Find that file and comment the line.</... | <p>What SSH/telnet software are you using? </p>
<p>When logging in via SSH, username/password entry is usually handled by the client, so it may be irrelevant.</p>
<p>My guess would be that the TERM environment variable is being set incorrectly by your terminal software, eg. set to "vt100" when terminal is set to beh... | 38,676 |
<p>I have the following in a program (written in VB.NET):</p>
<pre><code>Imports Microsoft.Office.Interop.Excel
Public Class Form1
Dim eApp As New Excel.Application
Dim w As Excel.Workbook
w = eApp.Workbooks.Open( "path.xls", ReadOnly:=True)
.. Processing Code ..
//Attempts at killing the excel ap... | <p>I had to do this a while back in NET 1.1, so please forgive the rust. </p>
<p>On the eApp, there was a Hwind (a win32 window handle - <a href="http://msdn.microsoft.com/en-us/library/bb255823.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb255823.aspx</a> ) or similar object. I had to use ... | <p>I posted a solution to this a few days ago:
<a href="https://stackoverflow.com/questions/51462/killing-excelexe-on-server#312513">Killing Excel.EXE on server</a></p>
<p>Same method as StingyJack mentions; the only one I know to really work.</p>
| 41,667 |
<p>What are some toolkits for developing 2D games in Python? An option that I have heard of is Pygame, but is there anything that has more range to do more things? What are the good and bad parts about the modules?</p>
| <p>I use <a href="http://www.pygame.org/news.html" rel="nofollow noreferrer">pygame</a> myself and it is very good. It has good documentation and tutorials, and is quite well designed. I've also heard wonderful reviews of <a href="http://www.pyglet.org/" rel="nofollow noreferrer">pyglet</a>.</p>
| <p>I've only heard people talk about pygame. It has tons of followers & plenty of functionality.</p>
<p>Recently I saw <a href="https://rads.stackoverflow.com/amzn/click/com/1590598725" rel="nofollow noreferrer" rel="nofollow noreferrer">this book</a> at barnes & noble which I might check out one day. It loo... | 5,492 |
<p>I've tried printing in vase mode (or "spiralise outer contour" in Cura) and while the floor looks fine, the vertical sides look "saggy"</p>
<p>I'm using a 0.4 mm nozzle, with eSUN PLA+ at 218 °C and a bed temp of 60 °C. This combination works fine for normal printing. Layer height is 0.28 mm (... | <p>Presuming that you're talking about an 8 hour period, your printer should be designed to run for 8 hours continuous anyway, so nothing will happen regarding the bed or screen that wouldn't happen with a normal print.</p>
<p>If the first few layers stick to the bed, it's likely that you're print will at least be part... | <p>There are software solutions like "Spaghetti Detective" (recently renamed to "Obico") which can watch your print via a camera, and potentially stop the job if it looks bad.</p>
<p>Most of the time my print failures come early, in the form of poor bed adhesion - watch the job start for a while be... | 2,158 |
<p>In asp.net 3.5, I have a problem that if I upload my global.asax to the remote web server, the app starts looking for my local sql server and eventually times out. I use a different config file for the local and remote because of the sql server login. Local is windows auth and remote is sql server auth. However,... | <p>Dropping in the global.asax file that will cause the inherited class to be used, is there any code in the inherited class that could be causing changes? </p>
<p>The .asax maybe blank but that doesn't mean the inherited class is.</p>
| <p>Have you checked the class it's inheriting from? It looks to be inheriting from <strong>myapp.Global</strong></p>
| 41,071 |
<p>Whilst debugging my program in VS 2008 I have come across the following error:</p>
<p>The CLR has been unable to transition from COM context 0x34fc1a0 to COM context 0x34fc258 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very l... | <p>You can turn this off if you think you've definitely <em>not</em> got a deadlock situation:</p>
<p>Debug->Exceptions->Managed Debug Assistants menu in Visual Studio and uncheck the ContextSwitchDeadlock</p>
| <p>Couple thoughts/questions:</p>
<p>1) The code snippet looks like your interval is every 1 second (not 5 as mentioned in the comments).
2) The big question is what is <code>RequestWork()</code> doing?</p>
<p>Without knowing what <code>RequestWork()</code> is doing, we can't really comment on why you are seeing a ... | 43,351 |
<p>we have SAP Business One - Fourth Shift Edition running here at a small manufacturing company. The consulting company that has come in to do the installation/implementation uses the "sa" id/pass to initially connect to the database to get the list of companies. From then on, I have to assume that its the sa id/pas... | <p>That sa usage sounds like a recipe for disaster.</p>
<p>In most security models I have seen, regardless of how you connect, the first lookup SPs, views or tables are read-accessible to all authenticated users. Even if the application has a dedicated logon, it's not sa.</p>
<p>Without knowing more about SAPs limit... | <p>That is very wrong, the sa account should not be used for general use.</p>
<p>A separate ('application' specific) user account should be used so that:</p>
<ul>
<li>Security can be applied on a per user (application) level</li>
<li>If anything goes wrong with the application (e.g. it locks the user account), just t... | 47,118 |
<p>I'd like to add scrolling capability to a <code>javax.swing.JDesktopPane</code>. But wrapping in a <code>javax.swing.JScrollPane</code> does not produce the desired behavior.</p>
<p><a href="http://www.google.com/search?q=scrollable+jdesktoppane" rel="nofollow noreferrer">Searching the web</a> shows that this has b... | <p>I've used <a href="http://www.javaworld.com/javaworld/jw-11-2001/jw-1130-jscroll.html" rel="noreferrer" title="Scrollable JDesktopPane">JavaWorld's solution</a> by creating my own <code>JScrollableDesktopPane.</code> </p>
| <p>I've found this : <a href="http://www.javaworld.com/javaworld/jw-11-2001/jw-1130-jscroll.html?page=1" rel="nofollow">http://www.javaworld.com/javaworld/jw-11-2001/jw-1130-jscroll.html?page=1</a></p>
<p>It's a nice tutorial with lots of explanations and infos on Swing & so, which permits to create a JscrollableD... | 17,915 |
<p>I'm trying to import an excel file in to a SQL Server 2000 database using DTS. This is nothing fancy, just a straight import. Where I work, we do this 1000 times a day. This procedure usually works without an issue but something must have changed in the file.</p>
<p>I'm getting the below error:</p>
<p><a href="http:... | <p>I'm not sure what books are out there, but here is some required reading on how ItemsControls work:</p>
<ul>
<li><a href="http://drwpf.com/blog/ItemsControlSeries/tabid/59/Default.aspx" rel="nofollow noreferrer">Dr, WPF - Items Control A- Z</a></li>
<li><a href="http://www.codeproject.com/KB/WPF/TreeViewWithViewMod... | <p>Here's a real world example of where this override is used in relation to a TreeView control: <a href="http://blogs.msdn.com/jpricket/archive/2008/08/05/wpf-a-stretching-treeview.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/jpricket/archive/2008/08/05/wpf-a-stretching-treeview.aspx</a></p>
<p>I hope this h... | 47,526 |
<p>I have a <code>List<int></code> and a <code>List<customObject></code>. The customObject class has an ID property. How can I get a <code>List<customObject></code> containing only the objects where the ID property is in the <code>List<int></code> using LINQ?</p>
<p><strong>Edit</strong>: I acc... | <pre><code>var result = from o in objList where intList.Contains(o.ID) select o
</code></pre>
| <p>Please note that using the join instead of contains DOES NOT work when the count of items in the list exceeds 49! You will get the error: <code>Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries.</code></p>
| 5,861 |
<p>I need to be able to export Trac tickets from a report or custom query to Excel, including the ticket description. The catch is that the description must be formatted as defined by the wiki syntax rather than displaying the raw text.</p>
| <p>you can just go to "View Tickets" and chose "Custom Query" there you select all the columns you want to see. There will not be a "Description" column, cause it could be wiki formatted, therefore it is available only as a "row" option. But you can still edit the query manually, and add a: &col=description in it, ... | <p>I've had the same issue.
I've tried ExcelExportPlugin, but it is not better than exporting in CSV.
In particular, it doesn't format the "description".</p>
<p>I've had better luck saving the whole HTML report, isolating the html table, and importing it as html file in Excel : It keeps well all the formatting.</p>
<... | 49,301 |
<p>I am wondering how to get a process run at the command line to use less processing power. The problem I'm having is the the process is basically taking over the CPU and taking MySQL and the rest of the server with it. Everything is becoming very slow.</p>
<p>I have used <code>nice</code> before but haven't had much... | <p>You should use nice with 19 "niceness" this makes the process very unlikely to run if there are other processes waiting for the cpu.</p>
<pre><code> nice -n 19 <command>
</code></pre>
<p>Be sure that the program does not have busy waits and also check the I/O wait time.</p>
| <p>Using CPU cycles alone shouldn't take over the rest of the system. You can show this by doing:</p>
<pre><code>while true; do done
</code></pre>
<p>This is an infinite loop and will use as much of the CPU cycles it can get (stop it with ^C). You can use <code>top</code> to verify that it is doing its job. I am quit... | 32,154 |
<p>I recently inherited a VBA macro that needs to have validation logic added to it. I need to be able to determine if any characters in a text based cell are non ASCII characters (i.e. have a binary value > 0x7F). The cells may contain some carriage control values (particularly linefeeds) that need to be retained (s... | <p>The asc(character) command will convert a character to it's ASCII value. </p>
<p>hex(asc(character)) will convert the character to it's HEX value.</p>
<p>Once you've done that you can easily do some comparisons to determine if the data is bad and toss the errors if required.</p>
<p>Here's some sample code:
<a hr... | <pre><code>Function IsGoodAscii(aString as String) as Boolean
Dim i as Long
Dim iLim as Long
i=1
iLim=Len(aString)
While i<=iLim
If Asc(Mid(aString,i,1))>127 then
IsGoodAscii=False
Exit Function
EndIf
i=i+1
Wend
IsGoodAscii=True
End Function
</code></pre>
| 32,865 |
<p>In the C / Unix environment I work in, I see some developers using <code>__progname</code> instead of <code>argv[0]</code> for usage messages. Is there some advantage to this? What's the difference between <code>__progname</code> and <code>argv[0]</code>. Is it portable?</p>
| <p><code>__progname</code> isn't standard and therefore not portable, prefer <code>argv[0]</code>. I suppose <code>__progname</code> could lookup a string resource to get the name which isn't dependent on the filename you ran it as. But <code>argv[0]</code> will give you the name they <em>actually</em> ran it as which ... | <p>If your program was run using, for instance, a symbolic link, argv[0] will contain the name of that link.</p>
<p>I'm guessing that __progname will contain the name of the actual program file.</p>
<p>In any case, argv[0] is defined by the C standard. __progname is not.</p>
| 34,486 |
<p>I'd like to track changes in inputs in a form via javascript. My intent is (but not limited) to</p>
<ul>
<li>enable "save" button only when something has changed</li>
<li>alert if the user wants to close the page and something is not saved</li>
</ul>
<p>Ideas?</p>
| <p>Loop through all the input elements, and put an <code>onchange</code> handler on each. When that fires, set a flag which lets you know the form has changed. A basic version of that would be very easy to set up, but wouldn't be smart enough to recognize if someone changed an input from "a" to "b" and then back to "a"... | <p>Attach an event handler to each form input/select/textarea's onchange event. Setting a variable to tell you if you should enable the "save" button. Create an onunload hander that checks for a dirty form too, and when the form is submitted reset the variable:</p>
<pre>
window.onunload = checkUnsavedPage;
var isDirty... | 23,582 |
<p>I have a basic cs-major understanding of multi-threading but have never had to do anything beyond simple timers in an application. Does anyone know of a good resource that will give me a tour how to work with multi-threaded applications, explaining the basics and maybe posing some of the more difficult stuff?</p>
| <p>This is a great free resource by Joseph Albahari. <a href="http://www.albahari.com/threading/" rel="noreferrer">Threading in C#</a></p>
| <p>One of the best resources I know on the subject is the "threading in C#" book:
<a href="http://www.albahari.com/threading/" rel="nofollow noreferrer">http://www.albahari.com/threading/</a></p>
<p>I has a great overview of all a .net developer need to understand in order to program multi threaded applications.</p>
| 7,243 |
<p>I have CruiseControl.NET Version 1.4 set up on my development server. Whenever a developer checks in code, it makes a compile. </p>
<p>Now we're at a place where we can start giving our application to the testers. We'd like to use ClickOnce to distribute the application, with the idea being that when a tester go... | <p>We've done this and can give you some pointers to start.</p>
<p>2 things you should be aware of:</p>
<ul>
<li>MSBuild can generate the necessary deployment files for you.</li>
<li>MSBuild won't deploy the files to the FTP or UNC share. You'll need a separate step for this.</li>
</ul>
<p>To use MSBuild to generate... | <p>You want to use the ClickOnce manifest generation tasks in msbuild. The process is a little long winded, so I am just going to point you to a couple of links. Here is the <a href="http://msdn.microsoft.com/en-us/library/6wc2ccdc.aspx" rel="nofollow noreferrer">reference on msdn</a> and a <a href="http://windowscli... | 3,349 |
<p>I need to know how to iterate through records in CR2008 and when it reaches a record that is NOT NULL, record that in a variable.</p>
<p>I have a formula called "frmAccum" that I drop in the details section and suppress it. I use this to gather information for each record that's processed. I also have a formula c... | <p><strong>Please don't do this.</strong> It's a really, really, really, really, really <em>bad idea</em>.</p>
<p>Maybe not as bad as deleting files randomly, if the hard drive runs out of room - but just about as bad.</p>
| <p>Mark's code is probably better, but here's mine...</p>
<p>If you <strong>really</strong> want to do something like this, I'd use code something like this. Yes, you still have to manually call it, but your idea of indiscriminately retrying ALL excepting methods is a really, really bad idea.</p>
<pre><code>public c... | 43,553 |
<p>Does anyone have experience using the URL Rewrite Module (see <a href="http://blogs.iis.net/bills/archive/2008/07/09/new-iis7-releases-url-rewrite-application-routing-and-load-balancing-and-powershell-cmd-lets.aspx" rel="nofollow noreferrer">here</a>)?</p>
<p>Can it be used to do <a href="http://en.wikipedia.org/wi... | <p>If you have enough RAM, SQL will do an outstanding job determining what to load into RAM and what to seek on disk. </p>
<p>This question is asked a lot and it reminds me of people trying to manually set which "core" their process will run on -- let the OS (or in this case the DB) do what it was designed for.</p>
<... | <p><a href="http://msdn.microsoft.com/en-us/library/ms178015(SQL.90).aspx" rel="nofollow noreferrer">DBCC PINTABLE</a> will explicitly pin a table in core if you want to make sure it remains cached.</p>
| 6,455 |
<p>What is the proper way to modify environment variables like PATH in OS X?</p>
<p>I've looked on Google a little bit and found three different files to edit:</p>
<ul>
<li>/etc/paths</li>
<li>~/.profile</li>
<li>~/.tcshrc</li>
</ul>
<p>I don't even have some of these files, and I'm pretty sure that <em>.tcshrc... | <p>Bruno is right on track. I've done extensive research and if you want to set variables that are available in all GUI applications, your only option is <code>/etc/launchd.conf</code>.</p>
<p>Please note that <a href="https://web.archive.org/web/20100212232552/https://www.digitaledgesw.com/node/31" rel="noreferrer">e... | <p>For Bash, try adding your environment variables to the file <code>/etc/profile</code> to make them available for all users. No need to reboot, just start a new Terminal session.</p>
| 16,430 |
<p>My Ender 5 Plus (original) does not perform leveling.</p>
<p>After the self-leveling command, the Z axis only descends.
I have already exchanged the BLTouch three times, and the problem remains unchanged.</p>
<p>I bought my E5P in December, in America, to bring it to Brazil, I had to completely dismantle it.</p>
<p>... | <p>I had the same problem with my Ender 5 Plus.</p>
<p>There is a small set screw at the top of the BLTouch you will need to tighten this in to adjust the location of the sensor pin. Keep screwing it more and more until you see it initialize reliably that is it should move out and back twice to initialize.</p>
<p>When ... | <p>I had the same issue. The probe for the BL touch was just stuck.</p>
<p>I manually pulled it out and tightened the screw and then the problem was fixed.</p>
| 1,930 |
<p>Is there a better way to do the following:</p>
<pre><code>$array = array('test1', 'test2', 'test3', 'test4', 'test5');
// do a bunch of other stuff, probably a loop
$array[] = 'test6';
end($array);
echo key($array); // gives me 6
</code></pre>
<p>This will give the key of the most recently add array element.</p>
... | <p>You could also do:</p>
<pre><code>$end = end(array_keys($array));
</code></pre>
<p>But I think your way makes it clear what you want to do, so you could whip something up like:</p>
<pre><code>function array_last_key($array) {
end($array);
return key($array);
}
</code></pre>
<p>That's about it.</p>
| <p>There is no special function for this in PHP, so I think your way is the most efficent way of doing this. For readability you might want to put it in a function called something like array_last_key().</p>
| 26,556 |
<p>My client has a multi-page PDF file. They need it split by page. Does anyone know of a way to do this - preferably in C#.</p>
| <p><a href="http://www.pdfsharp.com/" rel="noreferrer">PDFSharp</a> is an open source library which may be what you're after:</p>
<blockquote>
<p>Key Features</p>
<ul>
<li>Creates PDF documents on the fly from any .Net language</li>
<li>Easy to understand object model to compose documents</li>
<li>One source code for d... | <p>I did this using <a href="http://itextsharp.sourceforge.net" rel="nofollow noreferrer">ITextSharp</a> -- there are commercial options that may have a good API but this is open source and free, and not hard to use.</p>
<p>Check out <a href="http://itextsharp.sourceforge.net/examples/Split.cs" rel="nofollow noreferre... | 14,845 |
<p>When I launch the "mvn install" command, maven sometimes tries to download dependencies that it has already downloaded. That's expected for SNAPSHOT but why does maven do that for other JARs?</p>
<p>I know I can avoid that behavior by "-o" flag but I just wonder what the cause is.</p>
| <p>I'd look for dependencies that don't have a specified version number. Maven will periodically check to make sure that it has the most up-to-date version of these artifacts.</p>
| <p>The -o flag still wasn't working for me, but this did:</p>
<pre><code>find ~/.m2/repository -name '_maven*' | xargs rm
find ~/.m2/repository -name '*lastUpdated' | xargs rm
</code></pre>
<p>Which will delete all the .lastUpdated and _maven.repositories files in your local repo. I ran into this issue because we hav... | 15,408 |
<p>When using CDT I would like to have std::string show up in the 'variable' debug window with the string it contains. For instance if it is currently holding the word <em>"history"</em> I would like to see <strong>history</strong> in the debugger window labeled "variables". </p>
<p>I think that there is a general way... | <p>Displaying stl containers with eclipse/gdb was also a major pain for me for a long time.</p>
<p>But now I've just discovered that the latest version of gdb with python enabled can help with that.</p>
<p>It follows what I've done (using Ubuntu Linux 8.10):</p>
<ul>
<li>Install gdb version >= 6.8.50 (for instance <... | <p>The only way I have found is to use the GDB command line:</p>
<ol>
<li>In the <em>Debug</em> window, click on <em>gdb</em>.
It's just below the stack trace.</li>
<li>In the <em>Console</em> window, use the GDB <code>up</code> command to get to the stack frame you want</li>
<li><p>Again in the <em>Console</em> wind... | 37,826 |
<p>I am creating a script on the fly to ftp some files from a remote computer. I create a file which is then called from the command line with</p>
<pre><code>ftp -s:filename proxy
</code></pre>
<p>where filename is the file I just created. The file has code similar to the following:</p>
<pre><code>anonymous@ip add... | <p>In most ftp clients you can set the working directory on the server with the command <strong>cd</strong>, and you set the working directory on the client with the command <strong>lcd</strong>.</p>
<p>But it is not clear to me what you are trying to do.</p>
<p>Are you trying to move or copy files that are on the ft... | <p>In most ftp clients you can set the working directory on the server with the command <strong>cd</strong>, and you set the working directory on the client with the command <strong>lcd</strong>.</p>
<p>But it is not clear to me what you are trying to do.</p>
<p>Are you trying to move or copy files that are on the ft... | 46,671 |
<p>We run a medium-size site that gets a few hundred thousand pageviews a day. Up until last weekend we ran with a load usually below 0.2 on a virtual machine. The OS is Ubuntu.</p>
<p>When deploying the latest version of our application, we also did an apt-get dist-upgrade before deploying. After we had deployed we n... | <p>The answer ended up being not-Apache related. As mentioned, we were on a virtual machine. Our user sessions are pretty big (think 500kB per active user), so we had a lot of disk IO. The disk was nearly full, meaning that Ubuntu spent a lot of time moving things around (or so we think). There was no easy way to exten... | <p>Another option that I can't assure you will do any good, but it's more than worth the effort. Is to read the detailed changelog for the new version, and review what might have changed that could remotely affect you. </p>
<p>Going through the changelogs has saved me more than once. Especially when some config optio... | 20,936 |
<p>My employer was recently acquired by a much larger company. In the process of sorting out all the legal details around our licenses for our development software, we have learned that the vendor of our IDE charges a "nominal" fee of 25% of the cost of a new license to transfer our existing licenses to the new corpor... | <p>Unfriendly? Yes. Abnormal? No. Its actually very common for tools with a hefty per-seat license fee to charge for a transfer after acquisition. I believe they do it because they can: the cost of transferring license is either overlooked during the M&A due diligence or is considered inconsequential compared to th... | <p>I would have expected your new overlords to have been made aware of this as part of their takeover plans. Part of the process involves checking for exactly this kind of gotcha.</p>
<p>Sounds like they chose to ignore the information or did not check it out.</p>
| 7,278 |
<p>Would you please help me in making a rollover effect using jquery, what i want to do is when someone hover over any of the menu items the text slide down and disappear and a picture slides from the top down to the center (e.g. you could see this effect here <a href="http://www.iviewcom.com/panda" rel="nofollow noref... | <p>Instead of doing it for you, I'll offer some places to start looking.. </p>
<p>Here is an example that could be easily modified to use 'rollover' instead of 'click': <a href="http://css-tricks.com/examples/MenuFader/" rel="noreferrer">http://css-tricks.com/examples/MenuFader/</a></p>
<p>Details on how the above ex... | <p>First things first, you'll really want to give your independent anchor tags ids, as it will make accomplishing what you're wanting much easier.</p>
<p>Look at the slideDown(), and slideToggle() functions, and it would basically require you setting up hidden divs and then on the mouseover event, you would slidetoggl... | 32,759 |
<p>This question has been asked in regards to 2005, but did not see anything with 2000. We have a new application that needs to run on 2005 or better but everything else we have is geared towards 2000. We could upgrade, but that is not within budget at this time. </p>
<p>We were thinking we could run SQL Server 200... | <p>On our development server we have lots of versions installed eg: 2000, 2005 Express, 2005 standard, 2008 express we haven't had any major problems.</p>
<p>You will need to install them as named instances when you go through the installation procedure, eg:</p>
<p>MyServer\SQL2000
MyServer\SQL2005Express
MyServer\SQ... | <p>I have a server that runs both sql2000 and 2005 and i have had not problems whatsoever - sql2005 is running a seperate instance.</p>
<p>I see no problems with proceeding. The only issue i've had is 2005 express does not have DTS/SSIS so getting data in is cumbersome, but that has nothing to do with running both :-... | 36,709 |
<p>My question is pretty straightforward: You are an executable file that outputs "Access granted" or "Access denied" and evil persons try to understand your algorithm or patch your innards in order to make you say "Access granted" all the time. </p>
<p>After this introduction, you might be heavily wondering what I a... | <p>You're getting into "Anti-reversing techniques". And it's an art basically. Worse is that even if you stomp newbies, there are "anti-anti reversing plugins" for olly and IDA Pro that they can download and bypass much of your countermeasures.</p>
<p>Counter measures include debugger detection by trap Debugger APIs... | <p>So, you want to write a program that accepts a key at the beginning and stores it in memory, subsequently retrieving it from disc. If it's the correct key, the software works. If it's the wrong key, the software crashes. The goal is that it's hard for pirates to generate a working key, and it's hard to patch the ... | 12,517 |
<p>I'm involved in a project that is attempting to use the Eclipse RCP splash screen to gather user credentials, language, etc. If this screen loses focus, it is not available (under Windows at least) through the ALt-Tab functionality, and can only be found by minimizing all other windows and uncovering it. Any way of ... | <p>I think it might be time to examine those unknown reasons. Even eclipse doesn't use the splash screen in this way. If it needs to prompt for information, it opens a new dialog to ask for it.</p>
<p>Good luck.</p>
<p><strong>[Edit]</strong> I stand corrected. <a href="http://dev.eclipse.org/newslists/news.eclip... | <p>Create your own implementation of AbstractSplashHandler.
When creating the shell, don't use the SWT.TOOL style.
The shell will be accessible through the windows task bar.</p>
| 19,709 |
<p>Say if I had a table of books in a MySQL database and I wanted to search the 'title' field for keywords (input by the user in a search field); what's the best way of doing this in PHP? Is the MySQL <code>LIKE</code> command the most efficient way to search?</p>
| <p>Yes, the most efficient way usually is searching in the database. To do that you have three alternatives:</p>
<ul>
<li><a href="http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html" rel="noreferrer">LIKE, ILIKE</a> to match exact substrings</li>
<li><a href="http://dev.mysql.com/doc/refman/5.0/en... | <p>You may also check soundex functions (soundex, sounds like) in mysql manual <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_soundex" rel="nofollow noreferrer">http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_soundex</a>
Its functional to return these matches if for... | 18,367 |
<p>I am pretty sure that sanding makes a lot of microplastics, so it would be nice to collect the dust, and melt it to got a blob of plastic again instead of millions of tiny particles. What is the best way for collecting it, do you use any dust extractor, or are there different techniques like sanding wet surfaces and... | <p>I decided to collect the dust and treat both PLA and ABS with chemicals to completely break them down. That solves the issue and I won't rely on false hopes that somehow it does not end up in the environment.</p>
| <p>As an environmental thing, micro plastics are an urgent problem for ocean life, it’s getting into the entire food chain. With that in mind dumping it down the drain would be the worst, city filtration systems can’t get the tiny bits of plastic before it drains into the ocean. Sanding outside is kind of bad. I sand s... | 1,974 |
<p>I need help logging errors from T-SQL in SQL Server 2000. We need to log errors that we trap, but are having trouble getting the same information we would have had sitting in front of SQL Server Management Studio.</p>
<p>I can get a message without any argument substitution like this:</p>
<pre><code>SELECT MSG.de... | <p>In .Net, retrieving error messages (and anything output from <em>print</em> or <em>raiserror</em>) from sql server is as simple as setting one property on your SqlConnection ( <em>.FireInfoMessageEventOnUserErrors = True</em>) and handling the connection's InfoMessage event. The data received by .Net matches what y... | <p>Any chance you'll be upgrading to SQL2005 soon? If so, you could probably leverage their TRY/CATCH model to more easily accomplish what you're trying to do.</p>
<p>The variables exposed in the catch can give you the object throwing the error, the line number, error message, severity, etc. From there, you can log i... | 15,596 |
<p>In answering this question (<a href="https://stackoverflow.com/questions/352317/c-coding-question#352327">https://stackoverflow.com/questions/352317/c-coding-question#352327</a>), it got me wondering...</p>
<p>Is there any danger in regarding a static class as being equivalent to a non-static class instatiation tha... | <p>The only thing that seems immediately apparent to me is that a static class is basically just a collection of scoped functions (explicitly avoiding "methods" here) and a singleton is still something you can instantiate, even if you can only have 1. 1 > 0.</p>
<p>You can pass a singleton as an argument to something ... | <p>Not sure about C#, but in C++ a static Object will get initialized when it gets initialized, and you have no direct control over that (especially in multithreaded apps). So you need a function to call your object, not just call it directly (unless you want unportable code)</p>
| 45,877 |
<p>Ok, I'm developing an application that has been in pretty much continous development over the last 16 years, from C in DOS, through various flavours of C++ and now is largely based around C++ with MFC and StingRay GUIs and various other SDKs.</p>
<p>While I use VS 2005 for the release builds, I still use MSVC 6 for... | <p>A follow up to those who are interested. ClassWizard may be re-introduced in VS2010, from Tarek Madkour [VC++ Team] </p>
<blockquote>
<p>'We are considering adding the Class
Wizard back to VS10. We hope this will
make DDX/DDV function creation more
keyboard-centric just like it was in
VC6. There are some... | <p>I will suggest avoid code generation at all and use your favorite editor to manually create new code. If i understand correctly your are expert in this area and i sure you know that manually created code will be much cleaner and simpler then the generated one.<br>
In additional the code generator is a nightmare for ... | 17,795 |
<p>I have the <a href="http://us.xyzprinting.com/us_en/Product/da-Vinci-1.0">XYZPrinting da-Vinci-1.0</a> with ABS filament. I am concerned about ventilation. If this is used inside, what safety precautions are necessary, which are recommended, and/or which are optional?</p>
| <p>Yes... The issue with <em>all</em> 3d printing materials. Not just ABS, but worse with ABS is the fine air particulate and Ultra fine it creates during the 3d printing process. PLA is considered <em>safer</em> than ABS. But I fear people will use this as justification, it is like saying I only smoke one cig a day in... | <p>your fine at practical temperatures.
source: <a href="https://en.wikipedia.org/wiki/Acrylonitrile_butadiene_styrene#Hazard_for_humans" rel="nofollow">https://en.wikipedia.org/wiki/Acrylonitrile_butadiene_styrene#Hazard_for_humans</a></p>
<p>recommended would probably be set your controller to not go above 380c if y... | 328 |
<p>I just received my new Creality Ender 3. I was going through and checking/adjusting everything for alignment, and I noticed that when you "auto home" the print head, the nozzle stops off the front of the print bed by 5-10 mm.</p>
<p>Is that normal?</p>
<p>Is it perhaps by design to allow purging the nozzle... | <p>Yes, this is the "intended" behavior, as the home in relation to the physical limit position is not placed correctly about 7.5 mm into the bed in both X and Y.</p>
<p>to correct this, please look at the <a href="https://3dprinting.stackexchange.com/questions/6399/recalibrating-home-position">Recalibrating ... | <p>It is intentional for the head to start slightly off the build plate. </p>
<p>If it did start on the build plate you could crash the nozzle when the bed is not levelled. Note the level varies with temperature and build plate type. If you switch from PLA to ABS etc you should relevel the bed. </p>
<p>Having just ha... | 999 |
<p>I know that some big players have embraced it and are actually exposing some of their services in APP compliant way, already. However, I haven't found many other (smaller) players in this field. Do you know any web application/service that uses APP as its public API protocol? What is <em>your</em> own take on AtomPu... | <p>My own research so far:</p>
<ul>
<li><a href="http://codex.wordpress.org/AtomPub" rel="nofollow noreferrer">Wordpress</a> supports AtomPub as its API protocol since version 2.3 </li>
<li><a href="http://code.google.com/apis/gdata/" rel="nofollow noreferrer">GData</a> is probably the biggest shot in the AtomPub fiel... | <p>Last time I checked (2007 or so) Atompub was fairly complex to implement. While you can whip together something that emits valid Atom feeds during the lunch break, implementing AtomPub was a fairly big undertaking.</p>
<p>That might have changed due to better libraries and tools but still it might be too complex to... | 47,776 |
<p>I want to checkout, and then update as necessary, the <a href="http://code.djangoproject.com/" rel="nofollow noreferrer">Django Subversion trunk</a> on a Mac OS X Leopard 10.5.5 machine. </p>
<p>I am only interested in having updated Django code on my Mac. I am not interested in contributing patches to the Django p... | <p>If you're not going to be making changes to the Django code, then there's no reason to import it into Git. Just use option 1.</p>
<p>Using <code>git-svn</code> (either by running it yourself or by cloning somebody else's repository) is useful if you want to make local modifications to a project that uses Subversio... | <p>I agree with @cjm. If you just want a copy of the Django sources, use plain Subversion.</p>
<p>My experience with git-svn is that it is most useful for people who prefer and are more familiar with Git who have to track a Subversion-repository, and not so useful to people who are know Subversion but are git-newbies ... | 30,869 |
<p>I recently downloaded ndepend and ran an analysis on an open source project I participate in.</p>
<p>I did not now where to look next - a bit of visual and information overload and it turned out I don't even know where to start.</p>
<p>Can anyone suggest starting points?</p>
<ul>
<li>What information should I loo... | <p>Scott Hanselman / Stuart Celarier / Patrick Cauldwell's <a href="http://www.hanselman.com/blog/EducatingProgrammersWithPlacematsNDependStaticAnalysisPoster.aspx" rel="noreferrer">poster</a> with ndepend metrics has some useful information on it. Rather than trying to break down all the heuristics being used I'd focu... | <p>Excellent pair of web casts (30 minute videos) where Patrick Smacchia and Filip Ekberg talk through some of the features of nDepend and how to use them:</p>
<p><a href="http://codebetter.com/patricksmacchia/2012/10/31/two-screencasts-on-how-to-demystify-spaghetti-code/" rel="nofollow">http://codebetter.com/patricks... | 6,640 |
<p>I'm starting a new project; I wish to follow a DDD approach. We have talked to the business and achieved some insight into the domain in some detail (internet TV).</p>
<p>The team is five strong and distributed. We have adopted the repository pattern for data-access. We are following a service-based approach ove... | <p>Have you looked at the concept of aggregate roots in DDD? Basically you only request aggregate roots out of repositories and the whole aggregate is loaded. The aggregate has everything it needs to do the required operation, so that would eliminate your concern of chattiness and would also address your team's conce... | <p>It seems that your team are using the ORM just as a way of mapping the database to a set of concrete classes in order to make the code a bit nicer. If you think of creating a Domain Model instead and not just an abstracted database model then it would be apparent you should include relationships. How data is loaded ... | 24,952 |
<p>Here is the situation: I have 2 pages.</p>
<p>What I want is to have a number of text links(<code><a href=""></code>) on page 1 all directing to page 2, but I want each link to send a different value.</p>
<p>On page 2 I want to show that value like this: </p>
<blockquote>
<p>Hello you clicked {value}</p>
... | <p>Can you use any scripting? Something like Javascript. If you can, then pass the values along in the query string (just add a "?ValueName=Value") to the end of your links. Then on the target page retrieve the query string value. The following site shows how to parse it out: <a href="http://adamv.com/dev/javascrip... | <p>You might be able to accomplish this using HTML Anchors.</p>
<p><a href="http://www.w3schools.com/HTML/html_links.asp" rel="nofollow noreferrer">http://www.w3schools.com/HTML/html_links.asp</a></p>
| 12,813 |
<p>What is the exact pixel size of one column when I used the columns attribute to determine a width of an ASP.NET textbox control?</p>
<pre><code><asp:TextBox id="MyTextBox" runat="server" columns="10" />
</code></pre>
| <p>The Columns property is mapped to the size-attribute on the rendered input-tag. </p>
<p>If size is 10, then the browser is supposed to render the input field in a size that would make 10 characters fit and be visible in the input field. But that only really works for monospace fonts, since in many other fonts "III"... | <p>@Ryan Smith: I used your suggestion and modified it to make it scalable to the user montior settings.</p>
<pre><code>style="width: 100%"
</code></pre>
| 47,176 |
<p>Env.: Vista SP1, SQL Server Express 2005</p>
<p>I'm able to connect to my localhost SQL Server using SQL Server Management Studio, using Windows authentication and, to the best of my knowledge, all default parameters, including network protocol.</p>
<p>Now I try to connect using sqlcmd.exe to no avail:</p>
<pre><... | <p>Lose the leading \\</p>
<p>Actually, try .\XPRESS (period slash instance)</p>
| <p>Try </p>
<ul>
<li>Disabling the firewall</li>
<li>Using localhost instead</li>
<li>Check the Server setup (in management studio) to make sure remote connections are enabled</li>
<li>Check the settings in Surface Area configuration and make sure all the transports are enabled and remote connections are enabled</li>
... | 36,412 |
<p>I have to do some work for college and my professor likes to torture us with Nassi-Shneiderman diagrams. </p>
<p>Has anyone a good editor/graphcial tool to draw these? Requirements:</p>
<ul>
<li>cross platform (or able to run within wine)</li>
<li>open source (or a least free to for private use)</li>
</ul>
<p>--<... | <p>After considering some editors, I ended up by using Strutorizer from <a href="http://structorizer.fisch.lu/" rel="noreferrer">http://structorizer.fisch.lu/</a></p>
<p>It hasn't the best usability but it's good enough. And it's written in Java.</p>
| <p>Did you try 'Nessi'?</p>
<p><a href="http://eii.ucv.cl/nessi/" rel="nofollow noreferrer">http://eii.ucv.cl/nessi/</a></p>
| 41,098 |
<p>Suppose I have one list:</p>
<pre><code>IList<int> originalList = new List<int>();
originalList.add(1);
originalList.add(5);
originalList.add(10);
</code></pre>
<p>And another list... </p>
<pre><code>IList<int> newList = new List<int>();
newList.add(1);
newList.add(5);
newList.add(7);
ne... | <pre><code>originalList = newList;
</code></pre>
<p>Or if you prefer them being distinct lists:</p>
<pre><code>originalList = new List<int>(newList);
</code></pre>
<p>But, either way does what you want. By your rules, after updating, originalList will be identical to newList.</p>
<p>UPDATE: I thank you all f... | <p>My initial thought was that you could call originalList.AddRange(newList) and then remove the duplicates - but i'm not sure if that would be any more efficient than clearing the list and repopulating it.</p>
| 17,906 |
<p>I have a database of companies. My application receives data that references a company by name, but the name may not exactly match the value in the database. I need to match the incoming data to the company it refers to.</p>
<p>For instance, my database might contain a company with name "A. B. Widgets & Co Ltd.... | <p>You can use an <a href="http://en.wikipedia.org/wiki/Longest_common_subsequence_problem" rel="nofollow noreferrer">LCS</a> algorithm to score them.</p>
<p>I do this in my <a href="http://github.com/dustin/photo" rel="nofollow noreferrer">photo album</a> to make it easy to email in photos and get them to fall into s... | <p>Your database may suport the use of Regular Expressions (regex) - see below for some tutorials in Java - here's the link to the MySQL documentation (as an example):<br>
<br>
<a href="http://dev.mysql.com/doc/refman/5.0/en/regexp.html#operator_regexp" rel="nofollow noreferrer">http://dev.mysql.com/doc/refman/5.0/en/r... | 41,764 |
<p>What delphi function asserts that an object is not nil?</p>
| <p>Like knight_killer pointed out above, you use the <code>Assert()</code> function, asserting that <code>Assigned(obj)</code> is <code>true</code>. Of course, like in most compiled languages, assertions are <em>not</em> executed (or even included in the compiler output) unless you've specifically enabled them, so you ... | <p>if Assigned(MyObject) then
...</p>
| 17,990 |
<p>With one worker, who can only perform one task at a time (but can switch between tasks instantly)</p>
<p>Given a list of tasks,<br>
-- defined as "n seconds, every m seconds" (eg, 5 seconds every 3600 seconds)</p>
<p>How could I find the best starting times and count for each task?</p>
<p>If every task were "1 se... | <p>I think it depends on how you define 'best'. For instance, if you wanted tasks to run every m seconds "on average", there's an easy way to do it using the same sort of algorithm as the Bresenham method to draw lines (a task that's 'n seconds every m seconds' is much like scattering n vertical steps among m horizonta... | <p>This type of problem is hard to solve, but relatively easy to optimize. Take a look at Simulated Annealing, Great Deluge, or Genetic Algorithms.</p>
| 26,479 |
<p>Is it possible to use the __unused attribute macro on Objective-C object method parameters? I've tried placing it in various positions around the parameter declaration but it either causes a compilation error or seems to be ignored (i.e., the compiler still generates unused parameter warnings when compiling with -Wa... | <p>Okay, I found the answer... it appears to be a bug with the implementation of Apple's gcc 4.0. Using gcc 4.2 it works as expected and the proper placement is the following:</p>
<pre><code>-(void)someMethod:(id) __unused someParam;
</code></pre>
<p>It's documented in the Objective-C release notes if anyone is inte... | <p>After fighting with the #pragma for a while, I discovered it's </p>
<pre><code>+ (NSString*) runQuery:(id)query name:(NSString*)name options:(NSDictionary*)options
{
#pragma unused(name)
...
}
</code></pre>
| 36,266 |
<p>I've been given an early Christmas Present:<br>
Permission to step out of the development cycle to <strong>reorganize</strong> and <strong>document</strong> our application.<br>
I have complete freedom to restructure, refactor, and set up any amount of infrastructure I see fit.</p>
<p>If you had <a href="ht... | <p>I think you are all leaning in the right direction.</p>
<p>Go with Visual Studio 2008. It's very stable with SP1, and you can target both version 2 and version 3 of the .NET framework.</p>
| <p>We use SourceGear's Vault for version control and it works well for us as a small team.</p>
<p>For project/bug/support tracking we use OnTime 2008 from AxoSoft. </p>
<p>We also use ScrewTurn Wiki to document procedures and sample code/best practices.</p>
<p>For our build process, we haven't fully automated into a... | 43,299 |
<p>I have a really simple Java class that effectively decorates a Map with input validation, with the obvious void set() and String get() methods.</p>
<p>I'd like to be able to effectively call those methods and handle return values and exceptions from outside the JVM, but still on the same machine <strong>Update: the... | <p>Ok. Here's another try now that I know the client is not Java. Since you want out-of-process access and possibly remote machine access, I don't think JNI is what you want since that's strictly in-process (and a total hassle). Here are some other options:</p>
<p><strong>Raw Sockets</strong> : just set up a listener ... | <p>JNI (Java Native Interface) allows access to java code from C or C++.</p>
| 48,150 |
<p>I've several textboxes. I would like to make the Enter button act as Tab. So that when I will be in one textbox, pressing Enter will move me to the next one. Could you please tell me how to implement this approach without adding any code inside textbox class (no override and so on if possible)?</p>
| <p>Here is the code that I usually use.
It must be on KeyDown event.</p>
<pre><code>if (e.KeyData == Keys.Enter)
{
e.SuppressKeyPress = true;
SelectNextControl(ActiveControl, true, true, true, true);
}
</code></pre>
<p><strong>UPDATE</strong></p>
<p>Other way is sending "TAB" key! And overriding the method m... | <p>Taking a wild guess:</p>
<pre><code>// on enter event handler
parentForm.GetNextControl().Focus();
</code></pre>
| 48,526 |
<p>Slashdot has a little widget that allows you to tweak your comment threshold to filter out down-modded comments. It will be in one place if you scroll to the top of the page, and as you scroll down, at some point, where its original home is about to scroll off the page, it will switch to fixed position, and stay on... | <p>Okay, I figured it out. I will post it here in case it help anyone else. This solution uses prototype, and an internal library that gives me the registerEvent, getElementX and getElementY functions, which do what you would think.</p>
<pre><code>var MenuManager = Class.create({
initialize: function initialize(... | <p>For a demo but not based on the code above checkout:</p>
<p><a href="https://stackoverflow.com/questions/2352896/fixing-tabs-to-the-top-of-the-page-but-underneath-the-header">fixed-floating-elements</a></p>
| 8,059 |
<p>I have two classes that each need an instance of each other to function. Ordinarily if an object needs another object to run, I like to pass it in the constructor. But I can't do that in this case, because one object has to be instantiated before the other, and so therefore the second object does not exist to be p... | <p>It's time to take a look at MVC. :-) When you have a model-view-controller situation, the consensus is that the model shouldn't be aware of the view-controller (MVC often plays out as M-VC), but the view is invariably aware of the model.</p>
<p>If the model needs to tell the view something, it does so by notifyin... | <pre><code>panel = new Panel(backend);
</code></pre>
<p>You do this in this routine something like</p>
<pre><code> Public Sub Panel(ByVal BackEnd as BackEnd)
Me.MyBackEnd = BackEnd
BackEnd.MyPanel = Me
End Sub
</code></pre>
<p>You don't need BackEnd.SetPanel</p>
<p>It is better to use Proxies. A ... | 48,584 |
<p>Is there a way to prematurely abort a transaction? Say, I have sent a command to the database which runs five minutes and after four, I want to abort it.</p>
<p>Does JDBC define a way to send a "stop whatever you are doing on this connection" signal to the DB?</p>
| <p>As mentioned by james, <a href="https://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html#cancel()" rel="noreferrer">Statement.cancel()</a> will cancel the execution of a running Statement (select, update, etc). The JDBC docs specifically say that Statement.cancel() is safe to run from another thread and ev... | <p>No, you can't abort it using standard JDBC.</p>
<p>You might try to check if your particular RDBMS define some extension to suppot it.</p>
| 37,837 |
<p>How do you schedule a task in Windows XP to run when you shutdown windows. Such that I want to run a simple command line program I wrote in c# everytime I shut down windows. There doesn't seem to be an option in scheduled tasks to perform this task when my computer shuts down.</p>
| <p>Execute gpedit.msc (local Policies)</p>
<p>Computer Configuration -> Windows settings -> Scripts -> Shutdown -> Properties -> Add</p>
| <p>I had to also enable "Specify maximum wait time for group policy scripts" and "Display instructions in shutdown scripts as they run" to make it work for me as I explain <a href="https://stackoverflow.com/a/57472148/6329629">here</a>.</p>
| 12,712 |
<p>I have a Javascript that changes the host in links to match the current development/test server.</p>
<p>Here's an example:</p>
<pre><code>var ndomain = document.domain;
var mydomain = 'www.foo.com';
var alink = document.getElementsByTagName('a');
for (var i = 0; i < alink.length; i++) {
if (alink[i].href.le... | <p>There is no way that I know of to generate a .build file from an sln. There should be decent examples of .build files at <a href="http://nant.sourceforge.net" rel="nofollow noreferrer">http://nant.sourceforge.net</a>.</p>
<p>That being said there are two ways to build a .sln file from NAnt.</p>
<ul>
<li>checkout n... | <p>With nant you will have to use the EXEC command to shell out to msbuild for the solution files. </p>
<p>Others have been experiencing the same issues.</p>
| 43,952 |
<p>All of a sudden I seem to be having a lot of issues with under extruding on my Ender 3. The bottom layer (of height 0.1 mm) prints perfectly fine. This is done at 15 mm/s speed. However, The moment the print moves to layer 2 and above (at the default speed of 60 mm/s), I start hearing a lot of clickin... | <p>Not allowed to comment, so have to answer:</p>
<ol>
<li><p>The temperature sensor is a thermally sensitive resistor. Unfortunately, the temperature is near the high limit of that sensor, and the manufacturing tolerances are very significant. That is why a temperature tower is important for each printer, as well as ... | <p>A temperature of 200 °C is fine. You probably have heat creep from a Bowden style extruder. The filament starts getting softer due to heat creeping up from the hot nozzle. Filament expands and clogs the tube causing gear clicking. Usually there is a heat sink at the the Bowden tube connection. You need to ... | 1,580 |
<p>I'm interested to know the best / common way of storing a <code>this</code> pointer for use in the <code>WndProc</code>. I know of several approaches, but each as I understand it have their own drawbacks. My questions are:</p>
<p>What different ways are there of producing this kind of code:</p>
<pre><code>CWindow:... | <p>In your constructor, call <strong>CreateWindowEx</strong> with "this" as the lpParam argument.</p>
<p>Then, on WM_NCCREATE, call the following code:</p>
<pre><code>SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) ((CREATESTRUCT*)lParam)->lpCreateParams);
SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE... | <p>In the past I've used the lpParam parameter of <code>CreateWindowEx</code>:</p>
<blockquote>
<p>lpParam [in, optional] Type: LPVOID</p>
<p>Pointer to a value to be passed to the window through the CREATESTRUCT
structure (lpCreateParams member) pointed to by the lParam param of
the WM_CREATE message. This... | 14,340 |
<p>In ASP.NET MVC, I'm trying to create a link that includes an anchor tag (that is, directing the user to a page, and a specific section of the page).</p>
<p>The URL I am trying to create should look like the following:</p>
<pre><code><a href="/category/subcategory/1#section12">Title for a section on the page&... | <p>I would probably build the link manually, like this:</p>
<pre><code><a href="<%=Url.Action("Subcategory", "Category", new { categoryID = parent.ID }) %>#section12">link text</a>
</code></pre>
| <p>My solution will work if you apply the ActionFilter to the Subcategory action method, as long as you always want to redirect the user to the same bookmark:</p>
<p><a href="http://spikehd.blogspot.com/2012/01/mvc3-redirect-action-to-html-bookmark.html" rel="nofollow">http://spikehd.blogspot.com/2012/01/mvc3-redirect... | 34,594 |
<p>In Team Build 2008, the Drop Location for a build is no longer specified in the .proj file, and instead is stored in the database and maintained in the GUI tool.</p>
<p>The GUI tool only accepts a network path as a drop location (i.e. \\server\share) and will not accept a local path.</p>
<p>Our build server also h... | <p>The connections only seem to stay in the pool and not being reused in case you get an exception, just like the example. If you increase the timeout the connection will be reused.</p>
<p>A workaround to this problem is to clear the connection pool in case you get an exception like this:</p>
<pre><code>using (SqlCon... | <p>For what it's worth, this issue was fixed in .Net 4.0.</p>
| 40,573 |
<p>Lot of googling did not help me! Are there any good dictionary web based available? </p>
<p>I am looking for a site which can send me the meaning of words if we pass the word through query string!</p>
| <p>I found you a <a href="http://words.bighugelabs.com/" rel="noreferrer">Big Huge Thesaurus</a> with a web API, and a dictionary at <a href="http://services.aonaware.com/DictService/" rel="noreferrer">Aonaware</a> that looks like it uses SOAP</p>
| <p>There also exists the <a href="http://dict.org" rel="nofollow noreferrer">dict</a> protocol which has been around for a long time. One of the things I like about dict is the command-line query program that is available.</p>
<p>I have also created a <a href="http://hewgill.com/dict/" rel="nofollow noreferrer">Wiktio... | 10,371 |
<p>I run php 5.2.6 as a cgi under lighttpd 1.4 and for some reason it's always running as root. All php-cgi processes in are owned by root and all files written to the file system are owned by root. </p>
<p>I've tried setting the user in lighttpd as non privileged, and confirmed, it's running right it's just php that ... | <ol>
<li><p>Ensure :</p>
<pre><code>server.username = "nonprivuser"
server.groupname = "nonprivgroup"
</code></pre></li>
<li><p>stop lighttpd. </p></li>
<li>check for existing php processes and kill them. </li>
<li>start lighttpd</li>
<li>check php processes are running as non priv</li>
</ol>
<p>... | <p>It is possible that you have a fastcgi process that was started on the server as root. If this is the case, then the fastcgi process will continue to run php processes called from lighttpd.</p>
<p>I suggest killing the fastcgi processes on your server and restarting lighttpd.</p>
<p>You might also want to take a ... | 20,867 |
<p>Is there such a thing as having the most prefered design pattern for building applications in TDD or the iterative mode?</p>
| <p>I think the question could be rewritten so it makes more sense in these words:</p>
<p><em>"Which architectural patterns and strategies are useful in order to achieve flexibility when using a Test-Driven and incremental development strategy?"</em></p>
<p>My answer would be: patterns that help you decouple your clas... | <p>Use a dynamic language like Python or Ruby to develop: You don't have to fight with many of the problems other languages have which are the reason for "design patterns" in the first place.</p>
<p>Dynamic languages in combination with automated testing will give results really quick so you know which direction to ta... | 14,575 |
<p>I want to select a bunch of <code>span</code>s in a <code>div</code> whose CSS contains a particular background color. How do I achieve this?</p>
| <p>if i understand the question correctly, the selector <code>[attribute=value]</code> <strong>will not work</strong> because <code><span></code> does not contain an attribute "background-color". you can test that out quickly to confirm it won't match anything:</p>
<pre><code>$('#someDiv span[background-color]')... | <p>Use the attribute selector [attribute=value] to look for a certain attribute value.</p>
<pre><code>#id_of_the_div span[background-color=rgb(255,255,255)]
</code></pre>
| 35,735 |
<p>Looking for some direction here as I'm running into some migration problems.</p>
<p>We have a legacy application. The 'infrastructure' is running just fine. Business logic and data access layers written in VB calling SQL Server for the database.</p>
<p>I have a LOT of experience writing Winforms (desktop) applic... | <p>The best advice I've heard on learning to use html/css layout goes something like this:</p>
<p>When building a new page, don't try to get all fancy up front. Start by building a very basic, text-only page. It should look like something from 1996- that brief period where everyone had just discovered the web but ha... | <p>By the sounds of it, you're looking for a crash course in HTML ?</p>
<p>the "Design Canvas" of an ASP.NET aspx Page & ascx Control is just HTML tag markup.</p>
<p>If you've no web design experience, I'd recommend starting somewhere like</p>
<p><a href="http://www.w3schools.com/html/default.asp" rel="nofollow ... | 35,070 |
<p>I will soon be working on AJAX driven web pages that have a lot of content generated from a Web Service (WCF).</p>
<p>I've tested this sort of thing in the past (and found it easy) but not with this level of dynamic content.</p>
<p>I'm developing in .NET 3.5 using Visual Studio 2008. I envisage this testing in:</... | <p>Most automation frameworks have some synchronizationfunctions built in. Selenium is no exception, and includes functionality like waitForText, waitForElementPresent,etc.</p>
<p>I just realized that you mentioned "waits" above, which I interpreted as Sleeps (which aren't good in automation). Let me know if I misinte... | <p><a href="http://www.artoftest.com/Resources/WebAii/Documentation/topicsindex.aspx?topic=ajaxsupport" rel="nofollow noreferrer">WebAii</a> has a <strong>WaitForElement(s)</strong> method that lets you specify the parameters of the elements to wait for.</p>
| 16,586 |
<p>Is there any good reason to use C-strings in C++ nowadays? My textbook uses them in examples at some points, and I really feel like it would be easier just to use a std::string.</p>
| <p>The only reasons I've had to use them is when interfacing with 3rd party libraries that use C style strings. There might also be esoteric situations where you would use C style strings for performance reasons, but more often than not, using methods on C++ strings is probably faster due to inlining and specializatio... | <p>The usual reason to do it is that you enjoy writing buffer overflows in your string handling. Counted strings are so superior to terminated strings it's hard to see why the C designers ever used terminated strings. It was a bad decision then; it's a bad decision now.</p>
| 13,460 |
<p>What's are the best practices for versioning web sites?</p>
<ul>
<li>Which revision control systems are well suited for such a job?</li>
<li>What special-purpose tools exist?</li>
<li>What other questions should I be asking?</li>
</ul>
| <p>Firstly you can - and should - use a revision control system, most will handle binary files although unlike text files you can't merge two different set of changes so you may want to set the system up to lock these files whilst they are being changed (assuming that that's not the default mode of operation for you rc... | <p>I use <a href="http://svnbook.red-bean.com/" rel="nofollow noreferrer">Subversion</a>.
As an easy way to reference the website version (production, testing, development), I use a very simple trick. I add the revision number somewhere on the site (eg in the admin footer). Something like this:</p>
<pre><code><?php... | 5,781 |
<p>I’m building a system that generates “work items” that are queued up for back-end processing. I recently completed a system that had the same requirements and came up with an architecture that I don’t feel is optimal and was hoping for some advice for this new system.</p>
<p>Work items are queued up centrally and ... | <p>It seems to me that your concept of an atomic unit of work is a Group. So I would suggest that you only queue up a message that identified a Group Id, and then your worker will have to go to a table that maps Group Id to 1 or more Work Items.</p>
<p>You can handle your other problems by using more than one queue -... | <p>Queues are for FIFO order, not random access order. Even though you are saying that you want FIFO order, you want FIFO order with respect to a random set of variables, which is essentially random order. If you want to use queues, you need to be able to determine order before the message goes in the queue, not after ... | 25,147 |
<p>I am trying to use cvs annotate. This is the what I run:</p>
<pre><code>cvs -d /mycvs/cvsroot/ annotate "projects/dg/SomeClass.java"
</code></pre>
<p>However, I get the following error:</p>
<pre><code>cvs annotate: failed to create lock directory for `/mycvs/cvsroot/projects/dg^M' (/mycvs/cvsroot/projects/dg^M/#c... | <p>From your description, I would guess that you've got it right with the stray ^M. What OS are you using? If Windows, are you using cygwin? I see you're using direct filesystem access to the repository. Might you consider setting up a server access mechanism like pserver to see if that helps?</p>
| <p>I too am experiencing this problem with cygwin. In fact, I am able to authenticate against a pserver using eclipse cvs tools. However, cygwin... not so much.</p>
<p>Here are a couple of posts that might be related:
<a href="http://www.sat-industry.net/forums/dreambox-development/19893-checkout-failed-create-lock-... | 23,162 |
<p>This is something I've ignored for awhile, but it keeps cropping up, and occasionally, if the filament snags real good, it can mess up a great print half way through, etc.</p>
<p>Basically I have my filament spools hanging on a PVC pipe mounted directly above the printer, and the printer just sucks it in from the s... | <p>I had the same problem with my FFC dual.</p>
<p>Consider using some kind of retaing clip to hold the spool in place, so it doesn't move back and forth on the post. This <a href="https://web.archive.org/web/20170127154947if_/http://www.thingiverse.com/thing:923340" rel="nofollow noreferrer">spool holder</a> worked fo... | <p>I used this solution, it makes a lot of sense, because I store the filament back in a box and the tip endup getting knotted.</p>
<p><div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/lE9LchCtKL4?start=0"></iframe>
</div></div></p>
| 397 |
<p>I've always wondered about when and where is the best time to cache a property value... Some of them seem pretty simple, like the one below...</p>
<pre><code>public DateTime FirstRequest {
get {
if (this.m_FirstRequest == null) {
this.m_FirstRequest = DateTime.Now;
}
return (... | <p>In general, you should get the code working first and then optimize later and then only do optimizations that profiling say will help you.</p>
| <p>I think you need to turn your question the other way around lest you fall into a trap of optimizing too early.</p>
<h3>When do you think is the point that a property no longer needs recalculating on every call and instead uses some form of caching?</h3>
<p>The caching of a value is an optimization and should there... | 44,392 |
<p>Mobile Safari is a very capable browser, and it can handle my website as it is perfectly. However, there are a few elements on my page that could be optimized for browsing using this device; such as serving specific thumbnails that are smaller than the desktop counterparts to help fit more content into the screen.</... | <p>Compare the user agent string with the one of a Safari Mobile uses:</p>
<p><a href="http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3" rel="nofollow noreferrer">Safari ... | <p>I have published a new mode to detect devices in any programming language (JSP, PHP, Perl, Python.....), it's called Apache Mobile Filter is an Apache module (<a href="http://modules.apache.org/search.php?id=1787" rel="nofollow noreferrer">http://modules.apache.org/search.php?id=1787</a>) that detect mobile device a... | 22,601 |
<p>Is there any setting using which the iPhone keyboard won't appear for a particular textbox in web page? May be some css kind of setting?</p>
| <p>you just make the input field as <strong>readonly="true"</strong>/ readonly mode so that keyboard wont appear!!</p>
| <p>I don't think you'll be able to truly disable the keyboard just like you cannot truly disable the keyboard when you browse a webpage via a PC or Mac. One trick would be to add JavaScript to intercept the OnKeyPress (or OnKeyDown) event to intercept the key stroke and cancel it based on the User Agent. I haven't tr... | 40,981 |
<p>I'm using a local artifactory to proxy the request, but the build and test phases are still a bit slow. It's not the actual compile and tests that are slow, it's the "warmup" of the maven2 framework. Any ideas?</p>
| <p>There are some possibilities to optimize some of the build tasks. For example the 'clean' task can be optimized from minutes to just milliseconds using simple trick - rename 'target' folder instead of delete.</p>
<p>To get details how to do it refer to <a href="http://bosy.dailydev.org/2009/02/speed-up-your-maven-b... | <p>Initially, you should get a finer analysis on your build times using something like <a href="https://github.com/timgifford/maven-buildtime-extension" rel="nofollow">this</a> and identify the candidates that are taking the most time. </p>
<p>Are tests spinning up a H2 database per test? Is the download of external j... | 19,550 |
<p>Where can you get information on the ASP.NET State Service e.g. how it works, performance, behaviour characteristics etc.
Have looked on internet but cant find in depth information or an article dedicated to the subject.
Thanks</p>
| <p>Programmatically, session state is nothing more than memory in the shape of a dictionary or hash table, e.g. key-value pairs, which can be set and read for the duration of a user's session.</p>
<p>Check following links for more details: </p>
<ul>
<li>"<a href="http://msdn.microsoft.com/en-us/library/ms972429.aspx... | <p>For SQL Server State Management remember that you don't call <code>Session["Key"]</code> in loops. (Try to avoid that) Because everytime it accesses the session then a roundtrip to sqlserver is made.</p>
| 45,464 |
<p>I saw a potential answer here but that was for YYYY-MM-DD: <a href="http://paulschreiber.com/blog/2007/03/02/javascript-date-validation/" rel="noreferrer">JavaScript date validation</a></p>
<p>I modified the code code above for MM-DD-YYYY like so but I still can't get it to work:</p>
<pre><code>String.prototype.is... | <pre><code>function isValidDate(date)
{
var matches = /^(\d{1,2})[-\/](\d{1,2})[-\/](\d{4})$/.exec(date);
if (matches == null) return false;
var d = matches[2];
var m = matches[1] - 1;
var y = matches[3];
var composedDate = new Date(y, m, d);
return composedDate.getDate() == d &&
... | <pre><code><script language = "Javascript">
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;
function isInteger(s){
var i;
for (i = 0; i < s.length; i++){
// Check that current character is number.
var c = s.charAt(i... | 34,863 |
<p>been searching for a quick example of sorting a IQueryable (Using Linq To SQL) using a Aggregate value.</p>
<p>I basically need to calculate a few derived values (Percentage difference between two values etc) and sort the results by this.</p>
<p>i.e.</p>
<p>return rows.OrderBy(Function(s) CalcValue(s.Visitors, s.... | <p>LINQ to SQL is never going to like you using your own methods within a query - it can't see inside them and work out what you want the SQL to look like. It can only see inside expression trees, built up from lambda expressions in the query.</p>
<p>What you want is something like:</p>
<pre><code>Dim stats = From x ... | <p>My VB is pretty bad, but I think this is what it should look like. This assumes that CalcValues returns a double and the type of <code>rows</code> is RowClass. This example does not use the IComparer version of the OrderBy extension but relies on the fact the doubles are comparable already and returns the CalcValu... | 48,387 |
<p>Inspired by <a href="https://stackoverflow.com/questions/277106/looking-for-some-interesting-c-programming-problems">this question</a>, I wanted to try my hand at the latest <a href="http://domino.research.ibm.com/Comm/wwwr_ponder.nsf/Challenges/November2008.html" rel="nofollow noreferrer">ponder this challenge</a>,... | <p>regarding your question about list traversal - you can start by writing a function that returns lists that represent the path - that's I think easier and it will be later easy to turn it into a function that returns a number.</p>
<p>This one takes a list as the first argument (path so far) and a tree and returns a ... | <p>Regarding laziness -
You can make this lazy by using F# "seq" type instead of "list" type. Here is an example:</p>
<pre><code>let rec visitor2 lst tree =
match tree with
| Branch(n, sub) -> Seq.map_concat (visitor2 (lst * 10 + n)) sub
| Leaf(n) ->
seq { do printfn "--yielding: %d" (lst * 10 + n)
... | 35,958 |
<p>Programming in vim I often go search for something, yank it, then go back to where I was, insert it, modify it.</p>
<p>The problem is that after I search and find, I need to MANUALLY find my way back to where I was.</p>
<p>Is there an automatic way to go back to where I was when I initiated my last search?</p>
| <p><kbd>Ctrl</kbd>+<kbd>O</kbd> takes me to the previous location. Don't know about location before the search.</p>
<p>Edit: Also, <kbd>`</kbd><kbd>.</kbd> will take you to the last change you made.</p>
| <p>The simplest way is to set a mark, with <code>m[letter]</code>, then go back to it with <code>'[letter]</code></p>
| 7,747 |
<p>I would appreciate your opinion/advice on the following</p>
<p><strong>Scenario</strong> </p>
<p>HTML has PDF file nick name, back end has URL for each nick. </p>
<p>The link URL is always <code>download.php?what=%PDF_Nick%</code> to ensure download for JS disabled clients. </p>
<p>For JS enabled clients I do JQ... | <p>Is there a reason you disable the asynchronous nature of the AJAX request? it will lock the browser until the request is completed.
You are better off using a callback instead:</p>
<pre><code>$.ajax({
type: "GET",
url: "download.php?ajax=true",
data: "what=" + what,
dataType: "script",
success: function(m... | <p>Is there a reason you disable the asynchronous nature of the AJAX request? it will lock the browser until the request is completed.
You are better off using a callback instead:</p>
<pre><code>$.ajax({
type: "GET",
url: "download.php?ajax=true",
data: "what=" + what,
dataType: "script",
success: function(m... | 45,974 |
<p>I'm trying to get the following SQL statement to work:</p>
<pre><code>UPDATE myschema.tableA update_tableA
SET field_id =
( SELECT src.field_id
FROM myschema.srcTable src
INNER JOIN myschema.tableB tableB ON
update_tableA.id = tableB.id
AND SDO_ANYINTERACT( tableB... | <p>I don't believe you can JOIN on a column (i.e. use it in the ON clause) that's not in one of the tables being joined. Additional predicates need to be in a WHERE clause.</p>
<p>Try this:</p>
<pre><code>UPDATE myschema.tableA update_tableA
SET field_id =
( SELECT src.field_id
FROM myschema.srcTabl... | <p>Looking at the SQL above, here is what I am thinking</p>
<p>1) myschema.tableA doesn't have ID column (it could be field_id) <br>
2) The SELECT doesn't seem to provide a join condition</p>
<p><code>
SELECT src.field_id
FROM myschema.srcTable src
INNER JOIN myschema.tableB tableB ON
</code></p>
... | 37,136 |
<p>I'm wondering if there's such a thing as Django-like ease of web app development combined with good deployment, debugging and other tools? </p>
<p>Django is a very productive framework for building content-heavy sites; the best I've tried and a breath of fresh air compared to some of the Java monstrosities out ther... | <p>You asked for someone who used both Grails and Django. I've done work on both for big projects. Here's my Thoughts:</p>
<p><strong>IDE's:</strong>
Django works really well in Eclipse, Grails works really well in IntelliJ Idea.</p>
<p><strong>Debugging:</strong>
Practically the same (assuming you use IntelliJ for G... | <p>cakephp.org</p>
<p>Cakephp is really good, really close to ruby on rails (1.2). It is in php, works very well on shared hosts and is easy to implement. </p>
<p>The only downside is that the documentation is somewhat lacking, but you quickly get it and quickly start doing cool stuff.</p>
<p>I totally recommend ca... | 10,146 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.