instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Can someone explain to me how XOR swapping of two variables with no temp variable works?</p>
<pre><code>void xorSwap (int *x, int *y)
{
if (x != y) {
*x ^= *y;
*y ^= *x;
*x ^= *y;
}
}
</code></pre>
<p>I understand WHAT it does, but can someone walk me through the logic of how it wor... | <p>You can see how it works by doing the substitution:</p>
<pre><code>x1 = x0 xor y0
y2 = x1 xor y0
x2 = x1 xor y2
</code></pre>
<p>Substituting,</p>
<pre><code>x1 = x0 xor y0
y2 = (x0 xor y0) xor y0
x2 = (x0 xor y0) xor ((x0 xor y0) xor y0)
</code></pre>
<p>Because xor is fully associative and commutative:</p>
<p... | <p>Others have posted explanations but I think it would be better understood if its accompanied with a good example.</p>
<p><a href="https://i.stack.imgur.com/MkNUN.jpg" rel="nofollow noreferrer">XOR Truth Table</a></p>
<p>If we consider the above truth table and take the values <code>A = 1100</code> and <code>B = 010... | 31,009 |
<p>I'm parsing big XML file with XPathExpression selection for some nodes existing at various depth levels.</p>
<p>What is the easiest way to export selected nodes to separate XML file, preserving all direct-ancestors nodes (and their attributes)? C# is preferred.</p>
<p>Example source XML :</p>
<pre><code><a>... | <pre><code>string xml = @"<xml>
<a>
<x/>
<b>
<c/>
<z/>
</b>
<c/>
</a>
<c/>
<d><e/></d></xml>";
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
XmlDocument results = new XmlDocument();
XmlNode root... | <p>I've used solution based on Marc's above, with small modification: I'm not using "descendant-or-self" switch but for selected (and validated) nodes I'm using following traversal:</p>
<pre><code> private void appendToOut(XmlNode node, XmlNode parameter)
{
if (node.ParentNode != null && node.Pa... | 49,916 |
<p>How do I make one of those hyperlinks where when you click it, it will display a popup asking "are you sure?"</p>
<pre><code><INPUT TYPE="Button" NAME="confirm" VALUE="???" onClick="message()">
</code></pre>
<p>I already have a message() function working. I just need to know what the input type for a hyperli... | <pre><code><a href="http://somewhere_else" onclick="return confirm()">
</code></pre>
<p>When the user clicks the link, the <code>confirm</code> function will be called. If the confirm function returns <code>false</code>, the link traversal is cancelled, if true is returned, the link is traversed.</p>
| <pre><code><a href="#" onclick="message(); return false;">???</a>
</code></pre>
<p>This answer would be OK only when the click <strong>need NOT navigate</strong> the user to another page.</p>
| 37,479 |
<p>I'm looking at opening up a website in the near future and aside from the standard domain registration costs, I'm unsure of how to proceed. I'm expecting the volume of data to be quite significant and looking at many webhosts it seems that while they might offer extreme bandwidth caps, I've been told they often susp... | <p>Check out <a href="http://aws.amazon.com/s3/" rel="nofollow noreferrer">Amazon S3</a>, I think they just revised their pricing model...</p>
| <p>You probably need to look at something like Amazon AWS. They are designed to help with scalability especially when you bandwidth and space requirements may get large. <a href="http://aws.amazon.com/" rel="nofollow noreferrer">http://aws.amazon.com/</a></p>
| 27,645 |
<p>Heres the link:</p>
<p><a href="http://tinyurl.com/596xva" rel="nofollow noreferrer">DAMNIE6TOHELL</a></p>
<p>As you can see if viewed in glorious 'IE6-o-color', the footer is shifting 1px over to the left.
I'm struggling to find a fix for this, I've whittled it down to a bare minimum of HTML.</p>
<p>Is it someth... | <p>Add </p>
<pre><code>background-position: 50% top;
</code></pre>
<p>to the css of container_bottom. </p>
<p>It works for me with IE Developer toolbar, but it's on a IE6 Virtual machine, so I'm not sure about real world results</p>
| <p>Add </p>
<pre><code>background-position: 50% top;
</code></pre>
<p>to the css of container_bottom. </p>
<p>It works for me with IE Developer toolbar, but it's on a IE6 Virtual machine, so I'm not sure about real world results</p>
| 32,236 |
<p>I've read quite a bit of the Red Bean Software SVN Book, and some of the questions here on SO, but I want to make sure I'm going about this in the right way the first time around step-by-step before I begin using it. Is this correct?</p>
<ol>
<li>Install SVN.</li>
<li><p>Create SVN repository at /usr/local/svn. Dir... | <blockquote>
<p>Create folders through command line for repository organization (including projects and vendors).</p>
</blockquote>
<p>Do you mean creating the repository structure by making directories inside the subversion intallation directory? That's very wrong.</p>
<p>You have to create the necessary folders ... | <p>You seem to have mostly the right idea, but your terminology is a bit wrong. That will really confuse the SVN people, since you're using words that have specific meanings in the context of SVN. To expand on what Davide said:</p>
<p>2) create your repository by doing something like <code>svnadmin create /usr/local... | 32,440 |
<p>What's the best way to write a LINQ query that inserts a record and then returns the primary key of that newly inserted record using C# ?</p>
| <p>The primary key value will be in that property after the SubmitChanges().</p>
<pre><code>MyTable record = new MyTable();
record.Name = "James Curran";
db.MyTable.InsertOnSubmit(record);
db.SubmitChanges();
Console.WriteLine("record inserted as ID : {0}", record.Id);
</code></pre>
| <p>Any field with AutoGeneratedValue=true will be filled in after that record is submitted to the database by dc.SubmitChanges()</p>
| 33,752 |
<p>When considering enclosures able to reach higher chamber temperatures, insulation is essential to keep the heater power low.</p>
<p>Typical insulation materials are not transparent: cork (fire retardant, good for the inner hot side), rock wool, styrofoam panels, aluminium insulating panels (aluminium walls with foam... | <p>Unfortunately there are very little solutions for fully transparent and thermally insulating materials. You may be able to use panels commonly used for greenhouses and hydroponics if you can accept losing full transparency and only being translucent. Another option may be to have <strong>two layers of your transpare... | <p>How about using thermally insulating transparent silicone rubber sheets?</p>
| 1,982 |
<p>I have to load a PDF within a page.</p>
<p>Ideally I would like to have a loading animated gif which is replaced once the PDF has loaded.</p>
| <p>Have you tried:</p>
<pre><code>$("#iFrameId").on("load", function () {
// do something once the iframe is loaded
});
</code></pre>
| <p>Here is what I do for any action and it works in Firefox, IE, Opera, and Safari.</p>
<pre><code><script type="text/javascript">
$(document).ready(function(){
doMethod();
});
function actionIframe(iframe)
{
... do what ever ...
}
function doMethod()
{
var iFrames = document.getElem... | 4,985 |
<p>I am considering building an application that is a blend of a dynamic language (python or ruby) and compiled language and need some help getting convincing myself that this is a good idea.</p>
<p>My thought are that I can use a dynamic language to get a lot of code written quickly, and then dropping down to a compi... | <p>I think your approach is very sensible. The way to address the downsides is to find out ahead of time how easy it is to interface the dynamic language with C or C++ before deciding whether or not to use it for your project. </p>
<p>Also, you need to think about whether or not you want your application to be cross... | <p>It's quite common, but make sure you know why you're architecting it the way you do.</p>
<p>One example is in games programming. In many games, the performance-critical game engine is written in C, while things like level scripting are done in Python, Scheme, a home-grown language or whatever.</p>
<p>This means th... | 17,125 |
<p>Which style of Ruby string quoting do you favour? Up until now I've always used <code>'single quotes'</code> unless the string contains certain escape sequences or interpolation, in which case I obviously have to use <code>"double quotes"</code>.</p>
<p>However, is there really any reason not to just use double quo... | <p>Don't use double quotes if you have to escape them. And don't fall in "single vs double quotes" trap. Ruby has excellent support for arbitrary delimiters for string literals:</p>
<p>Mirror of Site - <a href="https://web.archive.org/web/20160310224440/http://rors.org/2008/10/26/dont-escape-in-strings" rel="nofollow ... | <p>I use single quotes unless I need interpolation, or the string contains single quotes.</p>
<p>However, I just learned the arbitrary delimiter trick from Dejan's answer, and I think it's great. =)</p>
| 35,278 |
<p>There are some rumors floating around that the team at my company will soon be using web services for all future application development. The architecture is supposed to be something like this:</p>
<p>Application --> Web Service --> Database</p>
<p>The stated reasoning behind it is security. This sounds like a h... | <p>If it's true that there will be no business logic or validation on the web services, then there is only a limited security benefit to adding the additional layer of abstraction. I say limited because the interface between your application and the database is still more limited than if they were directly talking to e... | <p>If you use a webservice hopefully you will also be using some kind of queue when sending the data to the database. If you are using a webservice and queue combo then the security come into place with less chance of lost data. If you do not have a webservice and queue combo if you send data to the database and it nev... | 47,064 |
<p>I've seen the question (and answer) when posed for <a href="https://stackoverflow.com/questions/202940/unit-tests-framework-for-databases">MS SQL Server</a>, though I don't yet know of one for Oracle and PL/SQL. Are there xUnit style testing frameworks for Oracle's PL/SQL? What are they?</p>
| <p>The most commonly used is probably <a href="http://utplsql.org/" rel="nofollow noreferrer">utPLSQL</a></p>
<p>The original author of this toolkit now works for Quest, which has a <a href="http://www.quest.com/code-tester-for-oracle/" rel="nofollow noreferrer">commercial PL/SQL unit testing application</a>.</p>
| <p>Haven't used any, but last realese of utPLSQL was on July 2005 and since the author is the same from the commercial code tester for oracle (<a href="http://www.quest.com/code-tester-for-oracle/" rel="nofollow noreferrer">http://www.quest.com/code-tester-for-oracle/</a>) I don't think we'll be seeing much of utPLSQL ... | 24,881 |
<p>Hi I'm trying to get some practice with Linked Lists.</p>
<p>I Defined an Object class called <code>Student</code>:</p>
<pre><code>public class Student
{
protected string Student_Name;
protected int Student_ID;
protected int Student_Mark;
protected char Student_Grade;
public Stud... | <pre>
the head of the list.
( item1
Element: student1
Next ------------> ( item2
) Element: student2
Next ------------> ( item3
) Element: student3
Next: null
... | <p>Your question, as I read it, is too vague. I would start by googling 'linked lists' or picking up a book on 'data structures'. When you run into a specific problem, ask it on here, and I'm sure someone will help you.</p>
| 30,819 |
<p>I'm writing an application in Delphi which uses an SQLite3 database. I'd like to be able to start the application while holding some modifier keys, such as CTRL + SHIFT, to signal reinitialization of the database.</p>
<p>How can I capture that the application was started while these keys were held?</p>
| <p>Tim has the right answer, but you might need a little more framework:</p>
<pre><code>procedure TForm56.Button1Click(Sender: TObject);
begin
if fNeedReinit then
ReinitializeDatabase;
end;
procedure TForm56.FormCreate(Sender: TObject);
begin
fNeedReinit := False;
end;
procedure TForm56.FormShow(Sender: TObj... | <p>You have to capture keyboard hooks in your application.
<a href="http://www.delphifaq.com/faq/delphi_windows_API/f512.shtml" rel="nofollow noreferrer">See Here</a>
and then process the hooks before you show the main form - eg before the CreateForm and Run in the dpr file</p>
| 25,388 |
<p>Im trying to get a completly data copy from a gridview, itryed clone(), tryed cast DataView from DataSouce, but always get nulls or cant get the data, please exists a way to copy data from gridview, modified it and then reload it? or modifyng directly some rows in the gridview?
thanks in advance!</p>
| <p>You can try using the OnRowDataBound attribute to do something like this</p>
<pre><code>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
//HeaderStuff
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
... | <p>What exactly is it you're trying to do with the data? Also is it a datagrid or a dataview and in what framework? If it's a datagrid that you're trying to copy the rows from,loop through the datagrid rows and add the row values to an arraylist.</p>
| 47,004 |
<p>Today I was listening to the <a href="http://www.hanselminutes.com/default.aspx?showID=145" rel="nofollow noreferrer">Hanselminutes show about .NET 3.5 SP1...What's inside</a>, and they twice mentioned the Office 2007-like Ribbon control that is included in Visual Studio 2008 Service Pack 1. </p>
<p>I am very inte... | <p>Yeah I did a double-take when I heard them say that too.</p>
<p>The ribbon control, along with a DatePicker and DataGrid, are being developed out of band <a href="http://www.codeplex.com/wpf" rel="nofollow noreferrer">over here</a> on CodePlex. I'm not sure why Carl and Scott were suggesting that it was part of the... | <p>A preview of the WPF Ribbon control was released last week, you can find <a href="http://www.codeplex.com/wpf/Wiki/View.aspx?title=WPF%20Ribbon%20Preview" rel="nofollow noreferrer">here</a></p>
| 5,404 |
<p>Let's make a list of answers where you post your excellent and favorite <a href="http://en.wikipedia.org/wiki/Extension_method" rel="nofollow noreferrer">extension methods</a>. </p>
<p>The requirement is that the full code must be posted and a example and an explanation on how to use it.</p>
<p>Based on the high i... | <pre><code>public static bool In<T>(this T source, params T[] list)
{
if(null==source) throw new ArgumentNullException("source");
return list.Contains(source);
}
</code></pre>
<p>Allows me to replace:</p>
<pre><code>if(reallyLongIntegerVariableName == 1 ||
reallyLongIntegerVariableName == 6 ||
rea... | <p>Easily serialize objects into XML:</p>
<pre><code>public static string ToXml<T>(this T obj) where T : class
{
XmlSerializer s = new XmlSerializer(obj.GetType());
using (StringWriter writer = new StringWriter())
{
s.Serialize(writer, obj);
return writer.ToString();
}
}
"<roo... | 34,131 |
<p>I'm using System.Data.Linq.DataContext file for accessing a mdf Database</p>
<p>I want to use the Database from the project directory and not the one created by the debugger in the Debug directory.</p>
<p>The problem is when I edit the Connection String and choose the path for AttachDBFilename,
VS2008 automaticly ... | <p>Edit your application "app.config" file<br>
Go to the connectionStrings and change the connectionString to the path of your DB.</p>
<p>At the DataContext file properties, set the "Application Settings" = True<br>
Then choose the Connection by it's name and that it.</p>
| <p>already you can write like this:
SampledbDataContext sdc = new SampledbDataContext(Server.MapPath("~/Sampledb.mdf"));
or in design.cs file
public SampledbDataContext() :
base(global::"[write cnn string Here !]", mappingSource)
{
OnCreated();
}</p>
| 48,255 |
<p>I have a request to allow a dynamic table to have 1000 columns(randomly selected by my end users). This seems like a bad idea to me. It's a customizable table so it will have a mixture of <code>varchar(200)</code> and <code>float</code> columns(float best matches the applications c++ double type). This database i... | <p>This smells like a bad design to me.</p>
<p>Things to consider:</p>
<p>Will most of those columns be contain NULL values?</p>
<p>Will many be named Property001, Property002, Property003, etc...?</p>
<p>If so, I recommend you rethink your data normalization.</p>
| <p>Seems like an awful lot. I would first make sure that the data is normalized. That might be part of your problem. What type of purpose will this data serve? Is it for reports? Will the data change?</p>
<p>I would think a table that wide would be a nightmare performance and maintenance-wise.</p>
| 42,924 |
<p>I've googled around a bit, but maybe I didn't put the correct magik incantation into the search box. </p>
<p>Does anyone know how to get output parameters from a stored procedure in Python? I'm using pymssql to call a stored procedure, and I'm not sure of the correct syntax to get the output parameter back. I don't... | <p>I'm not a python expert but after a brief perusing of the <a href="http://www.python.org/dev/peps/pep-0249/" rel="nofollow noreferrer">DB-API 2.0</a> I believe you should use the "callproc" method of the cursor like this:</p>
<pre><code>cur.callproc('my_stored_proc', (first_param, second_param, an_out_param))
</cod... | <p>You might also look at using SELECT rather than EXECUTE. EXECUTE is (iirc) basically a SELECT that doesn't actually fetch anything (, just makes side-effects happen).</p>
| 23,274 |
<p>Is there any way to create - manipulate calendar events in Exchange Server 2003 ?
I'm using VB.NET 2005. I don't want to use MAPI because everytime I will have to type user name and passwords. Is there any other way ? I used redemption.dll but everytime I want to add for eg. a calendar event it displays the login sc... | <p>I'm a bit confused by your configuration file. What exactly are you trying to do? </p>
<p>You've defined 2 endpoints for using MINA (which won't use ActiveMQ at all); then you are using a route from an ActievMQ queue listener_A to listener_B then listener_B to listener_A (which is a recursive loop).</p>
<p>Maybe i... | <p>More on this:</p>
<p>When the endpoint is defined as a mina tcp connection, it cannot be identified as "activemq::listener_A" </p>
<pre><code><endpoint id="listener_A" uri="mina:tcp://localhost:42000?sync=false&amp;textline=true"/>
</code></pre>
<p>this is wrong:</p>
<pre><code> <from uri="act... | 33,257 |
<p>I'm refactoring some old JavaScript code and there's a lot of DOM manipulation going on.</p>
<pre><code>var d = document;
var odv = d.createElement("div");
odv.style.display = "none";
this.OuterDiv = odv;
var t = d.createElement("table");
t.cellSpacing = 0;
t.className = "text";
odv.appendChild(t);
</code></pre>
... | <p>Here's your example in the "one" line.</p>
<pre><code>this.$OuterDiv = $('<div></div>')
.hide()
.append($('<table></table>')
.attr({ cellSpacing : 0 })
.addClass("text")
)
;
</code></pre>
<hr>
<p><em>Update</em>: I thought I'd update this post since it still get... | <p>jQuery out of the box doesn't have the equivalent of a createElement. In fact the majority of jQuery's work is done internally using innerHTML over pure DOM manipulation. As Adam mentioned above this is how you can achieve similar results.</p>
<p>There are also plugins available that make use of the DOM over inne... | 33,697 |
<p>I'm trying to write some code to find a specific XmlNode object based on the URL in the XML sitemap but can't get it to find anything.</p>
<p>The sitemap is the standard ASP.net sitemap and contains:</p>
<pre><code><siteMapNode url="~/lev/index.aspx" title="Live-Eye-Views">
--- Child Items ---
</siteMapNo... | <p>The site map has a default name space, but you do not refer to it.</p>
<pre><code><siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/lev/index.aspx" title="Live-Eye-Views">
<!-- Child Items -->
</siteMapNode>
</siteMap>
</code></pre>
<p... | <p>looks good afaik, have you tried using an xpath like:</p>
<p>**//**siteMapNode[@url="~/lev/index.aspx"]</p>
| 48,063 |
<p>I'm in Quality Assurance and use Fisheye to track checkins to CVS. What other options do people use?</p>
<p>We have tens of thousands of files and have plans for migrating to Team Foundation Server's code management tool 'at some point' When we do that, there will be lots of information that will be available. </p>... | <p><a href="http://www.viewvc.org/" rel="nofollow noreferrer">ViewVC</a> provides a nice web interface to CVS (or SVN) and is reasonably easy to setup. It does not provide the same functionality as fisheye, however. I haven't tried the integration w/ a SQL DB backend though, I believe that will add some fisheye-like ca... | <p>Sorry, this doesn't help with CVS, but I'd recommend switching to subversion, which is designed to be a CVS replacement. Then you can use <a href="http://trac.edgewall.org/" rel="nofollow noreferrer">trac</a> to follow checkins, as well as manage change tickets and documentation. It was well worth the effort in my ... | 11,182 |
<p>We are developing a considerably big application using Ruby on Rails framework (CRM system) and are considering to rewrite it to use ExtJS so that Rails would just do the data handling, while ExtJS would do all the browser heavylifting in a desktop-like manner. </p>
<p>Anyone has some experience and hints about wha... | <p>I currently have an extremely large, desktop style app written in ExtJS. It used to run on top of Perl's Catalyst MVC framework, but once the entire View layer was converted to an ExtJS based desktop I started migrating to Ruby on Rails models and controllers. It is equally as fast, if not faster, and easier to ma... | <p>While I have no experience of ExtJS (besides reading about in the "<a href="http://www.amazon.co.uk/Practical-Rails-Projects-Experts-Voice/dp/1590597818/ref=sr_1_5?ie=UTF8&s=books&qid=1223974401&sr=8-5" rel="nofollow noreferrer">Practical Rails Projects</a>" book) I used a jQuery <a href="http://webplici... | 22,064 |
<p>Say I have an array of records which I want to sort based on one of the fields in the record. What's the best way to achieve this?</p>
<pre><code>TExample = record
SortOrder : integer;
SomethingElse : string;
end;
var SomeVar : array of TExample;
</code></pre>
| <p>You can add pointers to the elements of the array to a <code>TList</code>, then call <code>TList.Sort</code> with a comparison function, and finally create a new array and copy the values out of the TList in the desired order.</p>
<p>However, if you're using the next version, D2009, there is a new collections libra... | <p>I created a very simple example that works correctly if the sort field is a string.</p>
<pre><code>Type
THuman = Class
Public
Name: String;
Age: Byte;
Constructor Create(Name: String; Age: Integer);
End;
Constructor THuman.Create(Name: String; Age: Integer);
Begin
Self.Name:= Name;
Self.Age:=... | 6,313 |
<h3>Scenario:</h3>
<p>Currently we have a single solution supporting a single deployable entity, a WinForm/WPF client, this solution has a layer architecture with projects representing various layers (Data, Business, UI). We will be introducing other deployable entities such as a LiteClient, a Server and an RIA.</p>
<p... | <p>This is a reasonable and normal approach. At the end of the day, the Visual Studio solution is simply a collection of projects with deployment information.</p>
<p>In order to reduce possible dependency issues, make sure you use a build server (TFS or otherwise) that takes care of compiling and deployments.</p>
| <p>If you change something within the shared projects, you have to check if that didn't break the dependent projects. If you keep those projects in seperate solutions you have to remember to recompile them each time you modify the shared projects.</p>
<p>That's a drawback that I can see.</p>
| 22,009 |
<p>When using regular expressions we generally, if not always use them to extract some kind of information. What I need is to replace the match value with some other value... </p>
<p>Right now I'm doing this...</p>
<pre><code>def getExpandedText(pattern, text, replaceValue):
"""
One liner... really ugly b... | <pre><code>sub (replacement, string[, count = 0])
</code></pre>
<p><a href="https://docs.python.org/howto/regex.html#search-and-replace" rel="nofollow noreferrer">sub</a> returns the string obtained by replacing the leftmost non-overlapping occurrences of the RE in string by the replacement replacement. If the pattern... | <p>If you want to continue using the syntax you mentioned (replace the match value instead of replacing the part that didn't match), and considering you will only have one group, you could use the code below.</p>
<pre><code>def getExpandedText(pattern, text, replaceValue):
m = re.search(pattern, text)
expanded... | 16,963 |
<p>I'm having trouble trying to optimize the following query for sql server 2005. Does anyone know how could I improve it. Each one of the tables used there have about 40 million rows each. I've tried my best trying to optimize it but I manage to do the exact opposite.</p>
<p>Thanks</p>
<pre><code>SELECT
cos
... | <p>It seems that the query is just combining the separated history tables into a single result set containing all the data. In that case the query is already optimal.</p>
| <p>You might consider using a single partitioned table with a year indicator.</p>
<p>I'm still curious - is this code in a view or SP which operates on 160m rows or is it actually going to return 160m rows down the wire. If so, that's an awful lot of data to return that's effectively an extract and it's going to take... | 41,930 |
<p>I need to build a simple, single user database application for Windows. Main requirements are independence from windows version and installed software. What technologies (language/framework) would you recommend? My preference for language is the Visual Basic.</p>
<p>EDIT: What about VB.Net and SQL Server Compact Ed... | <p>I would recommend <a href="http://www.sqlite.org/" rel="noreferrer">Sqlite</a>. It's completely self-contained, and <em>public domain</em> so there are no license issues at all.</p>
| <p>Best Option would be to create a Win32 native application using <strong><a href="http://www.codegear.com/products/delphi/win32" rel="nofollow noreferrer">Delphi</a></strong> and use SQLLite as the database.</p>
<p>Reason being Delphi can produce native win32 applications without any other product being installed on... | 13,884 |
<p>How do you iterate through every file/directory recursively in standard C++?</p>
| <p>In standard C++, technically there is no way to do this since standard C++ has no conception of directories. If you want to expand your net a little bit, you might like to look at using <a href="http://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/index.htm" rel="noreferrer">Boost.FileSystem</a>. This has been a... | <p>File tree walk <code>ftw</code> is a recursive way to wall the whole directory tree in the path. More details are <a href="https://linux.die.net/man/3/ftw" rel="nofollow noreferrer">here</a>.</p>
<p>NOTE : You can also use <code>fts</code> that can skip hidden files like <code>.</code> or <code>..</code> or <code>.b... | 9,284 |
<p>I was wondering if there is a good IRC channel around somewhere that allows iPhone developers to get together and talk about code and etc.</p>
<p>Any channel already around that people are using?</p>
| <p>It's #iphonedev on irc.freenode.net. Without the dash.</p>
<p>There's also #cocoa-init. It's a new channel focused on asking and answering questions for beginning developers on iOS/OSX.</p>
| <p>As far as I know, the NDA that Apple forces iPhone developers to sign would prevent them from participating in such a discussion.</p>
<p>EDIT: See the comments to my answer. Apparently the NDA was lifted as of 10/01/08. So if the sort of resource you are looking for doesn't exist now, hopefully it will soon.</p>
| 36,716 |
<p>Basically, I'm trying to selectively copy a table from one database to another. I have two different [Oracle] databases (e.g., running on different hosts) with the same schema. I'm interested in a efficient way to load Table A in DB1 with the result of running a select on Table A in DB2. I'm using JDBC, if that's re... | <p>Use a database link, and use create table as select.</p>
<pre><code>create database link other_db connect to remote_user identified by remote_passwd using remote_tnsname;
create table a as select * from a@other_db;
</code></pre>
| <p>If the databases are from the same vendor they usually provide a native way to make a view
of a table in another database. in which case, a "select into" query will do it no problem</p>
<p>Oracle, for example, has the database link which works pretty well.</p>
<p>Outside of that you are going to have to make a co... | 21,699 |
<p>What tools are out there that compete with this product?</p>
<p><a href="http://www.codekana.com/" rel="nofollow noreferrer">CodeKana</a></p>
<p>I know ReSharper has improved syntax highlighting. Is it comparable to this? </p>
| <p>Both <a href="http://www.devexpress.com/Products/Visual_Studio_Add-in/Coding_Assistance/" rel="nofollow noreferrer">CodeRush</a> and ReSharper do way mode than just syntax highlighting, but if that's what you're looking for, go for it they are both excellent tools.</p>
| <p>Not only does Resharper provide syntax highlighting, it is imho the best refactoring tool for Visual Studio. Period. </p>
<p>It also has built in capabilities for running unit tests in the IDE.</p>
<p>Just a great tool overall.</p>
| 21,079 |
<p>I've got a reasonably simple query (this time) that I need ALL the results back from (I'm storing them in an Excel spreadsheet). The query itself times out the server, so how do I go about running it without that happening?</p>
| <p>Easiest way would be to break the domain of the query into several parts. For instance, add to the WHERE clause an expression that selects only the first half of the key range, then run a 2nd query to select the bottom half. Then merge the output.</p>
| <p>I would throw the query into a separate thread, loading it into a persistent scope (eg session). Forward to a page that checks for the existence of the query. Repeat the check until the query exists, then forward to a page that displays/processes/whatevers it.</p>
| 28,062 |
<p>We have a simple [spring-hibernate] application (console app) where in we have set the classpath in manifest file of the executable JAR file. And the app connects to the database using jTDS JDBC Driver, Everything works as expected on Windows machine and JDK 1.6, but on Linux, the app is unable to find the driver,
... | <p>This issue occurred because our jdbc.url had invalid url. This was because maven treats jdbc.url property as a special property and while profiling, instead of url defined in the filter.properties. And that is the reason "No Suitable Driver" exception. The question should have been more clear. </p>
<p>Anyways to fi... | <p>Honestly it sounds like bad CLASSPATH. One thing I suggest to start debugging this problem is copying the jtds package to same path as your main packages/classes and see if it works. This way you can assure the Classpath manifest is or isn't the problem. The Spring/Hibernate relies on the lib directory, so it will a... | 8,632 |
<p>I'm trying to get this simple PowerShell script working, but I think something is fundamentally wrong. ;-)</p>
<pre><code>ls | ForEach { "C:\Working\tools\custom-tool.exe" $_ }
</code></pre>
<p>I basically want to get files in a directory, and pass them one by one as arguments to the custom tool.</p>
| <pre><code>ls | %{C:\Working\tools\custom-tool.exe $_}
</code></pre>
<p>As each object comes down the pipeline the tool will be run against it. Putting quotes around the command string causes it to be... a string! The local variable "$_" it then likely doesn't know what to do with so pukes with an error.</p>
| <p>Both Jeffrery Hicks and slipsec are correct. Yank the double quotes off.</p>
<p>$_ or $_.fullname worked in my test script (below). YMMV with your custom-tool.</p>
<pre><code>gci | % { c:\windows\notepad.exe $_.fullname }
</code></pre>
<p>or</p>
<pre><code>gci | % { c:\windows\notepad.exe $_ }
</code></pre>
| 21,841 |
<p>Is this the best way to handle file moving in a windows service? we have many files that get matched and moved, but an end user may have the file opened at the time of moving.</p>
<p>This is what the code currently says:</p>
<pre><code>Do While IO.File.Exists(OriginalFilePath)
Try
IO.File.Move(Origina... | <p>No. You will need to use SQL Profiler. A standard trace with the <strong>Lock Timeout</strong> event and <strong>Deadlock Graph</strong> events should do it.</p>
<ul>
<li><p><a href="http://msdn.microsoft.com/en-us/library/ms189107.aspx" rel="noreferrer">Lock:Timeout Event Class</a></p></li>
<li><p><a href="http://... | <p>You could also use Event Notifications that get raised on the timeout and deadlock events. After it fires, you can write it to a table and or send yourself an email.</p>
<p>I've shown the general technique here:</p>
<blockquote>
<h2><a href="http://weblogs.sqlteam.com/mladenp/archive/2008/07/18/Immediate-deadloc... | 37,733 |
<p>Is there a way to create a Distinct query in HQL. Either by using the "distinct" keyword or some other method. I am not sure if distinct is a valid keywork for HQL, but I am looking for the HQL equivalent of the SQL keyword "distinct".</p>
| <p>Here's a snippet of hql that we use. (Names have been changed to protect identities)</p>
<pre><code>String queryString = "select distinct f from Foo f inner join foo.bars as b" +
" where f.creationDate >= ? and f.creationDate < ? and b.bar = ?";
return getHibernateTemplate().find(query... | <p>If you need to use <strong>new</strong> keyword for a custom DTO in your select statement and need <strong>distinct elements</strong>, use new outside of new like as follows-</p>
<pre><code>select distinct new com.org.AssetDTO(a.id, a.address, a.status) from Asset as a where ...
</code></pre>
| 33,043 |
<p>Since I upgraded to Visual Studio 2008 from vs2005, I have found a very annoying behaviour when debugging large projects. If I attempt to step into inline code, the debugger appears to lock up for tens of seconds. Each time that I step inside such a function, there is a similar pause. Has anyone experienced this ... | <p>I used to get this - I think it's a bug with the 'Autos' debug window:</p>
<p><a href="http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/eabc58b1-51b2-49ce-b710-15e2bf7e7516/" rel="nofollow noreferrer">http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/eabc58b1-51b2-49ce-b710-15e2bf7e7516/</a><... | <p>As a workaround, you could use something like this for debugging purposes:</p>
<pre><code>#ifdef _DEBUG
#define INLINE
#else
#define INLINE inline
#endif
</code></pre>
<p>For extra neatness you can place the functions in a separate .inc file that is included either in the header or the cpp file depending on bu... | 16,813 |
<p>I just noticed that you can do this in C#:</p>
<pre><code>Unit myUnit = 5;
</code></pre>
<p>instead of having to do this:</p>
<pre><code>Unit myUnit = new Unit(5);
</code></pre>
<p>Does anyone know how I can achieve this with my own structs? I had a look at the Unit struct with reflector and noticed the TypeConv... | <p>You need to provide an implicit conversion operator from int to Unit, like so:</p>
<pre><code> public struct Unit
{ // the conversion operator...
public static implicit operator Unit(int value)
{
return new Unit(value);
}
// the boring stuff...
private re... | <p>You need to provide a cast operator for the class that takes an Int32.</p>
| 24,515 |
<p>I heard that decision tables in relational database have been researched a lot in academia. I also know that business rules engines use decision tables and that many BPMS use them as well.
I was wondering if people today use decision tables within their relational databases?</p>
| <p>A decision table is a cluster of conditions and actions. A condition can be simple enough that you can represent it with a simple "match a column against this value" string. Or a condition could be hellishly complex. An action, similarly, could be as simple as "move this value to a column". Or the action could i... | <p>I would look into using an Object database rather than a traditional RDBMS (Relational Database Management System). Object databases are designed to be fast at handling hierarchical relationships between objects, whereas in an RDBMS, you have to represent these relationships across multiple table rows, or even table... | 15,884 |
<p>I've worked in shops where I've implemented Exception Handling into the event log, and into a table in the database.</p>
<p>Each have their merits, of which I can highlight a few based on my experience:</p>
<p>Event Log</p>
<ul>
<li>Industry standard location for exceptions (+)</li>
<li>Ease of logging (+)</li>
<... | <p>You need to differentiate between logging and tracing. While the lines are a bit fuzzy, I tend to think of logging as "non developer stuff". Things like unhandled exceptions, corrupt files, etc. These are definitely not normal, and should be a very infrequent problem.</p>
<p>Tracing is what a developer is intereste... | <p>One note about writing to the event log: that requires certain permissions for your application users that in some environments may be restricted by default.</p>
<p>Where I'm at we do most of our logging to a database, with flat files as backup. It's pretty nice, we can do things like get an RSS feed for an app t... | 29,509 |
<p>Can all .NET exception objects be serialized?</p>
| <p>Yes and no. As Jeff and others have pointed out, the all exception classes should and almost always are serializable. If you run across a particular exception class that is not serializable, it is quite possibly a bug. </p>
<p>But when considering serializability you need to consider both the immediate class and ... | <p><code>System.Exception</code> implements <code>ISerializable</code> and it is the base class for all exceptions, so yes. </p>
<p>See: <a href="http://msdn.microsoft.com/en-us/library/system.exception.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.exception.aspx</a></p>
| 44,530 |
<p>In a prior question, I asked about using xbuild to compile a solution file, only to be told it doesn't work for that. NAnt seems a little out of date. What other options are there? I need something that supports dependencies across multiple projects.</p>
| <p>I am using mono-trunk (mono 2.6) and xbuild is definitely far more capable now.</p>
| <p>xBuild used to be crap until 5 months ago.</p>
<p>I don't know if that changed, but judging from the fact the MonoDevelop still won't use it, I'd say it's still the same.</p>
<p>I highly doubt any official mono build contains a functional xbuild.</p>
<p>mdtool IMO is a very bad solution, esp. for people like me b... | 31,996 |
<p>Syntax aside, what is the difference between</p>
<pre><code>try {
}
catch() {
}
finally {
x = 3;
}
</code></pre>
<p>and </p>
<pre><code>try {
}
catch() {
}
x = 3;
</code></pre>
<p>edit: in .NET 2.0?</p>
<hr>
<p>so</p>
<pre><code>try {
throw something maybe
x = 3
}
catch (...) {
x = 3
}
</code... | <p>Depends on the language as there might be some slight semantic differences, but the idea is that it will execute (almost) always, even if the code in the try block threw an exception.</p>
<p>In the second example, if the code in the catch block returns or quits, the x = 3 will not be executed. In the first it will.... | <p>So you can clean up any open connections, etc. initialized in the try block. If you opened a connection and then an exception occurred, that exception would not be properly closed. This type of scenario is what the finally block is for.</p>
| 7,343 |
<p>I'm writing the memory manager for an application, as part of a team of twenty-odd coders. We're running out of memory quota and we need to be able to see what's going on, since we only appear to be using about 700Mb. I need to be able to report where it's all going - fragmentation etc. Any ideas?</p>
| <p>You can use existing memory debugging tools for this, I found Memory Validator <a href="http://www.vmvalidator.com/cpp/memory/index.html" rel="nofollow noreferrer" title="Memory Validator">1</a> quite useful, it is able to track both API level (heap, new...) and OS level (Virtual Memory) allocations and show virtual... | <p>Our (huge) application (a Win32 game) started throwing "Not enough quota" exceptions recently, and I was charged with finding out where all the memory was going. It is not a trivial job - this question and <a href="https://stackoverflow.com/questions/84234/is-there-a-single-resource-which-explains-windows-memory-th... | 11,627 |
<p>Sorry, I thought this was an inheritance question: it was an ArrayList question all along!</p>
<p>Ok, my problem is more specific than I thought. So I have two families of classes. Cards, and Zones. Zones are boxes for holding card. </p>
<p>The first two subClasses of Zone, ZoneList and ZoneMap are meant to be two... | <p>If I understand you correctly, you should probably declare:</p>
<pre><code>public class ZoneList<T extends Card> {
protected List<T> cardBox;
}
public class PokerHand extends ZoneList<PokerCard> {
public PokerHand() {
cardBox = new ArrayList<PokerCard>();
}
}
</code></pre>
| <p>This is going to depend on what the access control is on the Arraylist in <code>Zonelist</code>. My assumption from the debugger statement is that it is either unmarked, public, or protected. A subclass can "Hide" a parent class' variable it has access to by defining a variable with the same name. You can also use <... | 46,756 |
<p>We're trying to put together kiosk solution where we can charge people by hour for applications they use. As such, we need a way to figure out when an application is started, when it is closed and log this information for billing. I am a reasonably experienced .NET programmer so a managed code solution would be grea... | <p>This is simple enough with WMI calls. You can actually catch events from the OS on when an app is started, when it's closed, how long it was running, how much memory it used, etc.</p>
<p>Here is one example of monitoring process creating, deletion, etc. </p>
<p><a href="http://weblogs.asp.net/whaggard/archive/20... | <p>If you're talking about applications you wrote yourself, just log DateTime.Now on either side of the Application.Run() method:</p>
<pre><code>static void Main()
{
DateTime StartTime = DateTime.Now;
Application.Run(new frmBilling());
DateTime EndTime = DateTime.Now;
//Log information to DB for b... | 19,645 |
<p>I have a system in place which applies calculations to a set of numbers (the specifics aren't really relevant). There are a number of sets of calculations which can be applied by the system users and new sets are added frequently. Currently when a new set of calculations need to be added to the system they are added... | <p>Since you're redoing it in .Net, just put the calculations in plugins. Use reflection to load and examine these assemblies at runtime and present the user with functions. </p>
<p>Divil has a good (but fairly old now) article on writing plugin based applications. It will help you out: <a href="http://divil.co.uk/net... | <p>If you are using a standard set of mathematical functions you can use use allow the user to write their own mathematical functions in a textbox.<p>
Then use a grammar parser such as :<a href="http://www.codeproject.com/KB/recipes/TinyPG.aspx" rel="nofollow noreferrer">TinyPG on CodeProject</a>
<p>
With this you can ... | 20,151 |
<p>This is nice thing you have done. Could you please explain: How to use PhotoLibrary's CameraController without jailbreak. Actually I 've downloaded class-dump and tried dumping PhotoLibrary but did not work out well. It is giving: </p>
<pre><code>/*
* Generated by class-dump 3.1.2.
*
* class-dump is Copy... | <p>Do an "inner join fetch" on the Account.Order.Product entity. So instead of something like this (which is what you probably already have):</p>
<pre><code>"from Account a inner join fetch a.Order where a.ID = ?"
</code></pre>
<p>Tell it to fetch the Order.Product as well:</p>
<pre><code>"from Account a inner join... | <p>From "NHibernate in Action", page 225: </p>
<blockquote>
<p>NHibernate currently limits you to fetching just one collection eagerly.</p>
</blockquote>
<p>That might explain the second query for fetching the addresses.</p>
| 49,870 |
<p>I'm looking for an efficient way (using PHP with a Mysql Database) to suggest alternative spelling for a query.</p>
<p>I know I can use services such as <a href="http://developer.yahoo.com/search/web/V1/spellingSuggestion.html" rel="nofollow noreferrer">Yahoo's Spelling Suggestion</a> but I want the suggestions to ... | <p>I would do it as the user types and suggest by prefix (ala Google Suggest). A <a href="http://en.wikipedia.org/wiki/Trie" rel="nofollow noreferrer" title="wiki article">trie</a> would be nice for this. It wouldn't help to correct misspelled first letters, but those are pretty rare.</p>
| <p>Please, take a look to the <a href="http://developer.yahoo.com/yui/autocomplete/" rel="nofollow noreferrer">Yahoo! UI Library Autocomplete Component</a>. I think it is just what you're looking for. The section "Using DataSources" explains how to use different kind of data sources, including server side based ones l... | 10,659 |
<p>My employer just asked me to run a timed batch process in a Java EE WebSphere application they have running. It's supposed to run a certain class at 11:30 pm everyday.</p>
<p>I'm not very familiar with Java EE nor WebSphere server (or tomcat, in the development environment), and I've been digging around but all I'v... | <p>You should look at the open-source <a href="http://www.quartz-scheduler.org/" rel="noreferrer">Quartz library</a> from OpenSymphony. Very easy to use and perfect for this kind of thing.</p>
<p>TimerTasks are best suited for running something in a short time in the future. But for a repeated execution in a large tim... | <p>In your web.xml you can configure a servlet to load at startup.<br>
Syntax:</p>
<p><servlet servlet-name='hello'
servlet-class='test.HelloWorld'><br>
<load-on-startup/><br>
</servlet></p>
<p>Do this, then in the init method in the servlet you can set up a Timer / TimerTask to do whatev... | 10,366 |
<p>I am attempting to insert a Canvas3D object inside a Swing JPanel, but the code doesn't seem to be working (i.e. nothing happens):</p>
<pre>
Canvas3D canvas = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
SimpleUniverse universe = new SimpleUniverse(canvas);
BranchGroup root = ne... | <p>Probably you have to set a layout manager on the panel, which automatically expands the child components to the full area. A JPanel has a FlowLayout by default, which <em>does not</em> expand the child components. You could try a BorderLayout instead by calling:</p>
<pre><code>canvasPanel.setLayout(new BorderLayout... | <p>Canvas3D needs a size passed to it; setting the preferred configuration from SimpleUniverse is not enough. In my case, that meant this code:</p>
<pre> // 3D canvas initialization
Canvas3D canvas = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
SimpleUniverse universe = new SimpleUn... | 25,910 |
<p>When setting the export path in Unix, example:</p>
<pre><code>export PATH=$PATH: $EC2_HOME/bin
</code></pre>
<p>If I quit terminal and open it back up to continue working, I have to go through all the steps again, setting up the paths each time.
I'm wondering how I can set the path and have it "stick" so my system... | <p>Open <code>~/.bashrc.</code> This file is loaded every time you start up a new shell (if you're using Bash, which most people are). If you're using a different shell, the file may have a different name, like <code>~/.shrc</code>.</p>
<p>Add the line you need to the bottom of the file:</p>
<pre><code>export PATH=$P... | <p>add it to your .bashrc or another .bash startup file.</p>
| 25,661 |
<p>Does anyone know how I can, in platform-independent C++ code prevent an object from being created on the heap? That is, for a class "Foo", I want to prevent users from doing this:</p>
<pre><code>Foo *ptr = new Foo;
</code></pre>
<p>and only allow them to do this:</p>
<pre><code>Foo myfooObject;
</code></pre>
<p>... | <p><a href="https://stackoverflow.com/questions/10985/how-to-prevent-an-object-being-created-on-the-heap#11003">Nick's answer</a> is a good starting point, but incomplete, as you actually need to overload:</p>
<pre><code>private:
void* operator new(size_t); // standard new
void* operator new(size_t, v... | <p>Not sure if this offers any compile-time opportunities, but have you looked at overloading the 'new' operator for your class?</p>
| 3,218 |
<p>Is it possible to turn off the query re-formatting that happens when you edit a query for a database in Visual Studio? (i.e. r-click a data source and select New Query)</p>
<p>This is happening when we are writing sql queries against a sql compact 3.5 database.</p>
<p>Its rather irritating when your carefully inde... | <p>I use the Add New "Sql Script" instead of the Query to prevent re-formating but still keep the syntax highlighting.</p>
| <p>I use the Add New "Sql Script" instead of the Query to prevent re-formating but still keep the syntax highlighting.</p>
| 12,587 |
<p>I need a complete Object Pascal syntax (preferably Delphi 2009). Some of the syntax is given by the help files, but not all information is provided. So I started collecting loose bits of information. Recently I added these to a more or less complete syntax description (EBNF like).</p>
<p>Although it looks extensive... | <p>Try this: <strong><a href="http://dgrok.excastle.com/" rel="noreferrer">DGrok</a></strong> - Delphi grammar</p>
| <p>You could always read the source to the <a href="http://www.freepascal.org/" rel="nofollow noreferrer">Free Pascal Compiler</a>. It supports Object Pascal.</p>
| 20,715 |
<p>I have a TObjectList with OwnsObjects = true. It contains quite a few objects. Now I want to remove the object at index Idx from that list, without freeing it.</p>
<p>Is the Extract method the only option?</p>
<p><code>ExtractedObject := TheList.Extract(TheList[Idx]);</code></p>
<p>All other methods seem to free ... | <p>Why not just set OwnsObjects to false, do your removal, then set it to true again?</p>
| <p>I don't use Delphi/C++Builder some time ago, but as far as I can renmember thats the only way.
My suggestion is to use a TList instead, and manually delete the objects when required.</p>
| 36,013 |
<p>I was working with quality yesterday doing some formal testing. In their procedure they were verifying all files on the test machine were pulled from the release. The way they were verifying these files were the same was by checking the size and the date/time stamp windows put on them in Windows Explorer. These h... | <p>The only 100% way to figure out if two files are equal is to do a binary comparison of the two.</p>
<p>If you can live with the risk of false positives (ie. two files which aren't 100% identical but your code says they are), then the digest and checksum algorithms can be used to lessen the work, particularly if the... | <p>You should do a CRC check on each file... from the wiki:</p>
<p><a href="http://en.wikipedia.org/wiki/Cyclic_redundancy_check" rel="nofollow noreferrer">Cyclic redundancy check</a>, a type of hash function used to produce a checksum, in order to detect errors in transmission or storage.</p>
<p>It produces an almos... | 2,668 |
<p>I have an odd problem...I'm using a documentation generator which generates a lot of output like docs/foo.php.html. It's XHTML, and thus contains <code><?xml...></code> tags at the beginning of file. The problem is, Apache has somehow decided to run it through the PHP interpreter, even though ".php" appears in... | <p>The problem seems to be in <a href="http://httpd.apache.org/docs/2.2/mod/mod_mime.html" rel="noreferrer">mod_mime</a>.</p>
<p>Quote from the Apache mod_mime documentation page:</p>
<blockquote>
<p>If you would prefer only the last dot-separated part of the filename to be mapped to a particular piece of meta-data, th... | <p>Are .html files listed as being allowed to be parsed as PHP? I've seen some shared hosts set .html files to be usable as a valid PHP extension which may also be catching your .php.html files.</p>
| 23,021 |
<p>I've got a website running under ASP .NET 2/IIS7/Vista. I have a URL rewriting module which allows me to have extensionless URLs. To get this to work I have configured the system.webServer section of the config file such that all requests are forwarded to the aspnet_isapi.dll. I have also added the URL rewrite modul... | <p>I can't give you a generic solution, but this is what has worked for us. We have the app server connect to LDAP as a specific user that has the ability to request credentials for other users. Then we have some generic security code that we can use to request a users credentials from inside the session beans, based... | <p>Normally the Java EE security model will not allow the retrieval of the user password, for security reasons. But it depends on the implementation. Some vendors provide methods to retrieve this kind of information, but if you rely on such implementations, be aware that the portability of the application will be compr... | 42,882 |
<p>I'm having trouble saving a new row in the DataGridView back to the database. Briefly,</p>
<p>1) I use a SqlDataAdapter to fill a DataTable in a DataSet.</p>
<p>2) The DataTable is the DataSource for a Grid View.</p>
<p>3) If the user clicks on the blank "new row" at the bottom of the DataGridView, I capture the ... | <p>What you need is a clear separation between model and presentation. If you write a number of generic components that pull data out in a presentation-agnostic way (the model), you can then have a number of adapters, that render the output for each specific target (The views). There are frameworks around that tie all ... | <p>First of all you should not return HTML by a webservice. IMHO a webservice should return generic/client independent form. I would suggest to use a simple ASPX web page that gets a bunch of XSL Layout transformations for some clients.</p>
<p>Make it customizable and you will not have to touch the code for a long tim... | 38,324 |
<p>I have a class that extends Zend_Form like this (simplified):</p>
<pre><code>class Core_Form extends Zend_Form
{
protected static $_elementDecorators = array(
'ViewHelper',
'Errors',
array('Label'),
array('HtmlTag', array('tag' => 'li')),
);
public function loadDefa... | <p>the best place to set it is public function loadDefaultDecorators()</p>
<p>for example like this:</p>
<pre><code>class ExampleForm extends Core_Form
{
public function init()
{
//Example Field
$example = new Zend_Form_Element_Hidden('example');
$this->addEl... | <p>Here's what I do:</p>
<pre><code>class M_Form_Element_Hidden extends Zend_Form_Element_Hidden {
public function init() {
$this->setDisableLoadDefaultDecorators(true);
$this->addDecorator('ViewHelper');
$this->removeDecorator('DtDdWrapper');
$this->removeDecorator('HtmlTag');
... | 49,241 |
<p>I always see the code like this in the blogs: </p>
<pre><code>$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "WebService.asmx/HelloWorld",
data: "{}",
dataType: "json",
... | <p>You need to add this attribute to your webserver class</p>
<pre><code>[System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
</code></pre>
<p>and this attribute to your functions</p>
<pre><code>[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
</code></pre>
<p>You don... | <p>I already know this article, but It couldn't help me.</p>
<p>In my sample app, I use these codes:</p>
<p><strong>my Jquery code:</strong></p>
<pre><code> $(document).ready(function() {
$('#clKaydet').click(function() {
$.ajax({
type: "POST",
cont... | 37,297 |
<p>I tried to write a <code>TransformMesh</code> function. The function accepts a <code>Mesh</code> object and a <code>Matrix</code> object. The idea is to transform the mesh using the matrix. To do this, I locked the vertex buffer, and called Vector3::TransformCoordinate on each vertex. It did <em>not</em> produce exp... | <p>Without contextual code around what you are doing, it might be hard to know the exact problem. How is the mesh created? How is verts[] read, how is it written? Are you trying to read from a write only vertex buffer?</p>
<p>My recommendation would be to try with a very simple translation matrix first and debug the c... | <p>I recommend to use function D3DXConcatenateMeshes. Pass one mesh and one matrix. Result will be transformed mesh. It's quite easy.</p>
| 42,849 |
<p>I want to port a project from sybase to oracle. I need to port the tables scripts (around 30) and some data in meta data tables(100 rows 2/3 tables). What will the best tool for this work?</p>
| <p>For such a small volume you would be well of writing the scripts rather than using any tools.</p>
| <p>You do have scripts for the tables in sybase, right? Conversion by manually editing should be doable, as Dheer said.</p>
<p>What meta data are you referring to? Is it meta data you've generated or meta data that sybase generated as a consequence ofr your DDL scripts? </p>
<p>If it's meta data you've generated, y... | 32,638 |
<p>While searching the interweb for a solution for my VB.net problems I often find helpful articles on a specific topic, but the code is C#. That is no big problem but it cost some time to convert it to VB manually.
There are some sites that offer code converters from C# to VB and vice versa, but to fix all the flaws a... | <p>If you cannot find a good converter, you could always compile the c# code and use the dissasembler in <a href="http://www.red-gate.com/products/reflector/" rel="noreferrer">Reflector</a> to see Visual Basic code. Some of the variable names will change.</p>
| <p>The one at <a href="http://www.developerfusion.com/tools/convert/csharp-to-vb/" rel="nofollow noreferrer">http://www.developerfusion.com/tools/convert/csharp-to-vb/</a> (new url) now supports .NET 3.5 syntax (thanks to the #develop guys once again), and will automatically copy the results to your clipboard :)</p>
| 11,396 |
<p>I got this error when I checked out my database from source control. It might sounds weird to check in the sql server database, but this was what I have done because this is just a personal project.</p>
<p>Anyone knows how to fix this?</p>
| <p>Here's my finding.</p>
<p>As mentioned by other posters, you really don't want to check database files into and out of the source control.</p>
<p>But if you absolutely need to, and you have done check in the database files and you are encountering the same error that I encountered, here is a workaround:</p>
<p>Fi... | <p>This sounds like the data files do not match the structure files of your database.</p>
<p>Shortly spoken, the files where your data (i.e. table rows) resides in are (mostly) not the files the structure of your data (i.e. the description of the tables) is stored. At least in "modern" RDBMS systems. So you checked ou... | 14,667 |
<p>I'm failing to understand exactly what the IF statement is doing, from what I can see it is checking if the variable <code>x</code> is equal to the int <code>0</code>. If this is <code>true</code> the ABSOLUTE value of the variable <code>y</code> is returned... this is when I lose the plot, why would the return stat... | <p>Floating-point math is by its nature inaccurate, so rather than testing for equivalence (which is always a bad idea), instead the developer has chosen a small number (1x10^-14 in this case) as the acceptable tolerance for proximity to zero. The return statement returns a comparison, so what this will do is take the ... | <p>I haven't done Java in a long time but it would appear that this is actually returning a boolean (which might be implicitly cast).</p>
<p>I would say that if x equals 0, it returns true when the absolute value of y <= Epsilon, otherwise it returns false.</p>
<p>However if x doesn't equal 0 then it would return ... | 19,965 |
<p>I have a Data Access Object TransactionDao. When you call TransactionDao.Save(transaction) I would like for it to setting a transaction.IsSaved=true flag (this is a simplification the actual thing I'm trying to do is not quite so banal). So when mocking my TransactionDao with RhinoMocks how can I indicate that it ... | <p>Gorge, </p>
<p>The simplest solution, which I found, applied to your question is the following:</p>
<pre><code>Expect.Call(() => dao.Save(transaction))
.Do(new Action<Transaction>(x => x.IsSaved = true));
</code></pre>
<p>So you don't need to create a special delegate or anything else. Just use A... | <p>you should mock the transaction and make it return true fo IsSaved, if you can mock the transaction of course.</p>
<pre><code>ITransaction transaction = _Mocker.dynamicMock<ITransaction>;
Expect.Call(transaction.IsSaved).IgnoreArguments.Return(true);
_mocker.ReplayAll();
dao.Save(transaction);
</code></pre>
| 8,396 |
<p>This question is overflow from the following question:</p>
<p><a href="https://stackoverflow.com/questions/70096/how-do-i-programmatically-convert-mp3-to-an-itunes-playable-aacm4a-file">How do I programmatically convert mp3 to an itunes-playable aac/m4a file?</a></p>
<p>Anyway, I learned how to create an aac file ... | <p><code>ffmpeg</code> is a general purpose (de)muxer/transcoder. <code>MP4Box</code> is a (de)muxer/transcoder from <a href="http://gpac.wp.institut-telecom.fr/mp4box/" rel="nofollow noreferrer">GPAC</a>, a package dedicated to MP4 related software tech. Right now it seems wiser to use MP4Box because it writes the moo... | <p>Just use any mp4-Muxer like Yamb to create an <code>mp4</code>-file with only the <code>aac</code> audio track in it, then change the file extension to <code>m4a</code>.</p>
| 9,591 |
<p>I am seeing following exception when I try to use dynamic proxy </p>
<pre><code> com.intellij.rt.execution.application.AppMain DynamicProxy.DynamicProxy
Exception in thread "main" java.lang.IllegalArgumentException: interface Interfaces.IPerson is not visible from class loader
at java.lang.reflect.Proxy.getProx... | <p>If this is web application, then you should use the web application classloader when creating dynamic proxy. So, for example instead of:</p>
<pre><code>Proxy.newProxyInstance(
ClassLoader.getSystemClassLoader(),
new Class < ? >[] {MyInterface.class},
new InvocationHandler() {
// (...)
});
</code></p... | <p>I had the same problem using spring boot, I solve it injecting ResourceLoader, getting its class loader.</p>
<pre><code>@Autowired
private ResourceLoader resourceLoader;
....
ClassLoader classLoader = resourceLoader.getClassLoader();
...
Proxy.newProxyInstance(
classLoader, //for example...
new Class < ? &... | 25,939 |
<p>Is there a way to make OpenGL transform a general vector I give it with the current modelview matrix and get the result back?</p>
<p>The obvious way is to query the modelview matrix and do the multiplication myself but
I am almost sure there should be a way to make OpenGL do this for me.</p>
| <p>You are right, you have to get the modelview matrix and transform the vector yourself.</p>
<p>For a confirm, see <a href="http://www.opengl.org/resources/faq/technical/transformations.htm" rel="noreferrer">this link</a> at paragraph 9.120.</p>
| <p>The reason why opengl probably won't just do this for you is because the calculation isn't part of the rendering pipeline. and opengl (for the most part) only performs calculations during the display loop. So it doesn't make sense to provide these kind of synchronous interfaces.</p>
| 36,181 |
<p>I have a question about using <code>new[]</code>.</p>
<p>Imagine this:</p>
<pre><code>Object.SomeProperty = new[] {"string1", "string2"};
</code></pre>
<p>Where SomeProperty expects an array of strings.</p>
<p>I know this code snippet will work. But i want to know what it does under the hood. Does <code>new[]</c... | <p>Okay, there's still a <em>little</em> bit of confusion here.</p>
<p>The inference that's going on has nothing to with the type of Object.SomeProperty, but everything to do with the types of the expressions in the array initializer. In other words, you could do:</p>
<pre><code>object o = new[] { "string1", "string2... | <p>I do hope from your response you're not getting confused between type substitution and type inference here! I'm assuming the type of Object.SomeProperty is string[], though due to array covariance it could be object[] (note this would <em>not</em> be a good thing - check out <a href="http://blogs.msdn.com/ericlipper... | 42,113 |
<p>I'm building a form with php/mysql. I've got a table with a list of locations and sublocations. Each sublocation has a parent location. A column "parentid" references another locationid in the same table. I now want to load these values into a dropdown in the following manner:</p>
<pre><code>--Location 1
----Subloc... | <p>NOTE: This is only psuedo-code.. I didn't try running it, though you should be able to adjust the concepts to what you need.</p>
<pre><code>$parentsql = "SELECT parentid, parentname FROM table";
$result = mysql_query($parentsql);
print "<select>";
while($row = mysql_fetch_assoc($result)){
$childsql = ... | <p>optgroup is definitely the way to go. It's actually what it's for,</p>
<p>For example usage, view source of <a href="http://www.grandhall.eu/tips/submit/" rel="nofollow noreferrer">http://www.grandhall.eu/tips/submit/</a> - the selector under "Grandhall Grill Used".</p>
| 18,759 |
<p>I'm wondering how you can implement a program similar to <code>tail -f</code> in C/C++, a program that watches for and processes new lines added to a log file?</p>
| <p>You can use fseek() to clear the eof condition on the stream. Essentially, read to the end of the file, sleep for a while, fseek() (without changing your position) to clear eof, the read to end of file again. wash, rinse, repeat. man fseek(3) for details.</p>
<p>Here's what it looks like in perl. perl's seek() ... | <p><a href="https://stackoverflow.com/questions/18632/how-to-monitor-a-text-file-in-realtime#18635">See here</a></p>
<p>You could either call out to tail and retrieve the stream back into your app, or as it's open source, maybe try to pull it into your own code.</p>
<p>Also, it is possible in C++ iostream to open a f... | 4,240 |
<p>I have an existing Stored Procedure which I am trying to now call with LINQ to SQL, here is the stored procedure:</p>
<pre><code>ALTER procedure [dbo].[sp_SELECT_Security_ALL] (
@UID Varchar(15)
)
as
DECLARE @A_ID int
If ISNULL(@UID,'') = ''
SELECT DISTINCT
App_ID,
App_Name,
App_D... | <p>Since you are abstracting the creation inside <code>libname_newDevice()</code> (which I have to say isn't a good approach), you should destroy using something like <code>libname_destroyDevice (obj)</code>.</p>
<p>And as the comment from Martin suggests, it's best to put them in the constructor and destructor of a c... | <p>You definitely don't want to implement Obj::deleteMe(). It would have to do something like: </p>
<pre><code>delete this;
</code></pre>
<p>while you were still inside this->deleteMe(). Follow Jaywalker's suggestion and make the destroy function take an Obj* as a parameter.</p>
| 36,107 |
<p>I was always wondering why such a simple and basic operation like swapping the contents of two variables is not built-in for many languages.</p>
<p>It is one of the most basic programming exercises in computer science classes; it is heavily used in many algorithms (e.g. sorting); every now and then one needs it and... | <p>In my experience, it isn't that commonly needed in actual applications, apart from the already-mentioned sort algorithms and occasionally in low level hardware poking, so in my view it's a bit too special-purpose to have in a general-purpose language.</p>
<p>As has also been mentioned, not all processors support it... | <p>I think they just forgot to add it :-) Yes, not all CPUs have this kind of instructions, so what ? We have bunch of other things that most CPUs don't have instructions to compute. It would be much easier/clearer and also faster ( by intrinsic ) if we had it !!!</p>
| 36,405 |
<p>The SciTE editor comes with the Ruby installer, and it's just a generic code editor. I installed FreeRIDE but it seems a little buggy; it actually just crashed on me for no reason. :(</p>
<p>So my question is...</p>
<p>What IDE / Editor do you use for Ruby on Windows? What are the best editors out there?</p>
| <p><a href="http://www.netbeans.org/" rel="noreferrer">Netbeans IDE</a> is quite good.</p>
| <p>Go for Eclipse for everything. I tried Netbeans but it sucks! It doesn't even have a word-wrap feature! Can you believe that?</p>
| 31,992 |
<p>My Delphi7 project will not run on my clients computer if i don't have a few of the runtime packages in the path. eg rtl70.bpl</p>
<p>I have <I>Build with runtime packages</I> unticked, so shouldn't they be complied into the exe?</p>
<p>Edit: the Project uses Jedi Packages (TJvPlugin) and running the program with ... | <p>It has been a while, but it seems like there was something where you needed to (1) check build with runtime packages, and then that enables some other editor (maybe list of packages to use), and you (2) make a change there. (3) Then do a full build, and then (4) remove the runtime packages check and do another (5) ... | <p>You also need to uncheck the "Use Dynamic RTL" on the Linker tab of the Project Options.</p>
<p>Caveat: I'm using C++Builder, but I believe the options are the same.</p>
| 21,893 |
<p>How can I capture the event in Excel when a user clicks on a cell. I want to be able to use this event to trigger some code to count how many times the user clicks on several different cells in a column.</p>
| <p>Check out the Worksheet_SelectionChange event. In that event you could use Intersect() with named ranges to figure out if a specific range were clicked.</p>
<p>Here's some code that might help you get started.</p>
<pre><code>Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Not Intersect(Ta... | <p>Worksheet SelectionChange event would do it. Note that this fires <strong>every</strong> time user clicks a new cell. </p>
| 17,970 |
<p>Is it possible to get notifications using <a href="http://www.microsoft.com/sql/technologies/reporting/default.mspx" rel="nofollow noreferrer">SQL Server Reporting Services</a>? Say for example I have a report that I want by mail if has for example suddenly shows more than 10 rows or if a specific value drop below 1... | <p>I'd agree with Simon re Notification Services</p>
<p>Also, data driven SSRS Subscriptions are not available unless you use Enterprise Edition (and isn't available if you use SharePoint Integrated Mode).</p>
<p>An alternate way would be to create an Agent job that runs a proc. The proc could check the conditions y... | <p>I wouldn't go down the ntofications services route - it is pretty much a deprecated feature of SQL Server and even if it is around in future it will stagnate. So don't build a dependency on it.</p>
| 11,433 |
<p>How would I go about generating a list of all possible permutations of a string between x and y characters in length, containing a variable list of characters.</p>
<p>Any language would work, but it should be portable.</p>
| <p>There are several ways to do this. Common methods use recursion, memoization, or dynamic programming. The basic idea is that you produce a list of all strings of length 1, then in each iteration, for all strings produced in the last iteration, add that string concatenated with each character in the string individual... | <p>The possible string permutations can be computed using recursive function. Below is one of the possible solution.</p>
<pre><code>public static String insertCharAt(String s, int index, char c) {
StringBuffer sb = new StringBuffer(s);
StringBuffer sbb = sb.insert(index, c);
return sbb.toString... | 2,285 |
<p>Is there any way to find all references to an object while debugging?</p>
| <p>Not without using the profiling/debugger API, as far as I'm aware. (Even with the API, I don't know how to do it.)</p>
| <p>Not with the default tools that Visual Studio offers you. There are 3rd party "Memory Profilers" out there that will allow you to do this. I have used one myself to hunt down a "memory leak" in a .NET program.</p>
| 49,865 |
<p>Is there any way to capture the trace statements of your Flex app while not running in debug mode?</p>
<p>Or is there any other way to output logging information when not running a debugger?</p>
<p>Currently I'm trying to fix a bug that only presents itself in very specific deployment scenario, but I could see thi... | <p>I suppose you're talking about Adobe Flex, targeting the Flash Player?</p>
<p>If so, you can write your own logging wrapper class that propagates log messages sent to it to several targets (like the trace stack and internal memory so that you can access the log from within the app and e.g. send it to a server when ... | <p>You can try XPanel from Farata Systems. This is a native Windows UI that can show log messages using the Flex 3 Logging API even for Flex applications running in a browser. Unfortunately they have redesigned their site and I can't find it anymore... Maybe Google will help you.</p>
<p>We did something different usin... | 13,071 |
<p>In MFC I'm trying to set a null handler timer (ie. no windows). But I'm unable to process the WM_TIMER event in the CWinApp MESSAGE_MAP. Is this possible? If so, how?</p>
| <p>As told by MSDN, there are two modes of operation for <a href="http://msdn.microsoft.com/en-us/library/ms644906.aspx" rel="noreferrer"><code>SetTimer()</code></a>: one that associates a timer with a window, and one that associates a timer with a thread's message queue. When you have a window, you can use the former;... | <p>I've done this by making an invisible window and setting a timer on it.</p>
| 26,187 |
<p>What should I use to virtualize my desktop, vmx, xen, or vmware?</p>
<p><strong>Needs to work on a linux or windows host, sorry virtual pc.</strong></p>
<p>@Derek Park: Free as in speech, not beer. I want to be able to make a new virtual machine from my own licensed copies of windows, for that vmware is kind of ex... | <p>Try <a href="http://www.virtualbox.org/" rel="noreferrer">VirtualBox</a>. It's free, open source, and it runs on Windows, Linux, Macintosh and OpenSolaris.</p>
| <p>Um, <a href="http://info.vmware.com/content/GLP_VMwarePlayer" rel="nofollow noreferrer">VMware is free</a>.</p>
| 3,307 |
<p>I've a class which is a wrapper class(serves as a common interface) around another class implementing the functionality required. So my code looks like this.</p>
<pre><code>template<typename ImplemenationClass> class WrapperClass {
// the code goes here
}
</code></pre>
<p>Now, how do I make sure that <code>I... | <p>It's verbose, but you can do it like this:</p>
<pre><code>#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_base_of.hpp>
struct base {};
template <typename ImplementationClass, class Enable = void>
class WrapperClass;
template <typename ImplementationClass>
class Wrapp... | <p>See <a href="http://www.research.att.com/~bs/bs_faq2.html#constraints" rel="nofollow noreferrer">Stoustrup's own words on the subject</a>.</p>
<p>Basically a small class, that you instantiate somewhere, e.g. the templated classes constructor.</p>
<pre><code>template<class T, class B> struct Derived_from {
... | 7,921 |
<p>I use <code>public boolean mouseDown(Event ev, int x, int y)</code> to detect a click of the mouse.<br>
I can distinguish between the right mouse button (ev.metaDown() is true) and the left and middle.</p>
<p>How can i differentiate the left from the middle button?
Or if it is impossible with mouseDown, what should... | <p>Try using <a href="http://java.sun.com/javase/6/docs/api/java/awt/Event.html#ALT_MASK" rel="nofollow noreferrer">ALT_MASK</a>:</p>
<blockquote>
<p>This flag indicates that the Alt key was down when the event occurred. For mouse events, this flag indicates that the middle mouse button was pressed or released.</p>
... | <p>This might do it:</p>
<p><a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/SwingUtilities.html#isMiddleMouseButton(java.awt.event.MouseEvent)" rel="nofollow noreferrer">http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/SwingUtilities.html#isMiddleMouseButton(java.awt.event.MouseEvent)</a></p>
<p>Haven... | 23,743 |
<p>Is there a place to find all possible uses of the syscmd method in MS Access? I know Microsoft has a <a href="http://msdn.microsoft.com/en-us/library/bb214117.aspx" rel="nofollow noreferrer">developer reference</a>, but I have found there are many other uses for this method that are not listed here.</p>
| <p>Here's a comprehensive list, including which Access versions each command applies to, translated into English.</p>
<p><a href="http://www.excite-webtl.jp/world/english/web/?wb_url=http%3A%2F%2Fwww.f3.dion.ne.jp%2F%7Eelement%2Fmsaccess%2FAcTipsUnDocumentedSysCmd.html&wb_lp=JAEN&wb_dis=2" rel="nofollow norefe... | <p>Here are a few of the "undocumented" functions, I know from experience that you can basically run anything that windows can do using syscmd once you understand how to structure the commands from examples like these.</p>
<p><a href="http://www.everythingaccess.com/tutorials.asp?ID=Undocumented-SysCmd-Functions" rel=... | 13,465 |
<p>Edit: Closing this because i've found the reason why it's erroring, but instead of removing this post .. i generate a newer post with a more refined question.</p>
<hr>
<p>Hi folks,</p>
<p>i have some binary data i've read in. i wish to convert it to an <code>System.Drawing.Image</code>, so i create an instance of... | <p>Just tested your code, it worked, the code is fine. There must be a problem with the image file or path.
This is my test:</p>
<pre><code>private void Form1_Load(object sender, EventArgs e)
{
byte[] data = File.ReadAllBytes("c:\\t.jpg");
using (Stream originalBinaryDataStream = n... | <p>I've updated the initial question post with a link the entire VS solution (which is one class and one unit test). The unit test throws the fail fail fail exception. Please check it out.</p>
| 41,470 |
<p>We currently have a CruiseControl.Net server that is merrily building the trunk on our svn server. I have a new requirement to build the "latest" branch as well; is there a best practice in CruiseControl to handle this? What specific changes are needed to build from the trunk and a branch at the same time?</p>
| <p>Make a second project just like the original where the source control is pointed to the proper branch.</p>
| <p>I generally create a new working directory named branch, set up the source control to monitor the branch and pull to the new folder. I also put in an exculusion filter on the trunk build so it does not get kicked off by a check in to the branch (our branches usually reside within the trunk realm of checking for chan... | 33,011 |
<pre><code><servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>workflow.WDispatcher</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern&... | <pre><code><url-pattern>*NEXTEVENT*</url-pattern>
</code></pre>
<p>The URL pattern is not valid. It can either end in an asterisk or start with one (to denote a file extension mapping).</p>
<p>The url-pattern specification:</p>
<blockquote>
<ul>
<li>A string beginning with a ‘/’ character and ending ... | <p>A workaround that can achieve that is to add a servlet filter to do URL re-writes e.g.
re-write <em>NEXTEVENT</em> to /NEXTEVENT/<em>(the one before the NEXTEVENT)/</em>(the one after NEXTEVENT) or something similar.</p>
| 4,629 |
<p>I've got some sliced models that represent the <strong>right</strong>-side arms and legs of a robot. I'm really happy with how they printed, so now I'd like to print the <strong>left</strong>-side arms and legs.</p>
<p>I was thinking it would be pretty trivial to parse the G-code file using Python and change the val... | <p>If your slicer does not have a mirror operation or a scale that allows negative values then mirroring in the G-code should be straightforward.</p>
<p>As long as your printer doesn't have certain specific tool change or homing or purge positions that are done in the G-code you can just transform it, otherwise you wou... | <p>Usage: python3 [filename.gcode] [bed-width]</p>
<pre><code>#!/usr/bin/env python3
import re
from sys import argv
#first arg is the file, second arg is the bed x width
ifilename = argv[1];
ofilename = ifilename.replace('.gcode', '-reversed.gcode');
new_data =[]
BEDX = float(argv[2])
h = BEDX # Absolute Positioning... | 1,979 |
<p>I'm trying to think of a naming convention that accurately conveys what's going on within a class I'm designing. On a secondary note, I'm trying to decide between two almost-equivalent user APIs.</p>
<p>Here's the situation:</p>
<p>I'm building a scientific application, where one of the central data structures has... | <p>I generally prefer to have an explicit change, rather than lazily recomputing the result. This approach makes the performance of the utility more predictable, and it reduces the amount of work I have to do to provide a good user experience. For example, if this occurs in a UI, where do I have to worry about popping ... | <p>You could have a state variable. Have a method for starting the high level processing, which will only work if the STATE is in SECTION-1. It will set the state to SECTION-2, and then to SECTION-3 when it is done computing. If there's a request to the program to interpolate a given point, it will check if the state i... | 30,791 |
<p>What are your favorite applications, products, or any applications that you know of that use <strong><em>.NET or Asp.NET</em></strong> as their underlying platform? What popular companies do you know of as a .NET shop?</p>
<p><em>This question is related to a few others that I have seen. So I've just made this one ... | <p>Client apps</p>
<ul>
<li><a href="http://getpaint.net" rel="noreferrer">Paint.net</a></li>
<li>Windows Live Writer</li>
</ul>
<hr>
<p>Developer Tools</p>
<ul>
<li><a href="http://www.red-gate.com/products/reflector/" rel="noreferrer">.Net Reflector</a></li>
<li>Expression Blend</li>
</ul>
<hr>
<p>Asp.Net apps:... | <p>MySpace is probably one of the biggest ASP.NET sites going around. Proves ASP.NET can handle mega load.</p>
| 28,228 |
<p>I have a file of about 30000 lines of data that I want to load into a sqlite3 database. Is there a faster way than generating insert statements for each line of data?</p>
<p>The data is space-delimited and maps directly to an sqlite3 table. Is there any sort of bulk insert method for adding volume data to a databas... | <ul>
<li>wrap all INSERTs in a transaction, even if there's a single user, it's far faster.</li>
<li>use prepared statements.</li>
</ul>
| <p>I do a bulk insert with this method:</p>
<pre><code>colnames = ['col1', 'col2', 'col3']
nrcols = len(colnames)
qmarks = ",".join(["?" for i in range(nrcols)])
stmt = "INSERT INTO tablename VALUES(" + qmarks + ")"
vals = [[val11, val12, val13], [val21, val22, val23], ..., [... | 47,519 |
<p>I'm writing a Rails application which will monitor data quality over some specific databases. In order to do that, I need to be able to execute direct SQL queries over these databases - which of course are not the same as the one used to drive the Rails application models. In short, this means I can't use the trick ... | <p>I had a situation like this where I had to connect to hundreds of different instances of an external application, and I did code similar to the following:</p>
<pre><code> def get_custom_connection(identifier, host, port, dbname, dbuser, password)
eval("Custom_#{identifier} = Class::new(ActiveRecord::Base)")
... | <p>You may be able to do this through <a href="http://blog.whitet.net/articles/2008/01/30/rails-has_many-with-models-over-different-databases" rel="nofollow noreferrer"><code>self.establish_connection</code></a>.</p>
| 10,644 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.