instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Java has a convenient split method:</p>
<pre><code>String str = "The quick brown fox";
String[] results = str.split(" ");
</code></pre>
<p>Is there an easy way to do this in C++?</p>
| <p>C++ standard library algorithms are pretty universally based around iterators rather than concrete containers. Unfortunately this makes it hard to provide a Java-like <code>split</code> function in the C++ standard library, even though nobody argues that this would be convenient. But what would its return type be? <... | <p>This a simple loop to tokenise with only standard library files</p>
<pre><code>#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <conio.h>
class word
{
public:
char w[20];
word()
{
for(int j=0;j<=20;j++)
... | 7,745 |
<p>I have a JUnit 3.x TestCase which I would like to be able to parameterize. I'd like to parametrize the entire <code>TestCase</code> (including the fixture). However, the <code>TestSuite.addTestSuite()</code> method does not allow be to pass a <code>TestCase</code> object, just a class:</p>
<pre><code> TestSuite s... | <p>If this is Java 5 or higher, you might want to consider switching to JUnit 4, which has support for parameterized test cases built in.</p>
| <blockquote>
<p>a few details are not perfect, such as the names of the tests in the IDE being the same across parameter sets (JUnit 4.x appends [0], [1], ...).</p>
</blockquote>
<p>To solve this you just need to overwrite getName() and change the constructor in your test case class:</p>
<pre><code> private String ... | 24,013 |
<p>Warning: Java newbie. </p>
<p>Been looking at <a href="http://www.xoetrope.com/xui" rel="nofollow noreferrer">XUI</a> for Java. Its looks quite interesting. Sort of liek a WPF way of designing interfaces. But googling around I don't see much other than articles saying it had been released. So is it used much or a b... | <p>If you can't use JavaFx, Take a look <a href="http://www.swixml.org" rel="nofollow noreferrer">http://www.swixml.org</a>.</p>
| <p>JavaFx is a nice framework, it is pretty easy to learn and use. There are also some nice tutorials, doco, API's available, its still only in Preview SDK at the moment, but the next reelase is expected out relativly soon.</p>
<p>I would recommend giving it a try</p>
<p><a href="http://javafx.com/" rel="nofollow nor... | 19,967 |
<p>When I retrieve a record using LINQ that has a DateTime field only the ToString() is available. </p>
<p>Where are all the other DateTime methods? </p>
<p>I have to Convert.ToDateTime the DateTime? that the Field returns?</p>
<p>What is the difference between (DateTime) and (DateTime?)</p>
| <p>If by <em><code>DateTime?</code></em> you mean a <code>Nullable<DateTime></code>, then you can get the <code>DateTime</code> value via the <code>DateTime?.</code><strong><code>Value</code></strong> property.</p>
| <p>The namespace collision aside, I know that SQL's datetime has a different epoch (and therefore a different range of valid dates) than C# datetime. </p>
<p>Try to send a <code>new DateTime()</code> to a stored procedure and see what I mean. </p>
| 20,479 |
<p>I can't seem to get my application up and running on my dev server and I'm not sure why.</p>
<p>I have compiled my code in VS 2008 with a target framework of 3.5. I am using 3.5 mainly because I have implemented LINQ rather extensively. Compiling and runs local without any problems. </p>
<p>The hang up is that ... | <p>You are right in that 3.5 runs on the 2.0 CLR, but 3.5 contains libraries and if you have used any of those, you're out of luck unless you install 3.5 on that server.</p>
<p>There are plenty of options for a 3.5 program to not run correctly on only 2.0, so I'd consider downgrading the program, or upgrading the serv... | <p>You can just copy over the 3.5 dlls onto the server. You can absolutely run 3.5 code on a 2.0 server. </p>
| 20,239 |
<p>I have a flex web app and want to integrate it with Java.</p>
<p>The app will have a very small database (2-3 tables), and some routine logic like sending mail.</p>
<p>According to this link (<a href="http://learn.adobe.com/wiki/display/Flex/2b.+Code+Files" rel="nofollow noreferrer">http://learn.adobe.com/wiki/dis... | <p>Check out Blaze DS. It's pretty simple to set this up so that you can invoke methods on your Java classes from Flex.</p>
<p><a href="http://opensource.adobe.com/wiki/display/blazeds/BlazeDS/" rel="nofollow noreferrer">http://opensource.adobe.com/wiki/display/blazeds/BlazeDS/</a></p>
<p>Basically you register a Re... | <p>Another option would be to use Ajax (i.e. JavaScript) as an intermediary between Flex and your server side Java to help keep the view and business layers nicely decoupled. I have seen this done with success - Flex can invoke JavaScript easily, and there are many proven patterns to expose your Java objects/methods ... | 49,315 |
<p>Is it OK if the same OpenSSL context is used by several different accepting sockets?</p>
<p>In particular I'm using the same boost::asio::ssl::context with 2 different listening sockets. </p>
| <p>Yep, SSL_CTX--which I believe is the underlying data structure--is just a global data structure used by your program. From ssl(3):</p>
<blockquote>
<p><strong>SSL_CTX (SSL Context)</strong></p>
<p>That's the global context structure which is created by a server or client once per program life-time and which holds ma... | <p>It should be OK.</p>
<p>For example a typical RFC4217 FTPS server will use the same SSL context for the control socket and all data sockets within that session.</p>
| 13,658 |
<p>I would like to design very high availability(never take server down, roll out features without restart etc) application with both client(probably C# gui) and server components(Java,C++,Perl). </p>
<p>I got some advice from (<a href="http://database-programmer.blogspot.com/2008/05/minimize-code-maximize-data.html" ... | <p>I worked on a MUD game server that did dynamic compilation of scripts, such that almost anything in the game was changeable and recompileable at runtime without having to disconnect any users.</p>
<p>Perhaps the biggest lesson I learned from that project was that <strong>when you write code so flexible such that it... | <p>I worked on a MUD game server that did dynamic compilation of scripts, such that almost anything in the game was changeable and recompileable at runtime without having to disconnect any users.</p>
<p>Perhaps the biggest lesson I learned from that project was that <strong>when you write code so flexible such that it... | 36,267 |
<p>I'm playing around with CodeIgniter; hoping to convert some of my old, ugly PHP into a more maintainable framework. However, I've come across a rather frustrating roadblock - I can't seem to define methods in my views. Any time I try I get a completely blank page, and when I look in the debug log the processing seem... | <p>Define your functions in a <a href="http://codeigniter.com/user_guide/general/helpers.html" rel="nofollow noreferrer">helper</a> and load them from the controller. That way you can reuse the functions in other views, as well.</p>
| <p>I'm not familiar with CodeIgnitor, but it could be including your templates multiple times. Try wrapping your function in a check:</p>
<pre><code>if (!function_exists('myfunc'))
{
function myfunc() {}
}
</code></pre>
<p>CodeIgnitor is probably swallowing errors, so you could also try flushing buffers immediate... | 34,752 |
<p>When programming by contract a function or method first checks whether its preconditions are fulfilled, before starting to work on its responsibilities, right? The two most prominent ways to do these checks are by <code>assert</code> and by <code>exception</code>. </p>
<ol>
<li>assert fails only in debug mode. To m... | <p>The rule of thumb is that you should use assertions when you are trying to catch your own errors, and exceptions when trying to catch other people's errors. In other words, you should use exceptions to check the preconditions for the public API functions, and whenever you get any data that are external to your syst... | <p>See also <a href="https://stackoverflow.com/questions/56168/test-cases-and-assertion-statements#56174">this question</a>:</p>
<blockquote>
<p>I some cases, asserts are disabled when building for release. You may
not have control over this (otherwise, you could build with asserts
on), so it might be a good ide... | 14,272 |
<p>Using a Gearman RepRap with Slic3r, printing from an SD card, with an uniterupted power supply (UPS), and both PLA and ABS filaments, short power outages often result in x/y-axis offsets (see image). During an outage the power is not as clear from a UPS as from a power conditioner. If both x and y axes offset the ... | <p>Part of your self-answer:</p>
<blockquote>
<p>What is puzzling is why did the 3D printer run as if the computer was still operating it, when is was printing from the SD card? Was the circuitry getting power from the USB cable from the computer?</p>
</blockquote>
<p>is more of an extension of the question, which ... | <p>I believe I resolved this issue. The next power outage will tell. After getting a larger UPS used for robotic testers, when swapping out the UPS, I noticed the 3D printer was plugged in to the surge protector side without the battery, probably because the smaller UPS was only rated for power to the computer. Now... | 1,417 |
<p>While going through university and from following the development of SO, I've heard a lot about the Model-View-Controller architectural design pattern. I inadvertently used the MVC pattern even before I knew what it was, and still use it in my everyday job. From what I've seen, it's probably the most popular pattern... | <ol>
<li>Passive View - <a href="http://martinfowler.com/eaaDev/PassiveScreen.html" rel="noreferrer">http://martinfowler.com/eaaDev/PassiveScreen.html</a></li>
<li>Supervising Controller - <a href="http://martinfowler.com/eaaDev/SupervisingPresenter.html" rel="noreferrer">http://martinfowler.com/eaaDev/SupervisingPrese... | <p>You can roll your own MVC with the current ASP.NET framework and still keep the postback model.</p>
<p><a href="http://www.codeproject.com/KB/aspnet/RollingYourOwnMVCwithASP.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/aspnet/RollingYourOwnMVCwithASP.aspx</a></p>
| 4,411 |
<p>Let's say you have a dynamic language (similar to common scripting languages) and want to write a compiler for it. Is it good idea to reserve some bits of a machine word for something like type tags? Especially for microcontrollers and similar devices, is it a good idea?</p>
<p>I can think of some advantages like r... | <p>The added complexity of having to ensure your type bits didn't pass through to any calculations probably would far outstrip any storage savings. You could always allocate a type field adjacent to any primitive field which contains any needed metadata/flags. Then you know that any value always has a storage size of... | <p>No, no way that this is a good idea for a general-purpose compiler. The overhead of handling the "type tag" bits in arithmetic operations will be severe.</p>
<p>By their very nature, dynamically-typed languages require extra space to store the type information for each value. If you have to store lots and lots of... | 28,627 |
<p>Despite primarily being a windows user, I am a huge fan of rsync. Now, I don't want to argue the virtues of rsync vs any other tool...this is not my point.</p>
<p>The only way I've ever found of running rsync on windows is via a version that is built to run on top of Cygwin, and as Cygwin has issues with Unicode, ... | <p>The way that windows locks open files might cause an issue requiring you to hook into the Volume Shadowcopy Service. </p>
<p>About two years ago this fellow ported the algorithm to C#. I haven't taken a look at the code (or the provided binary), but it might be a place to start looking or someone to try contactin... | <p>Have you seen this:</p>
<p><a href="http://www.itefix.no/i2/taxonomy/term/39" rel="nofollow noreferrer">http://www.itefix.no/i2/taxonomy/term/39</a></p>
<p>I have used cwrsync without any problem (and with the much of the usual cygwin misery), but I haven't had any need for unicode filenames, so I've not seen that... | 5,469 |
<p>I have information spread out across a few databases and want to put all the information onto one webpage using PHP. I was wondering how I can connect to multiple databases on a single PHP webpage.</p>
<p>I know how to connect to a single database using:</p>
<pre><code>$dbh = mysql_connect($hostname, $username, $... | <p><strong>Warning :</strong> <code>mysql_xx</code> functions are deprecated since php 5.5 and removed since php 7.0 (see <a href="http://php.net/manual/intro.mysql.php" rel="noreferrer">http://php.net/manual/intro.mysql.php</a>), use <code>mysqli_xx</code> functions or see the answer below from @Troelskn</p>
<hr>
<p... | <pre><code><?php
// Sapan Mohanty
// Skype:sapan.mohannty
//***********************************
$oldData = mysql_connect('localhost', 'DBUSER', 'DBPASS');
echo mysql_error();
$NewData = mysql_connect('localhost', 'DBUSER', 'DBPASS');
echo mysql_error();
mysql_select_db('OLDDBNAME', $o... | 34,638 |
<p>I've got a ListBox control and I'm presenting a fixed number of ListBoxItem objects in a grid layout. So I've set my ItemsPanelTemplate to be a Grid.</p>
<p>I'm accessing the Grid from code behind to configure the RowDefinitions and ColumnDefinitions.</p>
<p>So far it's all working as I expect. I've got some custo... | <p>The binding problem comes from the default style for ListBoxItem. By default when applying styles to elements WPF looks for the default styles and applies each property that is not specifically set in the custom style from the default style. Refer to <a href="http://www.interact-sw.co.uk/iangblog/2007/02/14/wpfdefau... | <p>Simply creating a default style for the type "ComboBoxItem" doesn't work, because it it overwritten by the ComboBox's default "ItemContainerStyle". To really get rid of this, you need to change the default "ItemContainerStyle" for ComboBoxes, like this:</p>
<pre><code><Style TargetType="ComboBox">
<Set... | 19,396 |
<p>From my own "key logger like" process I figured out that another process Locale is wrong (i.e. by sniffing few keys, I figured out that the foreground process Locale should be something while it is set to another). What's the best way to do this?</p>
| <p>I'd use <a href="http://www.gnu.org/software/libtool/manual/libc/Setting-the-Locale.html" rel="nofollow noreferrer">setLocale</a> from within that process to change it, and notify the process about this with some form of IPC like:</p>
<ul>
<li><a href="http://www.gnu.org/software/libtool/manual/libc/Signal-Handling... | <p>You didn't specify operating system or anything, but in Linux this is quite hard unless the target process is willing to help (i.e. there's some IPC mechanism available where you can ask the process to do it for you)</p>
<p>What you <em>can</em> do is to attach to the process, like a debugger or strace does, and th... | 13,649 |
<p>Are there any obvious productivity gains in developing using webforms or MVC?</p>
| <p>No. Personally, I find MVC works much more like my brain does with pretty clear separation of what goes where and why. I banged out a complete prototype commerce site with MVC in a few weeks that would've taken me, I'm sure, at least double that using webforms.</p>
| <p>It depends on how you develop.</p>
<p>If you're someone who drags controls onto the designer surface, it would probably be hard to ever match that level of rapid development with MVC.</p>
<p>On the other hand, if you spend most of your time in source view, you'll probably find that MVC allows you to do so more eff... | 34,609 |
<p>Which version of JavaScript does Google Chrome support in relation to Mozilla Firefox? In other words, does Chrome support JavaScript 1.6, 1.7, or 1.8 which Firefox also supports or some combination of them?</p>
| <p>While Chrome will execute Javascript marked as "javascript1.7", it does not support JS1.7 features like the "let" scoped variable operator.</p>
<p>This code will run on Firefox 3.5 but not on Chrome using V8:</p>
<pre><code><script language="javascript" type="application/javascript;version=1.7">
function... | <p>This is an old thread, however here goes. Google Chrome does not respond to the following</p>
<pre><code>function foo(){
let a = 4;
alert(a);
}
foo();
</code></pre>
<p>hence it does not support JavaScript 1.7</p>
| 38,471 |
<p>Having some SSIS permissions issue.</p>
<p>I am calling the SSIS package in my .net console application with:</p>
<pre><code>Package pkg = app.LoadFromSqlServer(packagePath, serverName, serverUsername, serverPassword, dtsEvents);
</code></pre>
<p>It is working when manually running it using the windows accout, bu... | <p>There are plenty of reasons for it to fail when run under different account, to avoid trying to fix it blindly, you should get the error information. It looks like you are supplying dtsEvent parameter - so your app should get the error message. Another way to get it to examine package.Error collection after executio... | <p>This generally happens when you have sql queries that use linked server to access a database on a different server. </p>
| 48,173 |
<p>When creating scrollable user controls with .NET and WinForms I have repeatedly encountered situations where, for example, a vertical scrollbar pops up, overlapping the control's content, causing a horizontal scrollbar to also be needed. Ideally the content would shrink just a bit to make room for the vertical scro... | <p>You will need your controls to resize slightly to accommodate the width of the vertical scroll bar. One way to achieve this achieved through docking. Rather than just dropping controls on the form, you'll have to play a bit with panels, padding, min/max sizing and docking.</p>
<p>Here is example code you can place ... | <p>If your controls are inside a panel, try setting the AutoScroll property of the Panel to False. This will hide the scrollbars. I hope this points you in the right direction.</p>
<pre><code>myPanel.AutoScroll = False
</code></pre>
| 4,628 |
<p>I have a two-page SSRS report. When I exported it to PDF it was taking 4 pages due to its width, where the 2nd and 4th pages were displaying one of my fields from the table. I tried to set the layout size in report properties as width=18in and height =8.5in.</p>
<p>It gave me the whole table in a single page of PDF... | <p>In BIDS or SSDT-BI, do the following:</p>
<ol>
<li>Click on Report > Report Properties > Layout tab (Page Setup tab in SSDT-BI)</li>
<li>Make a note of the values for <strong>Page width</strong>, <strong>Left margin</strong>, <strong>Right margin</strong></li>
<li>Close and go back to the design surface</li>
<li>In... | <p>I've successfully used pdftk to remove pages I didn't want/need in pdfs. You can download the program <a href="http://www.pdfhacks.com/pdftk/#packages" rel="nofollow noreferrer">here</a></p>
<p>You might try something like the following. Taken from <a href="http://pwet.fr/man/linux/commandes/pdftk" rel="nofollow no... | 47,366 |
<p>We have always had languages that were preferable to be used in a particular scenario. For a quick prototype development, VB6 was an obvious choice. VB6 was chosen in projects that had a simple desktop user interface and standard and un-complicated database interaction requirements. If you wanted to develop a device... | <p>The language distinctions remain. It does not really make a difference whether you compile a language to assembly code or MSIL, except that maybe the abstraction level of MSIL is higher than that of assembly.</p>
<p>The big advantage of .Net though, and this may have inspired the question, is that you can use objec... | <p>I think it really depends on the context from which the question is asked.</p>
<p>Let's say you're developing a library for customers to use. You mark this assembly with the <code>CLSCompliant</code> attribute. This means that the compiler is going to force you to use features that are guaranteed by the CLR, and ... | 30,816 |
<p>Can Repetier host run a multi-material printer such as the Prusa i3 MK2S?</p>
| <p>Yes, it can. I have configured it for as many as four extruders. The problem may be in the slicing, as the slicer is responsible for generating the tool change commands.</p>
<p>One problem with the Repetier multi-extruder support is that, although the temperature of each extruder is reported by the RepRap firmwar... | <p>Yes, you can add a second extruder to it.</p>
| 760 |
<p>I have a function which launches a javascript window, like this</p>
<pre><code> function genericPop(strLink, strName, iWidth, iHeight) {
var parameterList = "location=0,directories=0,status=0,menubar=0,resizable=no, scrollbars=no,toolbar=0,maximize=0,width=" + iWidth + ", height=" + iHeight;
... | <p>Here is my solution using jQuery and jQuery UI libraries. Your API is not changed <del>, but parameter 'name' is ignored</del>. I use <code>iframe</code> to load content from given <code>strLink</code> and then display that <code>iframe</code> as a child to generated <code>div</code>, which is then converted to moda... | <p>Try <a href="http://livepipe.net/control/window" rel="nofollow noreferrer">Control.Window</a>, which requires Prototype</p>
<p>Here's how I use it:</p>
<pre><code><a href="/messages/new" class="popup_window">New Message</a>
</code></pre>
<p>And in my Javascript file:</p>
<pre><code>$(document).observ... | 28,791 |
<p>There seem to be many options to create an XML document in .NET. What's the best approach?</p>
| <p>XmlWriter has a nice interface for creating a document in a streaming, forward-only style. It works best if you have a recursive structure that you need to map into XML.</p>
<p>I would only use the DOM API as a last resort. As Jon says, LINQ to XML is another way to go. Whatever you do, though, don't fall back to s... | <p>The string.format (or any other form of string concatenation) is clearly a code smell, and in practice is considerably more opaque, more prone to human error, harder to break-up and so less maintainable, and slower than the DOM methods.</p>
<p>I <em>strongly</em> advise the DOM approach.</p>
| 40,959 |
<p>Is is possible to put a constant where clause to a Linq to SQl mapping.</p>
<p>I really don't want to do this at the query level or in my Data Access Object as these are currently completely generic and would like to keep it that way to make life for the other developers and save me repeating myself constantly.</p>... | <p>One way I have tackled this is to use an extension method that returns an IQueryable of your entity type, and then use this wherever that entity is needed.</p>
<p>For example, if all my custom queries were only interested in Horses that didn't have the Inactive flag set, I would have an extension method called GetH... | <p>I believe you can do this using the Options property of yourt DataContext.
Check the AssociateWith method.</p>
| 47,310 |
<p>I'm using VS2008 to debug an application that starts a new process. I believe that the spawned process is suffering (and handling) some kind of CLR exception during its start-up, but it is not being caught by turning on CLR Exception Notification in Debug -> Exceptions. Any suggestions on how I can see where the exc... | <p>You can add a call to Debugger.Launch() in your process startup code. This will launch a debugger (typically giving you the choice of using the running copy of VS2008 or a new copy) attached to the process. The same trick is handy for debugging Service startup issues.</p>
| <p>If the process fails during startup, then CreateProcess should return an error code. Check the error code. </p>
<p>If the process fails directly after startup, then check the process return code, and its documentation, logs etc.</p>
| 15,545 |
<p>I've had the Ender 5 Pro, as is, for 3 months.</p>
<p>After I tried a cheap PLA filament (maybe too cheap), it clogged the nozzle. I cleaned it, but any other filament I have would have similar problems from then on. After some days doing test prints, it clogged again. This time, I heated it up to 240 ºC, I un... | <p>Without images of the problem it is difficult to diagnose, but, the described symptoms sounds as if the nozzle is too close to the bed. If the nozzle is too close to the bed, and the extruder not strong enough, the filament flow is very limited due to pressure caused by a very small opening between the nozzle and th... | <p>Clearly you're having an extrusion problem. Extrusion problems usually come either from a clogged nozzle (as @Adam S. said) or from the extruder it self. To determine where the problem is located I would first do a flow rate test using <a href="https://www.youtube.com/watch?v=lWBkPIXTOlo&feature=emb_logo" rel="n... | 1,660 |
<p>I would like to specify a constraint which is another type with a generic argument.</p>
<pre><code>class KeyFrame<T>
{
public float Time;
public T Value;
}
// I want any kind of Keyframe to be accepted
class Timeline<T> where T : Keyframe<*>
{
}
</code></pre>
<p>But this cannot be done i... | <p>Read about this from <a href="http://blogs.msdn.com/ericlippert/archive/2008/05/19/a-generic-constraint-question.aspx" rel="nofollow noreferrer">Eric Lippert's blog</a>
Basically, you have to find a way to refer to the type you want without specifying the secondary type parameter. </p>
<p>In his post, he shows this... | <p>If the type T that <code>Timeline<T></code> represents is the same as the type <code>KeyFrame<T></code> represents you can just go with:</p>
<pre><code>class Timeline<T>
{
List<KeyFrame<T>> _frames = new List<KeyFrame<T>>(); //Or whatever...
...
}
</code></pre>
<p>If ... | 18,063 |
<p>By "fixed vector" I mean a static list of values, like 1 through 24.</p>
<p>The current query looks like this (simplified)</p>
<pre><code>SELECT Period, Profit FROM Projections
</code></pre>
<p>But the data is "sparse" — so there's not a row for every period.</p>
<p>What query will give me a row for peiods... | <p>Any time you allow a user to enter data into a query string like this you are vulnerable to SQL injection and it should be avoided like the plague!</p>
<p>You should be very careful how you allow your searchStrings[] array to be populated. You should always append variable data to your query using parameter object... | <p>Yes, they could still inject items, without spaces it might not do much, but it is still a vulnerability.</p>
<p>In general blindly adding user input to a query is not a good idea.</p>
| 48,759 |
<p>In Lua, using the = operator without an l-value seems to be equivalent to a print(r-value), here are a few examples run in the Lua standalone interpreter:</p>
<pre><code>> = a
nil
> a = 8
> = a
8
> = 'hello'
hello
> = print
function: 003657C8
</code></pre>
<p>And so on...</p>
<p>My question is : wh... | <p>Quoting the <a href="http://www.lua.org/manual/5.1/lua.html" rel="noreferrer">man page</a>:</p>
<blockquote>
<p>In interactive mode ... If a line starts with '=', then lua displays the values of all the expressions in the remainder of the line. The expressions must be separated by commas.</p>
</blockquote>
| <p>Assignment isn't an expression that returns something in <code>Lua</code> like it is in <code>C</code>.</p>
| 17,305 |
<p>I have a webpage that redirects to another webpage like this:</p>
<pre><code>http://www.myOtherServer.com/Sponsor.php?RedirectPage=http://mylink.com/whereIwasgoingtogo.html
</code></pre>
<p>Then the Sponsor.php page displays an ad with a link saying "Continue to your page" that links to the passed in RedirectPage.... | <p>It's a big problem. If I send you a link that looks like this:</p>
<pre><code> http://cnn.com/sponsor.php?redirectpage=http://bit.ly/jh2l14
</code></pre>
<p>You're going to think "Oh, CNN, that's a legit site", and you'll open it and click the 'Continue to Your Page' link. And then you'll be on one of the nastie... | <p>This is definitely a security risk. You should avoid using in-URL variables when security is involved.</p>
<p>While nothing is totally secure, this is a much better way of handling this issue: <a href="http://www.webmasterworld.com/forum88/2910.htm" rel="nofollow noreferrer">http://www.webmasterworld.com/forum88/2... | 25,885 |
<p>Why does the JavaScript function <code>encodeURIComponent</code> encode spaces to the hex Unicode value <code>%20</code> instead of <code>+</code>. Should URI parameters not spaces to <code>+</code>?
</p>
| <p>Spaces encode to %20, I believe that's their ASCII character code. </p>
<p>However, developers have taken a shine to encoding spaces to + because it generates URLs that are readable and typeable by human beings.</p>
| <p>As a general rule, file paths should have spaces encoded as %20. Query string parameters should have spaces encoded as +.</p>
<p>For example: <a href="http://www.example.com/a%20file.ext?name=John+Doe" rel="nofollow noreferrer">http://www.example.com/a%20file.ext?name=John+Doe</a></p>
| 12,688 |
<p>Anyone know of a control for asp.net that can achieve this either server or ajax.</p>
<p>I have a hierarchy of school, division and programme area. Unfortunately this hierarchy has complexities such that a programme area can appear in more than one school. </p>
<p>As it is for reporting I would like to give the en... | <p>The <a href="http://www.asp.net/ajax/" rel="nofollow noreferrer">ASP.NET AJAX Control Toolkit</a> has a cascading drop down list that uses a web service interface to determine what data will populate the next drop down list of data. I could easily see you leveraging this control so that your web service either retur... | <p>the options that show in the drop-down-list are controlled by the XML backing the control. If you include all possible values under the 'ANY' selectbox they will show in the control.</p>
<p>The real answer should be how much data and how many possible combinations will there be? If the number is minimal and can be ... | 39,031 |
<p>One of the biggest advantages of object-oriented programming is encapsulation, and one of the "truths" we've (or, at least, I've) been taught is that members should always be made private and made available via accessor and mutator methods, thus ensuring the ability to verify and validate the changes.</p>
<p>I'm cu... | <p>It depends. This is one of those issues that must be decided pragmatically.</p>
<p>Suppose I had a class for representing a point. I could have getters and setters for the X and Y coordinates, or I could just make them both public and allow free read/write access to the data. In my opinion, this is OK because the c... | <p>Certainly it makes a difference whether your writing internal code or code to be used by someone else (or even by yourself, but as a contained unit.) Any code that is going to be used externally should have a well defined/documented interface that you'll want to change as little as possible. </p>
<p>For internal ... | 12,491 |
<p>Multimap essentially has groups of data sorted by the key. I want a method by which I could access these individual groups and get their aggregate values.
For example, in a <code>std::multimap< string, int ></code> I store </p>
<pre><code>{"Group1", 1},
{"Group1", 2},
{"Group1", 3},
{"Group2", 10},
{"Gro... | <pre><code>pair<Iter, Iter> range = my_multimap.equal_range("Group1");
int total = accumulate(range.first, range.second, 0);
</code></pre>
<p>Is one way.</p>
<p><strong>Edit:</strong></p>
<p>If you don't know the group you are looking for, and are just going through each group, getting the next group's range c... | <p>Not a multimap answer, but you can do things like the following if you so choose.</p>
<pre><code>#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <boost/assign/list_of.hpp>
#include <boost/foreach.hpp>
using namespace std;
using namespace boost;
usi... | 30,785 |
<p>In GWT I have to specify what locales are supported in my application. The code get compiled in various files, one for each locale (beside other versions), but I have to give my clients one only URL. This URL is supposed to be a page that should be displayed according to the locale preferred by the browser.
I dont't... | <p>I had the same problem as you, but as I really need to know the current locale (I'm requesting a second server for data that I want to be localizable) I found this class:
<code>com.google.gwt.i18n.client.LocaleInfo#getCurrentLocale()</code>. That should give you what GWT uses currently.</p>
| <p>Unless I am reading the documentation incorrectly I don't think you have to do anything.</p>
<p><a href="http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Internationalization.html#SpecifyingLocale" rel="nofollow noreferrer">GWT and Locale</a></p>
<blockquote>
<p>By making locale ... | 3,742 |
<p>I got this error
Response object error 'ASP 0156 : 80004005' </p>
<p>Header Error </p>
<p>/ordermgmt/updateorderstatus.asp, line 1390 </p>
<p>The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content. </p>
<p>I put Response.Buffer=true;
Sti... | <p>Yes buddies, Its Fixed.Before Response.Buffer ,i included another file.Now i changed it to below the Response.Buffer=True line .Its working now .Thanks</p>
| <p>The first Response.Redirect changes the headers (and probably forces a Flush, because with a redirect, there can be no content). </p>
<p>The second Response.Redirect changes the headers again (probably to the same thing, but that doesn't matter, as the header were written during the Flush())</p>
| 28,473 |
<p>I'm constructing a method to take in an ArrayList(presumably full of objects) and then list all the fields(and their values) for each object in the ArrayList.</p>
<p>Currently my code is as follows:</p>
<pre><code>public static void ListArrayListMembers(ArrayList list)
{
foreach (Object obj in list)
... | <pre><code>foreach (Object obj in list) {
Type type = obj.GetType();
foreach (var f in type.GetFields().Where(f => f.IsPublic)) {
Console.WriteLine(
String.Format("Name: {0} Value: {1}", f.Name, f.GetValue(obj));
}
}
</code></pre>
<p>Note that this code re... | <pre><code> static void ListArrayListMembers(ArrayList list)
{
foreach (object obj in list)
{
Type type = obj.GetType();
foreach (FieldInfo field in type.GetFields(BindingFlags.Public))
{
Console.WriteLine(field.Name + " = " + field.GetValue(obj... | 29,364 |
<p>I posted this message to the Solr mailing list, but I'm trying here too in case there's a Solr expert lurking around.</p>
<p>I am trying to use the regex fragmenter and am having a hard time getting the results I want. I am trying to get fragments that start on a word character and end on punctuation, but for some ... | <p>Try:</p>
<pre><code>\w[^\.!\?]{400,600}[\.!\?]
</code></pre>
<p>You should not need the first square brackets around <code>\w</code></p>
<p>And you should escape the final dot.</p>
<p>And I do not think <code>.*</code> just before another quantifier (<code>{400,600}</code>)is a good idea, hence the <code>.{400,6... | <p>There seems to be a problem if you are using a <code>WordDelimiterFilterFactory</code>. The problem is described here <a href="http://www.mail-archive.com/solr-user@lucene.apache.org/msg30631.html" rel="nofollow">http://www.mail-archive.com/solr-user@lucene.apache.org/msg30631.html</a></p>
<p>As described in the li... | 47,562 |
<p>I'm using @media print in my external css file to hide menus etc. However while printing the little triangle of a dropdownlist still shows. Is there a css setting available to hide it as well and only print the selected item?</p>
| <p>This works in Chrome and Firefox (others may work also)</p>
<pre><code>-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
</code></pre>
| <p>This worked for me in IE6. I didn't try other browsers</p>
<p><a href="http://weblogs.asp.net/bleroy/archive/2005/08/09/how-to-put-a-div-over-a-select-in-ie.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/bleroy/archive/2005/08/09/how-to-put-a-div-over-a-select-in-ie.aspx</a></p>
| 19,505 |
<h2>Context</h2>
<ul>
<li>Take a look at Wordle: <a href="http://www.wordle.net/" rel="noreferrer">http://www.wordle.net/</a></li>
<li>It's much better looking than any other word cloud generators I've seen</li>
<li>Note: the source is not available - read the FAQ: <a href="http://www.wordle.net/faq#code" rel="norefer... | <p>I'm the creator of Wordle. Here's how Wordle actually works:</p>
<p>Count the words, throw away boring words, and sort by the count, descending. Keep the top N words for some N. Assign each word a font size proportional to its count. Generate a Java2D Shape for each word, using the Java2D API.</p>
<p>Each word "wa... | <p>There is a pretty nice little JavaScript library made by Tim Dream:</p>
<p><a href="https://github.com/timdream/wordcloud2.js/blob/gh-pages/API.md" rel="nofollow noreferrer">https://github.com/timdream/wordcloud2.js/blob/gh-pages/API.md</a></p>
<p>It can create a word cloud on a canvas or with HTML tags with a lot... | 44,556 |
<p>I've been discussing a code style issue with a friend. We have a series of packages that implement an interface by returning a specific type of value via a named subroutine. For example:</p>
<pre><code>package Foo::Type::Bar;
sub generate_foo {
# about 5-100 lines of code
return stuff here;
}
</code></pre>
... | <p>I think you should upgrade to Moose if you are asking these questions. There you'll be able to define your interface by creating a role or class with appropriate abstract methods.</p>
<p>I agree with you that doing this can add valuable information. In Java there is the concept of a "marker interface," which is a... | <p>In keeping with pragmatical spirit of Perl, I would only add base class if it was valuable by itself. Adding a collection of empty functions is not much fun.</p>
<p>On the other hand, the base class can be useful as a place to keep your POD. And to define some constants... Do you have Foo::Type.pm? If you do, and d... | 39,955 |
<p>I have this as Main</p>
<pre><code>int[] M ={ 10, 2, 30, 4, 50, 6, 7, 80 };
MyMath.Reverse(M);
for (int i = 0; i < M.Length; i++)
Console.WriteLine(M[i].ToString() + ", ");
</code></pre>
<hr>
<p>After I created the class MyMath I made the Reverse method </p>
<pre><code>public int Reverse(Array M)
{
... | <p>Working from your </p>
<pre><code>public static int Reverse(Array M)
{
return Reverse(M);
}
</code></pre>
<p>You have 2 problems.</p>
<ol>
<li>Reverse(M) looks like the same function that you're in, so you're calling your new function, which calls itself, which calls itself, etc., resulting in the stack overf... | <p>You need to pass you array as a reference. In C#, you do that by using the keyword 'ref' when declaring your parameters.</p>
<p>What you are currently doing is basically reversing a copy of your array which is never passed back to the caller.</p>
| 35,242 |
<p>I need to quickly build a parser for a very simplified version of a html-like markup language in Java. In python, I would use pyparsing library to do this. Is there something similar for Java? Please, don't suggest libraries already out there for html parsing, my application is a school assignment which will demonst... | <p>Another good parser generator is <a href="http://www.antlr.org/" rel="noreferrer" title="ANTLR">ANTLR</a>, that might be what you're looking for.</p>
| <p>There are quite a number choices for stringhandling in java.
Maybe the very basic <code>java.util.Scanner</code> and <code>java.util.StringTokenizer</code> Classes are helpfull for you?</p>
<p>Another good choice is maybe <code>the org.apache.commons.lang.text</code> library.
<a href="http://commons.apache.org/lan... | 42,451 |
<p>I've run across this sort of thing on multiple websites and was wondering what it was called, does anyone know? <a href="http://twitpic.com/h77i/full" rel="nofollow noreferrer" title="twitpic.com">Here's a screenshot.</a></p>
| <p>I don't see anything obviously out of place. If you're working with a very large database, you could try increasing your heap size by using the <code>-Xmx n</code> option in your JVM invocation. This is usually not the best solution - only do with this when you know your working set size is actually bigger than th... | <p>How many items are in your result set? If there are enough records, than you will use up all your memory, as there is nothing garbage collected in this case as you are doing an addDocument to the writer, which will hold a reference to all the documents you are creating.</p>
| 26,708 |
<p>Whenever I use the signal/slot editor dialog box, I have to choose from the existing list of slots. So the question is how do I create a custom named slot?</p>
| <p>This does seem to be possible in the version of Qt Designer 4.5.2, but it <em>can't</em> be done from the Signal/Slot Editor dock-widget in the main window.</p>
<p>This is what worked for me</p>
<ol>
<li>Switch to <a href="http://doc.qt.io/qt-4.8/designer-connection-mode.html" rel="noreferrer">Edit Signals/Slots</... | <p>click the widget by right button</p>
<p>promote the widget into a class you defined</p>
<p>click the widget by right button again</p>
<p>you will see that signal and slot is editable</p>
| 20,004 |
<p>I have an App that will send authenticated emails using System.Net.Mail and System.Net.NetworkCredential my question is how should I store the password that is needed to create a NetworkCrednetial object?</p>
<p>The application doesn't have a login but I could setup an option that allows the user to enter their ema... | <p>To store a username and password (in Windows) use the <a href="https://stackoverflow.com/search?q=dpapi">DPAPI</a>. The .Net interface to it is the <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.protecteddata.aspx" rel="nofollow noreferrer">ProtectedData</a> and ProtectedMemory classes... | <p>You could also use the Win32 Credentials UI - there exist a number of samples for using this from .NET, including <a href="http://msdn.microsoft.com/en-us/library/aa302353.aspx" rel="nofollow noreferrer">this one on MSDN</a>.</p>
| 33,189 |
<p>What is the correct way to get the process size on <code>Solaris, HP-UX</code> and <code>AIX</code>? Should we use <code>top</code> or <code>ps -o vsz</code> or something else?</p>
| <p>The exact definitions of <code>vsize</code>, <code>rss</code>, <code>rprvt</code>, <code>rshrd</code>, and other obscure-looking abbreviations vary from OS to OS. The manual pages for the <code>top</code> and <code>ps</code> commands will have some sort of description, but all such descriptions are simplified great... | <p>Yes, you are right to lock at the VSZ.</p>
<p><code>ps u</code> will give you the VSZ and RSS, which are the virtual memory size and resident set size. The RSS is how much physical memory has been allocated to the process, and the VSZ is the virtual memory size of the process. If you have several copies of a prog... | 2,351 |
<p>I'm building an ORM library with reuse and simplicity in mind; everything goes fine except that I got stuck by a stupid inheritance limitation. Please consider the code below:</p>
<pre><code>class BaseModel {
/*
* Return an instance of a Model from the database.
*/
static public function get (/* v... | <p>in short. this is not possible. in php4 you could implement a terrible hack (examine the <code>debug_backtrace()</code>) but that method does not work in PHP5. references:</p>
<ul>
<li><h1><a href="http://bugs.php.net/bug.php?id=30423" rel="noreferrer">30423</a></h1>
</li>
<li><h1><a href="http://bugs.php.net/bug.ph... | <p>The problem is not a language limitation, it is your design. Never mind that you have classes; the static methods belie a procedural rather than object-oriented design. You're also using global state in some form. (How does <code>get_row_from_db_as_array()</code> know where to find the database?) And finally it ... | 35,856 |
<p>Printing supports, either complete, or partially from PVA have not always resulted in successful prints according to my experience with the filament (used in a dual extruder Ultimaker 3 extended). But, when it works well, the surface finish is perfect as there is no gap between the PVA and PLA.</p>
<p>From my experi... | <p>PETG works as support material for PLA, see video</p>
<p><div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/3lZlyzYJd-I?start=12"></iframe>
</div></div></p>
<p>In theory, PLA printed on top of PETG will be fine because PETG softens a... | <p>While it is most certainly possible to use PETG as a support material, you might run into some trouble when the first layer of PETG goes down on top of the PLA. Since PETG prints so much hotter than PLA, the PETG may bond too aggressively to the PLA causing it to become very difficult to remove after the print has f... | 1,693 |
<p>I'm having a "minor" stringing issue, where I'm only getting stringing in helpers/support and infill area.</p>
<p>Background: Calibrating printer with 1 roll of PLA. Still getting minimal stringing, but mainly, stringing in helpers/support and infill areas. Tried different temps, but didn't seem to affect ... | <p>If the problem occurs in or immediately following printing of support material, it's probably Cura's <em>Limit Support Retractions</em> option, which defaults to on. This is probably the single worst default Cura has, and it causes all sorts of problems - surface defects, difficult-to-remove support, underextrusion,... | <p>It would be great if you could add an image showing the stringing that occurs on the filled and helper/support part of the print. It's quite difficult to visualise what is happening/your problem.</p>
<p>I would assume that the density/fill of the print will be different for infill versus helper/support parts of the ... | 1,862 |
<p>A while back I was reading the W3C article on '<a href="http://www.w3.org/International/articles/text-reuse/" rel="noreferrer">Re-using Strings in Scripted Content</a>', which contains some useful advice on internationalisation, but which strikes me as at odds iwth the DRY (Don't Repeat Yourself) principle of elimin... | <p>I'd try to keep complete sentences in the language resource. As you said you might need different words in different contexts. But a bigger problem is that the order of sentences might be different in different languages. So building up strings from words can cause problems.</p>
<p>Just store</p>
<pre><code>The pr... | <p>I would suggest using a CMS rather than hardcoding in your textual values to cover localisation.</p>
| 8,054 |
<p>I want to select an option in select tag through the value. - javascript</p>
<pre><code>var selectbox=document.getElementById("Lstrtemplate");
var TemplateName=selectbox.options[selectbox.selectedIndex].text;
</code></pre>
<p>Now i am having the option text in TemplateName, using this i want to update an another ... | <p>Try it like this : </p>
<pre><code>var TemplateName = selectbox.options[selectbox.selectedIndex].value;
</code></pre>
| <p>The sample above (selectobx2.value = selectbox.value) will correlate 2 select elements based on value, from your description I think you want to correlate 2 select elements based on the display value or text property. </p>
<p>Unfortunately there is no shortcut to do this and you need to enumerate the options yourse... | 47,714 |
<pre><code> <my:DataGridTemplateColumn
CanUserResize="False"
Width="150"
Header="{Binding MeetingName, Source={StaticResource LocStrings}}"
SortMemberPath="MeetingName">
</my:DataGridTemplateColumn>
</code></pre>
<p>I have the above column in a Silver... | <p>You can't Bind to Header because it's not a FrameworkElement. You can make the text dynamic by modifying the Header Template like this:</p>
<pre><code>xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
xmlns:dataprimitives="clr-namespace:System.Windows.Controls.Primitives;asse... | <p>I got some solution for the binding. Since you use DataGridTemlateColumn, subclass it and add a property of type Binding named for instance "HeaderBinding". Now you can bind to that property from the XAML. Next, you should propagate the binding to the TextBlock in the DataTemplate of your header. For instance, you c... | 18,276 |
<p>I have a set of Word documents which I want to publish using a PHP tool I've written. I copy and paste the Word documents into a text box and then save them into MySQL using the PHP program. The problem I Have arises from all the non-standard characters that Word documents have, like curly quotes and ellipses ("..."... | <p>A better solution would be to ensure that your database is set-up to support UTF-8 characters. The additional characters available in the extended set should cover all the "non-standard" characters that you're talking about.</p>
<p>Otherwise, if you really must convert these characters into HTML entities, use <a hr... | <p>htmlspecialchars() will get you a long way, but watch out because Word documents are messy.</p>
| 24,220 |
<p>How to, in C# round any value to 10 interval? For example, if I have 11, I want it to return 10, if I have 136, then I want it to return 140. </p>
<p>I can easily do it by hand</p>
<pre><code>return ((int)(number / 10)) * 10;
</code></pre>
<p>But I am looking for an builtin algorithm to do this job, something lik... | <p>There is no built-in function in the class library that will do this. The closest is <a href="http://msdn.microsoft.com/en-us/library/system.math.round.aspx" rel="noreferrer">System.Math.Round()</a> which is only for rounding numbers of types Decimal and Double to the nearest integer value. However, you can wrap you... | <p>Here's how I round to the nearest multiple of any arbitrary factor without converting from integral types to floating-point values. This works for any int from <code>int.MinValue + 1</code> to <code>int.MaxValue</code></p>
<p>I used the <a href="https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero" rel="... | 34,571 |
<p>I'm wanting to save some OpenId fields to a database table, such as</p>
<ul>
<li>OpenId identifier</li>
<li>Full Name</li>
<li>Alias</li>
<li>Email</li>
<li>etc..</li>
</ul>
<p>is there a place that summerizes the datatypes and lengths for all the common schema fields? I know there are custom ones (per provider) .... | <p>An OpenID identifier can technically be as long as a legal URL can be (practically around 2K), but I'd say 150 characters is a good maximum.</p>
<p>Incidentally be <strong>sure</strong> to store the Claimed Identifier as the primary key (or equivalent lookup column) rather than the user-supplied identifier or any o... | <p>See <a href="http://openid.net/specs/openid-simple-registration-extension-1_0.txt" rel="nofollow noreferrer">OpenID Simple Registration Extension 1.0</a>:</p>
<blockquote>
<p>openid.sreg.email: The email address of the End User as specified in
section 3.4.1 of [RFC2822].</p>
</blockquote>
| 45,214 |
<p>Do you know of a good means of learning C++ win32 (not .Net/MFC/ATL/Wx/Qt..) GUI programming ?
A book, a tutorial, an existing project, preferably a hands-on approach with realistic example..
I'm not a beginner, so I don't mind "advanced" starting points..</p>
<p>With thanks.</p>
| <p>Charles Petzolds book is the best.</p>
<p><a href="https://rads.stackoverflow.com/amzn/click/com/157231995X" rel="noreferrer" rel="nofollow noreferrer">Programming Windows</a></p>
| <p>I've learned a lot about win32 GUI from <a href="http://win32assembly.online.fr/tutorials.html" rel="nofollow noreferrer">Iczelion tutorials</a>. They are basically for win32 assembly, so the source code samples are in MASM not C++, but yet the mechanicks of windows GUI described pretty well. And the API itself does... | 26,123 |
<p>I was wondering if there is a good way to hook into the Application_Start of a SharePoint 2007 site when developing a feature? I know I can directly edit the Global.asax file in the site root, but is there a way to do this so that it gets deployed with the feature?</p>
<p>Thanks!</p>
| <p>This is actually possible, but it doesn't involve the Global.asax file.</p>
<p>Many of Microsoft's examples demonstrate wiring code in via the Global.asax, but this is not a best-practices approach when it comes to SharePoint. Ideally, your code should get packaged as a Feature and deployed via WSP (as you already... | <p>My gut feeling on this is that it won't be possible. Application_Start is called by the runtime as the asp.net engine is starting up, so there most likely can't be any way to hook the handler outside of modifying the Global.asax - e.g. the hook must be declarative and persistent as it has to survive the application ... | 14,857 |
<p>Is it possible to <strong>dynamically create and modify images</strong> on a <strong>per pixel level</strong> in JavaScript (on client side)? Or has this to be done with server based languaged, such as PHP? </p>
<p>My use case is as follows:</p>
<ul>
<li>The user opens webpage and loads locally stored image</li>
<... | <p>This has to be done on the server side. One thing you might look at doing is allowing all the editing to go on client side, and then in the end POST the final image (via AJAX) to the server to allow it to return it to you as the correct MIME type, and correctly packed. </p>
| <p>You can imagine a set of JS tools that will allow the user to define what kind of transformation he wants to do, but the final work of transformation MUST be done on a server side. JS on the client side is unable to create a file, for security reason.</p>
| 10,655 |
<p>Hey there, I've got a block of HTML that I'm going to be using repeatedly (at various times during a users visit, not at once). I think that the best way to accomplish this is to create an HTML div, hide it, and when needed take its innerHTML and do a replace() on several keywords. As an example HTML block...</p>
... | <p>It looks like you want to use a template.</p>
<pre><code>//Updated 28 October 2011: Now allows 0, NaN, false, null and undefined in output.
function template( templateid, data ){
return document.getElementById( templateid ).innerHTML
.replace(
/%(\w*)%/g, // or /{(\w*)}/g for "{this} instead of %... | <pre><code>var template = "<div id='sample'><h4>%VAR%</h4><p>Text text %VAR% text</p><p>%VAR%</p><img src="images/%VAR%/1.jpg" /></div>";
var replace = function(temp,replace){
temp = temp.split('%VAR%');
for(var i in replace){
if(typeof temp[i] != 'undefi... | 49,502 |
<p>Why are unsigned integers not CLS compliant?</p>
<p>I am starting to think the type specification is just for performance and not for correctness.</p>
| <p>Not all languages have the concept of unsigned ints. For example VB 6 had no concept of unsigned ints which I suspect drove the decision of the designers of VB7/7.1 not to implement as well (it's implemented now in VB8).</p>
<p>To quote:</p>
<blockquote>
<p><a href="http://msdn.microsoft.com/en-us/library/12a7a7h3.a... | <p>Unsigned integers are not CLS compliant because they're not interoperable between certain languages.</p>
| 2,807 |
<p>I have used Visual Studio for a long time, but one feature I have never used is the macro system. I saw a post where someone mentioned he used macros (no elaboration) so I was wondering is it really worth the time investing in learning how to create macros?</p>
<p>If so, what kind of stuff do you make?</p>
<p>Ther... | <p>Macros are not difficult to learn, and can make your life easier!</p>
<p>For an interesting appllication of macros see this <a href="https://stackoverflow.com/questions/80564/visual-studio-how-to-trigger-an-alarm-when-a-breakpoint-is-hit">question</a></p>
| <p>You use macros to make repetitive tasks easier. That is, if you find yourself doing 5 or 6 individual tasks regularly, then it may be worth converting it to a macro, so that you can do it with a single click of the button.</p>
<p>Other things that might be of interest are a switching to a .h file from a .cpp file, ... | 16,020 |
<p>Integration via Hibernate, Acegi, Spring, Tiles would be superb.</p>
| <p>you can use <a href="http://www.javabb.org/" rel="nofollow noreferrer">JavaBB</a></p>
| <p>simply compare them <a href="http://www.forum-software.org/forum-comparator/javabb-vs-jforum-vs-mvn-forum-vs-yazd" rel="nofollow noreferrer">JavaBB vs JForum vs MVN Forum vs Yazd</a>.</p>
<p>My personal choice would be, however, <a href="http://www.forum-software.org/jforum/review" rel="nofollow noreferrer">JForum<... | 38,275 |
<p>Just wondering what the difference between MFC control messages prefixed with the following is:</p>
<pre><code>LVN (e.g. LVN_ITEMCHANGED)
HDN (e.g. HDN_TRACK)
NM (e.g. NM_HOVER)
</code></pre>
<p>Also, I am using a ListControl and trapping when the user clicks on an item using the NM_CLICK message. I also want to t... | <p>For change in selection, you need to handle the LVN_ITEMCHANGED notification:</p>
<pre><code>NMLISTVIEW & nm = *(NMLISTVIEW *) pnmh;
if ( (nm.uNewState ^ nm.uOldState) & LVIS_SELECTED)
{
// nm.iItem was selected or deselected
if (!m_internalUIChange)
{
// see below
}
}
</code></pre>... | <ul>
<li>LVN = ListView Notification</li>
<li>HDN = HeaDer control Notification</li>
<li>NM = er..um.. "Notification for Mouse" ?</li>
</ul>
| 32,337 |
<p>I'm trying to link a Qt application with its libraries and the linker (MinGW) spews hundreds of lines like the following, and I am unsure how to proceed.</p>
<pre>
cpp: undefined reference to `_Unwind_SjLj_Register'
c:/qt/lib/libQtCore.a(qcoreapplication_win.o)(.text+0x29d):qcoreapplication_win.
cpp: undefined r... | <p>I don't know... but to me, spewing stuff about Unwind suggests that you have a mismatch between whether the library is compiled with exceptions and your application is compiled with exceptions.</p>
<p>If you want exceptions, make sure you have enabled them by adding the following line in your qmake file:</p>
<pre>... | <p>2 possible reasons that i know of:</p>
<ol>
<li>if you try to link gcc4 libraries with a gcc3 linker. </li>
<li>You need the <code>-lstdc++</code> flag to the end of the compile command</li>
</ol>
| 24,277 |
<p>I have a method that periodically (e.g. once in every 10 secs) try to connect to a server and read some data from it. The server might not be available all the time. If the server is not available the method throws an exception.</p>
<p>What would be the best way to implement a wrapper method that doesn't throw an e... | <p>Keep track of when the last time you successfully reached the server was. If the server throws an exception, catch it and compare to the last time you reached the server. If that time is more than a minute, rethrow the exception.</p>
| <p>You could have a retry count, and if the desired count (6 in your case) had been met then throw an exception</p>
<pre><code>int count = 0;
CheckServer(count);
public void CheckServer(count) {
try
{
// connect to server
}
catch(Exception e)
{
if(count < MAX_ATTEMPTS) {
// wait 10 seconds
CheckServer(... | 15,066 |
<p>Do you know any good tools for nicely formatting messy php code? Preferably a script for Aptana/Eclipse, but a standalone tool will do too.</p>
| <p><a href="http://www.waterproof.fr/products/phpCodeBeautifier/" rel="noreferrer">PHP Code Beautifier</a> is a useful free tool that should do what you're after, although their <a href="http://www.waterproof.fr/products/phpCodeBeautifier/download.php" rel="noreferrer">download page</a> does require an account to be cr... | <p>I've been having a lot of trouble finding a decent free formatter for PHP as well, there are many online and command-line tools but they just don't seem to work for some reason, the results are all still full of bad indenting with combinations of tabs and spaces, and they never get the braces the way you want them!<... | 18,029 |
<p>I need to upload some data to a server using HTTP <code>PUT</code> in python. From my brief reading of the urllib2 docs, it only does HTTP <code>POST</code>. Is there any way to do an HTTP <code>PUT</code> in python?</p>
| <p>I've used a variety of python HTTP libs in the past, and I've settled on <a href="https://requests.readthedocs.io/" rel="nofollow noreferrer">requests</a> as my favourite. Existing libs had pretty useable interfaces, but code can end up being a few lines too long for simple operations. A basic PUT in requests look... | <p>A more proper way of doing this with <code>requests</code> would be:</p>
<pre class="lang-py prettyprint-override"><code>import requests
payload = {'username': 'bob', 'email': 'bob@bob.com'}
try:
response = requests.put(url="http://somedomain.org/endpoint", data=payload)
response.raise_for_status()
except... | 13,713 |
<p>How can I create EPS files in C#? Are there any opensource libraries available or do I have to resort to <a href="http://www.adobe.com/devnet/postscript/pdfs/5002.EPSF_Spec.pdf" rel="noreferrer">the spec</a> and do it by hand?</p>
| <p><code>.bashrc</code> only gets read when a shell starts; it won't affect Carbon Emacs. Instead, use <code>setenv</code> in your <code>.emacs</code>:</p>
<pre><code>(setenv "PYTHONPATH" "PATH_STRING_HERE")
</code></pre>
<p>You can set <code>PYTHONPATH</code> for the entire Mac OS session, by adding it to <code>~/.M... | <p>In order not to manually copy paste:</p>
<pre><code>(setenv "PYTHONPATH" (shell-command-to-string "$SHELL --login -c 'echo -n $PYTHONPATH'"))
</code></pre>
| 30,104 |
<p>So I know that autocommit commits every sql statement, but do updates to the database go directly to the disk or do they remain on cache until flushed? </p>
<p>I realize it's dependent on the database implementation.</p>
<p>Does auto-commit mean
a) every statement is a complete transaction AND it goes straight t... | <p>Auto-commit simply means that each statement is in its own transaction which commits immediately. This is in contrast to the "normal" mode, where you must explicitly <code>BEGIN</code> a transaction and then <code>COMMIT</code> once you are done (usually after several statements).</p>
<p>The phrase "auto-commit" h... | <p>It's impossible to guarantee that commits are atomic, so modern databases use two-phase or three phase commit strategies. See <a href="http://en.wikipedia.org/wiki/Atomic_commit" rel="nofollow noreferrer">Atomic Commit</a></p>
| 26,292 |
<p>Hey everyone, I am researching a project where we would need to keep a value encrypted from the client all the way to a black box system without decrypting it at any point in between. We are using SSL between the browser and web server, but the values are automatically decrypted at the web server, which is what we ... | <p>you'll want to take a look at <a href="http://en.wikipedia.org/wiki/Public-key_cryptography" rel="nofollow noreferrer">public key encryption</a>. SSL protects your session (browser <-> server) but not the full transport. i'd suggest encrypting your data once it's received from the client, then sending the encrypt... | <p>The black box system, by definition, can't decrypt the data unless it was built to do that. I'll suggest discussing the problem with the developers of the black box system.</p>
| 25,174 |
<p>How do you programmatically find the number of hosts that a netmask supports.</p>
<p>Eg, If you have a /30 , how do you find how many IP's are in it without using a lookup table?</p>
<p>Preferably would be able to work with the "/" notation, rather than 255.xxx.xxx.xxx notation.</p>
| <p>Here's the formula: 2 ^ (32 - netmask) - 2 where netmask is a bit count as you've shown in the Cisco notation above. So a network with a /30 mask has 2 usable addresses.</p>
<p>The lowest network number always represents the network segment itself and the highest is always the broadcast ... this leads to the -2 a... | <p><a href="http://www.unixwiz.net/techtips/netmask-ref.html" rel="nofollow noreferrer">http://www.unixwiz.net/techtips/netmask-ref.html</a></p>
<p>That will provide you with all of the logic you need to determine what you need to do.</p>
| 12,422 |
<p>I'm looking to try out JRuby and JRuby on Rails. I'm having trouble finding information on what's difference between JRuby on Rails and Ruby on Rails. </p>
<p>What's the differences I need to look out for?</p>
| <p>JRuby is the Ruby implementation that runs on a JVM whereas Matz's Ruby is a C implementation. </p>
<p>Key features to note are: </p>
<ol>
<li>JRuby runs on Java VM's and it's either compiled or interpreted down to Java byte code.</li>
<li>JRuby can integrate with Java code. If you have Java class libraries (.jar'... | <p>mostly it should work the same. in jRoR you can access stuff you wouldn't have in RoR. Usually its mainly a deployment concern. </p>
<p>However, if your RoR app uses native libraries that don't have an equivalent that runs on the JVM, that can be a pain. However most libs have a non native version available (at lea... | 18,269 |
<p>I would like to display an RTF document in an SWT (actually Eclipse RCP) application.</p>
<p>I know there is a Swing widget for displaying and editing RTF text, but it is Swing and quite alien in look and feel when used in the otherwise platform (not to mention that to the last of my knowledge it did not display im... | <p>Actuall, I've just found another widget that is quite promising atm:</p>
<p><a href="http://onpositive.com/richtext" rel="nofollow noreferrer">http://onpositive.com/richtext</a></p>
| <p>I'm not sure of a way to do it without using ActiveX. If you do go this direction you might want to look into the <a href="http://www.alphaworks.ibm.com/tech/swtactivexcontainer?open&S_TACT=106AH21W&S_CMP=AWRSSJAV" rel="nofollow noreferrer">IBM Container for ActiveX Documents</a>, which is supposed to allow... | 10,741 |
<p>I'm looking for a method to assign variables with patterns in regular expressions with C++ .NET
something like </p>
<pre><code>String^ speed;
String^ size;
</code></pre>
<p>"command SPEED=[speed] SIZE=[size]"</p>
<p>Right now I'm using IndexOf() and Substring() but it is quite ugly</p>
| <pre><code>String^ speed; String^ size;
Match m;
Regex theregex = new Regex (
"SPEED=(?<speed>(.*?)) SIZE=(?<size>(.*?)) ",
RegexOptions::ExplicitCapture);
m = theregex.Match (yourinputstring);
if (m.Success)
{
if (m.Groups["speed"].Success)
speed = m.Groups["speed"].Value;
if (m.Groups["size"].... | <p>If you put all the variables in a class, you can use reflection to iterate over its fields, getting their names and values and plugging them into a string.</p>
<p>Given an instance of some class named InputArgs:</p>
<pre><code>foreach (FieldInfo f in typeof(InputArgs).GetFields()) {
string = Regex.replace("\\[... | 12,414 |
<p>I am going to be starting up a new project at work and want to get into unit testing. We will be using Visual Studio 2008, C#, and the ASP.NET MVC stuff. I am looking at using either NUnit or the built-in test projects that Visual Studio 2008 has, but I am open to researching other suggestions. Is one system better ... | <p><a href="https://stackoverflow.com/questions/92869/nunit-vs-visual-studio-2008s-test-projects-for-unit-testing/92900#92900">Daok</a> named all the pro's of Visual Studio 2008 test projects. Here are the pro's of NUnit.</p>
<ul>
<li>NUnit has a mocking framework.</li>
<li>NUnit can be run outside of the
IDE. This can... | <p>I would prefer to use MS's little test framework, but for now am sticking with NUnit. The problems with MS's are generally (for me)</p>
<ul>
<li>Shared "tests" file (pointless) that must be <em>maintained</em></li>
<li>Tests lists cause conflicts with multiple developers / VCSs</li>
<li>Poor integrated UI... | 11,840 |
<p>Which approach do you all think is better?</p>
| <p>Next to each field, highlighting each field in a distinctive color or with an easily distinguishable mark, so it's self evident where the problems are, especially on a long form. Also place a help icon next to each failure providing more information in case it's needed by some users. In addition, do not forget to pr... | <p>It will always depend on the situation, but...</p>
<p>I prefer to do a non-obtrusive indicator (* perhaps) beside each field and show more detailed messages or a summary message at the top (or bottom) of the form with longer forms.</p>
<p><strike>If the form is shorter, you can probably get away without providing ... | 14,140 |
<p>Is there a way to know and output the stack size needed by a function at compile time in C ?
Here is what I would like to know :</p>
<p>Let's take some function :</p>
<pre><code>void foo(int a) {
char c[5];
char * s;
//do something
return;
}
</code></pre>
<p>When compiling this function, I would l... | <p>Linux kernel code runs on a 4K stack on x86. Hence they care. What they use to check that, is a perl script they wrote, which you may find as scripts/checkstack.pl in a recent kernel tarball (2.6.25 has got it). It runs on the output of objdump, usage documentation is in the initial comment.</p>
<p>I think I alread... | <p>Not in general. The Halting Problem in theoretical computer science suggests that you can't even predict if a general program halts on a given input. Calculating the stack used for a program run in general would be even more complicated. So: no. Maybe in special cases.</p>
<p>Let's say you have a recursive function... | 15,324 |
<p>Using jquery how do I focus the first element (edit field, text area, dropdown field, etc)
in the form when the page load?</p>
<p>Something like:</p>
<pre><code>document.forms[0].elements[0].focus();
</code></pre>
<p>but using jquery.</p>
<p>Another requirement, don't focus the first element when the form has cl... | <pre><code>$('form:not(.filter) :input:visible:enabled:first').focus()
</code></pre>
<p>This will select the first visible input element (<code><input /></code>, <code><select></code>, <code><textarea></code>) that doesn't have the class <code>filter</code> in it.</p>
| <p>I had some problems with jQuery dialogs which were invisible on the page but were still selected by the selector:</p>
<pre><code>$(":text:visible:enabled:first").focus();
</code></pre>
<p>After alot of playing around I finally came up with a solution that excluded all inputs in divs with a class of .dialog by addi... | 33,564 |
<p>I have a requirement to hide a process in Task Manager. It is for Intranet scenario. So, everything is legitimate. :) </p>
<p>Please feel free to share any code you have (preferably in C#) or any other techniques or any issues in going with this route.</p>
<p><strong>Update1</strong>: Most of the users have admin ... | <p>There is no supported way to accomplish this. The process list can be read at any privilege level. If you were hoping to hide a process from even Administrators, then this is doubly unsupported.</p>
<p>To get this to work, you would need to write a kernel mode rootkit to intercept calls to <a href="http://msdn.micr... | <p>to stop the process from being permanently killed, have the first thing the process does is to call 'atexit()' and have the atexit() function start the process</p>
| 22,780 |
<p>I know that <code>M73 P19</code> means "Set completion progress to 19%", and I suspect that <code>M73 R42</code> means "Set remaining time to 42 minutes", but what is <code>M73 Q17 S43</code>? I can't find description of such syntax.</p>
<p>The command is seen in <code>.gcode</code> files produced by PrusaSlicer.</... | <p>The <a href="https://reprap.org/wiki/G-code#M73:_Set.2FGet_build_percentage" rel="nofollow noreferrer"><code>M73</code> Set/Get build percentage G-code</a> is only defined for a selected few printer firmwares.</p>
<p>As you suspected, next to <code>M73 P19</code> (tell the firmware at what completage percentage the... | <p>The tooltip for "Supports remaining times" under <code>Printer Settings -> General -> Firmware</code>in PrusaSlicer quotes:</p>
<pre><code>Emit M73 P[percent printed] R[remaining time in minutes] at 1 minute intervals
into the G-code to let the firmware show accurate remaining time.
As of now only the Prusa i... | 1,509 |
<p>I need to create a multi-dimensional (nested) hashtable/dictionary so that I can use syntax like </p>
<pre><code>val = myHash("Key").("key")
</code></pre>
<p>I know I need to use Generics but I can't figure out the correct syntax using VB in ASP.NET 2.0, there are plenty of c# examples on the net but they aren't h... | <p>OK, I'm better at C# than vb.net, but I'll give this a go....</p>
<pre><code>Dim myHash as Dictionary(Of string, Dictionary(Of string, Integer));
</code></pre>
| <p>There's also the System.Collections.Specialized.StringDictionary(Of T) collection, which is just a pre-defined Dictionary(Of String, T).</p>
<p>And the syntax to use either the normal Dictionary or the StringDictionary would look like this:</p>
<pre><code>val = myHash("key")("key")
</code></pre>
<p>Not like this:... | 16,199 |
<p>I have a very simple problem and a solution that will work, but I'm looking for a simpler one.</p>
<p>I'd like to prevent rows from being added to a database when multiple values equal existing values. For example, if a2=a1 AND b2=b1 then the data gets rejected. If only a2=a1 or only b2=b1 it is allowed. Basical... | <p>Create a unique index for the columns that you want to be unique.</p>
<p>Eg:</p>
<pre><code>CREATE UNIQUE INDEX index_name ON table(col1, col2);
</code></pre>
<p>See the MySQL <a href="http://dev.mysql.com/doc/refman/5.0/en/create-index.html" rel="nofollow noreferrer">Create index manual</a>.</p>
| <p>You want to use the MySQL <code>CONSTRAINT</code> syntax when creating your table (or alter an existing table).</p>
| 44,544 |
<p>I'm still trying to get my head around LINQ and accessing a SQL Database.</p>
<p>I was always taught that you should only have execute permissions of stored procedures to your data.</p>
<p>You should never have select / insert / update / delete.</p>
<p>(This is because of performance and security)</p>
<p>To get ... | <p>1) We're programmers, not DBA fascists. If your requirements state that the database must be locked down 100%, Linq is not for you. I'm not a DBA, so I believe that most of the performance/security hype is just that. Linq is for me.</p>
<p>2) You can do joins with linq.</p>
<p><em>@Philippe</em>: Linq automati... | <p>I'm very much in agreement with Jeff Atwood on the "Stored Procedures vs. Inline SQL/LINQ" issue: <a href="https://blog.codinghorror.com/who-needs-stored-procedures-anyways/" rel="nofollow noreferrer">Who Needs Stored Procedures, Anyways?</a>.</p>
<p>I'm confused as to why you'd even want to perform a JOIN if you'... | 7,216 |
<p>On a recent Java project, we needed a free Java based real-time data plotting utility. After much searching, we found this tool called the <a href="http://www.epic.noaa.gov/java/sgt/" rel="noreferrer">Scientific Graphics Toolkit or SGT</a> from NOAA. It seemed pretty robust, but we found out that it wasn't terribl... | <p>I've had success using <a href="http://www.jfree.org/jfreechart/" rel="noreferrer">JFreeChart</a> on multiple projects. It is <em>very</em> configurable. JFreeChart is open source, but they charge for the <a href="http://www.jfree.org/jfreechart/devguide.html" rel="noreferrer">developer guide</a>. If you're doing so... | <p>You might want to check out JMathPlot</p>
| 2,832 |
<p>I am writing Eclipse plugins, and frequently have a situation where a running Job needs to pause for a short while, run something asynchronously on the UI thread, and resume.</p>
<p>So my code usually looks something like:</p>
<pre class="lang-java prettyprint-override"><code>Display display = Display.getDefault... | <p>I think the Container above is the "right" choice. It could be also be genericized for type safety. The quick choice in this kind of situation is the final array idiom. The trick is that a any local variables referenced from the Runnable must be final, and thus can't be modified. So instead, you use a single element... | <p>Well, if it's sync you can just have a value holder of some kind external to the <code>run()</code> method.</p>
<p>The classic is:</p>
<pre><code>final Container container = new Container();
Display display = Display.getDefault();
display.syncExec(new Runnable()
{
public void run()
{
container.setValue("fo... | 46,227 |
<p>I'm trying to set up a small app to experiment with NHibernate in visual studio but I'm not getting far. </p>
<p>The error I get is: "Could not find the dialect in the configuration".</p>
<p>I've tried specifying settings in both app.config and hibernate.cfg.xml but neither seems to work. These files are in the sa... | <p>ok thanks everyone, I've got it sorted now. It seems I needed to call cfg.Configure() to process hibernate.cfg.xml ... once I did this there were a few other errors but they were all quite logical to fix up with error messages that made good sense.</p>
<p>Here's the initialization code that worked.</p>
<pre><code>... | <blockquote>
<p>cfg.Configure();</p>
</blockquote>
<p>really helped...Thanks a lot.
Earlier i was using </p>
<blockquote>
<p>cfg.AddAssembly(Assembly.GetCallingAssembly());</p>
</blockquote>
<p>without success</p>
| 49,757 |
<p>I want to check for empty arrays. Google gave me varied solutions but nothing worked. Maybe I am not applying them correctly.</p>
<pre><code>Function GetBoiler(ByVal sFile As String) As String
'Email Signature
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Se... | <p>As you are dealing with a string array, have you considered Join?</p>
<pre><code>If Len(Join(FileNamesList)) > 0 Then
</code></pre>
| <p>Another solution to test for empty array</p>
<pre><code>if UBound(ar) < LBound(ar) then msgbox "Your array is empty!"
</code></pre>
<p>Or, if you already know that LBound is 0</p>
<pre><code>if -1 = UBound(ar) then msgbox "Your array is empty!"
</code></pre>
<p>This may be faster than join(). (And I didn't ch... | 25,279 |
<p>How do you set a break points in server tags in .aspx pages. e.g.</p>
<pre><code><% dim breakhere =new object() %>
</code></pre>
<p>The web application is running in debug mode with the <code><compilation debug="true" ...</code> in the web.config. But the page says:</p>
<blockquote>
<p>The break poin... | <p>instead of setting the breakpoint directly, you could use</p>
<pre><code><% System.Diagnostics.Debugger.Break();
// more code here...
%>
</code></pre>
<p>Maybe a better suggestion though is to not put inline code in your markup - instead put it in a method in the code-behind file, and then call t... | <p>I havent tried this myself but in ASP (VBScript) you can inject a STOP statement and that will trigger the IDE to break on that line</p>
<p>Example</p>
<pre><code><%
STOP
Dim o as Object = new Object()
%>
</code></pre>
<p>HTH</p>
| 38,715 |
<p>Is there a way to run a one-liner in sas, or do I have to create a file? I'm looking for something like the -e flag in perl.</p>
| <p>My favourite is using the -stdio option</p>
<p>Either:</p>
<pre><code>sas -stdio
</code></pre>
<p>Then start typing. Or ...</p>
<pre><code>echo "proc options; run;" | sas -stdio
</code></pre>
| <p>Never having used sas, what I might try is something like:</p>
<pre><code>echo <insert sas code here> | sas --execute-file -
</code></pre>
<p>Oftentimes applications will let you specify '-' as a file to have it read from STDIN. And 'echo' just prints its arguments out, and the | connects them together.</p>
| 33,922 |
<p>A client of mine has told me the program I made for them won't connect to a SQL server named instance, I have a standard SQL server with no named instance so I'm wondering how I can test this. A named instance connection string look like the one below, could the backslash be were my code fails?</p>
<p>Driver={SQL N... | <p>We have SQL servers with named instances.
Examples: myservername\sql2005.
Backslash is fine, in the conection string server name will be "myservername\sql2005", works 100% fine. You can have a "regular instance" on the same server, will be "myservername"</p>
<p>PS just unit test your function making connection stri... | <p>Scott,
At the risk of stating the obvious, have you tried setting up a named instance in your own development environment? I don't actually know the answer to your question but I've never personally run into a solution where testing the scenario that is failing directly didn't help. At a minimum you ought to be ab... | 39,501 |
<p>The (web based) software I am working on needs a way for users to be able to customize an email template.</p>
<p>I'm familiar with TinyMCE et al. web based wysiwyg editors. However they strive to produce valid (x)html markup, with heavy use of style sheets. All of which won't render nicely in email clients (yes, I'... | <p>Someone's going to post a much better answer than this, but just wanted to make the point that personally I would never store a phone number in any kind of integer field, mainly because:</p>
<ol>
<li>You don't need to do any kind of arithmetic with it, and</li>
<li>Sooner or later someone's going to try to (do some... | <p>I am doing about the same thing, and here's what I did.</p>
<p>I used separate tables for name, address, email, and numbers, each with a NameID column that is a foreign key on everything except the Name table, on which it is the primary clustered key. I used MainName and FirstName instead of LastName and FirstName... | 46,223 |
<p>Sometimes I need to access some servers running Linux (or maybe another Unix-like SO), but I don't know how to verify which <a href="http://en.wikipedia.org/wiki/Linux_distribution" rel="noreferrer">distribution</a> is in use on the server (there are times that even the "responsible" person for the server doesn't kn... | <p><code>lsb_release -i</code> may work for you.</p>
<p>More detail is available with <code>lsb_release -a</code></p>
<p>Some discussion at <a href="http://etbe.coker.com.au/2007/08/30/identifying-the-distribution-of-a-linux-system/" rel="noreferrer">http://etbe.coker.com.au/2007/08/30/identifying-the-distribution-of... | <p>Try <code>uname -a</code></p>
| 33,101 |
<p>I'm trying to run a particular JUnit test by hand on a Windows XP command line, which has an unusually high number of elements in the class path. I've tried several variations, such as:</p>
<pre><code>set CLASS_PATH=C:\path\a\b\c;C:\path\e\f\g;....
set CLASS_PATH=%CLASS_PATH%;C:\path2\a\b\c;C:\path2\e\f\g;....
...... | <p>The Windows command line is very limiting in this regard. A workaround is to create a "pathing jar". This is a jar containing only a <code>Manifest.mf</code> file, whose <code>Class-Path</code> specifies the disk paths of your long list of jars, etc. Now just add this <em>pathing jar</em> to your command line classp... | <p>Have you tried stacking them?</p>
<pre><code>set CLASS_PATH = c:\path
set ALT_A = %CLASS_PATH%\a\b\c;
set ALT_B = %CLASS_PATH%\e\f\g;
...
set ALL_PATHS = %CLASS_PATH%;%ALT_A%;%ALT_B%
</code></pre>
| 24,652 |
<p>I want to add a mailto link on our web page. I want to add a urgent priority to this mail.</p>
| <p>mailto links just doesn't support this feature , sorry.</p>
<p>however, you could use a specific subject and filter it in your inbox</p>
<pre><code><a href="mailto:webmaster@website.com?subject=Urgent">Send a email</a>
</code></pre>
| <p>I guess if such a feature exist it's browser-specific.</p>
<p><a href="http://www.w3.org/TR/WD-html40-970917/htmlweb.html" rel="nofollow noreferrer">from w3's website:</a></p>
<blockquote>
<p>User agents may support MAILTO URL
extensions that are not yet Internet
standards (e.g., appending subject
informat... | 11,738 |
<p>When I open a file for reading in Haskell, I've found that I can't use the contents of the file after closing it. For example, this program will print the contents of a file:</p>
<pre><code>main = do inFile <- openFile "foo" ReadMode
contents <- hGetContents inFile
putStr contents
... | <p>As others have stated, it is because of lazy evaluation. The handle is half-closed after this operation, and will be closed automatically when all data is read. Both hGetContents and readFile are lazy in this way. In cases where you're having issues with handles being kept open, typically you just force the read. ... | <p>The explanation is rather long to be included here. Forgive me for dispensing a short tip only: you need to read about "semi-closed file handles" and "unsafePerformIO".</p>
<p>In short - this behaviour is a design compromise between a semantic clearness and lazy evaluation. You should either postpone hClose until y... | 37,956 |
<p>When my application opens too many windows the taskbar groups them into one button. Each window has its own icon, but the grouping icon is the default "unknown"-kind icon.</p>
<p>How can I set the grouping icon?</p>
| <p>This <a href="http://blogs.msdn.com/oldnewthing/archive/2004/04/08/109775.aspx#124579" rel="nofollow noreferrer">comment from Raymond Chen</a> indicates that the icon is coming from the exe itself, I would suggest using something like <a href="http://hp.vector.co.jp/authors/VA003525/Eindex.htm" rel="nofollow norefer... | <p>Application taskbar group icon can be set in two ways</p>
<ol>
<li><p>Through Project Properties:</p>
<p>Click Project in solution explorer → right click → select properties → select Application tab → go to resoruces and change the default icon and select the newicon and save and build.</p></li>
<li><p>Through Reg... | 26,963 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.