input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
How do i print the columns of a JAMA matrix? <p>I use the JAMA.matrix package..how do i print the columns of a matrix </p>
| <p>The easiest way would probably be to <a href="http://math.nist.gov/javanumerics/jama/doc/Jama/Matrix.html#transpose%28%29" rel="nofollow">transpose</a> the matrix, then print each row. Taking part of the example from the <a href="http://math.nist.gov/javanumerics/jama/doc/Jama/Matrix.html" rel="nofollow">API</a>:</... |
How to get different timezones' current time in PHP? <p>Unfortunately I'm not using PHP 5. On the documentation of the <a href="http://php.net/date" rel="nofollow">date</a> function it has a timezone section which lets you specify the difference from the GMT tome. How can you use that to get the current/local time in a... | <p>You can convert times to different timezones by using the PEAR Date package <a href="http://pear.php.net/package/Date" rel="nofollow">http://pear.php.net/package/Date</a></p>
<p>Examples here <a href="http://pear.php.net/manual/en/package.datetime.date.examples.php" rel="nofollow">http://pear.php.net/manual/en/pack... |
Keypress event is triggered twice for a single ENTER button press in Windows CE <p>During development i have observed that certain PDAs with Windows CE and possibly Windows Mobile too are sending the Enter key twice in the key pressed event thus i execute twice the code that lies under the control's key press event for... | <p>I donât know if this will help but if you read the keyboard port Enter is seen as two bytes rather than one.</p>
|
How can I sum values in a MySQL query? <p>I am using MySQL.<br />
I have a P_id that should be able to find the max value. I want to show the sum of two formulas by following:</p>
<pre><code> Then
Sum(max(pval)*S_val*Estimate)
Sum(max(pval)*P_val*Analyze)
Finally sum the Both above
</code>... | <p>You cannot nest aggregate functions - <code>SELECT SUM(MAX(x))</code> will always error.</p>
<p>You can get the inner value in a subquery instead:</p>
<pre><code>SELECT
SUM(maxpval * S_val * Estimate),
SUM(maxpval * P_val * Analyze)
FROM
yourTable
JOIN (
SELECT MAX(P_val) AS maxpval FROM yourTable
) ... |
Get current MethodBase through reflection <p>Can I get the current method's MethodInfo somehow?</p>
| <pre><code>System.Reflection.MethodBase.GetCurrentMethod()
</code></pre>
<p>Found it myself after some screwing around with the reflection namespace...</p>
|
Separating groups into nearly-equal stacks <p>I have a list of documents and I want to display them grouped by the first letter of their name on a web-page, over three columns.</p>
<p>In short, something like this:</p>
<pre><code>A | C | E
A | D | F
B | D | F
B | D | F
| D |
</code></pre>
<p>An important differenc... | <p>Perhaps it helps if you look at the problem like this:</p>
<p>For your example, you have a string like this:</p>
<pre><code>AA BB C DDDD E FFF
</code></pre>
<p>The space positions are the places where you could start a new column. Everywhere else you mustn't to keep same letters in the same column.
So you actuall... |
How to compile and run inter-dependent plugin jars <p>I have to build two eclipse-plugin projects into two separate jars with each one dependent on the other for compiling. Eclipse IDE complains about "cyclical dependency...".
How do I build these plugin jars? I guess running these plugins by just putting them in the e... | <p>If you have a cyclic dependency, you have two choices: </p>
<ol>
<li>You can get rid of it by putting them into one JAR. If they truly depend on each other, they really are just one entity.</li>
<li>You can split out the packages that cause the cyclic dependency into a third JAR and deploy two plug-ins with two JA... |
How can I implement Nested Master Pages in ASP.NET MVC RC2? <p>I have a main MasterPage which has a single column layout for the web application I am currently designing. I want to re-use the existing MasterPage to implement a two column layout using Nested MasterPages which was possible on previous releases of the AS... | <p>Nevermind! I had a bug in the page that was stopping the page from being rendered so it does work now.</p>
<p>The bug was the (;):</p>
<pre><code><div id="mainLeftContent">
<h3>Options</h3>
<%= Html.MenuCurrentChildren(); %>
</div>
</code></pre>
<p>The fix was:</p>
<pre><... |
PHP and ?? operator <p>Like some people know, C# has very useful <code>??</code> operator which evaluates and returns expression on the right if expression on the left is null. It's very useful for providing default values, for example:</p>
<pre><code>int spaces = readSetting("spaces") ?? 5;
</code></pre>
<p>If <code... | <p>It is a good idea to be more explicit in cases like this, especially in PHP since it has somewhat confusing type conversion rules (e.g. "0" is false as you pointed out).</p>
<p>If you want to be strict, let your function <code>readSettings</code> return the correct setting or a well-defined value if no setting is f... |
CPU load from Java <p>Is there a way to get the current cpu load under Java without using the JNI?</p>
| <p>Use the <a href="http://java.sun.com/javase/6/docs/api/java/lang/management/ManagementFactory.html"><code>ManagementFactory</code></a> to get an <a href="http://java.sun.com/javase/6/docs/api/java/lang/management/OperatingSystemMXBean.html"><code>OperatingSystemMXBean</code></a> and call <a href="http://java.sun.com... |
How do I display custom strings when multiple items are selected? <p>I have a property grid that helps me manage all of the controls on a form. These controls are for designer-type folks, so I'm not really worried that much about the user interface... until someone selects multiple objects.</p>
<p>I have a UITypeEdito... | <p>Place a <code>TypeConverter</code> attribute on each property too..</p>
|
Converting indexed polygons to unindexed ones. Several problems have cropped up <p>Yet again I have some questions regarding polygon algorithms.</p>
<p>I'll try to explain my problem:</p>
<p>I am using a subset of a third party library called Geometric Tools(GT) to perform boolean operations on my polygons. To accomp... | <p>You are effectively trying to find all <a href="http://en.wikipedia.org/wiki/Cycle%5F%28graph%5Ftheory%29" rel="nofollow">cycles</a> in an <a href="http://www.brpreiss.com/books/opus4/html/page529.html" rel="nofollow">undirected</a> <a href="http://en.wikipedia.org/wiki/Graph%5F%28mathematics%29" rel="nofollow">grap... |
Tool to upgrade SQL Express database after deployment <p>I have an app which uses SQL Express and my customers are mainly people who don't have a dedicated IT staff, so wouldn't know how to run scripts. So the deployment and upgrades has to be easy. The deployment part is all figured out. What I need to know is when ve... | <p>Keep track, or else use a product like Red Gate's Compare tool to generate a script, then have your installer program run the upgrade script. The user will never need to do more than double-click setup.exe.</p>
|
Multiple versions of .NET CLR running concurrently <p>Let's say I have a .NET user application (.exe) running under Windows that was compiled in .NET Framework Version 3.0 (VS2008). If that application loads another .NET Assembly (.dll) that was compiled on a different computer using .NET Framework Version 2.0 (VS2005... | <p>There is no .NET 3.0 CLR. .NET 3.0 and 3.5 both use the .NET 2.0 CLR.</p>
<p>Of course, if your .NET 3.0 application uses .NET 3.0 features, then .NET 3.0 will need to be installed.</p>
|
Save snapshot data to XML <p>I have 5 tables belonging to 2 different datasets, I use them to populate some grids in a page. I want to implement some snapshot functionality and I need to save the data in the tables in an XML in the database. I was thinking of simply serializing the tables to XML using the .Net XmlSeria... | <p>With a DataSet, you can create the XML. You already are aware of this, based on your question. If you want to prune the data out a bit, you could build your own XML, but you can also create an XSLT file and transform the XML to the simplified XML you are looking at. It is a one-step process, unlike the looping neces... |
What is SVN? (PHP) <p>Basically i am quite new to PHP and recently i have had heard quite abit about SVN. After searching (googleing) for it, all i could really find was the SVN functions on the php.net website.</p>
<p>Could someone please explain what SVN is, what its used for and is it worth learning? </p>
<p>Thank... | <p>I think you may be wondering how people use Subversion (SVN) in a PHP development environment. </p>
<p>At the company I work for we develop PHP on Linux. We use subversion to track changes and help publish changes to live server. With subversion there is no file locking or check-in. Each developer has a working cop... |
How to implement Watir classes (e.g. PageContainer)? <p>I'm writing a sample test with Watir where I navigate around a site with the IE class, issue queries, etc..
That works perfectly.</p>
<p>I want to continue by using <a href="http://wtr.rubyforge.org/rdoc/classes/Watir/PageContainer.html" rel="nofollow">PageContai... | <p>Currently, the best place to get answers to your Watir questions is the <a href="http://groups.google.com/group/watir-genera" rel="nofollow">Watir-General</a> email list.</p>
<p>For this question, it would be nice to see more code. Is the application under test (AUT) opening a new window/tab that you were having t... |
Oracle tables in one view <p>I have 2 tables in an oracle database, which has the same column-names and types.
For example:</p>
<p>Table1: id, name, comment<br>
Table2: id, name, comment</p>
<p>How can I show all data from both table in one view?</p>
| <p>If you want 4 separate columns, simply use aliases, like you would any other select.</p>
<pre><code>create or replace view vw_my_view as
select t1.id t1_id
,t1.comment t1_comment
,t2.id t2_id
,t2.comment t2_comment
from table1 t1
inner join table2 t2 on join condition
where filter ... |
Converting Excel to PDF with VS2008 and Office2007 <p>I am trying to use Interop.Excell to save an Excel Workbook as a PDF file. I am using VS2008 and Office2007, and have downloaded and installed the SaveAsPDFandXPS.exe from Microsoft. This enabled me to save a Word document as a pdf using the following code:
... | <p>This question has been answered here:</p>
<p><a href="http://stackoverflow.com/questions/738829/what-is-the-filetype-number-for-pdf-in-excel-2007-that-is-needed-to-save-a-file-a"><strong>What is the FileType number for PDF in Excel 2007 that is needed to save a file as PDF through the API?</strong></a></p>
<p>You ... |
Safari force scroll <pre><code>html {overflow-y:
scroll;height:101%;overflow-y:hidden;}
</code></pre>
<p>To force scrolling, when I view one my sites on my Mobile phone the bottom gets cut off, but looks fine in FirefoxF/IE.</p>
<p>Any ideas?</p>
| <p>It should be enough to say:</p>
<pre><code>html { overflow-y: scroll; }
</code></pre>
<p>but I would also try</p>
<pre><code>body { overflow-y: scroll; }
</code></pre>
|
Incompatible pointer type: How can I use a CFType derived object within NSObject derived collection objects? <p>I'm trying to use ABRecordRef within an NSMutableArray, but it doesn't seem to work. I know that ABRecord is a C class, but I thought that ABRecordRef was the work around Objective-C class that allowed me to ... | <p>What do you mean by "Not Working"? As in, you get compile or run-time errors?</p>
<p>As I noted in the response to the other poster, you can't use the Objective-C API on the iPhone (There also is no true ABrecord class to brdge to).</p>
<p>Generally it's a really good idea with the address book stuff on the iPhon... |
SWT DropTargetListener has empty event data under Mac OS X <p>I'm currently experiencing a weird platform inconsistency between Mac OS X and Windows/Linux.</p>
<p>I've implemented an SWT <code>DropTargetListener</code> and tried to analyze the data dropped in the <code>dragEnter</code> method. Unfortunately, the <code... | <p>Since the <a href="https://bugs.eclipse.org/bugs/buglist.cgi?query%5Fformat=advanced&short%5Fdesc%5Ftype=allwordssubstr&short%5Fdesc=&classification=Eclipse&product=Platform&component=SWT&long%5Fdesc%5Ftype=allwordssubstr&long%5Fdesc=TransferData&bug%5Ffile%5Floc%5Ftype=allwordssubstr... |
Visual Studio 2005 Build of Python with Debug .lib <p>I am looking for the Visual Studio 2005 build of Python 2.4, 2.5 or 2.6, I also need the python2x_d.lib (the debug version of the .lib) since I embed the interpreter into my app and the python libs implicitly link to the python2x_d.lib with pragmas (grrr).</p>
<p>A... | <p>I would recommend that you <a href="http://python.org/download/" rel="nofollow">download the Python source</a> (tgz and tar.bz2 zipped versions available) and compile it yourself. It comes with a VS2005 solution so it isn't difficult. I had to do this for a SWIG project I was working on.</p>
|
How to call a WCF service from FitNesse <p>When calling a WCF service from a console app, asp.net app, wpf/winform app, you have to have a app.config or web.config file for the WCF service endpoint information. But from FitNesse, I'm calling a fixture which is a .dll (class library) and this fixture is calling my WCF ... | <p>Anything you can do with a config in WCF can also be done programmatically. Could you create the endpoints in code and then compile it?</p>
|
Selecting all empty text fields in Jquery <p>How can I find all text fields that have an empty value?</p>
<pre><code>$(":text[value='']")
</code></pre>
<p>gives a JavaScript error</p>
<p>I know I can do <code>$(":text")</code>, iterate through and return all fields with <code>$(this).val()==''</code></p>
<p>I am lo... | <h2> Latest Answer: Upgrade to 1.3.2 </h2>
<p>Here are various tests I ran via FireBug on <a href="http://docs.jquery.com/Downloading_jQuery">http://docs.jquery.com/Downloading_jQuery</a> </p>
<p>Different jQuery versions are switched in at page-load with special greasemonkey scripts. </p>
<pre><code>>>> jQ... |
WPF DataGrid Button Column Disable <p>Is it possible to disable a button in a DataGridTemplateColumn? I have a DataGridTemplate as follows:</p>
<pre><code><toolkit:DataGridTemplateColumn Header="Timer" Width="50">
<toolkit:DataGridTemplateColumn.CellTemplate>
&l... | <p>I would have the object the Datagrid is bound to expose a "IsEnabled" boolean property I can bind the button to. Whenever the handler is called, simply get the other object from your original collection and have them change their property to false. This will automatically disable the other buttons.</p>
<p>If your a... |
surfing with the same CookieContainer <p>How can you surf on a website assigning the same CookieContainer to each web request? </p>
| <p>This is a class I wrote a few years back. It's not quite complete and was done before I fully understood how everything works (It doesn't properly encode complex POST data, for example), but it does work pretty well for the all the flaws and it will demonstrate how you can keep your cookiecontainer. It's also in V... |
Moving Selected rows Between Gridviews <p>I currently have Gridview1 which gets it's data from a database and displays a list of people.I also have a Gridview2 which is initially blank.
I would like to add the functionality of adding/removing rows to gridview2 from gridview1.
I've added a checkbox column to gridview1 ... | <pre><code> Gridview2.rows.add(Gridview1.rows[INDEXTOMOVE]);
</code></pre>
|
Append an xml document to an xml node in C#? <p>How can I append an XML document to an xml node in c#?</p>
| <p>An <code>XmlDocument</code> <em>is</em> basically an <code>XmlNode</code>, so you can append it just like you would do for any other <code>XmlNode</code>. However, the difference arises from the fact that <em>this</em> <code>XmlNode</code> does not belong to the target document, therefore you will need to use the Im... |
ODBC Connection to iSeries Giving Odd Number of Results <p>I'm using UnixODBC with PHP 5.2.4 on Ubuntu 8.04 LTS and trying to pull all the results from a table sitting on an IBM i and replicate them to a local MySQL table. </p>
<p>Code-wise it is working with no errors but I'm ending up with more rows that what is con... | <p>Is it the same rows being duplicated each time? If so, is there anything unique about these records that could hint on why they are duplicated?</p>
<p>Perhaps use another binding for getting results -- like <code>odbc_fetch_row()</code>. What does <code>odbc_num_rows()</code> say?</p>
<p>These and other techniqu... |
Mailing Exception logs in a live Grails webapp <p>I'd like my Grails web-app to send an e-mail for each exception that reaches the end-user.</p>
<p>Basically I'm looking for a elegant way to achieve something equivalent to:</p>
<pre><code> try {
// ... all logic/db-access/etc required to render the page is exe... | <p>Turns out this exact question was <a href="http://www.nabble.com/How-to-send-email-on-unhandled-exception-td22247616.html" rel="nofollow">answered on the Grails mailing list</a> a couple of days ago.</p>
<p>The solution is to add the following to the log4j-section of Config.groovy:</p>
<pre><code>log4j {
...
... |
How to get the Join of Two One to Many associations? <p>I have two hibernate entities User and Blog. User can be interested in multiple Tags. Blog can belong to multiple Tags. For a User, How do i find the Blogs which belong to the Tags the User is interested in?</p>
<p>I need something like </p>
<pre><code>Select * ... | <p>Are you looking for something like this?</p>
<pre><code>select b.*
from blog b
join blog_tags bt on bt.blog_id = b.id
join user_tags ut on ut.tag = bt.tag
where ut.user_id = (this_user)
</code></pre>
<p>Contrary to the comment, I believe HQL does permit explicit joins (I may be wrong, but see <a href="ht... |
GC.KeepAlive versus using <p>In his <a href="http://www.ai.uga.edu/~mc/SingleInstance.html">article about preventing multiple instances</a> of an application, Michael Covington presents this code:</p>
<pre><code>static void Main() // args are OK here, of course
{
bool ok;
m = new System.Thread... | <p>Wrapping the mutex in a <code>using</code> statement will indeed prevent it from being garbage collected, but will <em>also</em> dispose of it (it calls <code>Dispose</code>, not <code>Close</code>) at the end (whereas <code>GC.KeepAlive</code> won't, obviously).</p>
<p>If the end of the method is genuinely going t... |
How to find a method in assembly code <p>From a memory leak log I have the following info: </p>
<p>TestApp.exe! + 2238ch</p>
<p>Let us say this means that method at offset '2238c' (hex value) is leaking. </p>
<p>How can I locate the corresponding method in my source code? I have the linker map (testapp.map) but not ... | <p>Your map file will have a bunch of entries like these:</p>
<pre>
0001:00000070 ??0logic_error@std@@QAE@ABV01@@Z 00401070 f i scratch.obj
0001:000000e0 _main 004010e0 f scratch.obj
0001:00000310 ??1?$list@V?$variant@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@... |
Inline output document selection using result document in XSLT 2.0 <p>Greetings,</p>
<p>I'm looking for a method to do in-line result (output) document selecting in XSLT. I know of the method where one creates an <code>xsl:result-document</code> node to have one transformation apply to multiple documents. Usually this... | <p><strong>Here is a working example how to do this</strong>:</p>
<p><strong>This transformation</strong>:</p>
<pre><code><xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output omit-xml-declaration="yes" indent="yes"... |
The Art of Computer Programming, Vol 4, Fascicle 2 typo? <p>At the bottom of page 5 is the phrase "changes <i>k</i> to <i>k</i> ⊕ (1<sup><i>j</i>+1</sup>)<sub>2</sub>". Isn't 1 to any power still 1 even in binary? I'm thinking this must be a typo. I sent an email to Dr. Knuth to report this, but I don't expect to... | <p>This can be resolved by using the convention that (...)<sub>2</sub> represents a bitwise representation. (1<sup>j+1</sup>)<sub>2</sub> then consists solely of j+1 ones, rather than referring to an exponentiation. You can see this convention explained more explicitly in TAOCP Volume 4 Fascicle 1 at page 8, for exampl... |
mxmlc compiles differently under linux and windows? <p>I have a project which has several components loaded by a single preloader swf.</p>
<p>The preloader swf is strictly AS3 (No flex) and uses Loaders to load two different swfs which both use the flex library (Statically compiled, not rsl). </p>
<p>When I compile a... | <p>So wait, are you using different version of the SDK in each platform? That would certainly account for some differences (at the very least in the size of the swf...)</p>
<p>IIUC you get this error when you're loading the page in the browser, right? It's hard to tell from just the stack trace what's wrong, but I can... |
Do asynchronous web service calls always call the AsyncCallback? <p>I'm making asynchronous web service calls from a C# app:</p>
<pre><code>{
//Put UI in 'loading' state
...
//Now call web service
webServiceProxy.BeginMyMethod(param, new AsyncCallback(MyCallback), null);
}
private void MyCallback(IAsyncResu... | <p>Yes, the callback is guaranteed to be called. The callback is what permits asynchronous code using the <code>Begin*</code> / <code>End*</code> pattern to be written in a continuation-passing style.</p>
<p>You must call the corresponding <code>End*</code> method in your callback (normally, the first thing in the ca... |
How can I handle fractional quantities in an e-store shopping cart? <p>I am building an e-store and I need to have the ability to add fractional quantities to the shopping cart. </p>
<p>Admin would set a denominator per product (e.g. 8 would mean that the minimum purchase is 1/8 of a case)</p>
<p>I currently use a <a... | <p>One way would be for you to have your quantity textbox followed by a " / [denominator]" string that would allow them to say something like [4] / 8 to designate half a case of 8.</p>
<p>Your only problem there is you're going to having a simple method to keep track of what those denominators are.</p>
|
Jump to function definition in vim <p>How can i jump to to a function definition using VIM? For example with Visual Assist i can type <kbd>Alt</kbd>+<kbd>g</kbd> under a function and it opens a context menu listing the files with definitions.</p>
<p>How can i do something like this in vim?</p>
| <p>Use ctags. Generate a tags file, and tell vim where it is using the :tags command. Then you can just jump to the function definition using <kbd>Ctrl</kbd>-<kbd>]</kbd></p>
<p>There are more tags tricks and tips in <a href="http://stackoverflow.com/questions/563616/vimctags-tips-and-tricks">this question</a>.</p>
|
Why does glibc "timezone" global not agree with system time on DST? <p>I'm experiencing a bizarre issue where my system clock knows that it's daylight savings time, but glibc seems not to. This is an up-to-date Ubuntu installation, and I have checked /etc/localtime and it has the correct changeover time for last week's... | <p>I don't think "timezone" changes with daylight time. Try the "daylight" variable. On my system:</p>
<pre>
The external variable timezone contains the difference, in seconds,
between UTC and local standard time (for example, in the U.S. Eastern
time zone (EST), timezone is 5*60*60). The external v... |
How to create a list from beginning number and end number <p>I have a set of numbers:</p>
<pre><code> | A B
--------------
1| 100 102
2| 103 103
3| 104 105
4| 106 110
</code></pre>
<p>Column A is the beginning number and Column B is the end number. We need to create a list (on a separate cell) of numbers... | <p>Not sure I completely understand your question, but I think you want to turn this:</p>
<pre>
100 102
103 103
104 105
106 110
</pre>
<p>into this?</p>
<pre>
100 102 100, 101, 102
103 103 103
104 105 104, 105
106 110 106, 107, 108, 109, 110
</pre>
<p>If so, the following code will achieve this:</p>
<pre>
Priv... |
Replacement for JAXMServlet? <p>I am maintaining an application that has classes (written in 2005) that extend <em>javax.xml.messaging.JAXMServlet</em>. While upgrading to a new app server that implements the latest J2EE standards, I discovered that <em>JAXMServlet</em> was removed in JWSDP 2.0 (Java Web Services Devel... | <p>Why replace it? Why not find the relevant libraries and use them?</p>
<p><a href="http://java.sun.com/webservices/downloads/previous/webservicespack.jsp" rel="nofollow">http://java.sun.com/webservices/downloads/previous/webservicespack.jsp</a></p>
|
Inputs empty on post-back despite having values <p>I'm using a telerik RadGrid, with a UserControl edit form. When the InsertCommand event fires, I get the user control, and find edit controls on it, but there Text properties are all string.Empty. I suspect this has something to do with ViewState, but I don't know wh... | <p>I believe your controls are empty because you are rebinding the grid before the inserted event. To avoid such behavior I suggest you populate RadGrid using the NeedDataSource event. It is fired whenever the grid needs rebinding.</p>
|
What is the best practice when implementing a data transfer object or POCO ? How should your POCOs look like? <p>Which of the following is the best way to implement a poco?</p>
<p>Option 1:</p>
<pre><code>public class PocoOption1
{
public PocoOption1(int val1,string val2)
{
Val1=val1; Val2=val2;
}
public... | <p>With the new C# syntax where you can do things like:</p>
<pre><code>Customer customer = new Customer{ Id = 1,
Name="Dave",
City = "Sarasota" };
</code></pre>
<p>you can safely use Option 2.</p>
<p>Please check <a href="http://msdn.microsoft.com/en-us/librar... |
Unobtrusive Javascript to insert element that contains a Rails RESTful URL? <p>I have a simple page with a single rendered iFrame. There's a link called "Add File" and unobtrusively I would like to attach an event to the "Add File" anchor so that when clicked, it inserts a new iFrame below the existing one with the ID... | <p>This should do it for you:</p>
<pre><code>var g_maxNum = 1; // The latest iframe number
function copyIframe()
{
// Get the latest iframe
var iframe = document.getElementById('uploadForm' + g_maxNum);
g_maxNum++
// Create a new iframe by cloning the existing one
var newIframe = iframe.cloneNode... |
DD img different MD5's? <p>We have a smart media card with a linux install on it that we need to duplicate. We created an img with DD and then used dd to write the img back to a couple of new smart media cards. We have compared the MD5 checksum of both the original and the new copies and they are different. </p>
<p>He... | <p>If the cards are different sizes, dd'ing the smaller image to a larger card will not "fill it up", and zeros will remain at the end of the card. An image made from this card will be different than the original image.</p>
<p>It's also always possible that data was mis-written, mis-read, or otherwise corrupted in-tra... |
does adding new member function into d pointer class break binary compatibility? <p>Will adding new member function into d pointer class definition break binary compatibility?</p>
<p>For example, will the new definition below break binary compatibility compared to the original? (side question, is there a tool that wi... | <p>No it does not.</p>
<p>You should understand how C++ builds its objects.</p>
<p>In your case it is just almost "POD" class with non-virtual member functions. These
functions do not affet the representation of object in memory. Thus new version
is binary compatible with old.</p>
<p>More then that, if you do not ex... |
Calling a method and waiting for a return value <p>How do I call a method that returns a bool, but inside that method in order to determine the value of the bool, it calls a web service asyncronously? </p>
<pre><code>bool myBool = GetABoolean(5);
public bool GetABoolean(int id)
{
bool aBool;
client.CallAnA... | <p>Most asyncronous methods return IAsyncResult.</p>
<p>If yours does, you can use the IAsyncResult.AsyncWaitHandle to block (IAsyncResult.AsyncWaitHandle.WaitOne) to block until the operation completes.</p>
<p>ie:</p>
<p><code><pre>
bool aBool;</p>
<p>IAsyncResult res = client.CallAnAsyncMethod(id);
res.AsyncWaitH... |
When learning Ruby on Rails, should I focus on just learning Rails or learn associated technologies along with it? <p>I'm planning on taking the time to actually learn Ruby on Rails in-depth (I've previously done some very minor dabbling with it) so I can hopefully reinvent myself as a Rails developer.</p>
<p>The issu... | <p>If you want to do well in the rails world you should plan on learning (and relearning) things on a regular basis. It isn't as hard as it might sound, but it is important. I'd suggest you make a list of things to learn, and just work your way down it doing by getting an hour or so of hands-on-time with something ne... |
How do you make a webpage change its width automatically? <p>In HTML, is there a way to make a webpage expand to the user's monitor? Like say I have a 15inch, but someone else has a 24 inch. The webpage would be small on their screen, but would fit on min. How would I make the page expand to 100%, or maybe 95%?</p>
| <p>Fluid-width is achieved by using percentage units or em units. It's all about crafting a site layout based on grids and containers. <a href="http://www.maxdesign.com.au/presentation/liquid/" rel="nofollow">Read more</a>.</p>
|
Finding out what caused equals() to return false <p>How can I find out what caused equals() to return false?</p>
<p>I'm not asking about a sure-way, always right approach, but of something to aid in the development process. Currently I have to step into the equals() calls (usually a tree of them) until one of them is ... | <p>It's presumably not a full graph comparison... unless your equals include every property in each class ... (you could try == :))</p>
<p>Try <a href="http://code.google.com/p/hamcrest/" rel="nofollow">hamcrest matchers</a> - you can compose each matcher in an "all of" matcher:</p>
<pre><code>Matcher<MyClass> ... |
EJBs and Storing Objects in a Data Structure (Map, List, etc) <p>Is it possible to have objects stored in a data structure for the duration of an App Server's uptime? Basically I want an EJB that interfaces with this Data Structure, but does not require a full fledged database solution.</p>
<p>As an example I made th... | <p>This can be accomplished by putting the Map in a Singleton and accessing this singleton from the beans. That way there is a single instance for all the EJB instances (since they share the same classloader). Different Session beans in different EAR's would not work though as they would each have their own classload... |
Java Component.show() / hide() are deprecated ... why? <p>Anyone know the reason (just curious)</p>
| <p>JDK 1.1 introduced Java Beans. Java Beans rely in reflection and introspection to determine what the properties of a Bean are (a Bean is a "component"). Properties are then displayed in a Property Sheet. </p>
<p>By default beans use the following foormat:</p>
<pre><code>boolean isXXX()
<type> getXXX()
voi... |
Silverlight MessageBox.Show blocking WCF service call in BackgroundWorker <p>When a MessageBox is being displayed from Silverlight, any calls to a WCF service being executed in a BackgroundWorker are blocked. The OpenFileDialog.ShowDialog allows these calls to go through. Is the browser (IE7) blocking network access ... | <p>Can you design your application in such a way as to avoid the use of a modal messagebox? Perhaps use a Popup - you can make these act as a modal dialog by covering the entire app in a grid and forcing keyboard navigation to cycle within the popup.</p>
<p>See <a href="http://wildermuth.com/2008/05/01/Creating%5Fa%5F... |
Is there any Java equivalent of PHP's http_build_query function? <p>I have a Map with my data and want to build a query string with it, just like I would with http_build_query on PHP. I'm not sure if this code is the best implementation of it or if I'm forgetting something?</p>
<pre><code>public String toQueryString(M... | <p>look at the <a href="http://code.google.com/p/workingonit/source/browse/addenda/src/main/java/org/workingonit/addenda/http/QueryStringBuilder.java" rel="nofollow">QueryStringBuilder</a> class and its <a href="http://code.google.com/p/workingonit/source/browse/addenda/src/test/java/org/workingonit/addenda/http/QueryS... |
What scenarios are possible where the VS C# compiler would not compile a reference of a reference? <p>I'm probably asking this question wrong (and that may be why Google isn't helping), but here goes:</p>
<p>In Visual Studio I am compiling a C# project (let's call it Project A, the startup project) which has a referen... | <p>Have you changed your build configuration? In Visual Studio 2008, the default Solution Configurations are Debug and Release while the default Solution Platform is Any CPU. My experience suggests the Solution Configuration/Platform pair has a unique build configuration. In other words, <em>Debug/Any CPU</em> and <... |
Mac OSX - Xcode Installation Directory <p>After Xcode has finished building is there a way to make it copy the executable to specific directory</p>
<blockquote>
<p>~/Sites/cgi-bin/</p>
</blockquote>
<p>I have the target <code>Installation Directory</code> set to the correct folder, with <code>skip installation</cod... | <p>Check the "Deployment Postprocessing" build setting in your target's Release configuration. Installation is normally done only with a command-line xcodebuild install, but setting Deployment Postprocessing makes it install on every build.</p>
<p>Ensure your user account has write privileges in the directory you want... |
Register DLL in GAC without Assembly Manifest <p>I have a DLL I wish to register with my GAC. I enter the command:</p>
<pre><code>gacutil /i c:\temp\msvcr100.dll
</code></pre>
<p>and I get the error:
<PRE>Failure adding assembly to the cache: The module was expected to contain an as
sembly manifest.</PRE></p>
<p>... | <p>Is this actually a GAC-able DLL? It doesn't seem like it. Maybe it's just reg-able? Why do you want to GAC it?</p>
|
Best UI Library to use with jQuery <p>What do you guys recommend for a UI library to use with jQuery. <a href="http://jqueryui.com/">jQuery UI</a> seems to have less widgets compared to other frameworks. I've been playing around lately with the <a href="http://www.dojotoolkit.org/">Dojo Toolkit</a> which seems pretty n... | <p>Those other "ui libraries" depend on entire other frameworks. If you're using Prototype, choose Scriptaculous. If you're using Dojo, use Dijit.</p>
<p>If you're using jQuery, really, use jQuery UI. You can style the jQuery UI "widgets" a number of different ways; take a look at the Theme Roller Gallery: <a href="ht... |
AJAX not working with ASP.NET HTTP Handler <p>I'm doing something stupid, I suppose. I swear I've done this before without issues but right now I can't get it to work. I have an HTTP handler written in ASP.NET that I want to invoke via AJAX (using jQuery). In my web.config, I register the handler like this...</p>
<... | <p>Got it. I had my path wrong in web.config</p>
<pre><code><httpHandlers>
<add verb="GET" path="getPage.axd" type="Handlers.GetPage"/>
</httpHandlers>
</code></pre>
|
wxPython or pygame for a simple card game? <p>I have been playing around with writing some simple card games in Python for fun and I would like to add a graphical user interface (GUI) to the games. Which library would you recommend for writing the GUI for a simple card game?</p>
| <p>If all you want is a GUI, wxPython should do the trick.</p>
<p>If you're looking to add sound, controller input, and take it beyond a simple card game, then you may want to use pygame.</p>
|
Powershell Add-Content <p>So Im being a bit anal here but I cant get add-content to add both a string and the output of a cmdlet so it would look something like this;</p>
<pre><code>Add-content -path $logfile -value "This is my text"+(Get-Date)
</code></pre>
<p>I realise I can just add another line to set a variable ... | <p>Try <code>"This is my text $(Get-Date)"</code></p>
<p>In PowerShell, strings in double quotes can contain variables and expressions. If it's not a simple expression (e.g. <code>"This is a $value"</code>), then you need to wrap the expression in <code>$()</code> (e.g. <code>"This is a $($value + 1)"</code>).</p>
<... |
Lowercase constraint - Sql Server <p>I'm not sure if this should be a constraint or not, but I want the "UserName" column of a table to ignore the value that is set when an insert or update is executed and instead, store the value of "DisplayUserName" column converted to lowercase. And if "DisplayUserName" is changed, ... | <p>it sounds like you're looking for a computed column. Something like:</p>
<pre><code>CREATE TABLE [dbo].[SampleTable](
[ID] [int] IDENTITY(1, 1) NOT NULL,
[DisplayUserName] [varchar](100) NOT NULL,
[UserName] AS (lower([DisplayUserName]))
) ON [PRIMARY]
</code></pre>
<p>This way, you would never have ... |
"Access Denied" when trying to connect to remote IIS server - C# <p>I receive an "Access Deined" COMException when I try to connect to a remote IIS 6 server from my C# application that is running under IIS 5.1.</p>
<p>Any ideas? I am experiencing all the same issues with the original questions.</p>
<p><b>Update - 4/... | <p>If it is an identity problem, you could try setting your IIS 5.1 application to use <a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/5f8fe119-4095-4094-bba5-7dec361c7afe.mspx?mfr=true" rel="nofollow">Integrated Windows Authentication</a>, and then add the following to you web.confi... |
Java: Reading a pdf file from URL into Byte array/ByteBuffer in an applet <p>I'm trying to figure out why this particular snippet of code isn't working for me. I've got an applet which is supposed to read a .pdf and display it with a pdf-renderer library, but for some reason when I read in the .pdf files which sit on ... | <p>Just in case these small changes make a difference, try this:</p>
<pre><code>public static ByteBuffer getAsByteArray(URL url) throws IOException {
URLConnection connection = url.openConnection();
// Since you get a URLConnection, use it to get the InputStream
InputStream in = connection.getInputStream()... |
Porting code from using timers to scheduledexecutorservice <p>I am trying to port code from using java <a href="http://java.sun.com/j2se/1.3/docs/api/java/util/Timer.html" rel="nofollow">timers</a> to using <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html" rel="nofollo... | <p><strong>NOTE: The way you did this will leak threads!</strong></p>
<p>If your class <code>B</code> will be kept around and <em>each instance</em> will eventually be closed or shut down or released, I would do it like this:</p>
<pre><code>class B {
final ScheduledExecutorService scheduler = Executors.newSchedule... |
SQL: filter on a combination of two column values <p>I have a table <code>balances</code> with the following columns:</p>
<pre><code>bank | account | date | amount
</code></pre>
<p>I also have a table <code>accounts</code> that has <code>bank</code> and <code>account</code> as its composite primary key.</p>
<p>I wan... | <p>It may be helpful to have some more information.</p>
<p>If you have criteria that are driving your particular list of bank and account entities then you should be joining on these tables. </p>
<p>You do have a Bank table and an Account table don't you?</p>
<p>Assuming you have the information in the accounts tabl... |
Django: Uploaded file locked. Can't rename <p>I'm trying to rename a file after it's uploaded in the model's save method. I'm renaming the file to a combination the files primary key and a slug of the file title.</p>
<p>I have it working when a file is first uploaded, when a new file is uploaded, and when there are no... | <p>I think you should look more closely at the upload_to field. This would probably be simpler than messing around with renaming during save.</p>
<p><a href="http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield" rel="nofollow">http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield</a></p>
<bl... |
nHibernate (w/ Castle ActiveRecord) with C# interfaces (esp for DTO's) <p>Any using nHibernate with a Domain object & DTO object implemented from a common interface? I'm trying to separate all of my nHibernate attributes into the Domain object, leaving my DTO's and interface clean.</p>
<p>The problem comes with nH... | <p>In your concrete case you should just add <code>Type = typeof(Contact)</code> to the mapping attribute, like so:</p>
<pre><code>[HasMany(Inverse=true, Table="Contact", ColumnKey="CompanyId", Type=typeof(Contact))]
</code></pre>
|
How to pass arguments when debugging a dot net application <p>I have an command line that uses arguments, I have no problem with this, but each time I want to test the application, I need to compile it, run the CMD, call the application with the parameters from the CMD, because I didn't find any solution that let me dy... | <p>Goto <code>Project->Properties</code> and click the <code>Debug</code> Tab. </p>
<p>There is a section for command line arguments:</p>
<p><img src="http://i.stack.imgur.com/40c4M.png" alt="enter image description here"></p>
|
Unable to call system commands and shell scripts from PHP Fedora 10 <p>I am working on an application that runs locally on a Fedora 10 machine through PHP and Apache. It depends on a process that runs in the background.</p>
<p>The higher-ups want to be able to start/stop/restart the process, through the browser. I w... | <p>If you have administrative control over this system you will want to check the PHP configuration (make sure it is the config profile for the web server).</p>
<p>Safe_Mode will prevent PHP from executing anything outside a particular folder. In a shared hosting environment, this usually means you can only execute th... |
How to use Apache HWPF to extract text and images out of a DOC file <p>I downloaded the <a href="http://poi.apache.org/hwpf/index.html" rel="nofollow">Apache HWPF</a>. I want to use it to read a doc file and write its text into a plain text file. I don't know the HWPF so well.</p>
<p>My very simple program is here:</p... | <p><a href="http://tika.apache.org/" rel="nofollow">Apache Tika</a> will do this for you. It handles talking to POI to do the HWPF stuff, and presents you with either XHTML or Plain Text for the contents of the file. If you register a recursing parser, then you'll also get all the embedded images too.</p>
|
Modifying my website to allow anonymous comments <p>I write the code for my own website as an educational/fun exercise. Right now part of the website is a blog (like every other site out there :-/) which supports the usual basic blog features, including commenting on posts. But I only have comments enabled for logged-i... | <p>The whole point of anonymous comments is that users don't have to login, right? </p>
<p>My personal taste is to not force the user to enter anything, not even their name! The only requried field is the comment text itself. If they don't want to give out their name or email, fine, who cares? </p>
<p>If they provide... |
C# clearing the thread principal <p>How do you clear the thread principal in c#.</p>
<p>I have a background thread that does a</p>
<pre><code>Membership.ValidateUser(username, password);
</code></pre>
<p>which then copies the resulting Principal back to the main thread</p>
<pre><code>AppDomain.CurrentDomain.SetThre... | <p>I don't think you can reset the principal without shutting down the AppDomain and recreating it. You only get one shot at calling SetThreadPrincipal. </p>
<p>Assuming that you are using your own custom principal object that you create after ValidateUser; you can probably put a "Logout" method on your principal th... |
Is current graphic only available in view's drawRect:? <p>I tried invoking UIGraphicsGetCurrentContext() in other places other than in drawRect. It give me a NULL. Is it true that I can can only get current context in UIView's drawRect: only?</p>
| <p>Yes, outside of drawRect, the default context is nil. Before drawRect is called, a view will push its context onto the stack, and pop it after drawRect ends.</p>
|
Export contact list from Gmail, Hotmail, Yahoo, LinkedIn, Facebook <p>I'm looking for library/API to retrieve contact list (emails address to which user had sent mail to, regardless whether user had explicitly added it as contact). Does anybody know such library/API available there?</p>
| <p>Please have a look at socialauth. This Java library will help you get the contacts from most of the networks.</p>
<p><a href="http://code.google.com/p/socialauth" rel="nofollow">http://code.google.com/p/socialauth</a></p>
|
SQL: How to SELECT tablename.* <p>I tried doing this but it failed.</p>
<pre><code>SELECT table2.ID, table1.* FROM table2
LEFT JOIN table1 ON table1.ID = table2.table1ID
</code></pre>
<p>How do you select all columns from a table?</p>
<p>EDIT: There is no error in the above query. I don't know what caused the error ... | <p>You had field names conflict as both tables have ID field. You must to </p>
<pre><code> SELECT table2.ID as t2_id, table1.* FROM table2
LEFT JOIN table1 ON table1.ID = table2.table1ID
</code></pre>
|
REST on IIS <p>I'm wondering how many folks using the Microsoft development stack (IIS and/or ASP.NET) are actually using REST? If so, what forms of rest are being used?</p>
<p>REST can be categorized a zillion ways, but for the purpose of this question I'll categorize it as follows:</p>
<ol>
<li>Radically REST: Us... | <p>I'm involved in a project that uses WCF REST on IIS, but of course I'd recommend having a look at the framework I built: OpenRasta is a .net open-source stack that makes implementing REST much easier.</p>
<p>Google is your friend. The main site is <a href="http://trac.caffeine-it.com/openrasta">http://trac.caffeine... |
MSSQL Server - get a whole part of a decimal value in the computed column <p>Here's my simplified table (SQL Server 2005):</p>
<pre><code>table1: col1 int, col2 int, col3 cast(col1/col2 as int) [computed column]
</code></pre>
<p>for some reason the above doesn't work. i just want to save a WHOLE part of col1/col2, ho... | <p>One option would be to use the <a href="http://msdn.microsoft.com/en-us/library/ms178531.aspx" rel="nofollow">floor function</a>:</p>
<p>FLOOR(col1/col2)</p>
<p>or</p>
<p>CONVERT(int, FLOOR(col1/col2)) -- Might be overkill</p>
|
ASP.NET TextBox filter <p>is there a simple way to suppress certain keystrokes within a textbox? for example if i only want to allow numbers.</p>
| <p>There's nothing built-in, you will need to <a href="http://www.w3schools.com/jsref/jsref%5Fonkeydown.asp" rel="nofollow">write some JavaScript</a> to capture and ignore the keys you want to disallow.</p>
<p>Or you can use this <a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/FilteredTextBox/FilteredTextB... |
How do you get the top-right corner of an image in Flex <p>I want to get the top-right corner of an image in flex .... so far i can just get the x and y which are top-left by default .... sorry im a noob and if this is a dumb question</p>
| <p>Have you tried adding the image width to x?</p>
|
Memory Consumption? <p>I have a piece of code where </p>
<pre><code>for ( ; ; )
{
char *buf;
/* Some code */
}
</code></pre>
<p>The question here will the code allocate memory every time when it cycles through the loop .
I mean atleast 4 bytes will be reserved for the pointer when it cycles .</p>
| <p>Space for the pointer will be allocated on the stack, but it will be popped off at the end of every iteration, so you don't need to worry about it.</p>
|
Problem with SafeArray access using CComVariant <p>I have following block of code</p>
<pre><code> /////////////////////////////////////
CComVariant newVal;
//pass the CComVariant and get the strings array!!!
GetStrList(newVal);
USES_CONVERSION;
if (((newVal.vt & VT_ARRAY) == VT_ARRAY) && ((newVal.vt... | <p>CComVariant destructor calls VariantClear() which frees whatever the variant was incapsulating, arrays included.</p>
<p>One caveat: the array should not be locked at the time when VariantClear() is called. This means that if an exception is thrown after SafeArrayAccessData() but before SafeArrayUnaccessData() the l... |
What happens when I reboot an EC2 instance? <p>When I reboot an EC2 instance, do I get the initial image again, or is the state of the hard disk before the reboot kept?</p>
<p>And what happens with billing, does the hour start again, or do I continue with the fraction of the hour I was in when I rebooted?</p>
| <p>Rebooting an instance is like rebooting a PC. The hard disk isn't affected. You don't return to the image's original state, but the contents of the hard disks are those before the reboot.</p>
<p>Rebooting isn't associated with billing. Billing starts when you instantiate an image and stops when you terminate it. Re... |
Showing page count with ReportLab <p><br />
I'm trying to add a simple "page x of y" to a report made with ReportLab.. I found <a href="http://two.pairlist.net/pipermail/reportlab-users/2002-May/000020.html">this old post</a> about it, but maybe six years later something more straightforward has emerged? ^^;<br />
I fo... | <p>I was able to implement the NumberedCanvas approach from ActiveState. It was very easy to do and did not change much of my existing code. All I had to do was add that NumberedCanvas class and add the canvasmaker attribute when building my doc. I also changed the measurements of where the "x of y" was displayed:</p... |
geographic location uri scheme <p>I'd like to use a URI scheme to enable the users of one of my apps to share geographic locations.</p>
<p>I don't want to invent my own URI scheme and "geo" seems the most appropriate but there are only two Internet Drafts on the subject (<a href="http://tools.ietf.org/html/draft-mayrh... | <p>final note: The draft is now in the RFC Editors queue within the IETF, so it should become an RFC within the next 3 - 5 months. </p>
<p><a href="http://tools.ietf.org/html/draft-ietf-geopriv-geo-uri-07" rel="nofollow">http://tools.ietf.org/html/draft-ietf-geopriv-geo-uri-07</a></p>
|
how to send signal from one program to another? <p>i am using message queue as an ipc between 2 programs.
Now i want to send data from one program to another using message queue and then intimate it through a signal SIGINT.</p>
<p>I dont know how to send a signal from one program to another .
Can anybody pls provide a... | <pre><code>#include <sys/types.h>
#include <signal.h>
int kill(pid_t pid, int sig);
</code></pre>
|
How to conditionally compile VC6 resources <p>depending on a compile switch (values are <code>COMPILE_A</code> or <code>COMPILE_B</code>), which is set in the form of an envorinment variable, I want to compile my application with different settings, like application name and splash screen.</p>
<p>I got this far:</p>
... | <p>I guess I just solved my problem...</p>
<p>The resource compiler uses its own preprocessor.<br />
Therefore the same preprocessor definition has to be added under "Project / Settings / Resources / Preprocessor Definitions".</p>
<h3>Edit: String Resources</h3>
<p>The above doesn't work for string resources as they... |
Getprivateprofilestring Bug <p>I encrypted some text and put it in a INI file. Then I used getprivateprofilestring() to retrieve the value but some of the end characters are missing. I suspect it may be a new line character causing it to be incomplete. Writing to the INI file is OK. Opening the INI file and looking at ... | <p>First off when encrypting strings, make sure that they are converted to Base64 before dumping them into the INI file.</p>
<p>Most likely, the encrypted string created an ascii character which is not handled very well by the INI related APIs. </p>
|
BPEL switch-case in Netbeans <p>I'm using netbeans to develop some BPEL but can't figure out how to add a switch-case block, it's not in the palette anywhere.
I'm using netbeans 6.5.
Any ideas?</p>
<p>Switch is definitely a valid element: <a href="http://charltonb.typepad.com/weblog/2003/08/bpel4ws_switch_.html" rel="... | <p>Have you tried just inserting the switch in the xml source itself? Not sure if Netbeans would support it but it is defined in the standard for BPEL markup.</p>
|
Continuous build with .NET and Java projects on a single machine <p>Is it possible to set up continuous build of projects written in .NET and Java on single build server with single set of applications?</p>
<p>I've seen CruiseControl has support for both world but as far as I know these are two separate applications. ... | <p><a href="http://hudson-ci.org/" rel="nofollow">Hudson</a> has support for both Ant (out of the box IIRC) and <a href="http://wiki.hudson-ci.org/display/HUDSON/NAnt+Plugin" rel="nofollow">NAnt</a> (through plugin) so that's an option for you.</p>
|
if/else and if/elseif <p>If I have a statement block like this:</p>
<pre><code>if (/*condition here*/){ }
else{ }
</code></pre>
<p>or like this: </p>
<pre><code>if (/*condition here*/)
else if (/*condition here*/) {}
else if (/*condition here*/) {}
</code></pre>
<p>What is the difference?</p>
<p>It seems that with... | <p>Without "elseif" syntax you would have to write chain if-statements for processing one of several possible outcomes this way:</p>
<pre><code>if( str == "string1" ) {
//handle first case
} else {
if( str == "string2" ) {
//handle second case
} else {
if( str == "string3" ) {
//han... |
How to change prompt_alternatives_on flag in prolog from .plrc? <p>I can change <code>prompt_alternatives_on</code> flag in the REPL. </p>
<ol>
<li>But how do I change this flag in .plrc?</li>
</ol>
<p>Then I get</p>
<pre><code> permission to modify static_procedure `set_prolog_flag/2'
</code></pre>
<p>Goal: To not... | <p>Put :- (a colon and a hypen) in front of the line to execute it when the file is loaded.</p>
<pre><code>:- set_prolog_flag(key, value).
</code></pre>
<p>This is true of any line of code in any source file that you want to have evaluated when the file is loaded instead of considered a new fact or rule (which causes... |
How to calculate or approximate the median of a list without storing the list <p>I'm trying to calculate the median of a set of values, but I don't want to store all the values as that could blow memory requirements. Is there a way of calculating or approximating the median without storing and sorting all the individua... | <p>If the values are discrete and the number of distinct values isn't too high, you could just accumulate the number of times each value occurs in a histogram, then find the median from the histogram counts (just add up counts from the top and bottom of the histogram until you reach the middle). Or if they're continuou... |
How can I convert non-ASCII characters encoded in UTF8 to ASCII-equivalent in Perl? <p>I have a Perl script that is being called by third parties to send me names of people who have registered my software. One of these parties encodes the names in UTF-8, so I have adapted my script accordingly to decode UTF-8 to ASCII ... | <p>I believe you could use <a href="http://search.cpan.org/dist/Text-Unidecode/">Text::Unidecode</a> for this, it is precisely what it tries to do.</p>
|
Profiling C++ multi-threaded applications <p>Have you used any profiling tool like Intel Vtune analyzer? </p>
<p>What are your recommendations for a C++ multi threaded application on Linux and windows? I am primarily interested in cache misses, memory usage, memory leaks and CPU usage. </p>
<p>I use valgrind (only on... | <p>Following are the good tools for multithreaded applications. You can try evaluation copy.</p>
<ol>
<li>Runtime sanity check tool
<ul>
<li>Thread Checker -- Intel Thread checker / VTune, <a href="https://software.intel.com/en-us/articles/intel-thread-checker-documentation" rel="nofollow">here</a></li>
</ul></li>
<li... |
Ruby on Rails versus Python <p>I am in the field of data crunching and very soon might make a move to the world of web programming. Although I am fascinated both by Python and Ruby as both of them seem to be having every similar styles when it comes to writing business logic or data crunching logic.</p>
<p>But when I ... | <p>Ruby and Python are languages.</p>
<p>Rails is a framework.</p>
<p>So it is not really sensible to compare Ruby on Rails vs Python.</p>
<p>There are Python Frameworks out there you should take a look at for a more direct comparison - <a href="http://wiki.python.org/moin/WebFrameworks">http://wiki.python.org/moin/... |
Why does this take so long to compile in VCC 2003? <p>My team need the "Sobol quasi-random number generator" - a common RNG which is famous for good quality results and speed of operation. I found <a href="http://people.scs.fsu.edu/~burkardt/cpp%5Fsrc/sobol/sobol%5Fold.C" rel="nofollow">what looks like a simple C imple... | <p>I'm using VC++ 2003 and it compiled instantly in both debug/release modes.</p>
<p><strong>Edit:</strong></p>
<p>Do you have the latest service pack installed on your systems?</p>
|
In SQL how can I convert a money datatype to a decimal? <p>I want to convert a money datatype to a decimal, because I want to record the results to 8 decimal places.</p>
<p>For example, in a currency rate table I see the rate stored as 2871047428.20 as a money datatype; using Microsoft SQL Management Studio, I want to... | <p>Here a comparison left column the decimal value, right column the calculated money value:</p>
<pre><code>DECLARE @money AS money
SET @money = 2871047428.20
SELECT CAST(@money AS decimal(34,4)) / 10000000, @money / 10000000
</code></pre>
<p>See also here on Stack Overflow:</p>
<ul>
<li><a href="http://stackoverflo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.