instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I'm using Java's <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/transform/Transformer.html" rel="nofollow noreferrer">Transformer</a> class to process an XML Document object.</p>
<p>This is the code that creates the Transformer:</p>
<pre><code>import javax.xml.transform.TransformerFactory;
import javax... | <p>Note that <code><svg xmlns="SVGNS" /></code> is the same as <code><svg:svg xmlns:svg="SVGNS" /></code>. </p>
<p>Did you check you called <code>setNamespaceAware(true)</code> on your <code>DocumentBuilderFactory</code> instance ?</p>
| <p>The package description for <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/transform/package-summary.html#package_description" rel="nofollow noreferrer">javax.xml.transform</a> has a section <em>Qualified Name Representation</em> which seems to imply that it is possible to get the namespace represented i... | 35,058 |
<p>I have a string like "1234567890". Now I need to store/print out this with the following format,
123-456-7890</p>
<p>What is the best method to implement this in C?</p>
<p>Thanks for comments/answers.</p>
| <p>There will be two schools of thought on this as far as what is "best".</p>
<p>One school says that, as long as it's functional and secure, whatever method uses the fewest resources (memory and processor cycles) is "best".</p>
<p>One school says that, as long as it's functional and secure, whatever method is easies... | <p>You could use <strong>realloc</strong> to reallocate the string buffer (it's not on the stack, is it?) then <strong>memmove</strong> to shift the necessary characters.</p>
| 41,130 |
<p>Using Crystal Reports Developer XI</p>
<p>I have a crosstab report. The crosstab can span many pages horizontally. For a report 10 pages wide and 3 pages long, I display page numbers as '1-1 of 3' through '3-10 of 3' but I'd like to be able to display them as '1 of 30' through '30 of 30'.</p>
<p>Unfortunately the ... | <p>In your Field Explorer, go to <strong>Special Fields->Horizontal Page Number</strong> and insert that. I've never used it myself, but it seems to be what you need.</p>
| <p>There is a special field called "Page N of M". Drag that onto your page and that should give you the numbering scheme that you're after.</p>
<p><strong>Edited to add:</strong> Sorry, I read your post and didn't "read" your post. The problem is that these aren't really pages but a continuation of a page or virtua... | 43,956 |
<p>I want to be able to run a single spec file's tests — for the one file I'm editing, for example. <code>rake spec</code> executes all the specs. My project is not a Rails project, so <code>rake spec:doc</code> doesn't work.</p>
<p>Don't know if this matters, but here is my directory structure.</p>
<pre>
./R... | <p>Or you can skip rake and use the 'rspec' command:</p>
<pre><code>bundle exec rspec path/to/spec/file.rb
</code></pre>
<p>In your case I think as long as your ./spec/db_spec.rb file includes the appropriate helpers, it should work fine.</p>
<p>If you're using an older version of rspec it is:</p>
<pre><code>bundle exe... | <p>And you can run specific line into your test file</p>
<pre><code>rspec spec/models/model_spec.rb:47
</code></pre>
| 17,362 |
<p>Here is the issue I am having: I have a large query that needs to compare datetimes in the where clause to see if two dates are on the same day. My current solution, which sucks, is to send the datetimes into a UDF to convert them to midnight of the same day, and then check those dates for equality. When it comes ... | <p>This is much more concise:</p>
<pre><code>where
datediff(day, date1, date2) = 0
</code></pre>
| <p>I would use the dayofyear function of datepart:</p>
<pre><code>
Select *
from mytable
where datepart(dy,date1) = datepart(dy,date2)
and
year(date1) = year(date2) --assuming you want the same year too
</code></pre>
<p>See the datepart reference <a href="http://www.tizag.com/sqlTutorial/sqldatepart.php" rel="nofollo... | 4,261 |
<p>I have an existing Perl program that uses <code>Getopt</code> package and <code>Getopt::Long::Configure</code> with <code>permute</code> as one of the options. However, now I need to keep the order of the options entered by the user. There is an option <code>$RETURN_IN_ORDER</code> mentioned in the <code>Long.pm</co... | <p>It's called <code>require_order</code>, according to the manpage I have here. :-)</p>
| <p><em>Very</em> late to the party. I did this using an <a href="https://metacpan.org/pod/Getopt::Long#User-defined-subroutines-to-handle-options" rel="nofollow noreferrer">option-handling subroutine</a>. My particular use case is that I need to handle any number of <code>-e <foo></code> and <code>-f <foo>... | 26,742 |
<p>As one of those people that never got around to properly learning design (or having no talent for it), the design seems to be the step always holding me back. It's not a problem for rich-clients, as the standard GUI toolkits provide some acceptable ways to design a good-looking interface, but the web is another stor... | <p>Try the <a href="http://www.extjs.com/products/extjs/" rel="noreferrer">samples on ExtJs</a>.
I find them immensely useful in working out the UI. (trees, panels, modals, etc etc)</p>
| <p>Check out <a href="http://jacanasoftware.com" rel="nofollow noreferrer">http://jacanasoftware.com</a>. Their templates feature multi level tabs, clean css, it validates, and the CSS won't mess with your controls. I highly recommend them.</p>
| 6,972 |
<p>Say i have this PHP code:</p>
<pre><code>$FooBar = "a string";
</code></pre>
<p>i then need a function like this:</p>
<pre><code>print_var_name($FooBar);
</code></pre>
<p>which prints:</p>
<pre><code>FooBar
</code></pre>
<p>Any Ideas how to achieve this? Is this even possible in PHP?</p>
| <p>You could use <a href="http://php.net/get_defined_vars" rel="noreferrer">get_defined_vars()</a> to find the name of a variable that has the same value as the one you're trying to find the name of. Obviously this will not always work, since different variables often have the same values, but it's the only way I can t... | <p>I really fail to see the use case... If you will type print_var_name($foobar) what's so hard (and different) about typing print("foobar") instead? </p>
<p>Because even if you were to use this in a function, you'd get the local name of the variable...</p>
<p>In any case, here's the <a href="http://www.php.net/oop5.... | 31,855 |
<p>We currently use a hand-rolled setup and configuration script and a hand-rolled continuous integration script to build and deploy our application. I am looking at formalizing this somewhat with a third party system designed for these purposes.</p>
<p>I have looked into Phing before, and I get that it's basically li... | <p>phing is pretty much ant written in PHP where phpUnderControl adds support for PHP projects to CruiseControl and uses phing or ant on the backend to parse the build.xml file and run commands. </p>
<p>I just set up CruiseControl and phpUnderControl and it's been working great. It checks out my SVN, runs it through ... | <p>I'm sure lots of people will say this by the time I've typed this but...</p>
<p>I know it's not PHP but we're finding <a href="http://www.capify.org/" rel="nofollow noreferrer">Capistrano</a> just the job for this kind of thing. It really is an excellent piece of software. </p>
| 17,072 |
<p>I'd like to invoke bash using a string as input. Something like:</p>
<pre><code>sh -l -c "./foo"
</code></pre>
<p>I'd like to do this from Java. Unfortunately, when I try to invoke the command using <code>getRuntime().exec</code>, I get the following error: </p>
<pre><code> foo": -c: line 0: unexpected EOF ... | <p>Use this:</p>
<pre><code>Runtime.getRuntime().exec(new String[] {"sh", "-l", "-c", "./foo"});
</code></pre>
<p>Main point: don't put the double quotes in. That's only used when writing a command-line in the shell!</p>
<p>e.g., <code>echo "Hello, world!"</code> (as typed in the shell) gets translated to:</p>
<pre... | <p>The cause for this error is most likely a missing syntax token that bash expects but the string you pass ends before bash encountered it. Look for ifs, fors etc. that have no closing fi or done.</p>
| 19,572 |
<p>I have a MySQL table with approximately 3000 rows per user. One of the columns is a datetime field, which is mutable, so the rows aren't in chronological order.</p>
<p>I'd like to visualize the time distribution in a chart, so I need a number of individual datapoints. 20 datapoints would be enough.</p>
<p>I could ... | <p>Michal Sznajder almost had it, but you can't use column aliases in a WHERE clause in SQL. So you have to wrap it as a derived table. I tried this and it returns 20 rows:</p>
<pre><code>SELECT * FROM (
SELECT @rownum:=@rownum+1 AS rownum, e.*
FROM (SELECT @rownum := 0) r, entries e) AS e2
WHERE uid = ? AND... | <p><a href="https://stackoverflow.com/questions/3682/sql-distribution-of-table-in-time#3691">@Michal</a></p>
<p>For whatever reason, your example only works when the where @recnum uses a less than operator. I think when the where filters out a row, the rownum doesn't get incremented, and it can't match anything else.... | 2,575 |
<p>Using VB.net (.net 2.0)
I have a string in this format:</p>
<pre><code>record1_field1,record1_field2,record2_field3,record2_field1,record2_field2,
</code></pre>
<p>etc...</p>
<p>I wonder what the best (easiest) way is to get this into an xml?</p>
<p>I can think of 2 ways:</p>
<p>Method 1:
- use split to get the... | <p>I would do something like this:</p>
<pre>
<code>
XmlDocument doc = new XmlDocuent();
string[] data = csv.split(',');
XmlNode = doc.CreateElement("root");
foreach(string str in data)
{
XmlNode node = doc.CreateElement("data");
node.innerText = str;
root.AppendChild(node);
}
Console.WriteLine(doc.InnerX... | <p>Instead of doing string concatenation, you could probably create an XmlDocument and stuff it with the appropriate XmlElement and XmlAttribute objects from your string... Then, write out the XmlDocument object...</p>
| 31,365 |
<p>I think I am pretty good with programming C# syntax. What I am looking for now is some resources, books(preferable), websites, blogs, that deal with the best way to design object oriented Desktop Applications and Web applications, especially when it comes to data and databases. </p>
<p>Thanks</p>
| <p>You are asking to drink from a firehose. Let me encourage you to write some small programs before you tackle big ones. However, here are a few books about design and a paper which argues that a lot of design can't be learned from books:</p>
<ul>
<li><p><a href="http://research.sun.com/techrep/Perspectives/PS-2006... | <p>Years ago, as a c programmer who had done some Windows 3.1 programming, I learned a lot about object oriented design by using a development framework, specifically Borland's Object Windows Library. Their package back then also had a well-designed database object library for their database engine. Nowadays, all the d... | 47,797 |
<p>I'd like to be able to print the definition code of a lambda function.</p>
<p>Example if I define this function through the lambda syntax:</p>
<pre><code>>>>myfunction = lambda x: x==2
>>>print_code(myfunction)
</code></pre>
<p>I'd like to get this output:</p>
<pre><code>x==2
</code></pre>
| <p><em>As long as you save your code to a source file</em> you can retrieve the source code of
an object using the inspect module.</p>
<p>example:
open editor type:</p>
<pre><code>myfunction = lambda x: x==2
</code></pre>
<p>save as lamtest.py</p>
<p>open shell type python to get to interactive python
type the fol... | <p>Why do you want to do this? </p>
<p>I guess you could use the "dis" module to disassemble your code to python bytecode, but it's probably not what you want. </p>
<p><a href="http://www.python.org/doc/2.5.2/lib/module-dis.html" rel="nofollow noreferrer">http://www.python.org/doc/2.5.2/lib/module-dis.html</a></p>
<... | 43,426 |
<p>I'm currently trying to get into the Java EE development with the Spring framework. As I'm new to Spring, it is hard to imaging how a good running project should start off.</p>
<p>Do you have any <em>best practices</em>, tipps or major <em>DO NOTs</em> for a starter? How did you start with Spring - big project or s... | <p>Small tip - I've found it helpful to modularize and clearly label my Spring xml context files based on application concern. Here's an example for a web app I worked on:</p>
<ul>
<li><code>MyProject / src / main / resources / spring /</code>
<ul>
<li><em><strong>datasource.xml</strong></em> - My single data sourc... | <p>Spring is also very much about unit testing and therefore testability of your classes. That basically means thinking about modularization, separation of concerns, referencing a class through interfaces etc.</p>
| 3,002 |
<p>I once wrote a Crawler in .NET. In order to improve its scalability, I tried to take advantage of asynchronous API of .NET. </p>
<p>The System.Net.HttpWebRequest has asynchronous API BeginGetResponse/EndGetResponse. However, this pair of API is just to get a HTTP response headers and a Stream instance from which we... | <p>Hmya, this is not a .NET framework problem. The linked KB article could have been a bit more explicit: "you're using a loaded gun, this is what happens when you aim it at your foot". The bullets in that gun are .NET giving you the ability to start as many asynchronous I/O requests as you dare. It will do what you... | <p>No KB article can give you an upper bound. Upper bounds can vary depending on the hardware available - what is an upperbound for a 2G memory machine will be different for a machine with 16g of ram. It will also depend on the size of the GC heap, how fragmented it is etc.</p>
<p>What you should do is come up with a ... | 29,225 |
<p>The application I'm trying to localize is a WinForms application that has a few hosted WPF user controls (WPF user controls hosted in an ElementHost WinForms control).</p>
<p>I use <a href="http://msdn.microsoft.com/en-us/library/y99d1cd3.aspx" rel="nofollow noreferrer">resx</a> files to localize the WinForms, whic... | <p>Blech...The WPF team sure seemed to leave something to be desired with their localization solution. Well, for what it's worth, here's what I've been doing (to be fair, I've actually borrowed this idea from <a href="http://www.codeproject.com/KB/WPF/WPF_Localization.aspx" rel="nofollow noreferrer">Jecho Jekov</a> on... | <p>In order to get <a href="https://stackoverflow.com/a/637370/383129">the method dustyburwell posted</a> working in WinForms-embedded WPF user controls, you need to set the culture to the usercontrol after the InitializeComponent() call at the WinForms form constructor and then update the values.</p>
<ol>
<li>Declare... | 48,980 |
<p>It is my understanding that I can test that a method call will occur if I call a higher level method, i.e.:</p>
<pre><code>public abstract class SomeClass()
{
public void SomeMehod()
{
SomeOtherMethod();
}
internal abstract void SomeOtherMethod();
}
</code></pre>
<p>I want to test that... | <p>You can see if a method in something you have mocked has been called by using Verify, e.g.:</p>
<pre><code>static void Main(string[] args)
{
Mock<ITest> mock = new Mock<ITest>();
ClassBeingTested testedClass = new ClassBeingTested();
testedClass.WorkMethod(mock.Object);
... | <p>Even though I agree that the <a href="https://stackoverflow.com/a/347907/3311799">@Paul's answer</a> is the recommended way to go I just want to add one alternative way which is provided by <code>moq</code> off the self.</p>
<p>Since <code>SomeClass</code> is <code>abstract</code> it is indeed mockable, but <code>p... | 45,262 |
<p>How can I find the last row that contains data in a specific column and on a specific sheet?</p>
| <p>How about:</p>
<pre><code>Function GetLastRow(strSheet, strColumn) As Long
Dim MyRange As Range
Set MyRange = Worksheets(strSheet).Range(strColumn & "1")
GetLastRow = Cells(Rows.Count, MyRange.Column).End(xlUp).Row
End Function
</code></pre>
<p>Regarding a comment, this will return the row number ... | <pre><code>Function LastRow(rng As Range) As Long
Dim iRowN As Long
Dim iRowI As Long
Dim iColN As Integer
Dim iColI As Integer
iRowN = 0
iColN = rng.Columns.count
For iColI = 1 To iColN
iRowI = rng.Columns(iColI).Offset(65536 - rng.Row, 0).End(xlUp).Row
If iRowI > iRowN T... | 9,663 |
<p>What are the best/most popular ways to do aspect-oriented programming (AOP) in C#/.Net?</p>
| <ul>
<li><a href="http://www.castleproject.org/projects/dynamicproxy/" rel="nofollow noreferrer">DynamicProxy</a> from Castle is
probably the most used tool for
doing AOP on the CLR.</li>
<li><a href="http://www.springframework.net/docs/1.2.0-M1/reference/html/aop.html" rel="nofollow noreferrer">Spring framework</a> al... | <p>I've played around with rolling my own, for several different types of things. I've had some luck. In general, I make an interface, implement it with a class, and then make a proxy which implements the interface, does whatever precondition steps I want, calls the real object's method, and then does whatever postco... | 16,208 |
<p>I'm trying to read the data in a Win32 ListView owned by another process. Unfortunately, my WriteProcessMemory() call fails with the error "This function is not supported on this system." when I specify "NULL" for the base address in my VirtualAlloc() call. If, however, I offset that VirtualAlloc() address by some "... | <p>Instead of trying to allocate memory in another process, why not use named shared memory instead. This article will take you through the basic setup of <a href="http://msdn.microsoft.com/en-us/library/aa366551(VS.85).aspx" rel="nofollow noreferrer">shared memory</a>, and I did a quick check to make sure these funct... | <p>You have to keep in mind that you're writing to the <em>virtual</em> address space of a program. On Windows, it often starts at an address like your magic number.</p>
<p>Have you ever debugged a program? What do addresses look like?</p>
<p>On my system, the executables are usually loaded around 00400000 or 0100000... | 35,557 |
<p>I'm working on a MS Access database. I've made some changes to one of the modules. I want to go out for lunch, but when I try closing the database, I get the following message:</p>
<p>"You do not have exclusive access to the database. Your design changes cannot be saved at this time. Do you want to close withou... | <p>If you're sure no one else is in the db but you, it's an additional connection to your db from your own pc. You can verify this with the LDB viewer, downloadable in the free JetUtils.exe download from Microsoft:</p>
<p><a href="http://support.microsoft.com/kb/176670" rel="nofollow noreferrer">http://support.microso... | <p>If even a word mail merge is linked to the access database, that counts as an access connection.</p>
| 16,583 |
<p>I have a <a href="http://en.wikipedia.org/wiki/Windows_Forms" rel="noreferrer">Windows Forms</a> <a href="http://www.google.com/search?hl=en&q=TreeView%20msdn&btnG=Search" rel="noreferrer">TreeView</a> (node, subnodes). Each node contains some additional information in its Tag. Also, each nodes maps a file o... | <p>Consider using the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.clipboard_members.aspx" rel="noreferrer">Clipboard class</a>. It features all the methods necessary for putting data on the Windows clipboard and to retrieve data from the Windows clipboard.</p>
<pre><code>StringCollection paths... | <p>If you are only copying and pasting within your application, you can map the cut/copy operation of your treeview to a method that just clones your selected node. Ie:</p>
<pre><code>TreeNode selectedNode;
TreeNode copiedNode;
selectedNode = yourTreeview.SelectedNode;
if (selectedNode != null)
{
copiedNode = se... | 26,006 |
<p>The PHP documentation can be found <a href="http://us.php.net/manual/en/book.xmlwriter.php" rel="nofollow noreferrer">here</a>, but I think it's rather lacking. There are no examples of how to use these functions, and few (if any) of the pages have user comments. So where might I be able to find an explanation (and ... | <p>You should be able to move the *.eml files to the Exchange server's <strong>pickup directory</strong>. Or set the IIS SMTP service to <strong>smart host</strong> to the new MTA, assuming they (the 3rd party) allow SMTP relay from your IP address.</p>
| <p>Moving the files will work. However, any email with a BCC line in the header will get sent out with the BCC intact. Some clients, such as gmail, will display the information to the recipient, thus breaking the whole point of BCC.</p>
<p>This happens when copying EML files to MS-SMTP (which Exchange also uses) becau... | 12,829 |
<p>How can I monitor an SQL Server database for changes to a table without using triggers or modifying the structure of the database in any way? My preferred programming environment is <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="noreferrer">.NET</a> and C#.</p>
<p>I'd like to be able to support any <a h... | <p>Take a look at the CHECKSUM command:</p>
<pre><code>SELECT CHECKSUM_AGG(BINARY_CHECKSUM(*)) FROM sample_table WITH (NOLOCK);
</code></pre>
<p>That will return the same number each time it's run as long as the table contents haven't changed. See my post on this for more information:</p>
<p><a href="http://msdn.mic... | <p>Check the last commit date. Every database has a history of when each commit is made. I believe its a standard of ACID compliance.</p>
| 2,242 |
<pre><code>enum MyEnum {
A( 1, 2, 3, 4),
B(1, 2),
C(4, 5, 8, 8, 9);
private MyEnum( int firstInt, int... otherInts ) {
// do something with arguments, perhaps initialize a List
}
}
</code></pre>
<p>Are there any problems with this? Any reasons not to do it?</p>
| <p>Sure, this is perfectly legal. No reason not to do it if your program requires it.</p>
| <p>it does work.
You should try to </p>
<pre><code>private MyEnum(int... Ints )
</code></pre>
<p>With enums you need to make sure that you access them in a manner the initializes them. A lot of the time an access is all that is needed</p>
<pre><code>MyEnum bob = MyEnum.A;
</code></pre>
| 48,733 |
<p>I would like to create an application that serves web pages internally and can be run in multiple instances on the same machine. To do so, I would like to create an <code>HttpListener</code> that listens on a port that is:</p>
<ol>
<li>Randomly selected </li>
<li>Currently unused</li>
</ol>
<p>Essentially, what I... | <p>TcpListener will find a random un-used port to listen on if you bind to port 0.</p>
<pre><code>public static int GetRandomUnusedPort()
{
var listener = new TcpListener(IPAddress.Any, 0);
listener.Start();
var port = ((IPEndPoint)listener.LocalEndpoint).Port;
listener.Stop();
return port;
}
</cod... | <p>I do not believe this is possible. The documentation for UriBuilder.Port states, "If a port is not specified as part of the URI, ... the default port value for the protocol scheme will be used to connect to the host.".</p>
<p>See <a href="https://msdn.microsoft.com/en-us/library/system.uribuilder.port(v=vs.110).asp... | 27,532 |
<p>I have apache 2.2 and tomcat 5.5 running on a Windows XP machine.</p>
<p>Which tomcat/apache connector is the easiest to set up and is well documented? </p>
| <p><code><a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html" rel="noreferrer">mod_proxy_ajp</a></code> would be the easiest to use if you are using Apache 2.2. It is part of the Apache distribution so you don't need to install any additional software.</p>
<p>In your <code>httpd.conf</code> you need to make s... | <p><code>mod_jk</code>, or simply just use <code>mod_proxy</code> even though it's not really a Tomcat connector.</p>
| 9,576 |
<p>Can anyone suggest a way, or a link to an example, of building a function in PHP that allows users to send a link via e-mail to multiple friends?</p>
| <p>By "secure" do you mean not allowing your form to be used to send spam?</p>
<p>There are a few ways to combat this:</p>
<ul>
<li>Don't allow the sender to enter any information. You'll just send to that list of e-mails: "such and such" suggested you check out this link. This removes the incentive from spammers.<... | <p>The most recent send to a friend form I've done keeps track of the sender's IP, "from" email address, "to" email address and makes sure there are no more than five of any one of those within 24 hours.</p>
<p>Make sure you validate any email addresses with regular expressions, put character limits on any text areas,... | 45,781 |
<p>I want to exceute a simple command which works from the shell but doesn't work from Java.
This is the command I want to execute, which works fine:</p>
<pre><code>soffice -headless "-accept=socket,host=localhost,port=8100;urp;"
</code></pre>
<p>This is the code I am excecuting from Java trying to run this command:... | <p>I'm not sure if I'm not mistaken, but as far as I see you're generating the commands but never passing them to the "execute" method... you're executing "".</p>
<p>Try using Runtime.getRuntime().exec(commands) =)</p>
| <p>I believe you aren't handling quoting correctly. The original sh command line includes double quotes to prevent the shell interpreting the semicolons. The shell strips them off before the soffice process sees them.</p>
<p>In your Java code the shell will never see the arguments, so the extra double quotes (escape... | 49,551 |
<p>What's the best way to terminate a program and then run additional code from the program that's being terminated? For example, what would be the best way for a program to self update itself?</p>
| <p>You have a couple options:</p>
<p>You could use another application .exe to do the auto update. This is probably the best method.</p>
<p>You can also rename a program's exe while it is running. Hence allowing you to get the file from some update server and replace it. On the program's next startup it will be usi... | <p>I don't know of a way to do it without a second program that the primary program launches prior to shutting down. Program 2 downloads and installs the changes and then relaunches the primary program.</p>
| 6,805 |
<p>I've just started learning Lisp and I can't figure out how to compile and link lisp code to an executable.</p>
<p>I'm using <code>clisp</code> and <code>clisp -c</code> produces two files:</p>
<ul>
<li>.fas</li>
<li>.lib</li>
</ul>
<p>What do I do next to get an executable?</p>
| <p>I was actually trying to do this today, and I found typing this into the CLisp REPL worked:</p>
<pre><code>(EXT:SAVEINITMEM "executable.exe"
:QUIET t
:INIT-FUNCTION 'main
:EXECUTABLE t
:NORC t)
</code></pre>
<p>where main is the name of the functi... | <p>I know this is an old question but the Lisp code I'm looking at is 25 years old :-)</p>
<p>I could not get compilation working with clisp on Windows 10.
However, it worked for me with <a href="https://www.cs.utexas.edu/users/novak/gclwin.html" rel="nofollow noreferrer">gcl</a>.</p>
<p>If my lisp file is jugs2.lisp... | 4,470 |
<p>I've got an extremely long XML file, like</p>
<pre><code><Root>
<ele1>
<child1>context1</child1>
<child2>test1</child2>
<child1>context1</child1>
</ele1>
<ele2>
<child1>context2</child1>
<child2>tes... | <p><strong>This question requires a little bit more detailed answer</strong> than just pointing to a good <a href="http://dpawson.co.uk/xsl/sect2/N4486.html#d6060e85" rel="nofollow noreferrer"><strong>Muenchian Grouping</strong></a> source.</p>
<p>The reason is that <strong>the needed grouping requires to identify bot... | <p>Your xml and question are kind of unclear, but what you're looking for is commonly called the <a href="http://www.jenitennison.com/xslt/grouping/muenchian.html" rel="nofollow noreferrer">Muenchian Grouping</a> method - it's another way of asking for distinct nodes. With the appropriate keys this can be done very eff... | 46,363 |
<p>Is it possible to generate a list of all source members within an iSeries source file using SQL?</p>
<p>Might be similar to getting table definitions from SYSTABLES and SYSCOLUMNS, but I'm unable to find anything so far.</p>
| <p>Sadly SQL doesn't know anything about members, so all the sourcefile-info you could get from qsys2.syscolumns is, that they consist of three columns.</p>
<p>you want the member info and i suggest using the qshell( STRQSH ) together with a query to qsys2.systables as source files are specially marked there.</p>
<pr... | <p>Basically, for just library and source file:</p>
<pre><code>SELECT sys_dname, sys_tname
FROM qsys2/systables
ORDER BY sys_dname, sys_tname
</code></pre>
<p>However, for more detail, a procedure is outlined in <a href="https://groups.google.com/forum/#!topic/comp.sys.ibm.as400.misc/nThciz0QS58" rel="no... | 46,028 |
<p>It sounds wonky, but this is what I'm trying to do with javascript (this is all triggered by an event handler):</p>
<ol>
<li>Save the contents of a page (preferably the whole document or at least documentElement object) into a variable.</li>
<li>Create an iframe and insert it into
the body.</li>
<li>Replace the doc... | <p>In regards to the last method, perhaps the DOM of the window you are copying FROM has not loaded yet?</p>
<p>As for the Doctype, you could rebuild it from scratch and insert it before the html node using a document.write.</p>
<p>The doctype is accessible through document.doctype , but this only has a getter.</p>
| <p>How about if you load an empty html boilerplate doc in an iframe?
Make a doc in some folder "myFolder/sparePage.html" and then do </p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-overrid... | 49,610 |
<p>I am using the function below to match URLs inside a given text and replace them for HTML links. The regular expression is working great, but currently I am only replacing the first match.</p>
<p>How I can replace all the URL? I guess I should be using the <em>exec</em> command, but I did not really figure how to d... | <p>First off, rolling your own regexp to parse URLs is a <em>terrible idea</em>. You must imagine this is a common enough problem that someone has written, debugged and <a href="http://benalman.com/code/test/js-linkify/" rel="noreferrer">tested</a> a library for it, according to <a href="https://metacpan.org/pod/Regexp... | <p>Replace URLs in text with HTML links, ignore the URLs within a href/pre tag.
<a href="https://github.com/JimLiu/auto-link" rel="nofollow">https://github.com/JimLiu/auto-link</a></p>
| 5,848 |
<p>I need to create some functionality in our SharePoint app that populates a list or lists with some simple hierarchical data. Each parent record will represent a "submission" and each child record will be a "submission item." There's a 1-to-n relationship between submissions and submission items. Is this practical... | <p><em>Proper</em> Parent/Child in Sharepoint is near impossible without developing it yourself. There is one approach to that here: <a href="http://medhatelmasry.blogspot.com/2007/10/simulate-parent-child-relationship-in.html" rel="nofollow noreferrer">Simulate Parent / Child relationship in SharePoint 2007 with Folde... | <p>I do this a lot just using sharepoint, using a framework called AAA (Activity,Assignment,Artifact), which allows you to use lookup columns to link an assignment or artifact to a parent Activity. You then build a web part page with connected web parts that allow you to filter all assignments and artifacts by activity... | 39,446 |
<p>Given a grammar and the attached action code, are there any standard solution for deducing what type each production needs to result in (and consequently, what type the invoking production should expect to get from it)?</p>
<p>I'm thinking of an OO program and action code that employs something like c#'s <code>var<... | <p>If you are writing code in a functional language it is easy; standard Hindley-Milner type inference works great. <strong>Do not do this</strong>. In my EBNF parser generator (never released but source code available on request), which supports Icon, c, and Standard ML, I actually <strong>implemented the idea</stro... | <p>The return value of a grammar action is really no different from a local variable, so you should be able to use C# type inference to do the job. See <a href="http://lambda-the-ultimate.org/node/2234" rel="nofollow noreferrer">this paper</a> for some insight into how C# type inference is implemented.</p>
<p>The stan... | 48,868 |
<p>I upgraded from Cura 2.7 to 3.1.0 and I'm getting horrible under extrusion, I'm sure this is the software because I rolled back to 2.7 and everything is working fine again.</p>
<p>My printing is a Robo3D R1+ using the "custom FDM printer" profile.</p>
<p>Is there any new setting or a setting that isn't migrated pr... | <p>Some users have reported upgrades to Cura changing the filament size to the default 2.85 mm. If you are using 1.75 mm filament (which most printers do), you will get extreme under-extrusion.</p>
| <p>I hit this issue again in January 2019 with CuraEngine 3.6+git. Since support for multiple extruders was added, it now auto-loads a per-extruder settings file that overrides the main settings file <strong>and the command line</strong>, so <code>-s material_diameter=1.75</code> on the command line did not help. Given... | 770 |
<p>I'm trying to measure height of some text for table printing purpose.</p>
<p>Here's the code. In my case it prints different numbers in preview and on actual page.
I can't try on any printers other than Microsoft Office Document Image Writer right now, but I'm pretty sure it isn't a printer issue.</p>
<p>Perhaps s... | <p>I guess that the problem is that System.Drawing.Graphics is based on GDI+ where as the actual printing is based on GDI.</p>
<p>You could replace the call to MeasureString to use a GDI based method:</p>
<pre><code>SizeF hT = TextRenderer.MeasureText(s, new Font("Arial", 24));
</code></pre>
<blockquote>
<p>The Sy... | <p>Try a PageUnit other than Graphics.Pixel in your PrintPage event. Inch, Millimeter or Point (among others) should give you the same result in Preview or printed out. Pixel I would expect not to, since the preview screen and the printer have different pixel resolutions.</p>
| 38,605 |
<p>I've been dipping into SitePoint book concerning CSS.</p>
<p>The thing that struck me about the examples was the use of ID as a CSS selector.</p>
<p>Some bits of CSS design I've done, I've always found it easier and more versatile to use Class as the selector.</p>
<p>Maybe its a .Net thing as we don't always have... | <p>I guess they always use the id in examples because it's less ambiguous. You know that they're talking specifically about <em>that</em> one element and its styles.</p>
<p>In general, the rule of thumb is that you should ask yourself: "is there more than one element which requires the same style, now or at any time i... | <p>Use only classes, almost never use IDs if you don't have to worry about speed or compatibility.</p>
<p>Using IDs is bad just like using global variables in Visual Basic code. The reason is that IDs have to be unique which introduces unnecessary and bad dependency between different independent parts of your code. Us... | 38,235 |
<p>I'm planning to add XML support to application, but I'm not familiar with XML programming in Delphi.
Basically I need to create objects based on XML nodes and generate XML file based on objects.</p>
<p>Which XML component library I should use? Are there any good tutorials for XML with Delphi?</p>
| <p>You can start by looking at Delphi's TXMLDocument component. This will provide you with the basics of working with XML/DOM. It's simple and can be added by dropping it onto your Form. It has LoadFromFile and SaveToFile methods and is easily navigated.</p>
<p>However, at some point you will exhaust TXMLDocument's fe... | <p>I have been working with nativeXML for about a year now. My needs are fairly simple. XML fluency is a small part of a larger application for me, but I have been able to implement the pieces I need almost as fast as I can code them, the online help is good and my needs were met in a day rather than a week or longer... | 32,981 |
<p><strong>This problem has been solved thanks to your suggestions.</strong> See the bottom for details. Thanks very much for your help!</p>
<p>Our ASP.NET website is accessed from several specific and highly secure international locations. It has been operating fine, but we have added another client location which is... | <p>If they're at all tech-savvy, I would have them download Fiddler or something similar, capture the entire HTTP session, and then send you the saved session. Maybe something in there will stick out.</p>
<p>Meanwhile, see if you can get an install of ISA Server (an evaluation install, if you have to, or one from MSDN... | <p>Is it possible the client has disabled Javascript and it's not picking up the _EVENTTARGET form value?</p>
| 43,104 |
<p>In an HTML table, the <code>cellpadding</code> and <code>cellspacing</code> can be set like this:</p>
<pre class="lang-html prettyprint-override"><code><table cellspacing="1" cellpadding="1">
</code></pre>
<p>How can the same be accomplished using CSS?</p>
| <p><strong>Basics</strong></p>
<p>For controlling "cellpadding" in CSS, you can simply use <code>padding</code> on table cells. E.g. for 10px of "cellpadding":</p>
<pre class="lang-css prettyprint-override"><code>td {
padding: 10px;
}
</code></pre>
<p>For "cellspacing", you can apply ... | <p>I used <code>!important</code> after the border-collapse like</p>
<pre class="lang-css prettyprint-override"><code>border-collapse: collapse !important;
</code></pre>
<p>and it works for me in IE7. It seems to override the cellspacing attribute.</p>
| 44,149 |
<p>What is the difference between Views and Materialized Views in Oracle?</p>
| <p>Materialized views are disk based and are updated periodically based upon the query definition.</p>
<p>Views are virtual only and run the query definition each time they are accessed.</p>
| <p>Adding to Mike McAllister's pretty-thorough answer...</p>
<p>Materialized views can only be set to refresh <em>automatically</em> through the database detecting changes when the view query is considered <strong>simple</strong> by the compiler. If it's considered too complex, it won't be able to set up what are ess... | 11,905 |
<p>On ASP.net MVC, what is the "correct" way to have a controller return a 301 Redirect to an external site?</p>
<p>The various RedirectTo-Function seem to only return either relative links or routes that i have mapped manually, but there is no way to say "Perform a 301 Redirect to <a href="http://example.com" rel="no... | <p>Use</p>
<pre><code>Response.RedirectPermanent("http://www.google.com");
</code></pre>
<p>or for returning an ActionResult type from a controller:</p>
<pre><code>return RedirectPermanent("http://www.google.com");
</code></pre>
<p>provided by the ASP.net 4.0 framework. </p>
| <p>Does that help any? <a href="http://blog.eworldui.net/post/2008/04/ASPNET-MVC---Legacy-Url-Routing.aspx" rel="nofollow noreferrer">http://blog.eworldui.net/post/2008/04/ASPNET-MVC---Legacy-Url-Routing.aspx</a></p>
<p>It looks like you would just need to replace the virtual path by an URL of your liking.</p>
| 26,795 |
<p>I have Prusa i3 derivative with MK8 extruder and Marlin 1.1RC8 as firmware. I already reduced the default speeds as well as the accelerations. But sometimes when trying to print with BQ PLA filament (220°C), mostly during filling areas, my extruder clicks. The below screenshot of Slic3rs Layers view shows the clicki... | <p>I've tried to reduce the "Extrusion multiplier" from 1 to 0.95, but that caused gaps. Now I've minimized the clicking by setting the Slic3r option "Infill before perimeters" on the "Print Settings > Infill" page.</p>
| <p>I had this issue and it turned out to be the extruder cog rubbing on the inside of the hole in the heatsink, causing the stepper to slip. </p>
| 452 |
<p>What is the correct way to import a C++ class from a DLL? We're using Visual C++. </p>
<p>There's the dllexport/exports.def+LoadLibrary+GetProcAddress trifecta, but it doesn't work on C++ classes, only C functions. Is this due to C++ name-mangling? How do I make this work?</p>
| <p>You need to add the following:</p>
<pre><code>extern "C"
{
...
}
</code></pre>
<p>to avoid function mangling.</p>
<p>you might consider writing two simple C functions:</p>
<pre><code>SomeClass* CreateObjectInstace()
{
return new SomeClass();
}
void ReleaseObject(SomeClass* someClass)
{
delete someClass;
... | <p>I normally declare an interface base class, use this declaration in my application, then use LoadLibrary, GetProcAddress to get the factory function. The factor always returns pointer of the interface type.</p>
<p>Here is a practical example, <a href="http://www.codeproject.com/KB/docview/docviewfromdll.aspx" rel="... | 13,601 |
<p>I'm working on a Windows Forms (.NET 3.5) application that has a built-in exception handler to catch any (heaven forbid) exceptions that may arise. I'd like the exception handler to be able to prompt the user to click a <kbd>Send Error Report</kbd> button, which would then cause the app to send an email to my FogBug... | <p>You'll want to use the SmtpClient class as outlined <strong><a href="http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx" rel="nofollow noreferrer">here</a></strong>.<br>
There are no gotchas - sending email is about as easy as it gets.</p>
| <blockquote>
<p>You'll want to use the SmtpClient class as outlined <a href="http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx" rel="nofollow noreferrer">here</a>.
There are no gotchas - sending email is about as easy as it gets.</p>
</blockquote>
<p>An extensive <a href="http://www.systemnet... | 8,237 |
<p>A general architecture question in Sitecore 6...</p>
<p>Let’s say we have a situation where we have 10,000 items implementing a “Press Release” template. These items are stored in Sitecore at <code>/sitecore/content/home/press/*</code>. On our homepage, we’d like to display some information concerning the 3 most re... | <p>Sitecore Query (or a fast query) does not support sorting or TOP constructs, so these things have to be expressed in code. </p>
<p>Focusing on caching is a good thing. Using standard Sitecore rendering caching is a simplest approach, I don't think you need anything more complex than that in this case.</p>
<p>It he... | <p>One solution to the "10 latest news" problem is to use Lucene.</p>
<p>This is <a href="http://usoniandream.blogspot.com/2007/10/tutorial-advanced-lucenenet-usage.html" rel="nofollow noreferrer">one way of doing</a> it.</p>
| 26,445 |
<p>I wonder if there is a less verbose way to do Input Verification in my methods. For example, i commonly write stuff like this:</p>
<pre><code>public string SomeFunction(string param1, int param2)
{
if(string.IsNullOrEmpty(param1)){
throw new ArgumentException("bla", "param1");
}
if(param2 < 0... | <p>Well, you could do something with AOP, look at <a href="http://www.postsharp.org" rel="nofollow noreferrer">PostSharp</a>.</p>
<p>This could be used to just inject the necessary code, but it adds some overhead, both to the compilation step and to the compiled code.</p>
<p>Code Contracts are also slated to be inclu... | <p>You can keep all the parameter-checking code as-is, but then delegate the real work to a private function. The private function will do no parameter checking because it will only ever be called by the public gatekeeper function.</p>
<pre><code>private string InternalSomeFunction(string param1, int param2)
{
/* im... | 47,053 |
<p>I have a folder "FolderA" which contains three sub-folders: foldera1 foldera2 and foldera3</p>
<p>I need to write a batch file which resides inside "FolderA". It should delete all the folders under "FolderA" as a cleanup activity. I don't know the folder names. <code>rmdir</code> does not support wild cards.</p>
<... | <p>something like :</p>
<pre><code>for /f %%a in ('dir /ad /b') do (rmdir /S /Q "%%a")
for /d %%a in (*) do (rmdir /S /Q "%%a")
</code></pre>
<p>should do the trick. The second form allow some wildcard selection for directories.</p>
<p>To test it outside a script, in a plain DOS session:</p>
<pre><code>for /f %a in... | <p>When you are inside FolderA, run "rmdir /s /q ."</p>
<p>This shows an error on command line of "file in use..."<br>
Yet, it deletes the directory inside it.</p>
| 38,010 |
<p>Another discussion (we've been having a lot of them these days!) in our work is whether data binding is a bad idea or not.</p>
<p>Personally, I think it is a Bad Thing™.</p>
<p>My reasons are thrice:</p>
<ol>
<li><p>It circumvents my well architectured MVP framework - with databinding, the view communicates bi-di... | <p>As we say in the UK, <em>"It's Horses for courses"</em></p>
<p>First off all, I agree with you! But...</p>
<p>For enterprise level applications, then spending the extra time on the system architecture, modelling and standards will give you a robust and sustainable system.</p>
<p>But it will take longer to develop... | <p>@Timbo:</p>
<p>Yes and no.... but from a TDD perspective I'd like to cordon-off each controller so that I can test it in isolation. Also, say we want to run each edit via an EditCommand (so that we support Undo, for example) - for me, this rules out databinding.</p>
<p>@Guy:</p>
<p>Yes, this is exactly my POV. ... | 3,996 |
<p>Whilst looking to fix a different problem I had I came across this video.</p>
<p>It's a filament reel holder, but at 02:40 the person uses a mysterious fluid. I haven't seen anything like this before (though had wondered).</p>
<p><a href="https://youtu.be/X6ArZeWYSZE" rel="nofollow noreferrer" title="Mystery clea... | <p><a href="https://i.stack.imgur.com/gMDDx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gMDDx.png" alt="enter image description here"></a></p>
<p>That's a filament cleaner/oiler combo. The black bottle is a variety of machine oil. </p>
<p>The effect of oilers on prints is heavily disputed in th... | <p>For really long Bowden tubes, some people use Teflon lubricant in a cleaner bead.</p>
<p>Never used it myself, since I use a small tube my printer with the stepper on top of one of the Z axis steel rod mounting plates (Anet A8).</p>
<p>Off topic, but by cooking and being a vaper, I vouch that organic compounds lea... | 1,170 |
<p>Joel often talks about using MS Excel for lightweight project management, but I'm curious about actual implementations of this idea. I've seen some templates that seem to clone MS Project via macros, which would be overkill for a lightweight project. Anyone have any useful templates?</p>
| <p>try</p>
<pre> feature task estimated hours actual hours current %
---------- ---------- --------------- ------------ ---------</pre>
<p>if estimated hours times current % is greater than actual hours, you are behind schedule</p>
<p>update the actual hours and current % on a daily basis</p>
<p>see... | <p>I use EasyProjectPlan which is an <strong>Excel Project Plan</strong> that syncs with <strong>Outlook</strong> and <strong>MSProject</strong>.</p>
<p><strong><a href="http://www.easyprojectplan.com" rel="nofollow noreferrer">www.EasyProjectPlan.com</a></strong></p>
<p>I use the Outlook and Calendar sync feature... | 36,648 |
<p>What's the difference between <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/ref/WeakReference.html" rel="noreferrer"><code>java.lang.ref.WeakReference</code></a> and <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/ref/SoftReference.html" rel="noreferr... | <p>From <a href="https://web.archive.org/web/20061130103858/http://weblogs.java.net/blog/enicholas/archive/2006/05/understanding_w.html" rel="noreferrer">Understanding Weak References</a>, by Ethan Nicholas:</p>
<blockquote>
<p><strong>Weak references</strong></p>
<p>A <em>weak reference</em>, simply put, is a
... | <p><strong>WeakReference</strong>: objects that are only weakly referenced are collected at every GC cycle (minor or full).</p>
<p><strong>SoftReference</strong>: when objects that are only softly referenced are collected depends on: </p>
<ol>
<li><p>-XX:SoftRefLRUPolicyMSPerMB=N flag (default value is 1000, aka 1 se... | 38,403 |
<p>I am looking for a regex statement that will let me extract the HTML content from just between the body tags from a XHTML document.</p>
<p>The XHTML that I need to parse will be very simple files, I do not have to worry about JavaScript content or <code><![CDATA[</code> tags, for example.</p>
<p>Below is the ex... | <p>Would this work ?</p>
<pre><code>((?:.(?!<body[^>]*>))+.<body[^>]*>)|(</body\>.+)
</code></pre>
<p>Of course, you need to add the necessary <code>\s</code> in order to take into account <code>< body ...></code> (element with spaces), as in:</p>
<pre><code>((?:.(?!<\s*body[^>]*... | <p>Match the first body tag: <code><\s*body.*?></code></p>
<p>Match the last body tag: <code><\s*/\s*body.*?></code></p>
<p>(note: we account for spaces in the middle of the tags, which is completely valid markup btw)</p>
<p>Combine them together like this and you will get everything in-between, includin... | 46,459 |
<p>Logging can get complicated, quickly. Considering that you have some code, how do you add logging to it? What library(ies) do you use? </p>
<p>What are some good code techniques for getting the most out of your logging statements while having minimal impact on your application?</p>
| <p>Libraries: <a href="http://logging.apache.org/log4j/1.2/index.html" rel="nofollow noreferrer">Log4J</a> and <a href="http://logging.apache.org/log4net/index.html" rel="nofollow noreferrer">Log4Net</a> (for Java and .NET respectively)</p>
<p>From Log4J site:</p>
<blockquote>
<p>Inserting log statements into your code... | <p>There are few things to consider when you decide your logging philosophy to make it performance conscious. First let us breakdown the resources spent on logging.</p>
<ul>
<li>CPU time spent on appending or assembling a particular log line & garbage collection </li>
<li>Working memory spent on appending or assem... | 21,584 |
<p>Looking for an example in linq about how to insert a row of a gridview into datacontext. </p>
| <p><a href="http://ex-parrot.com/~pdw/Mail-RFC822-Address.html" rel="noreferrer">This</a> regular expression complies with the grammar described in <a href="http://www.faqs.org/rfcs/rfc2822.html" rel="noreferrer">RFC 2822</a>, it's very long, but the grammar described in the RFC is complex...</p>
| <p>I had to recently build some RSS feeds, and part of that included going over the Xml schema, including the items for Webmaster and ManagingEditor, both of which are defined as an e-mail address matching this pattern:</p>
<pre><code>([a-zA-Z0-9_\-])([a-zA-Z0-9_\-\.]*)@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|... | 25,905 |
<p>I'm working on trying to generate a report from a couple of database tables. The simplified version looks like this</p>
<pre><code>Campaign
----------
CampaignID
Source
-----------------------
Source_ID | Campaign_ID
Content
---------------------------------------------------------
Content_ID | Campaign_ID | Cont... | <p>This is my first stab at it. Refinement coming once I know more about the contents of the Content table.</p>
<p>First, you need a temporary table:</p>
<pre><code>CREATE TABLE pivot (count integer);
INSERT INTO pivot VALUES (1);
INSERT INTO pivot VALUES (2);
</code></pre>
<p>Now we're ready to query.</p>
<pre><co... | <p>If you need a dynamic number of columns, I don't believe this can be done in standard SQL which, alas, exceeds my knowledge. But there are features of Oracle that can do it. I found some resources:</p>
<p><a href="http://www.sqlsnippets.com/en/topic-12200.html" rel="nofollow noreferrer">http://www.sqlsnippets.com/e... | 26,243 |
<p>Suppose you have the following EJB 3 interfaces/classes:</p>
<pre><code>public interface Repository<E>
{
public void delete(E entity);
}
public abstract class AbstractRepository<E> implements Repository<E>
{
public void delete(E entity){
//...
}
}
public interface FooRepository&l... | <p>I tried it with a pojo and it seems to work. I had to modify your code a bit.
I think your interfaces were a bit off, but I'm not sure.</p>
<p>I assumed "Foo" was a concrete type, but if not I can do some more testing for you.</p>
<p>I just wrote a main method to test this.
I hope this helps!</p>
<pre><code>publi... | <p>Can you write a unit test against your FooRepository class just using it as a POJO. If that works as expected then I'm not familiar with any reason why it would function differently inside a container.</p>
<p>I suspect there is something else going on and it will probably be easier to debug if you test it as a POJ... | 3,559 |
<p>as google does not deliver what i want to know, i try to ask stackoverflow :)
what is the number of max concurrent connections to a sql ce 3.5 database?
thanks
j.</p>
| <p>I believe the information you are looking for is the SQL Server Edition Comparison. </p>
<p>For standard Editions - <a href="http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx?PHPSESSID=0324345d45ef1bf1f764044e03584cd0" rel="noreferrer">Compare Features</a></p>
<p>For Compact Edition - <a href="... | <p>You can wait, when 200 + 57th SQL-Ce connection request arrives.</p>
<p>For more-
<a href="http://ourtech24.com/Programming/OT-182638/Wait-for-upcoming-request-when-SQL-CE-connection-limit-is-exceeded/" rel="nofollow">http://ourtech24.com/Programming/OT-182638/Wait-for-upcoming-request-when-SQL-CE-connection-limit-... | 29,767 |
<p>Does the compiler optimize out any multiplications by 1? That is, consider:</p>
<pre><code>int a = 1;
int b = 5 * a;
</code></pre>
<p>Will the expression 5 * a be optimized into just 5? If not, will it if a is defined as:</p>
<pre><code>const int a = 1;
</code></pre>
| <p>It will pre-calculate any constant expressions when it compiles, including string concatenation. Without the <strong><code>const</code></strong> it will be left alone.</p>
<p>Your first example compiles to this IL:</p>
<pre><code>.maxstack 2
.locals init ([0] int32, [1] int32)
ldc.i4.1 //load 1
stloc.0 //sto... | <p>What the compiler would optimise here is not multiplication by 1 per-se, but rather arithmetic with values known at compile-time. So yeah, a compiler would optimise out all the maths in your example, with or without the <code>const</code>.</p>
<p><strong>Edit:</strong> A <em>competent</em> compiler, I should say.</... | 19,436 |
<p>I have a website that will eventually display multiple languages. I notice the common fonts used in web CSS (ex: Arial, Verdana, Times New Roman, Tahoma) and even the newer Vista/Office 2007/VS2008 fonts (Calibri,Cambria, Candara, Corbel, etc) are significantly larger (~350K) than your average (US only?) TTF font (... | <p>I just checked the character set of Calibri and Cambria and confirm that they cover all the major languages of Europe (hence also of America). I can check for the other ClearType fonts if that makes you feel more comfortable, but I doubt the coverage is any different.</p>
<p>As has already been stressed, though, y... | <p>If you limit your requirements to languages that are based on latin scripts with some extensions, then you'll have a much larger choice as if you were to require "wide unicode support". Most professional, high-quality fonts should support those easily.</p>
<p>A good indication of this is that Microsoft uses the sam... | 49,215 |
<p>Can anyone provide some pseudo code for a roulette selection function? How would I implement this:</p>
<p><img src="https://upload.wikimedia.org/math/0/d/2/0d24a82d8e813380f670bf80ae74486b.png" alt="alt text"></p>
<p>I don't really understand how to read this math notation. I never took any probability or statisti... | <p>It's been a few years since i've done this myself, however the following pseudo code was found easily enough on google.</p>
<pre>
for all members of population
sum += fitness of this individual
end for
for all members of population
probability = sum of probabilities + (fitness / sum)
sum of probabiliti... | <p>I wrote a version in C# and am really looking for confirmation that it is indeed correct:</p>
<p>(roulette_selector is a random number which will be in the range 0.0 to 1.0)</p>
<pre><code>private Individual Select_Roulette(double sum_fitness)
{
Individual ret = new Individual();
bool loop = tr... | 21,355 |
<p>I have a DotNetNuke site where my main logo is a PNG file using transparency. I tried GIF but the quality wasn't good enough.</p>
<p>Anyways it worked great on IE7 but I just saw my site in IE6 and noticed that the transparency isn't working with my logo.</p>
<p>Does anyone know of a quick way to fix this in a Do... | <p>I don't know that it's a DotNetNuke issue as much as it is IE6. Anyways, here's a site that shows you how to work around IE6's png issues. Hope it helps.</p>
<p><a href="http://24ways.org/2007/supersleight-transparent-png-in-ie6" rel="nofollow noreferrer">http://24ways.org/2007/supersleight-transparent-png-in-ie6</... | <p>Googling "pngfix" should find a lot of different techniques for enabling alpha transparency in IE6.</p>
<p>One common one is a <a href="http://webfx.eae.net/dhtml/pngbehavior/pngbehavior.html" rel="nofollow noreferrer">HTC behaviour file</a>.</p>
| 6,878 |
<p>JBoss 5 has just come out of beta after 2 years, giving us a Java EE 5 compliant container several months before the release of Java EE 6 (JavaOne in May or thereabouts 2009). We've had GlassFish v2 for awhile and now have GlassFish v3 Prelude.</p>
<p>Is there any reason to JBoss 5 over these? I've had the feelin... | <p>JBoss is by no means a dead project; it is very active and has strong commercial backing from RedHat. They spent a significant amount of time redesigning the entire app server to run off the new JBoss Microcontainer. Not sure if it was worth the 3+ year effort but the release notes are here:</p>
<p><a href="http:... | <p>If your planning to use JMS be careful as connecting to JMS providers like IBM MQ can be a nighmare with glassfish.</p>
<p>As well as features you should consider how well it fits with the rest of your stack.</p>
<p>Karl</p>
| 45,490 |
<p>We're running a Debian with a 2.6.16 kernel, with iptables enabled. The system is running a custom made HTTP proxy, which is subjected to a mild load (it works fine with the same load on other sites). The system comprises of 4 servers that are preceded by a load balancer with virtual IP, which is preceded by an arra... | <p>Look at the second parameter to the listen call, as mentioned in the first link you posted. It's the maximum number of pending (not accepted yet) connections. According to the listen(2) man page, if the protocol supports retransmission (TCP does), the connection request will be dropped when the queue is full (expect... | <p>Indeed, the iptables turned out to be the culrpit, with the rule that dropped INVALID packets. We still do not know for sure what made iptables to think those SYNs were invalid (no TIME_WAIT for sure, since we did not have any traffic with the same source ports for at least 30 mins prior to the drops).</p>
| 26,623 |
<p>We are using fmt:setBundle to load a resource bundle from a database (we extended the ResourceBundle class to do that).
When we modify a value in database, we have to reload the web server to display the new value on the web app.</p>
<p>Is there any simple way to use the new value without restarting the web server ... | <p>If you're using JDK 1.6 you can use the callback methods <code>getTimeToLive()</code> and <code>needsReload()</code> in <a href="http://java.sun.com/javase/6/docs/api/java/util/ResourceBundle.Control.html" rel="noreferrer">ResourceBundle.Control</a> to control if the bundle cache needs to be loaded with new values f... | <p>First you can create a class which extends from <code>ReloadableResourceBundleMessageSource</code> to expose its inner class protected method called <code>getProperties</code>. This method return a concurrent map from <code>PropertiesHolder</code> object. Second you should configure a bean of that extended class in ... | 18,948 |
<p>This java program I am working on seems to hang on startup, so I tried using jconsole to debug the problem.
As it turns out it is waiting on a call to a method which is declared as -</p>
<pre><code>synchronized void stopQuery()
</code></pre>
<p>But here is the crazy part, the lock for the 'synchronized' method is ... | <p>This looks like a particularly nasty deadlock. It's hard to tell for sure without a little more information. Here's what I see without the code in front of me, though:</p>
<p>Possible deadlock on (or at least contention for) Object reference 0x00002aace2276720 between "Text Viewer Hover Presenter" and "Worker-3" ... | <p>Is the method recursive, somehow? Maybe you're using an object inside of it which requires that very same method?</p>
| 43,675 |
<p>In contrast to most software development organizations, our little research group within a university department consists of a professor and a flow of grad and undergrad students, it's hard to retain any working knowledge beyond the research itself. Our backgrounds vary, and rarely involves much computer science ba... | <p>I'd say that Subversion should give you the right balance between usefulness and easiness in an academic environment like the one you're describing. I've been thinking about similar issues (I'm a physics graduate; <a href="https://stackoverflow.com/questions/38239/practices-for-programming-in-a-scientific-environmen... | <p>Even if you never use branching and merging, svn is valuable. If you're on Windows the, VisualSVN server app is easy to set up and makes it easy to use security. Try it out.</p>
| 48,266 |
<p>I am developing a .NET CF based Graphics Application, my project involves a lot of drawing images, We have decided to go for porting the application on different handset resolution.(240 X 240 , 480 X 640) etc. </p>
<p>How would i go onto achieve this within single solution/project?</p>
<p>Is there a need to create... | <p>Don't listen to that idiot MusiGenesis. A much better way of handling different screen resolutions for Windows Mobile devices is to use <strong>forms inheritance</strong>, which can be tacked onto an existing CF application with minimal effort.</p>
<p>Basically, you design each form for a standard 240x320 screen. ... | <p>I gave up on the designer for all but the most basic compact applications. I try to place every control mathematically using the screen dimensions. It sounds painful but once you get going it becomes second nature.</p>
<p>For every form I create a 'regenerate' method which is fired whenever the form is shown or r... | 38,130 |
<p>Does anyone know any source of examples and templates for software requirements, build environment description and other kind of documentations that are common for software development?</p>
<p>Thanks!</p>
| <p>The <a href="http://readyset.tigris.org/nonav/templates/frameset.html" rel="nofollow noreferrer">ReadySet templates</a> from tigris are quite comprehensive though you need to know html or have a good html editor to use them.</p>
| <p>The state of Texas has a <a href="http://dir.texas.gov/View-Resources/Pages/Content.aspx?id=16" rel="nofollow noreferrer">fine framework for the whole system development cycle</a>.</p>
| 36,494 |
<p>I would like to know how to setup an SVN repository with LDAP authentication.
I do not want to use Apache DAV though.</p>
| <p>There are two options:</p>
<ol>
<li>Run svnserve as a server, and authenticate using <a href="https://svn.apache.org/repos/asf/subversion/trunk/notes/sasl.txt" rel="nofollow noreferrer">SASL</a>. Configure <a href="https://web.archive.org/web/20140528175339/http://www.imc.org:80/ietf-sasl/mail-archive/msg01862.html... | <p>You could use <a href="https://bitbucket.org/sdorra/scm-manager" rel="nofollow">scm-manager</a> which has an ldap plugin.</p>
| 43,175 |
<p>I am a complete noob when it comes to the 3d printing world. I just finished assembling my printer and I plug it into my computer with the included usb cable and nothing happens. My computer does recognize the printer being plugged in but it just says "unrecognized device in com 4". Nothing else past that. Somebody ... | <p>Your question addresses (USB) computer connection, so that will be addressed in this answer. For connection to the printer, you need 2 things (apart from the apparent things as computer, printer and cable):</p>
<ol>
<li>A working CH340 driver installed on the computer for USB communication with the board,</li>
<li>... | <p>Try using the provided SD card and SD adapter with Cura to give the printer gcode. If your computer isn't communicating properly with your printer, you can just download Cura 14 (it comes on the SD card) and upload the configuration file (also on the SD card). You can then plug the SD card into your main board and a... | 895 |
<p>Whats the easiest way to find out what programming language an application was written in?
I would like to know if its vb or c++ or delphi or .net etc from the program exe file.</p>
| <p>Try <a href="http://www.softpedia.com/get/Programming/Packers-Crypters-Protectors/PEiD-updated.shtml" rel="noreferrer">PEiD</a></p>
<p>of course if they used a packer, some unpacking will need to be done first :)</p>
| <p>In general, you can't. </p>
<p>If you can load it into <a href="http://www.red-gate.com/products/reflector/" rel="nofollow noreferrer">Reflector</a>, you know it is a managed assembly.</p>
| 48,544 |
<p>I have followed the suggestion in this question...</p>
<p>[<a href="https://stackoverflow.com/questions/220020/how-to-handle-checkboxes-in-aspnet-mvc-forms][1]">How to handle checkboxes in ASP.NET MVC forms?</a></p>
<p>...to setup multiple checkboxes with the same name="..." attribute and the form behaves as expec... | <p>FWIW, here is what I do (not sure if it related):</p>
<pre><code> // please MS, stop screwing around!!!!!!!!!!!!!!!
string r = Request.Form["r"];
</code></pre>
<p>Then proceed to extract the values manually from 'r'. I still use Preview 4, as they have really broken too many existing features, and not fixed rep... | <p>I'm not sure what is causing your issue, but I have a WAG... </p>
<p>Do you RedirectToAction in your controller's Post method?</p>
<pre><code>[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SelectItems(Guid[] selectedItems)
{
/* lol snip */
return RedirectToAction("WhateverActionIsTheGetVersionOfThisPostAct... | 42,835 |
<p>I see that Adobe AIR uses WebKit as its render and I see that WebKit (at least the most current build) has some SVG support. Does this mean (and has anyone specifically tried) that an Adobe AIR application could render SVG on an HTML page?</p>
| <p>On the offchance that it's helpful (and that you don't already know), Flex can embed SVG at <s>runtime</s> compile time, which effectively converts it to SWF format and embeds it as a resource.</p>
<pre><code>[Embed(source="assets/frog.svg")]
[Bindable]
public var SvgAsset:Class;
</code></pre>
<p>More info at Adob... | <p>Adobe AIR can only support SVG once Adobe updates their version of WebKit (AIR's HTML rendering engine) and enables the SVG support within their version of WebKit. Might be a business decision not to (ie Flash).</p>
| 11,411 |
<ul>
<li>I want to obtain maximum performance out of a process with many variables, many of which cannot be controlled. </li>
<li>I cannot run thousands of experiments, so it'd be nice if I could run hundreds of experiments and
<ul>
<li>vary many controllable parameters</li>
<li>collect data on many parameters indicat... | <p>It sounds like you want to do some <a href="http://en.wikipedia.org/wiki/Regression_analysis" rel="nofollow noreferrer">regression analysis</a>. You certainly have plenty of data!</p>
<hr>
<p>Regression analysis is an extremely common modeling technique in statistics and science. (It could be argued that statist... | <p>I have used the Perl module <a href="http://search.cpan.org/~iawelch/Statistics-Regression-0.53/Regression.pm" rel="nofollow noreferrer">Statistics::Regression</a> for somewhat similar problems in the past. Be warned, however, that regression analysis is definitely an art. As the warning in the Perl module says, i... | 13,149 |
<p>I'm working on an open source project that uses SQL Server 2005 as the data store. We need a DB compare tool to generate diff scripts to be able to upgrade a DB from one version to another.</p>
<p>Is there an open source or free SQL Server DB diff tool out there that generates a convert script?</p>
| <p>I think that Open DBiff does a good job.
It's simple and I works with SQL Server 2005/2008.</p>
<p>But only generate the change script. Nothing more and nothing less.</p>
| <p>Hmm, none that I know of. You can always retrieve the definitions as SQL and then run a diff tool on them, but it's a bit of a pain in the rear.</p>
<p>Probably the best solution for this is using some kind of "Migrations" tool, so you can keep your database definitions together with your code, and version them, et... | 4,280 |
<p>Let's say that I create a Sub (not a function) whose mission in life is to take the active cell (i.e. Selection) and set an adjacent cell to some value. This works fine.</p>
<p>When you try to convert that Sub to a Function and try to evaluate it from from spreadsheet (i.e. setting it's formula to "=MyFunction()")... | <p>It can't be done, which makes sense because:</p>
<ul>
<li><p>When a worksheet function is called, the cell containing the function is not necessarily the active cell. So you can't find the adjacent cell reliably.</p></li>
<li><p>When Excel is recalculating a worksheet, it needs to maintain dependencies between cel... | <p>Thank you all for responding. It is possible to do this! Kinda. I say 'kinda' because technically speaking the 'function' isn't affecting the cells around it. Practically speaking, however, no user could tell the difference.</p>
<p>The trick is to use a Win32 API to start a timer, and as soon as it goes off you... | 24,572 |
<p>Python's convention is that variables are created by first assignment, and trying to read their value before one has been assigned raises an exception. PHP by contrast implicitly creates a variable when it is read, with a null value. This means it is easy to do this in PHP:</p>
<pre><code>function mymodule_importan... | <p><strong>PHP</strong> doesn't do much forward checking of things at parse time. </p>
<p>The best you can do is crank up the warning level to report your mistakes, but by the time you get an E_NOTICE, its too late, and its not possible to force E_NOTICES to occur in advance yet.</p>
<p>A lot of people are toting the... | <p>I'm pretty sure that it generates an error if the variable wasn't previously declared. If your installation isn't showing such errors, check the error_reporting() level in your php.ini file.</p>
| 11,711 |
<p>From the .net 4.0 previews I have read until now there has been lots of talk on how the next .net version will handle and use cpus with multiple cores. We will have additions like plinq that will help us make use of multiple cores. My question is why should I have to bother my mind with handling multiple cores when ... | <p>Because parallelisation just can't be done without the aid of a human.</p>
<p>There's a certain amount which <em>can</em> be done - and already <em>is</em> done within a single core. Microparallelism is a lot easier than "analyse this whole program and make it run in parallel" for obvious reasons. In general, many... | <p>Yes and no.. If you want to be able to program as normal, but having the system 'magically' use multiple threads, then you need to look at some of the multi-processing frameworks out there. For example: <a href="http://openmp.org/wp/" rel="nofollow noreferrer">OpenMP</a>.</p>
<p>If you want to run through an array,... | 40,362 |
<p>I have a simple POJO web service published with Axis2 on Tomcat5.5
I try to consume it with ATL C++ client and it fails. Doing the same with a C# client works.
The problem is that ATL client sends soap body which looks like </p>
<pre><code><soap:Body>< xmlns="http://fa.test.com/xsd"></></soap:... | <p>ATL Server is entirely capable of generating the request correctly. Looks like there's some issue with the WSDL. My cursory test generates the request:</p>
<pre><code><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http:... | <p>I don't think it has anything to do with UTF-8.</p>
<p>The valid message from C# doesn't have anything inside the soap:Body, while the invalid message has . It looks like the ATL C++ client is trying to force something inside the SOAP body when there shouldn't be anything there at all.</p>
<p>Note also that the C... | 32,872 |
<p>I've been working on a visualization project for 2-dimensional continuous data. It's the kind of thing you could use to study elevation data or temperature patterns on a 2D map. At its core, it's really a way of flattening 3-dimensions into two-dimensions-plus-color. In my particular field of study, I'm not actually... | <p>The <a href="http://en.wikipedia.org/wiki/Gradient" rel="nofollow noreferrer">gradient</a> is a mathematical operator that may help you.</p>
<p>If you can turn your interpolation into a differentiable function, the gradient of the height will always point in the direction of steepest ascent. All curves of equal he... | <p>I always check places like <a href="http://mathworld.wolfram.com" rel="nofollow noreferrer">http://mathworld.wolfram.com</a> before going to deep on my own :)</p>
<p>Maybe their <a href="http://mathworld.wolfram.com/topics/Curves.html" rel="nofollow noreferrer">curves</a> section would help? Or maybe the entry on <... | 32,960 |
<p>How can I escape a bracket in a full-text SQL Server <code>contains()</code> query? I've tried all the following, <em>none</em> of which work:</p>
<pre><code>CONTAINS(crev.RawText, 'arg[0]')
CONTAINS(crev.RawText, 'arg[[0]]')
CONTAINS(crev.RawText, 'arg\[0\]')
</code></pre>
<p>Using double quotes does work, but it... | <p>You don't have to escape the [ as it has no special meaning in Full Text Search. If you do need to search for an exact match though, you can use "" marks. </p>
<p>Further, you can use multiple "" inside the single quotes:</p>
<pre><code>CONTAINS('"word1" or "word2" or "word3"')
</code></pre>
<p>This also works:</... | <p>Not in the spirit of fulltext indexing apparently.</p>
<blockquote>
<p>word</p>
<p>Is a string of characters without
spaces or punctuation.</p>
<p>phrase</p>
<p>Is one or more words with spaces
between each word.</p>
</blockquote>
<p>And</p>
<blockquote>
<p>Punctuation is ignored. Therefore... | 41,345 |
<p>Is anyone using the Obout controls in C# .Net? How would you rate these controls, especially the Grid Control?</p>
| <p>I was thoroughly impressed with them. Of all the other control sets out there (infragistics, telerik) this is the only (more than) respectable one I've worked with that was 1) free! and 2) lightweight!. The only caveat to Obout is I had trouble with merging some of these controls and some of the stock AJAX compone... | <p>I used their tree for a project. Not bad for free controls.</p>
| 8,158 |
<p>Where I work we only have IE 7. I want to view IE 6 on my computer also. </p>
<p>How can I view both on the same computer? </p>
<p>I want more than just a screen shot. I want to view both versions of IE as I write code.</p>
| <p>You want <a href="http://tredosoft.com/Multiple_IE" rel="nofollow noreferrer">Multiple IE</a>... IE3 to 6 in one package!</p>
| <p>I used to use Multiple IE, but have found some limitations - it only handles the browser window display functionality, but it doesn't show you the print preview and has some other limitations.</p>
<p>So I suggest <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=04d26402-3199-48a3-afa2-2dc0b40a73b6&... | 27,542 |
<p>What is best language to learn next to Java?</p>
<p>Criteria for this secondary language are:</p>
<ol>
<li><p>High potential of being the "next big thing". e.g. If the market for Java open positions <em>hypothetically</em> dies/dwindles, what is the next programming language that will have a bigger market for open... | <p>Python almost meets all of them, but I don't know about being "the next big thing", but hey, Google uses it, and I think its popularity is raising.</p>
<p>It's a scripting language, btw.</p>
<p>I use it for web applications (using <a href="http://djangoproject.com" rel="nofollow noreferrer">django</a>), and you ca... | <p>If you don't have any religious issues with Microsoft, I would argue for C#.
The only downside I can see is that it's not cross-platform. Otherwise it fits your requirements as far as I can see</p>
| 49,391 |
<p>What is a good implementation of a IsLeapYear function in VBA? </p>
<p><b>Edit: </b>I ran the if-then and the DateSerial implementation with iterations wrapped in a timer, and the DateSerial was quicker on the average by 1-2 ms (5 runs of 300 iterations, with 1 average cell worksheet formula also working).</p>
| <pre><code>Public Function isLeapYear(Yr As Integer) As Boolean
' returns FALSE if not Leap Year, TRUE if Leap Year
isLeapYear = (Month(DateSerial(Yr, 2, 29)) = 2)
End Function
</code></pre>
<p>I originally got this function from Chip Pearson's great Excel site.</p>
<p><a href="http://www.cpearson.... | <p>Here's another simple option.</p>
<pre><code>Leap_Day_Check = Day(DateValue("01/03/" & Required_Year) - 1)
</code></pre>
<p>If Leap_Day_Check = 28 then it is not a leap year, if it is 29 it is.</p>
<p>VBA knows what the date before 1st March is in a year and so will set it to be either 28 or 29 February for u... | 15,593 |
<p>So I am just starting out developing PHP web applications and have finished setting up my server with the following:</p>
<ul>
<li>Ubuntu Server</li>
<li>Apache2</li>
<li>PHP</li>
<li>MySQL</li>
<li>VSFTPD</li>
<li>and all the other goodies...</li>
</ul>
<p>Currently when I edit files, I have two methods to update/... | <p>I don't like very much the idea about making changes directly on the server, I can recommend you another approach: Use a version control system, there you check in all the changes that you do to your code, then you can easily checkout or export all the modifications when you deploy, and in that way you'll have the ... | <p>I use Zend Studio. I get the benefit of the IDE on my local machine (Linux/Mac/Win), and when I save it saves remotely on the server. It's kind of like the old HomeSite with some features (code completion, etc..) specific to PHP. I believe it will also work with version control, but since I'm one guy working alone I... | 32,623 |
<p>I want add the new node as parent node of the old nodes in XML using C#. for example node have the following XMl file:</p>
<pre><code><bookstore>
<books>
<author>
</author>
</books>
</bookstore>
</code></pre>
<p>like that now I want add the new like below:</p>... | <p>Try this:-</p>
<pre><code>XmlDocument doc = new XmlDocument();
doc.Load("BookStore.xml");
XmlElement newNode = doc.CreateElement("newnode");
doc.DocumentElement.AppendChild(newNode);
newNode.AppendChild(doc.SelectSingleNode("/bookstore/books"));
doc.Save("BookStore.xml");
</code></pre>
| <p>Don't have VS here so can't confirm that this works but something like this:</p>
<pre><code>XmlDocument xd = new XmlDocument();
xd.Load("oldxmlfile.xml");
XmlNode oldNode = xd["nameOfRootNode"];
xd.RemoveAll();
XmlNode newParent = xd.CreateNode("nodename");
newParent.AppendChild(oldNode);
xd.AppendChild(newParent);... | 40,874 |
<p>Does anybody know of any resources (books, classes, lecture notes, or anything) about the general theory of computer algebra systems (e.g. <a href="http://wolfram.com" rel="noreferrer">mathematica</a>, <a href="http://code.google.com/p/sympy/" rel="noreferrer">sympy</a>)?</p>
<p>"Introductory" materials are preferr... | <p>"General Theory" of CAS is a pretty huge scope for a question. That being said, I'll do my best to cover as much as I can in the hopes that something helps you find what you're looking for :)</p>
<p>The proceedings of the ISSAC and SIGSAM groups would no doubt have some good stuff about techniques for building CAS... | <p>Here's one link from Wikipedia: <a href="http://en.wikipedia.org/wiki/Computer_algebra_system" rel="nofollow noreferrer">Computer Algebra Systems</a><br>
And another here: <a href="http://www.math.wpi.edu/IQP/BVCalcHist/calc5.html" rel="nofollow noreferrer">http://www.math.wpi.edu/IQP/BVCalcHist/calc5.html</a></p>
| 45,387 |
<p>Delphi (and probably a lot of other languages) has class helpers. These provide a way to add extra methods to an existing class. Without making a subclass.</p>
<p>So, what are good uses for class helpers?</p>
| <p>I'm using them:</p>
<ul>
<li>To <a href="http://17slon.com/blogs/gabr/2007/03/fun-with-enumerators-part-5-class.html" rel="noreferrer" title="Class helper enumerators">insert enumerators</a> into VCL classes that don't implement them.</li>
<li>To <a href="http://gp.17slon.com/gp/gpstreams.htm" rel="noreferrer" titl... | <p>I've seen them used for making available class methods consistent across classes: Adding Open/Close and Show/Hide to all classes of a given "type" rather than only Active and Visible properties. </p>
| 31,586 |
<p>I am using freeglut for opengl rendering...</p>
<p>I need to draw an envelop looking like a cone (2D) that has to be filled with some color and some transparency applied.</p>
<p>Is the freeglut toolkit equipped with such an inbuilt functionality to draw filled geometries(or some trick)?
or is there some other api ... | <p>It feels like what you really want is a class representing the weapon, with attributes to handle the base values and calculate hit values with various modifiers. Here's a simple example:</p>
<pre><code>SHORT_RANGE = 'S'
MEDIUM_RANGE = 'M'
LONG_RANGE = 'L'
SHORT_RANGE_MODIFIER = 0.6
MEDIUM_RANGE_MODIFIER = 0.3
LONG_... | <p>@Vinko: perhaps make calcBaseHitNumbers, do the "if not self.calculatedBase:" check internally, and just no-op if it's been done before. That said, I can't see the pressing need for precalculating this information. But I'm no Python performance expert.</p>
| 29,429 |
<p>The code is</p>
<pre><code>return min + static_cast<int>(static_cast<double>(max - min + 1.0) *
(number / (UINT_MAX + 1.0)));
</code></pre>
<p>number is a random number obtained by rand_s. min and max are ints and represent minimum and maximum values (inclusive).</p>
<p>If you provide a solution not... | <p>The <code>static_cast<double></code> is redundant because the "+1.0"s will cause promotion to double anyway.</p>
| <p>Something like</p>
<pre><code>min + number % (max - min + 1)
</code></pre>
<p>Check the end-cases</p>
| 17,015 |
<p>For a long time I've been trying different languages to find the feature-set I want and I've not been able to find it. I have languages that fit decently for various projects of mine, but I've come up with an intersection of these languages that will allow me to do 99.9% of my projects in a single language. I want... | <p>Sadly, there's no metrics or stories around failed languages. Just successful languages. Clearly, the failures outnumber the successes.</p>
<p>What do I base this on? Two common experiences.</p>
<ol>
<li><p>Once or twice a year, I have to endure a pitch for a product/language/tool/framework that will Absolutel... | <p>It would be interesting to hear some of the things you feel you can't do in existing languages. What kind of projects are you working on that can't be done in C#?</p>
<p>I'm just curios!</p>
| 23,571 |
<p>How do you pass <code>$_POST</code> values to a page using <code>cURL</code>?</p>
| <p>Should work fine.</p>
<pre><code>$data = array('name' => 'Ross', 'php_master' => true);
// You can POST a file by prefixing with an @ (for <input type="file"> fields)
$data['file'] = '@/home/user/world.jpg';
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURL... | <pre><code><?php
function executeCurl($arrOptions) {
$mixCH = curl_init();
foreach ($arrOptions as $strCurlOpt => $mixCurlOptValue) {
curl_setopt($mixCH, $strCurlOpt, $mixCurlOptValue);
}
$mixResponse = curl_exec($mixCH);
curl_close($mixCH);
retur... | 4,806 |
<p>I am setting up my Java EE version of Eclipse to compile Servlets. I have the problem where Eclipse says "HttpServlet" cannot be resolved because it can't find the Java EE jar files.</p>
<p>I am using Windows XP. I already have Tomcat 6.0 up and running. I think the easiest solution would be to link to the servlet-... | <p>You can add the servlet-api.jar file into the project properties.
From the project hierarchy right click the project name->properties->Java build path->Libraries tab.
From there, add the servlet-api.jar as an external jar file.</p>
| <p>Eclipse doesn't make use of the CLASSPATH environmental variable, or any other (except maybe to find a VM to run). Doing so would make it difficult if not impossible to cleanly target different VMs and servers from the same machine and installation. The list of jars used is solely based on the project's Java Build... | 25,430 |
<p>What, at a minimum, should an application health-monitoring system do for you (the developer) and/or your boss (the IT Manager) and/or the operations (on-call) staff?</p>
<p>What else should it do above the minimum requirements?</p>
<p>Is monitoring the 'infrastructure' applications (ms-exchange, apache, etc.) suf... | <ul>
<li>Whether the application is running.</li>
<li>Unusual cpu/memory/network usage.</li>
<li>Report any unhandled exceptions.</li>
<li>Status of various modules (if applicable).</li>
<li>Status of external components (databases, webservices, fileservers, etc.)</li>
<li>Number of pending background tasks (if applica... | <p>Minimum: make sure it is running :)</p>
<p>However, some other stuff would be very useful. For example, the CPU load, RAM usage and (in multiuser systems) which user is running what. Also, for applications that access network, a list of network connections for each app. And (if you have access to client computer(s)... | 10,475 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.