instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I'm looking for a library that has functionality similar to Perl's <a href="http://search.cpan.org/dist/WWW-Mechanize/lib/WWW/Mechanize.pm#SYNOPSIS" rel="noreferrer">WWW::Mechanize</a>, but for PHP. Basically, it should allow me to submit HTTP GET and POST requests with a simple syntax, and then parse the resulting ... | <p>SimpleTest's <a href="http://simpletest.sourceforge.net/en/browser_documentation.html" rel="nofollow noreferrer">ScriptableBrowser</a> can be used independendly from the testing framework. I've used it for numerous automation-jobs.</p>
| <p>If you're on a *nix system you could use shell_exec() with wget, which has a lot of nice options.</p>
| 24,260 |
<p>I'm working on a site which contains a whole bunch of mp3s and images, and I'd like to display a loading gif while all the content loads. </p>
<p>I have no idea how to achieve this, but I do have the animated gif I want to use. </p>
<p>Any suggestions?</p>
| <p>Typically sites that do this by loading content via ajax and listening to the <code>readystatechanged</code> event to update the DOM with a loading GIF or the content.</p>
<p>How are you currently loading your content?</p>
<p>The code would be similar to this:</p>
<pre class="lang-js prettyprint-override"><code>f... | <p>You can use <code><progress></code> element in HTML5. See this page for source code and live demo. <a href="http://purpledesign.in/blog/super-cool-loading-bar-html5/" rel="nofollow">http://purpledesign.in/blog/super-cool-loading-bar-html5/</a></p>
<p>here is the progress element...</p>
<pre><code><progres... | 30,270 |
<p>I am opening a new window from a button using var myWindow = window.open(...). I then want to move that window to the correct location on the screen. I use myWindow.moveTo(10,10) to do this but I get an Access Denied error.</p>
<p>The window I open contains information from another server to the one I am executing ... | <p>You could try to put the information from the other site in an iframe located on the same host that runs the window.open JavaScript. Or maybe even better, get the information server-side and present it directly from your site. Iframes can be trouble.</p>
| <blockquote>
<p>The window I open contains information from another server to the one I am executing on. When it isn't, the window moves correctly. Is this the limitation and is there a way around it?</p>
</blockquote>
<p>Browsers security model have been increasingly restrictive over the last couple of years. What ... | 46,818 |
<p>I have a type (System.Type) of an enum and a string containing enumeration value to set.</p>
<p>E.g. given: </p>
<pre><code>enum MyEnum { A, B, C };
</code></pre>
<p>I have typeof(MyEnum) and "B".</p>
<p>How do I create MyEnum object set to MyEnum.B?</p>
| <pre><code>MyEnum enumValue = (MyEnum)Enum.Parse(typeof(MyEnum), "B");
</code></pre>
<p>You also have a case-insensitive overload.</p>
| <p>You can do this with generics. I created a Utility class to wrap this:</p>
<pre><code>public static class Utils {
public static T ParseEnum<T>(string value) {
return (T)Enum.Parse(typeof(T), value, true);
}
</code></pre>
<p>Then invoked like:</p>
<pre><code>string s = "B";
MyEnum enumValue =... | 20,410 |
<p>Given an arbitrary sequence of points in space, how would you produce a smooth continuous interpolation between them?</p>
<p>2D and 3D solutions are welcome. Solutions that produce a list of points at arbitrary granularity and solutions that produce control points for bezier curves are also appreciated.</p>
<p>Al... | <p>The <a href="http://en.wikipedia.org/wiki/Catmull-Rom_spline#Catmull.E2.80.93Rom_spline" rel="noreferrer">Catmull-Rom spline</a> is guaranteed to pass through all the control points. I find this to be handier than trying to adjust intermediate control points for other types of splines.</p>
<p>This <a href="http://... | <p>Google "orthogonal regression". </p>
<p>Whereas least-squares techniques try to minimize vertical distance between the fit line and each f(x), orthogonal regression minimizes the perpendicular distances.</p>
<p><strong>Addendum</strong></p>
<p>In the presence of noisy data, the venerable <a href="http://en.wikip... | 13,303 |
<p>Is there an easy way to generate an array containing the letters of the alphabet in C#? It's not too hard to do it by hand, but I was wondering if there was a built in way to do this. </p>
| <p>I don't think there is a built in way, but I think the easiest would be </p>
<pre><code> char[] alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
</code></pre>
| <pre><code>char alphaStart = Char.Parse("A");
char alphaEnd = Char.Parse("Z");
for(char i = alphaStart; i <= alphaEnd; i++) {
string anchorLetter = i.ToString();
}
</code></pre>
| 40,575 |
<p>I have 4 2D points in screen-space, and I need to reverse-project them back into 3D space. I know that each of the 4 points is a corner of a 3D-rotated rigid rectangle, and I know the size of the rectangle. How can I get 3D coordinates from this?</p>
<p>I am not using any particular API, and I do not have an existi... | <p>Alright, I came here looking for an answer and didn't find something simple and straightforward, so I went ahead and did the dumb but effective (and relatively simple) thing: Monte Carlo optimisation.</p>
<p>Very simply put, the algorithm is as follows: Randomly perturb your projection matrix until it projects your... | <p>Yes, Monte Carlo works, but I found better solution for this issue. This code works perfectly (and uses OpenCV):</p>
<pre><code>Cv2.CalibrateCamera(new List<List<Point3f>>() { points3d }, new List<List<Point2f>>() { points2d }, new Size(height, width), cameraMatrix, distCoefs, out rvecs, out... | 10,174 |
<p>I'm experimenting with OpenSSL on my network application and I want to test if the data sent is encrypted and can't be seen by eavesdropper.</p>
<p>What tools can you use to check? Could this be done programmatically so it could be placed in a unit test?</p>
| <p>check out wire shark <a href="http://www.wireshark.org/" rel="noreferrer">http://www.wireshark.org/</a></p>
<p>and tcp dump <a href="http://en.wikipedia.org/wiki/Tcpdump" rel="noreferrer">http://en.wikipedia.org/wiki/Tcpdump</a></p>
<p>Not sure about integrating these into unit tests. They will let you look at a v... | <p>For a quick check you can use <a href="http://www.wireshark.org/" rel="nofollow noreferrer">Wireshark</a> (formerly known as Ethereal) to see if your data is transmitted in plain-text or not.</p>
| 17,837 |
<p>At work, I use Cygwin a lot because it offers me a small oasis in the vast desert of Windows. I inevitably end up running some non-Cygwin programs through the bash shell, such as build scripts (batch files created in-house) and the Subversion CLI binaries (I have the Windows ones installed). 99% of the time, I don... | <p>Unfortunately, I think you are hitting one of the issues of Cygwin and windows/dos console apps. See "Console Programs" at <a href="http://www.cygwin.com/cygwin-ug-net/using-effectively.html" rel="noreferrer">http://www.cygwin.com/cygwin-ug-net/using-effectively.html</a>.</p>
<p>It is just a limitation on windows ... | <p>The lengthy discussion on the mintty project is here - <a href="http://code.google.com/p/mintty/issues/detail?id=56" rel="nofollow">http://code.google.com/p/mintty/issues/detail?id=56</a></p>
<p>One solution mentioned which worked in my case (entering authentication passwords for native subversion) is <strong>conin... | 24,747 |
<p>Is there some way I can use URLs like: </p>
<p><em><a href="http://www.blog.com/team-spirit/" rel="nofollow noreferrer">http://www.blog.com/team-spirit/</a></em></p>
<p>instead of</p>
<p><em><a href="http://www.blog.com/?p=122" rel="nofollow noreferrer">http://www.blog.com/?p=122</a></em></p>
<p>in a Windows hos... | <p>This is how I did it with WordPress on IIS 6.0</p>
<p><a href="http://www.coderjournal.com/2008/02/url-rewriter-reverse-proxy-iis-wordpress/" rel="nofollow noreferrer">http://www.coderjournal.com/2008/02/url-rewriter-reverse-proxy-iis-wordpress/</a></p>
<p>However it all depends on what version of IIS you are usin... | <p>We use the free version of <a href="http://www.isapirewrite.com/" rel="nofollow noreferrer">ISAPI_Rewrite</a>. It uses similar syntax to mod_rewrite, so if you're familiar with that you may have an easier time getting started.</p>
<p>There used to be a (syntax-compatible) port of mod_rewrite for IIS, but I can't f... | 5,252 |
<p>Is there any tool that can parse a valid <strong>C</strong> program and generate a report which contains list of <em>functions</em>, <em>global variables</em>, <em><code>#define</code> constants</em>, <em>local variables in each function</em>, etc.</p>
| <p>Doxygen does all of the above.</p>
| <p>Try exuberant-ctags with the -x option and tell it to generate all of its kinds.
Exuberant CTAGS is the default ctags on many linux distros.</p>
<p>You might try: exuberant-ctags -x --c-kinds=cdefglmnpstuvx --language-force=c filename</p>
<p>will even work if filename doesn't have .c extension.</p>
<p>You can us... | 10,985 |
<p>Are there any good source-code analyses tools for OSX. I am particularly interested in tools that are capable of diagramming function-call hierarchies for C and C++ source files.</p>
| <p>You might take a look at <a href="http://www.doxygen.nl/" rel="nofollow noreferrer">doxygen</a></p>
| <p><a href="http://www.doxygen.nl/" rel="nofollow noreferrer">doxygen</a> can do this and a lot more.</p>
| 33,552 |
<p>My Google-fu is failing me on this question.</p>
<p>I have a coworker who has Visual Studio 2005 on his machine. I have Visual Studio 2008. He wants to open a project I wrote in C# 3.0, and we've gotten that far, but VS2005 barfs on the 3.0 code, like <code>var</code>.</p>
<p>He has the 3.0 and 3.5 frameworks inst... | <p>So far as I understand it, this isn't possible. If you weren't using the new C# 3.0 code features, he should be able to work with a project created in VS2008 (and compile it against the 2.0 framework), but I don't think the 2005 compiler is ever going to be able to cope with the new syntax.</p>
| <p>The IDE itself may not support the 3.0 functionality. If you can live without the 3.0 features you can compile to 2.0 which he should be able to run ok.</p>
| 15,026 |
<p>I've got a C# program that's supposed to play audio files. I've figured out how to play any sound file for which Windows has a codec by using DirectShow, but now I want to properly fill in the file type filter box on the Open dialog. I'd like to automatically list any file format for which Windows has a codec. If... | <p>If I remember correctly, a codec does not know which file types, i.e. file extensions, it supports, since a codec takes some stream as input and not actually a file. So if what you want is to display the file extensions of the supported audio file formats, you'll most likely be out of luck unless you have a extensiv... | <p>You could look in the Windows Registry for all file types with a content type of "audio/*". Specifically, look at all of the keys under HKCR/Software/*/Content Type.</p>
| 18,139 |
<p>So if you have a RIA version (Silverlight or Flash) and a standard HTML version (or AJAX even), should you have the same URL for both, or is it ok to have a different one for the RIA app and just redirect accordingly?</p>
<p>So, for instance, if you have a site (<a href="http://example.com" rel="nofollow noreferrer... | <p>The URLs of your pages denote the identity of the content. In my view, if the content is the same but the presentation varies (i.e RIA vs. HTML), then the URL should be the same and you should use some other mechanism to select between the different presentation forms. Choices of other mechanisms include cookies, co... | <p>I guess what I really need here is not a Question/Answer format but some kind of poll. While I agree (and accepted) that because they are getting two different views of the same content, that different urls are ok, but I'm thinking more of sharing these urls out. </p>
<p>Thanks for the reply though!</p>
| 10,292 |
<p>The sample below has two TextBoxes. The second TextBox has a handler for the LostFocus event which calls Clear() on itself. Changing focus between the two text boxes works fine; however, if the focus is on the second text box when the window is closed, TextBox.Clear() generates a NullReferenceException. Is this ... | <p>Could the Test property be null by the time the LostFocus event is fired?</p>
<p>Try:</p>
<pre><code> private void Test_LostFocus(object sender, RoutedEventArgs e)
{
if (Test != null)
Test.Clear();
}
</code></pre>
<p><strong>EDIT:</strong> I'm having trouble reproducing the NullRefe... | <p>Hooking LostKeyboardFocus instead of LostFocus works OK for my situation and stops the event handler throwing exceptions.</p>
| 18,898 |
<p>I just order myself an Ender 3 Pro which will come by the end of the week.
Before it arrives I want to be ready to flash a bootloader onto it.</p>
<p>I was wondering what other options there are to flashing except using an Arduino?</p>
<p>I have a bunch of ESP8266/ESP32 and a <a href="https://www.banggood.com/FT23... | <p>What you need to is called a ICSP or ISP: <a href="https://en.wikipedia.org/wiki/In-system_programming" rel="noreferrer">in-circuit serial programmer or in-system programmer</a>, which excludes the USB to TTL device you own.</p>
<p>I've never used an ESP8266 as ICSP but it seems there are <a href="https://arduino.s... | <p>You can do AVR programming using USB-TTL adapters. This relies on bit-banging, i.e. emulating the programming protocol by using the serial control lines as general purpose IO.</p>
<p>But this has a few caveats:</p>
<ul>
<li>USB-TTL adapters limit the speed of control line changes. So the programming will be very s... | 1,508 |
<p>I want to use a "spin button control" (also known as an up-down control) in my Delphi Win 32 application (I'm using Delphi 2007). </p>
<p>The aim is to have a control that looks like in Microsoft Office:</p>
<p><a href="http://img167.imageshack.us/my.php?image=updownzn8.png" rel="nofollow noreferrer">image of up/d... | <p>Have a look at TUpDown. It wraps the Win32 control.</p>
| <p><a href="http://tmssoftware.com" rel="nofollow noreferrer">TMS Software</a> do a wide range of components including spin edits (fancy an iPhone style one!) and I have found their support through the newsgroups to be excellent.</p>
| 39,140 |
<p>I currently work for a bespoke software agency. Does anyone have any experience of how to win well priced work?</p>
<p>It seems there is so much competition from offshore/bedroom programming teams, that cost is extremely competetive these days. I feel that it is very different compared to a software product company... | <p>If you are concerned with doing too much work for too little money then work on an hourly basis. Yes, that is harder to sell in most situations.</p>
<p>Maybe you can try a two-phased approach instead. Have a very short initial engagement where the deliverables are very specific requirements documents that become th... | <p>Sell fixed price, fixed scope work, not hourly work. That mitigates your customer's risk of an over-run (you absorb all the risk, but you're doing that anyway), and frames the project in terms of the value of the software, not the quality of the effort going into it.</p>
| 25,046 |
<p>I would like to replace only the group in parenthesis in this expression :</p>
<pre><code>my_string.gsub(/<--MARKER_START-->(.)*<--MARKER_END-->/, 'replace_text')
</code></pre>
<p>so that I get : <code><--MARKER_START-->replace_text<--MARKER_END--></code></p>
<p>I know I could repeat the w... | <p>You could do something like this:</p>
<pre><code>my_string.gsub(/(<--MARKER_START-->)(.*)(<--MARKER_END-->)/, '\1replace_text\3')
</code></pre>
| <p>You can do it with <a href="http://www.perlmonks.org/?node_id=518444" rel="nofollow noreferrer">zero width look-ahead and look-behind assertions</a>.</p>
<p>This regex should work in ruby 1.9 and in perl and many other places:</p>
<p><em>Note: ruby 1.8 only supports look-ahead assertions. You need both look-ahead ... | 14,463 |
<p>There is a similar question going around, but it just got the same old answers that people always give about Regex syntax, but that's not the point here, so please try to not knee jerk the same old answers about regex syntax. Try to be a little more original and personal about it this time.</p>
<p>Regex syntax is v... | <p>Most of what I have to say were addressed by Adam and DGM, but I don't think they cover your second point very well.</p>
<p>"how about all the very easy to understand, non compact, non cryptic and dare I say pretty domain languages out there like SQL or LINQ?"</p>
<p>I think a good way to express an answer to this... | <p>I bet all participants in this discussion will agree that for certain <strong>small</strong> regex codes one would have to write a long paragraph in English describing what it does. Any kind of language that may be used to do what even the simplest regexp describes will probably do it with N lines of code, where N (... | 33,103 |
<p>I have just built my first 3D printer, and I am having some problems. It is a Cartesian based 3D printer, using Marlin firmware and Pronterface software. My problem is homing the 3D printer. I do not have a probe to calibrate the z offset but I have all 6 endstops. The problem is that the "ZMIN" endstop isn't precis... | <p>It is possible to "home a printer" without having endstops, technically, you don't <strong>require</strong> endstops, but it makes your job a lot easier if you want to print something!</p>
<p>Basically, when you don't have endstops or limit switches, you need to define where the head of the printer is located. E.g.... | <p>You can reconfigure marlin to use the MAXZ endstop instead of MINZ in Configuration.h, and then reflash it to your printer.</p>
<p><a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/Configuration.h#L877" rel="nofollow noreferrer">https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/Configurat... | 1,216 |
<p>For some reason I'm not getting this. (Example model below) If I write: </p>
<pre><code>var property = typeof(sedan).GetProperty("TurningRadius");
Attribute.GetCustomAttributes(property,typeof(MyAttribute), false)
</code></pre>
<p>the call will return MyAttribute(2) despite indicating I don't want to search the in... | <p>Okay, given the extra information - I believe the problem is that <code>GetProperty</code> is going up the inheritance change.</p>
<p>If you change your call to <code>GetProperty</code> to:</p>
<pre><code>PropertyInfo prop = type.GetProperty("TurningRadius",
BindingFlags.Instance | BindingFlags.Public | Bindin... | <p>I think this is what you're after - note that I had to make TurningRadius abstract in Vehicle and overridden in Car. Is that okay?</p>
<pre><code>using System;
using System.Reflection;
public class MyAttribute : Attribute
{
public MyAttribute(int x) {}
}
public class Sedan : Car
{
// ...
}
public class C... | 34,517 |
<p>I have a situation in which I parse a body of text and replace certain phrases with links. I then need to re-parse the string to replace a second set of phrases with links. The problem arises at this point, where certain words or phrases in the second set can be substrings of phrases already replaced in the first pa... | <p>This might work for all passes:</p>
<pre><code>$string = preg_replace('/([^>]|^)grand canyon\b/','$1<a href=#>grand canyon</a>',$string);
</code></pre>
<p>EDIT: assuming you can afford missing when the text contains stuff like "amazonas>grand canyon"</p>
| <p>For the second pass, you could use a regex such as:</p>
<pre><code>(<a[^>]*>.*?</a>)|grand
</code></pre>
<p>This regex matches either a link, or the word "grand". If the link is matched, it is captured into the first (and only) capturing group. If the group matched, simply re-insert the existing li... | 49,899 |
<p>I am new at this and maybe my model is not the best, I adapted it for another one actually. Can you tell me why I can't get the holes printed? I already checked the faces and they are all in the correct orientation (I think)</p>
<p>What happens is that I start printing with the holes facing down and they are not pri... | <h1>The problem is internal geomoetry</h1>
<p>The body you modeled consists of a non-manifold shell: There exists a fully enclosed shell on the inside of the item that tries to define an "outside" of the body. In the following picture, I have hidden part of the geometry to better show the problematic internal... | <p>The overall appearance is that the normals are "normal," that you have no reversed facets, but there are discontinuities within the model that Meshmixer and Netfabb show as failure points. Windows 10 3DBuilder also attempts a repair which fills in the holes.</p>
<p><a href="https://i.stack.imgur.com/L92T7.... | 2,125 |
<p>I had a little discussion with a friend about the usage of collections in return/input values of a method. He told me that we have to use
- the most derived type for return values.
- the least derived type for input parameters.</p>
<p>So, it means that, for example, a method has to get a ReadOnlyCollection as param... | <p>Regarding input parameters, it's generally more flexible to use the least specific type. For example, if all your method is going to do is enumerate the items in a collection passed as an argument, it's more flexible to accept IEnumerable<T>.</p>
<p>For example, consider a method "ProcessCustomers" that acce... | <p>I tend to agree with not returning or using List or Dictionary as parameters in API's because it really limits the developer targeting the API. Instead returning or passing IEnumerable<> works really well.</p>
<p>Of coarse, all of this depends on the application. Just my opinion.</p>
| 21,402 |
<p>I need to find occurrences of ~ 25 000 words within a text. What is the most suitable algorithm/library for this purpose?</p>
<p>target language is C++</p>
| <p>build a hashtable with the words, and scan throuhgt the text, for each word lookup in the wordtable and stuff the needed info (increment count, add to a position list, whatever).</p>
| <p>viceBerg says:</p>
<blockquote>
<p>I once used the Boyer-Moore algorithm
and it was quite fast.</p>
</blockquote>
<p>With Boyer-Moore, aren't you typically searching a block of text for a <strong>single</strong> string?</p>
<p>For a simple to implement solution go with the hash table approach suggested by Jav... | 18,654 |
<p>I want to save and store simple mail objects via serializing, but I get always an error and I can't find where it is.</p>
<pre><code>package sotring;
import java.io.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import com.sun.org.apache.bcel.internal.generic.INEG;
public c... | <p>If an exception occurs, you never get to the return statement in getStoredMails. You need to either throw the exception you catch (possibly wrapping it in another more descriptive exception) or just return null at the end of the method. It really depends on what you want to do if there's an error.</p>
<p>Oh, and yo... | <p>I modified the source. I added "return null" in exception and the for loop the output in the function. And the function gives me the right output but then throws it the exception.</p>
| 21,207 |
<p>We're working on a Log Viewer. The use will have the option to filter by user, severity, etc. In the Sql days I'd add to the query string, but I want to do it with Linq. How can I conditionally add where-clauses?</p>
| <p>if you want to only filter if certain criteria is passed, do something like this</p>
<pre><code>var logs = from log in context.Logs
select log;
if (filterBySeverity)
logs = logs.Where(p => p.Severity == severity);
if (filterByUser)
logs = logs.Where(p => p.User == user);
</code></pre>
<p... | <p>Just use C#'s && operator:</p>
<pre><code>var items = dc.Users.Where(l => l.Date == DateTime.Today && l.Severity == "Critical")
</code></pre>
<p>Edit: Ah, need to read more carefully. You wanted to know how to <em>conditionally</em> add additional clauses. In that case, I have no idea. :) What I... | 3,235 |
<p>I have a web app that uses log4net to log errors to a log file.
It works well when I publish my website via xcopy but when I build a package installer, log4net does not appear to work when remote users access my site.</p>
<p>I use <em>impersonate=true</em> in my web.config and log4net only logs errors when I am the... | <p>After all it was a permission issue
setting the write permission to everyone log4net started logging well as it uses the
current logged user account</p>
<p>regards</p>
| <p>i don't think so because same config is used in a working app</p>
<p>but here it is</p>
<p>what user does log4net uses when writing to disk?!
Is there any need to add permissions to write to log folders? Because i use impersonate=true the user logged to the site is the one that log4net is using to write
to file s... | 46,399 |
<p>I have created a multi column datastore on a table that allows me to do full text indexing on the table. What I need to be able to do is weight each column different and add the scores together.</p>
<p>The following query works, but is slow:</p>
<pre><code>SELECT document.*, Score(1) + 2*Score(2) as Score
FROM doc... | <p>Instead of the OR operator, use ACCUM:</p>
<p>SELECT document.*, Score(1) as Score
FROM document
WHERE CONTAINS(dummy, '(((the_keyword) within documentTitle))*2 <strong>ACCUM</strong> ((the_keyword) within documentText)',1) > 0)
ORDER BY Score Desc</p>
| <p>What if you do a nested select?</p>
<pre><code>select *, Score(1) + 2 * Score(2) as Score
from (
SELECT document.*, Score(1) as Score
FROM document
WHERE CONTAINS(dummy, '(((the_keyword) within documentTitle))
OR ((the_keyword) within documentText)',1) > 0)
)
ORDER BY Score Desc
</code></pre>... | 28,911 |
<p>Has anyone gotten the jquery plugin <a href="http://www.appelsiini.net/projects/jeditable" rel="nofollow noreferrer">jeditable</a> to run properly in a Rails applications. If so, could you share some hints on how to set it up? I'm having some trouble with creating the "submit-url".</p>
<hr>
<p>IIRC, you cannot sim... | <p>Excuse me for bringing this up only now, but I just found the time to look into my code again. I think I solved my problem by the following javascript (my application.js within rails):</p>
<pre><code>jQuery(document).ready(function($) {
$(".edit_textfield").each( function(i) {
$(this).editable("update", {
... | <p>I"m not sure I entirely understand the problem you're having, but I think you could put something like this in your javascript:</p>
<pre><code><%= url_for(@post) %>
</code></pre>
<p>It depends how you're structuring your javascript, how you've got your files organised etc...</p>
| 27,283 |
<p>I'm working on a program to do some image wrangling in Python for work. I'm using FreeImagePy because PIL doesn't support multi-page TIFFs. Whenever I try to save a file with it from my program I get this error message (or something similar depending on which way I try to save):</p>
<pre><code>Error returned. TI... | <p>Looks like a permission issues, make sure you don't have the file open in another application, and that you have write permissions to the file location your trying to write to.</p>
| <p>That's what I thought too, but I figured it out a couple hours ago. Apparently if the directory/file I'm trying to write to doesn't exist, FreeImagePy isn't smart enough to create it (most of the time. Creating a new multipage image seems to work fine) but i guess running it within IDLE, IDLE figures it out and ta... | 29,710 |
<p>Many products/services we are interact with (including our own) uses XML-over-HTTP or derivatives (like OMA IMPS IM/presence protocol).</p>
<p>I am looking for some tool that will "listen" to a traffic and produce client/server stubs for simulation/testing.</p>
<p>Thanks. </p>
| <p>To some degree, it sounds like what <a href="http://maxq.tigris.org/" rel="nofollow noreferrer">maxq</a> is trying to do.</p>
| <p>That sounds like a good idea for a project.</p>
<p>This is not a solution, but your first step should be to at least support know webservice descriptors. </p>
<p>To do that should sniff the traffic using wireshark or something similar and see the URL's that are being accessed. If you are lucky these services woul... | 37,398 |
<p>Is it possible to skip a couple of characters in a capture group in regular expressions? I am using .NET regexes but that shouldn't matter.</p>
<p>Basically, what I am looking for is:</p>
<blockquote>
<p>[random text]AB-123[random text]</p>
</blockquote>
<p>and I need to capture 'AB123', without the hyphen.</p>... | <p>In short: You can't. A match is always consecutive, even when it contains things as zero-width assertions there is no way around matching the next character if you want to get to the one after it.</p>
| <p>Kind of late, but I think I figured this one out. At least one way to do it.</p>
<p>I used positive lookahead to stop at the # sign in my text. I didn't want the space or the # sign, so I had to figure a way out to "skip" over them. So when I was forced to match them again, I dumped them into a garbage group that... | 35,027 |
<p>If I would write:</p>
<pre>
int selectedChannels = selector.select();
Set selectedKeys = selector.selectedKeys();
if ( selectedChannels != selectedKeys.size() ) {
// Selector.select() returned because of a call to Selector.wakeup()
// so do synchronization.
}
// Continue with handling selected channels.
</p... | <p>I would guess that the proposed snippet would not work at all in principle, per the contracts of <code>Selector#select()</code> and <code>Selector#selectedKeys()</code>. From <a href="http://java.sun.com/javase/6/docs/api/java/nio/channels/Selector.html" rel="nofollow noreferrer">Selector</a>:</p>
<blockquote>
<... | <p>You can't really be sure that the only reason that the selector woke up was due to the wakeup call. You may also have socket activity.</p>
<p>So, you need to make the caller of wakeup also do something like setting a volatile boolean to indicate its desire for attention. The the selector loop can check the value ... | 43,242 |
<p>I know that <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>B</kbd> launches a solution build, but I would like a shortcut that just builds the current project. Is a custom shortcut my only option?</p>
<p><strong>Edit:</strong> Looks like a custom shortcut is my only option as <kbd>Shift</kbd> + <kbd>F6</kbd> does not wo... | <p>Assigning the shortcut to "Build.BuildOnlyProject" command doesn't seem to work in VS2008.</p>
<p>Assign the shortcut to "Build.BuildSelection". If you have a solution with several projects and files open from the various projects, whatever file you are currently editing will define the project ... | <p>In the Visual Studio options window, under "Keyboard", look for the "Build.BuildOnlyProject" command and you can set whatever you want.</p>
| 30,775 |
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/164926/c-sharp-how-do-i-round-a-decimal-value-to-2-decimal-places-for-output-on-a-pa">c# - How do I round a decimal value to 2 decimal places (for output on a page)</a> </p>
</blockquote>
<p>I want to truncate ... | <p>You can use <a href="http://msdn.microsoft.com/en-us/library/zy06z30k.aspx" rel="noreferrer">Math.Round</a>:</p>
<pre><code>decimal rounded = Math.Round(2.22939393, 3); //Returns 2.229
</code></pre>
<p>Or you can use ToString with the N3 <a href="http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx" rel="noreferr... | <p>Try this:</p>
<pre><code>decimal original = GetSomeDecimal(); // 22222.22939393
int number1 = (int)original; // contains only integer value of origina number
decimal temporary = original - number1; // contains only decimal value of original number
int decimalPlaces = GetDecimalPlaces(); // 3
temporary *= (Math.Pow(... | 42,745 |
<p>Mine would have to be the float and margin bugs...</p>
<p>If you float an element, and then specify a margin for it, it will double the margin.</p>
<p>The solution to this is to add <code>display: inline</code> to the element. This will stop the double margin, and all other browsers will ignore it because only blo... | <p>I wish I'd known that I'd be spending hours trying to fix a bug in IE 6 over and over again for years on end and I really would have been happier delivering pizza.</p>
| <p>in addition to other IE bug lists that Ross and Loque gave above (gtalbot.com, what a beautiful site!</p>
<p><a href="http://css-discuss.incutio.com/?page=InternetExplorerWinBugs" rel="nofollow noreferrer">http://css-discuss.incutio.com/?page=InternetExplorerWinBugs</a></p>
<p><a href="http://webbugtrack.blogspot.... | 29,987 |
<p>When debugging, a trick I do whenever I want to exit the current method without running of its any statements, I move the current execution pointer to the end of the method, then click F10/11.</p>
<p>Is there a keyboard shortcut (or can I program one) to accomplish this?</p>
<p>(I don't mean shift-F11 (step out) -... | <p>The following sequence of keystrokes works for me (tested in Visual Studio 2008); I was able to record them as a temporary macro and play them back successfully:</p>
<ol>
<li><code>Ctrl+M, Ctrl+M</code> (Edit.ToggleOutliningExpansion: collapses the current method)</li>
<li><code>Right arrow</code> (skips past the c... | <p>AFAIK that's the only way to do it.</p>
| 26,813 |
<p>Something happened that I'm not sure should be possible. Obviously it is, because I've seen it, but I need to find the root cause & I was hoping you all could help.</p>
<p>We have a system that looks up latitude & longitude for a zipcode. Rather than access it every time, we cache the results in a cheap i... | <p>Why it's happening is hard to tell. More code could help.</p>
<p>You should probably just be using a ConcurrentHashMap anyway. This will be more efficient, in general, than a synchronized Map. You don't synchronize access to it, it handles it internally (more efficiently than you could).</p>
| <p>I don't really see anything wrong with the code you posted that would cause the problem you described. My guess would be that it's a problem with the client of your geo-code cache that has problems.</p>
<p>Other things to consider (some of these are pretty obvious, but I figured I'd point them out anyway):</p>
<ol... | 30,295 |
<p>I have to read data from some files and insert the data into different tables in a database. Is Unix shell script powerful enough to do the job?</p>
<p>Is it easy to do the job in shell script or should I go about doing this in Java?</p>
| <p>If the data you are trying to import is in a reasonable format -- comma-delimited, for example -- and your database server has reasonable command line utilities, this should be no problem. MySQL has the "mysqlimport" command-line tool that will accept various arguments describing the format of the file:</p>
<pre cl... | <p>Shell scripting (Bash or similar) primary intention is not to deal with databases. Go for Java or even better, ride this opportunity to learn the basics of a scripting language like Python or Ruby.</p>
| 9,731 |
<p>I have a foxpro app, that contains hard coded path for icons and bitmaps. That's how foxpro does it and there is no way around it. And this works fine, except that when a removable drive has been used but is not connected, and when is connected windows assigns the same letter as hard coded path, when opening any for... | <p>Nelson:</p>
<p>"That's how foxpro does it and there is no way around it"?</p>
<p>I'm using FOX since FoxPro 2.5 to Visual FoxPro 9, and you are NEVER forced in any way to hard-code a path, you can use SET PATH TO (sYourPath), you can embed the icons and bitmaps in your EXE / APP file and therefore there's no need ... | <p>I agree with @PabloG - it's been over a decade since I worked with FoxPro (Dos & Windows) but even back in FPW2.6 you could determine where your app was running 'from', set absolute or relative search paths and even bundle your resources straight into the "compiled" (heh) exe. All of our resources lived in a spe... | 8,037 |
<p>Is there any way to add a field to a class at runtime ( a field that didn't exist before ) ? Something like this snippet :</p>
<pre><code>Myobject *ob; // create an object
ob->addField("newField",44); // we add the field to the class and we assign an initial value to it
printf("%d",ob->newField); // now we ca... | <h2>Use a map and a variant.</h2>
<p>For example, using boost::variant. See <a href="http://www.boost.org/doc/libs/1_36_0/doc/html/variant.html" rel="noreferrer">http://www.boost.org/doc/libs/1_36_0/doc/html/variant.html</a></p>
<p>(But of course, you can create your own, to suit the types of your XML attributes.)</p>
... | <p>No -- C++ does not support any manipulation of the type system like this. Even languages with some degree of runtime reflection (e.g. .NET) would not support exactly this paradigm. You would need a much more dynamic language to be able to do it.</p>
| 29,135 |
<p>In postgres I am fairly sure you can do something like this</p>
<pre><code>SELECT
authors.stage_name,
count(select id from books where books.author_id = authors.id)
FROM
authors,
books;
</code></pre>
<p>Essentially, in this example I would like to return a list of authors and how many books each has wri... | <p>Well, for one thing, it returns a Cartesian product of all authors to all books, regardless of whether that author wrote that book.</p>
<p>Here's how I'd write a query to get the result you say you want:</p>
<pre><code>SELECT a.stage_name, COUNT(b.id)
FROM authors a
LEFT OUTER JOIN books b ON (a.id = b.author_id... | <p>How about using a join:</p>
<pre><code>SELECT authors.stage_name, count(*)
FROM authors INNER JOIN books on books.author_id = authors.id
GROUP BY authors.stage_name
</code></pre>
| 47,063 |
<p>I'm writing a PHP application with testability in mind, so my classes always ask in their constructors for the "collaborator objects" they depend on, in respect to the Dependency Injection pattern.</p>
<p>That way, I'm able to pass in mocks or test implementations in my unit tests.</p>
<p>What I want to achieve th... | <p>Of course you'd better use an IoC/DIP container to do the job. Your code above (the if statements) increase the coupling of the classes. The client class (Engine) should not care what’s implementing the loader and logger roles. That’s the factory’s or DIP container work to know this. By putting a concrete class n... | <p>You could use my tiny library <a href="https://github.com/LapaLabs/ValueResolver" rel="nofollow">ValueResolver</a> in this case, for example:</p>
<pre><code>$logger = ValueResolver::resolve($logger, new DefaultLogger);
</code></pre>
<p>and don't forget to use namespace <code>use LapaLabs\ValueResolver\Resolver\Val... | 49,322 |
<p>I figured someone can answer the question generally but if anyone wants to get specific I am trying to use:</p>
<p>using System.Web.Security.SingleSignOn;
using System.Web.Security.SingleSignOn.Authorization;</p>
<p>I've googled my brains out and this is the closest answer I found:</p>
<p>"We discussed this offli... | <p>I found an <a href="http://web2.minasi.com/forum/topic.asp?TOPIC_ID=23116" rel="nofollow noreferrer">install log</a> showing that it was expected to be in</p>
<blockquote>
<p>C:\WINDOWS\ADFS\System.Web.Security.SingleSignon.dll</p>
</blockquote>
<p>on Windows Server 2003. You probably need to have active directo... | <p>For projects using specific environment (like SharePoint object model)is recommended using virtual pc with installed in GAC assemblies. ADFS assemblies should have only Win server. If you find them and install manually in work environment (desktop) some possibilities (like debugging) will not impossible.</p>
| 12,875 |
<p>Is there a way using Python's standard library to easily determine (i.e. one function call) the last day of a given month?</p>
<p>If the standard library doesn't support that, does the dateutil package support this?</p>
| <p><a href="https://docs.python.org/library/calendar.html#calendar.monthrange" rel="noreferrer"><code>calendar.monthrange</code></a> provides this information:</p>
<blockquote>
<p>calendar.<b>monthrange</b>(year, month)<br>
Returns weekday of first day of the month and number of days in month, for the specified <em... | <p>If you pass in a date range, you can use this:</p>
<pre><code>def last_day_of_month(any_days):
res = []
for any_day in any_days:
nday = any_day.days_in_month -any_day.day
res.append(any_day + timedelta(days=nday))
return res
</code></pre>
| 6,456 |
<p>I've been always thinking that DOMNodeInsertedIntoDocument/DOMNodeRemovedFromDocument events should not bubble, and for me that made enough sence. However, just recently I looked into specification once again and found out that in one location it says these events should not bubble (<a href="http://www.w3.org/TR/DOM... | <p>What about something like this?</p>
<pre><code>for(i=0;i<array_size;i++) {
print "group" + (Math.floor(i/(array_size/N)) + 1)
}
</code></pre>
| <p>I think the problem is a little more complicated; and considering that your only look at group as a 1 dimensional problem your going to get a very odd view of what groups actually are.</p>
<p>Firstly the problem is dimensional according to the number of group primes, and group combinations you are dealing with. In ... | 41,734 |
<p>How do you go about verifying the type of an uploaded file reliably without using the extension? I'm guessing that you have to examine the header / read some of the bytes, but I really have no idea how to go about it. Im using c# and asp.net.</p>
<p>Thanks for any advice.</p>
<hr>
<p>ok, so from the above links I... | <p>Here's a quick-and-dirty response to the followup question you posted:</p>
<pre><code>byte[] jpg = new byte[] { 0xFF, 0xD8, 0xFF, 0xE0 };
bool match = true;
for (int i = 0; i < jpg.Length; i++)
{
if (jpg[i] != b[i])
{
match = false;
break;
}
}
</code></pre>
| <p>Reading the contents of the file is the fool proof way. Since you are building it in .Net, you could probably check the MIME Type of the uploaded file.</p>
<p>You can DllImport urlmon.dll to help. Please refer a post at:
<a href="http://coding-passion.blogspot.com/2008/11/validating-file-type.html" rel="nofollow no... | 30,414 |
<p>How do you determine when to use <a href="http://www.iselfschooling.com/mc4articles/mc4cluster.htm" rel="noreferrer">table clusters</a>? There are two types, index and hash, to use for different cases. In your experience, have the introduction and use of table clusters paid off?</p>
<p>If none of your tables are se... | <p>The killer feature of table clusters is that you can store <strong>related rows of different tables</strong> at the same physical location.</p>
<p>That can improve join performance by an order of magnitude. However, it doesn't pay of so often as it sounds.</p>
<p>The only time I used it was a three-table join, exe... | <p>I haven't used Oracle's table clusters myself, but I understand that its index table clusters are very much like MS SQL Server's clustered indexes. That is, the row data is physically organized by the clustered index's key.</p>
<p>That makes one ideal for a heavily-accessed column that has a reasonably small number... | 4,769 |
<p>Is there a generic way to clone objects in VBA? So that i could copy x to y instead of copying just the pointer?</p>
<pre><code> Dim x As New Class1
Dim y As Class1
x.Color = 1
x.Height = 1
Set y = x
y.Color = 2
Debug.Print "x.Color=" & x.Color & ", x.Height=" & x.Height
</code></pre>
<... | <p>OK, here's the beginning of something that illustrates it:</p>
<p>Create a class, call it, oh, "Class1":</p>
<pre><code>Option Explicit
Public prop1 As Long
Private DontCloneThis As Variant
Public Property Get PrivateThing()
PrivateThing = DontCloneThis
End Property
Public Property Let PrivateThing(value)
... | <p>I don't think there's anything built in, although it would be nice.</p>
<p>I think there should at least be a way to create a Clone method automatically using the VBA Editor. I'll see if I can take a look at it once I've got the kids to bed...</p>
| 26,909 |
<p>We've got some problems with an external company trying in integrate into a WCF service we expose and they are a Java shop. I was wondering if there are more than one toolkit that they can try to solve their issues and would like a list to suggest to them but I'm not familiar with the Java world at all.</p>
<p>Esse... | <p>Microsoft and Sun <a href="https://wsit.dev.java.net/" rel="nofollow noreferrer">worked together</a> to ensure that their latest web services toolkits worked with each other. Sun's java implementation is <a href="https://metro.dev.java.net/" rel="nofollow noreferrer">Metro</a>.</p>
| <p>Are they using Axis, if you are presenting a standard webservice to them? Or are you presenting a custom REST service that they have had to do more manual coding for (HTTPClient, XML generators/parsers, etc)?</p>
| 16,810 |
<p>This is something I've pseudo-solved many times and have never quite found a solution for.</p>
<p>The problem is to come up with a way to generate <code>N</code> colors, that are as distinguishable as possible where <code>N</code> is a parameter.</p>
| <p>My first thought on this is "how to generate N vectors in a space that maximize distance from each other."</p>
<p>You can see that the RGB (or any other scale you use that forms a basis in color space) are just vectors. Take a look at <a href="http://mathworld.wolfram.com/topics/RandomPointPicking.html" rel="norefe... | <p>I've read somewhere the human eye can't distinguish between less than 4 values apart. so This is something to keep in mind. The following algorithm does not compensate for this.</p>
<p>I'm not sure this is exactly what you want, but this is one way to randomly generate non-repeating color values:</p>
<p>(beware, i... | 2,268 |
<p>One of the local libraries has a new small Makerbot 3D printer. I have been submitting Sketchup files converted to STL files for printing. </p>
<p>The tech guy who runs the printer for patrons is having trouble getting a project of mine to come out to be the right size. I need this item go be 2 inches wide. The tec... | <p>It appears that you have scaled the object after the raft and supports were added. As you can see in your photo of the raft, the clip is approximately 7/8ths (1.75/2) the size of the raft.</p>
<p>Edit: As a side note, STL files don't actually have a concept of units. Each axis is defined in arbitrary units. That's ... | <p>My advice is to use a micrometer (i.e., sliding dial caliper) accurate to within .001" and measure the printed object. If it is 1 7/8" for example, you would open the STL file in Makerbot software and use their scaling tool to scale the object to 1.0666666...., which is what you get when you divide the desired size... | 212 |
<p>I'm currently developing a security solution that should work across domains and as such I need a small private dns server to add various entries to. I could alter the hosts file to achieve the same result but since the hosts file doesn't support wildcard chars I will have a whole lot of entries, so a DNS server tha... | <p>As a reference: <a href="http://sourceforge.net/projects/acrylic/" rel="noreferrer">http://sourceforge.net/projects/acrylic/</a></p>
<p>Acrylic is a local DNS proxy which improves the performance of your computer by caching the responses coming from your DNS servers.</p>
<p>I found it to work flawless on every Win... | <p>You can use Microsoft DNS if you are using Windows Server (except Web edition). Or install a <a href="http://www.simpledns.com/" rel="nofollow noreferrer">Simple DNS Plus</a> trial (14 day) if you don't manage with BIND.</p>
| 48,023 |
<p>I'm coding a small CMS to get a better understanding of how they work and to learn some new things about PHP. I have however come across a problem.</p>
<p>I want to use mod_rewrite (though if someone has a better solution I'm up for trying it) to produce nice clean URLs, so site.com/index.php?page=2 can instead be ... | <p>One approach is to rewrite everything to a handling script</p>
<pre><code>RewriteEngine on
RewriteBase /
# only rewrite if the requested file doesn't exist
RewriteCond %{REQUEST_FILENAME} !-s
# pass the rest of the request into index.php to handle
RewriteRule ^(.*)$ /index.php/$1 [L]
</code></pre>
<p>so if... | <p>Your PHP should for very obvious reasons not be able to modify <code>.htaccess</code>. Even if you get that to work, I'm not sure if it is wise.</p>
<p>How about using a more abstract setup in regard to mod_rewrite rules? Define your general URL pattern, as you would like to use it. For example:</p>
<pre>
/object/... | 33,342 |
<p>Google custom search code is provided as a form tag. However, Asp.net only allows a single form tag on a page. What is the best way to implement their code so you can include it on an aspx page (say as part of a Masterpage or navigation element). </p>
| <p>You can have multiple form tags on an ASP.NET page. The limitation is on server-side (runat="server") form tags. </p>
<p>You can implement two form tags (or more) as long as only one has the runat="server" attribute and one is not contained in the other. Example:</p>
<pre><code><body>
<form action="http:/... | <p>You could use Javascript:</p>
<pre><code><input name="Query" type="text" class="searchField" id="Query" value="Search" size="15" onfocus="if(this.value == 'Search') { this.value = ''; }" onblur="if(this.value == '') { this.value = 'Search'; }" onkeydown="var event = event || window.event; var key = event.which |... | 10,073 |
<p>I want to use the <a href="http://simplehtmldom.sourceforge.net/manual_api.htm" rel="noreferrer">php simple HTML DOM parser</a> to grab the image, title, date, and description from each article on a page full of articles. When looking at the API I notice it has a set_callback which Sets a callback function. However ... | <p>Here's a basic callback function example:</p>
<pre><code><?php
function thisFuncTakesACallback($callbackFunc)
{
echo "I'm going to call $callbackFunc!<br />";
$callbackFunc();
}
function thisFuncGetsCalled()
{
echo "I'm a callback function!<br />";
}
thisFuncTakesACallback( 'thisFuncGe... | <p>With <code>PHP 5.3</code>, you can now do this:</p>
<pre><code>function doIt($callback) { $callback(); }
doIt(function() {
// this will be done
});
</code></pre>
<p>Finally, a nice way to do it. A great addition to <code>PHP</code>, because callbacks are awesome.</p>
| 28,636 |
<pre><code>test[_nObjectives].pool[j].feedbackCorrect =
oQuestions[j].getElementsByTagName("feedbackCorrect")[0].firstChild.data;
</code></pre>
<p>and the XML in this case contains this: </p>
<pre><code> <feedbackCorrect>
</feedbackCorrect>
</code></pre>
<p>When executing that line of code the follow... | <p>you are getting the error because</p>
<pre><code>oQuestions[j].getElementsByTagName("feedbackCorrect")[0]
</code></pre>
<p>is returning that tag, and the .firstChild is returning null, because it has no children...</p>
<p>Are you sure you dont want</p>
<pre><code>oQuestions[j].getElementsByTagName("feedbackCorre... | <p>but why it is working when the xml is like this: </p>
<pre><code><feedbackCorrect>any value</feedbackCorrect>
</code></pre>
<p>?</p>
| 47,568 |
<p>We're getting our feet wet with unit testing in VS 2008 Professional Edition and have hit what might be a pretty large snag: there appears to be no way to determine code coverage in this particular VS edition. It seems that this is something only available in VS Team System Development Edition.</p>
<p>In other word... | <p><a href="http://www.ncover.com/" rel="nofollow noreferrer">NCover</a></p>
| <p>I've been using <a href="http://www.ncover.com/" rel="nofollow noreferrer">NCover</a> with <a href="http://www.nunit.org/" rel="nofollow noreferrer">NUnit</a> under VS2008 for a few days. I've found it so easy to find and fill gaps in my test coverage, I've giggled aloud when NCover pops up. </p>
<p>One tip: if you... | 22,258 |
<p>I'm building an application that is targeting Windows, Mac and Linux soon. I was wondering where should I keep application data such as settings, etc.</p>
<p>Application's installation folder is the easiest choice, but I think that might be a problem with new Vista security model. Besides, users might want differen... | <p>Each platform has its own API for finding the user's home folder, or documents folder, or preferences folder. </p>
<ul>
<li>Windows: SHGetFolderPath() or SHGetKnownFolderPath()</li>
<li>Mac OS X and iPhone OS: NSSearchPathForDirectoriesInDomains()</li>
<li>Unix: $HOME environment variable</li>
</ul>
<p>Don't hard... | <p>Never, ever store user data in the application folder. It's just a bad idea.</p>
<p>Most operating systems have a $HOME (or %HOME%) environment variable. That would be the first place to look. </p>
<p>If you want to cleanly support multiple operating systems, though, you're going to have to have some OS-specifi... | 8,122 |
<p>I'm trying to understand how namespaces work in XML. When I have an element like foo:bar, the attributes will often not have namespaces on them. But sometimes they will. Are the attribute in the namespace of the element, even when the default namespace has been declared? Looking over the xsd for xhtml it seems the a... | <p>Most of the time, attributes will not be in any namespace. The <a href="http://www.w3.org/TR/REC-xml-names/#defaulting" rel="noreferrer">namespace spec</a> says (<em>emphasis</em> mine):</p>
<blockquote>
<p>A default namespace declaration applies to all unprefixed <em>element</em> names within its scope. Default ... | <p>Read up at <a href="http://www.w3.org/TR/REC-xml-names/#scoping" rel="nofollow noreferrer">6.1 Namespace Scoping</a> and <a href="http://www.w3.org/TR/REC-xml-names/#defaulting" rel="nofollow noreferrer">6.2 Namespace Defaulting</a> on w3c.</p>
<p>Basically:</p>
<blockquote>
<p>The scope of a namespace declarati... | 6,287 |
<p>Can anyone recommend a good (preferably open source) tool for creating WSDL files for some soap web services?</p>
<p>I've tried playing around with some of the eclipse plug ins available and was less than impressed with what I found.</p>
| <p>As mentioned above, probably the easiest thing to do is use Apache CXF or Apache Axis2 to automatically generate your WSDL for you.</p>
<p>If you have downloaded the Java EE version of Eclipse, you should be able to create a Dynamic Web Project with the Axis2 facets. If you create a simple Java class in the projec... | <p>Depends on which language you're working in, but if you're active in Java then I'd recommend looking at <a href="http://cxf.apache.org/" rel="nofollow noreferrer">Apache CXF</a>. It's a pretty solid framework for publishing java code as a SOAP web service. It also includes a tool for directly generating WSDL files: ... | 9,842 |
<p>All the generated webservice-stubs from our backend have an equals-method similar to this one:</p>
<pre><code>private java.lang.Object __equalsCalc = null;
public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof PropertyData)) return false;
PropertyData other = (PropertyData) obj;
... | <p>I suspect it's trying to stop recursion - if something has itself as its key, you don't want it to recurse forever.</p>
<p>However, at that point it uses reference equality for the test, which is possibly not desirable.</p>
<p>What's generating this code? Is it a home-grown system, or a public one? If it's home-grow... | <p>The __equalsCal behave as a Cache for the last call to Equals. So, if two calls in the same instance to equals method are invoked with the same parameter the method will be faster</p>
<p>EDIT: Sorry this would be true if the </p>
<pre><code>__equalsCalc = null;
</code></pre>
<p>would not be there, but rechecking ... | 48,021 |
<p>I'm looking for a method to reliably extract the host name from a URL string in Ruby.</p>
<p>e.g.
<a href="http://www.mglenn.com/directory" rel="noreferrer">http://www.mglenn.com/directory</a> = www.mglenn.com
OR
<a href="http://www.mglenn.com?param=x" rel="noreferrer">http://www.mglenn.com?param=x</a> = www.mglen... | <p>You could try something like this:</p>
<pre><code>require 'uri'
myUri = URI.parse( 'http://www.mglenn.com/directory' )
print myUri.host
# => www.mglenn.com
</code></pre>
| <pre><code>URI("http://www.mglenn.com/directory").host
</code></pre>
| 35,182 |
<p>I want to create variables inside function from dictionary.</p>
<p>Lets say I have a dictionary</p>
<pre><code>bar = {'a': 1, 'b': 2, 'c': 3}
</code></pre>
<p>and function</p>
<pre><code>def foo():
pass
</code></pre>
<p>What I want to do is to create inside function "foo" variables with names of each dictiona... | <p>Your question is not clear.</p>
<p>If you want to "set" said variables when foo is not running, no, you can't. There is no frame object yet to "set" the local variables in.</p>
<p>If you want to do that in the function body, you shouldn't (check the <a href="http://docs.python.org/lib/built-in-funcs.html" rel="nof... | <p>Why would you want to do such a thing? Unless you actually do anything with the variables inside the function, a function that just assigns several variables and then discards them is indistinguishable to def foo(): pass (An optimiser would be justified in generating exactly the same bytecode).</p>
<p>If you als... | 14,585 |
<p>I’ve built a custom Maven2 plug-in using Ant. I would like to call another maven plug-in in particular the Cargo Maven2 plug-in immediately after the custom Ant plug-in successfully completes. However, I do not want to attach the Cargo plug-in to another goal or phase. Is there a way to have them run consecutively w... | <p>See this discussion: <a href="http://mail-archives.apache.org/mod_mbox/maven-users/200706.mbox/%3C4669508E.1020903@apache.org%3E" rel="nofollow noreferrer">Re: calling plugin in another plugin?</a> According to the Maven developers, this is not the way plugins are supposed to work.</p>
<p>However, there is this int... | <p>The Ant script that the maven-ant-plugin executes is not really aware of Maven as such; this plugin is designed for backwards compatibility with custom Ant tasks. I cannot think of a clean way of doing what you want though there may be some kind of hack that allows you to do it.</p>
<p>It should also be possible to... | 41,779 |
<p>I have a print I need to make holes in.<br>
I have read some other threads where the answers was in short, "don't, print the holes", and "make sure to make the hole from the top or bottom".<br>
The problem is I need the hole in the side of a print with about 1 mm walls. </p>
<p>The holes I need is to run a USB ca... | <p>You're going to have to drill those holes. The plastic will melt if you drill too quickly. If at all possible, use a slow speed drill, a hand drill, or wrap a cloth around a drill bit and twist it with your hand. If you go too fast, the part will melt. If you press to hard the part will break.</p>
<p>Once the hole ... | <p>As a follow up on this I wanted to post some pictures of the result with only the soldering iron.<br>
I was soldering some cables and when it was still hot I figured I could give it a go. </p>
<p>The hole is on the underside and in a closed compartment so it's not visible.</p>
<p>Anyways, about 3 mm hole at this ... | 1,442 |
<p>I am trying to setup tracd for the project I am currently working on.
After creating a password file with the python script given in the <a href="http://trac.edgewall.org/wiki/TracStandalone" rel="noreferrer">site</a> I am trying to start the server with authentication on. But it throws up warning saying No users fo... | <p>Replacing the above said command line with the one bellow helps.</p>
<p>tracd --port 8000 --auth=Trac,D:\My_Test_Project\Documents\Trac\digest.txt,Trac D:\My_Test_Project\Documents\Trac</p>
<p>The string after --auth= should be the environment name and not the project name.</p>
| <p>The text referred to says that you must specify the realm name as "trac", not "<strong>T</strong>rac", but I have no chance of testing whether that makes any difference, sorry.</p>
| 24,452 |
<p>I'm trying to have the modrewrite rules skip the directory <code>vip</code>. I've tried a number of things as you can see below, but to no avail.</p>
<pre><code># BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#RewriteRule ^vip$ - [PT]
RewriteRule ^vip/.$ - [PT]
#RewriteCond %{REQUEST_... | <p>Try putting this before any other rules.</p>
<pre><code>RewriteRule ^vip - [L,NC]
</code></pre>
<p>It will match any URI beginning <code>vip</code>. </p>
<ul>
<li>The <code>-</code> means do nothing. </li>
<li>The <code>L</code> means this should be last rule; ignore everything following. </li>
<li>The <code>NC<... | <p>I'm not sure if I understand your objective, but the following might do what you're after?</p>
<pre><code>RewriteRule ^/vip/(.*)$ /$1?%{QUERY_STRING} [L]
</code></pre>
<p>This will cause a URL such as <a href="http://www.example.com/vip/fred.html" rel="nofollow noreferrer">http://www.example.com/vip/fred.html</a... | 19,737 |
<p>I've found out how to convert errors into exceptions, and I display them nicely if they aren't caught, but I don't know how to log them in a useful way. Simply writing them to a file won't be useful, will it? And would you risk accessing a database, when you don't know what caused the exception yet?</p>
| <p>You could use <a href="http://www.php.net/manual/en/function.set-error-handler.php" rel="noreferrer">set_error_handler</a> to set a custom exception to log your errors. I'd personally consider storing them in the database as the default Exception handler's backtrace can provide information on what caused it - this o... | <p>I think it depends a lot of where your error occured. If the DB is down logging it to the DB is no good idea ;)</p>
<p>I use the <a href="http://php.net/syslog" rel="nofollow noreferrer">syslog()</a> function for logging the error, but I have no problems writing it to a file when I'm on a system which has no syslog... | 4,069 |
<p>I'm trying to do a very simple INSERT using VB.NET. For some reason I'm getting a SqlException on every insert though. The data is inserted, but still get the following: </p>
<p>Violation of PRIMARY KEY constraint 'PK_User'. Cannot insert duplicate key in object 'dbo.Employee'. The statement has been terminated</... | <p>Two theories. Either your code is being executed twice, or there's a trigger on the Employee table that's attempting an insert following the successful insert. (Edit: @Mitchel Sellers is exactly right, if the same code works in c# it's absolutely not a trigger issue.)</p>
<p>My hunch is that your code is being exec... | <p>As another side note, I noticed that your code could potentially leave a sql connection open. If you're using the .NET 2.0 framework you should use the Using statement. It ensures that connections are closed and disposed even if an exception is thrown. Check this article on MSDN for more detail: <a href="http://m... | 28,979 |
<p>One example is described <strong><a href="http://sujitmanolikar.blogspot.com/2007/07/generic-statemanagedcollection.html" rel="nofollow noreferrer">here</a></strong>. But the author apparently forgot to include the code for download.</p>
<p>Another example is shown <strong><a href="http://blog.spontaneouspublicity... | <p>DanHerbert got it. Darn, I spent hours on this too! In the process of trying to answer this question I came up with a simplified generic StateManagedCollection that inherits from the framework's built-in StateManagedCollection, based on the version <a href="http://blog.spontaneouspublicity.com/post/2007/05/Child-Col... | <p>I have used the code above the provided solution is ok but i was getting exception - "StackOverflow " cool :) the issue is reproducible by adding a few child items in the aspx page and switch to Design view to design view of Visual studio ( Visual Studio just restart and nobody knows what is going on....). </p>
... | 47,567 |
<p>I'm wondering about the practical use of #undef in C. I'm working through K&R, and am up to the preprocessor. Most of this was material I (more or less) understood, but something on page 90 (second edition) stuck out at me:</p>
<blockquote>
<p>Names may be undefined with <code>#undef</code>,
usually to ensu... | <h3>What it does</h3>
<p>If you read Plauger's <a href="https://smile.amazon.com/dp/0131315099" rel="nofollow noreferrer">The Standard C Library</a> (1992), you will see that the <code><stdio.h></code> header is allowed to provide <code>getchar()</code> and <code>getc()</code> as function-like macros (with speci... | <h3>If a macro can be def'ed, there must be a facility to undef.</h3>
<p>a memory tracker I use defines its own new/delete macros to track file/line information. this macro breaks the SC++L.</p>
<pre><code>#pragma push_macro( "new" )
#undef new
#include <vector>
#pragma pop_macro( "new" )
</c... | 26,662 |
<p>There's some object-oriented engineering principle that states something along the lines of "a class should only know about the contracts of the classes that it takes as arguments, or any internal ones it uses."</p>
<p>The counter-example, in C++, is:</p>
<pre><code>Foo::bar( Baz* baz)
{
baz()->blargh()->p... | <p>The <a href="http://en.wikipedia.org/wiki/Law_of_Demeter" rel="nofollow noreferrer">law of demeter</a> <sub>thanks to <a href="https://stackoverflow.com/users/20164/jim-burger">Jim Burger</a></sub> says:</p>
<blockquote>
The Law of Demeter (LoD), or Principle of Least Knowledge, is a design guideline for developing... | <p>That may or may not compile (due to the parentheses after the baz pointer), but your example breaks at least one principle that I can think of. It breaks the Law of Demeter (also called the Law of Parsimony, I believe). The main principles can be found here:
<a href="http://www.lostechies.com/blogs/chad_myers/archiv... | 38,085 |
<p>I am messing around with different PHP logging frameworks. I am currently trying PEAR::Log. I figured that I would use its <code>singleton</code> function to make sure there was only one instance of the class around.</p>
<p>I have a small daemon-like script I wanted to add logging to because it was probably the s... | <p>I don't know much about PEAR::Log, but why not create another singleton that wraps/simplifies logging.</p>
<pre><code>class Logger {
private static $log;
private function __construct() { }
public static function init(Log $log) {
self::$log = $log;
}
public static function get() {
... | <blockquote>
<p>Another alternative is passing the instance into every function. Again, seems like its less than ideal.</p>
</blockquote>
<p>Basically you have the choice of passing dependencies per function, per object instance or in one of the global scopes. I find that using the object instance scope usually hits... | 47,390 |
<p>I'm wondering what the best practices are for storing a relational data structure in XML. Particulary, I am wondering about best practices for enforcing node order. For example, say I have three objects: <code>School</code>, <code>Course</code>, and <code>Student</code>, which are defined as follows:</p>
<pre><code... | <p>Don't think in SQL or relational when working with XML, because there are no order constraints. </p>
<p>You can however query using XPath to any portion of the XML document at any time. You want the courses first, then "//Courses/Course". You want the students enrollments next, then "//Students/Student/EnrolledI... | <p>From experience, XML isn't the best to store relational data. Have you investigated <a href="http://www.yaml.org/" rel="nofollow noreferrer" title="YAML">YAML</a>? Do you have the option?</p>
<p>If you don't, a safe way would be to have a strict DTD for the XML and enforce that way. You could also, as you suggest, ... | 17,110 |
<p>I'm looking for the concept to <strong>spawn a process</strong> such that:</p>
<ul>
<li>it has only access to certain libraries/APIs</li>
<li>it cannot acess the file system or only specific parts</li>
<li>it can <strong>do least harm should malicious code run in it</strong></li>
</ul>
<p>This concept is known as ... | <p>Mac OS X has a sandbox facility code-named Seatbelt. The public API for it is documented in the sandbox(7), sandbox_init(3), and related manual pages. The public API is somewhat limited, but the facility itself is very powerful. While the public API only lets you choose from some pre-defined sandboxes (e.g. “All ... | <p>I'm not an expert on the topic, but i think the standard answer for linux is to define a SeLinux policy with the right capabilities for the process. </p>
| 16,444 |
<p>I know what PermGen is, what it's used for, why it fails, how to increase it etc.</p>
<p>What I don't know is what PermGen actually stands for. Permanent... Gen... something?</p>
<p>Does anyone know what PermGen actually stands for?</p>
| <p>Permanent Generation. Details are of course implementation specific.</p>
<p>Briefly, it contains the Java objects associated with classes and interned strings. In Sun's client implementation with sharing on, <code>classes.jsa</code> is memory mapped to form the initial data, with about half read-only and half copy-... | <p>Permgen stands for Permanent Generation. It is one of the JVM memory areas. It's part of Heap with fixed size by using a flag called MaxPermSize.</p>
<p><strong><em>Why the name "PermGen" ?</em></strong></p>
<p>This permgen was named in early days of Java. Permgen mains keeps all the meta data of loaded classes. B... | 41,235 |
<p>I have a Java program that uses Hibernate and MySQL to store a lot of tracing data about the use of the Eclipse IDE. This data contains a lot of strings such as method names, directories, perspective name, etc. </p>
<p>For example, an event object (which is then reflected in a record) can specify the source file an... | <p>Building on sblundy's answer, you could probably get away with something like:</p>
<pre><code>class Foo {
// client code uses this to get the value... ignored by Hibernate
@Transient
public String getString() {
return getStringHolder().getString();
}
public StringHolder getStringHolder(... | <p>I suspect you'll need a string holder object and then make sure all these objects refer to that. </p>
<pre><code>class StringHolder {
private Long id;
private String string;
public StringHolder() {/* Not sure if this is necessary */}
public StringHolder(String string) {
this.string = string;
}
pu... | 17,441 |
<p>A method I work with that is called tens of thousands of times started throwing exceptions recently. In most debugging circumstances I would set a breakpoint at the top of this method and run through until I reach the call I'm interested in with a parameter value that triggers the exception. In this case that woul... | <p>Anytime that I have tried to use conditional breakpoints in Visual Studio I've had the same problem. The debugger runs so slowly that it becomes useless. Instead I end up temporarily adding an if statement to the code and adding my breakpoint inside of that. This isn't as convenient, but the code executes at a no... | <p>I wonder if you are getting a stack overflow. Does VS track all the values for str or anything to do with each state of Bar? If so, the thousands of copies might add up.</p>
<p>I wonder if you could eliminate the problem monitoring the value via a global variable instead, rather than one within the function.</p>
| 36,706 |
<p>Is there an online resource somewhere that maintains statistics on the install-base of Java including JRE version information? If not, is there any recent report that has some numbers?</p>
<p>I'm particularly interested in Windows users, but all other OS's are welcome too.</p>
| <p>Take a look at <a href="http://www.pixel-technology.com/freeware/tessnet2/" rel="noreferrer">tessnet</a></p>
| <p>Disclaimer: I work for Atalasoft</p>
<p>Our <a href="http://www.atalasoft.com/products/dotimage/ocr" rel="nofollow noreferrer">OCR module supports Tesseract</a> and if that proves to not be good enough, you can upgrade to a better engine and just change one line of code (we provide a common interface to multiple OC... | 5,026 |
<p>I have a website which uses themes. Depending on the url (if it is A.something.com or B.something.com, where A and B represent clients), I will load a different theme. The intention is to use one codebase for different clients. I have an app_themes folder, several themes inside, for different clients, and different ... | <p>Is this occurring only when you run the code from within Visual Studio? </p>
<p>When running in ASP.Net Development Server, the styles in App_Themes won't be used on any unauthenticated page (such as Login.aspx or ForgotPassword.aspx). That's because the user doesn't have browse permissions on that folder yet, or t... | <p>Instead of doing this though code, you can specify the theme used by the application (or a folder) through your web.config:</p>
<pre><code><system.web>
<pages theme="concepglobal"></pages>
</system.web>
</code></pre>
<p>This assumes you have different web.config files for each client.</... | 33,277 |
<p>While building a small experimental HTTP server, I need to implement the persistent connection feature of HTTP 1.1 (and the pipelining feature).
How do I test it?
Using a browser like Firefox gives me little or no control, and it's hard to check.
Any ideas?</p>
<p>Thanks</p>
| <p>curl(<a href="http://curl.haxx.se/" rel="nofollow noreferrer">http://curl.haxx.se/</a>) -- gives you very good control over GET/POST and many other attributes.</p>
<p>curl also comes with libcurl so that you can do things programatically.</p>
<p>Perl and python(urllib or urllib2 ) will help you get there.</p>
| <p>Netcat. You can type in the request(s) and see the response(s) from the server. If you know the HTTP protocol, it's not a problem at all. In fact, it's better than curl or other higher-level libraries/applications, since here you can send whatever you like (malformed requests) and test the corner cases in your serve... | 25,883 |
<p>I am having a problem with deploying a ASP.NET V2 web application to our deployment environment and am having trouble with the sql server setup .</p>
<p>When I run the website I get a Login failed for user 'MOETP\MOERSVPWLG$'. error when it tries to connect to the database.</p>
<p>This seems to be the network serv... | <p>It sounds like you're able to connect to the database alright and you're using integrated windows authentication.</p>
<p>With integrated windows authentication your connection to your database is going to use whatever your application pool user identity is using. You have to make sure that the user identity that a... | <p>Make sure there is a login created for the user you are trying to log in as on the sql server.</p>
| 12,337 |
<p>Here's a curious one. I have a class A. It has an item of class B, which I want to initialize in the constructor of A using an initializer list, like so:</p>
<pre><code>class A {
public:
A(const B& b): mB(b) { };
private:
B mB;
};
</code></pre>
<p>Is there a way to catch exceptions that might ... | <p>Have a read of <a href="http://weseetips.wordpress.com/tag/exception-from-constructor-initializer-list/" rel="noreferrer">http://weseetips.wordpress.com/tag/exception-from-constructor-initializer-list/</a>)</p>
<p>Edit: After more digging, these are called "Function try blocks".</p>
<p>I confess I didn't know this... | <p>I don't see how you'd do that with initializer-list syntax, but I'm also a bit sceptical that you'll be able to do anything useful by catching the exception in your constructor. It depends on the design of the classes, obviously, but in what case are you going to fail to create "mB", and still have a useful "A" obje... | 19,368 |
<p>It appears that each app has access to its own config settings, which could be kept after app be shutdown. I am wondering whether one app's config setting could be accessed from other app. </p>
<p>Should I save sensitive data like password to the app config?</p>
<p>Is there some better way?</p>
| <p>The Keychain is where passwords or other sensitive information should be saved.</p>
| <p>Buzz Andersen has code that will get and set Keychain passwords correctly on both the simulator and on the iPhone: <a href="http://log.scifihifi.com/post/55837387/simple-iphone-keychain-code" rel="nofollow noreferrer">SFHFKeychainUtils</a>.</p>
| 46,019 |
<p>We have an SVN repository running on a Windows server, and I want to link internal documentation, feature changes, bugs and so on to code changes.</p>
<p>We've found WebSVN to be amazingly slow - the repository is too large for it (I think).</p>
<p>The team using it is primarily coding in C#, and while some have e... | <p>Have a look at <a href="http://warehouseapp.com" rel="nofollow noreferrer">http://warehouseapp.com</a></p>
<p>It's Mongrel/Ruby/MySQL stack (should work on Windows though)</p>
<blockquote>
<p>but I'm looking to avoid installing
MySQL and Ruby on the server.</p>
</blockquote>
<p>I know (also using C# stack mys... | <p>Not web-based but if your team is using TortoiseSVN there's a great repository browser there. Just right click on your local checkout and select TortoiseSVN / Repo-Browser.</p>
| 3,214 |
<p>I have an iframe inside my main page. There is a modalpopup inside the iframe page. So when the modalpopup is shown, the parent of the modalpopup is the iframe body and the main page parent body. Thus the overlay only covers the iframe and not the entire page.</p>
<p>I tried moving the modalpopup from the iframe to... | <p>If you're using the iframe simply for scrollable content you might consider a styled div with <strong>overflow: auto</strong> or <strong>scroll</strong>, instead.</p>
<p>A set up such as this makes it easier to modify the appearance of the entire page since you're not working with multiple documents that each essen... | <p>You answered your own question in your update. The modal dialog needs to live on the parent page and invoked from the iframe. Your only other option is to use a scrolling div instead of an iframe. </p>
| 37,786 |
<p>I'm having a problem dynamically adding columns to a GridView. I need to change the layout -- i.e. the included columns -- based on the value in a DropDownList. When the user changes the selection in this list, I need to remove all but the first column and dynamically add additional columns based on the selection.... | <p>I recently conquered silmilar issues with dynamic columns in gridviews, perhaps this will help. </p>
<p>First turn the viewstate off<br>
Second add the columns programatically in a function fired in the oninit event<br>
Lastly I used the following helper class to cause the checkboxes to instantiate when the RowDat... | <p>I found this little nugget in the documentation, under the DataControlFieldCollection Class. </p>
<p><em>If you are using the GridView or DetailsView control, the DataControlField objects that are automatically created (for example, when the AutoGenerateColumns property is true) are not stored in the publicly acce... | 29,079 |
<p>I'm coming from a .net background and want to know the accepted way of creating a method that returns a boolean and modifies a string that was passed in via parameter. I understand Strings are immutable in Java so the below snippet will always produce an empty string. I am constrained to return boolean only. Excepti... | <p>Use a java.lang.StringBuilder - basically a mutable String. However, it would be safer and more "Java style" to return the modified String.</p>
| <p><code>
public boolean doStuff(String msg)
{
boolean boolTest = false;
msg += "Appending something to msg";
int msgLength = msg.length();
if ( msgLength > 80 )
{
boolTest = true;
return boolTest;
}
return boolTest;
}
</code></p>
<p>Is this kind of what you're looking for? I'm assumin... | 44,551 |
<p>As of SQL Server 2005, you used to be able to open a flat file in SQL Management Studio off the right click menu for any database table. Once opened, you could add or update records right there in the grid.</p>
<p>Now that SQL Server 2008 is out, Microsoft has hidden that feature, at least from the right-click menu... | <p>It's replaced by "Edit Top 200 Rows". You can change that command in the Tools > Options > SQL Server Object Explorer > Commands.</p>
<p>But once you right-click a table, choose "Edit Top 200 Rows", hunt on the toolbar for a button called "Show SQL Pane". From here you can edit the query so the grid shows a subset ... | <p>You could sett the default value of "Edit Top 200 Rows" too "0"</p>
<p>In the Tools Menu -> Options... under SQL server Object Explorer\Table and view options\Value Edit Top Rows Command. Change the default value 200 too "0".</p>
<p>You should now have the option "Edit All Rows" instead of "Edit Top 200 Rows" as ... | 46,733 |
<p>I'm currently using <code>.resx</code> files to manage my server side resources for .NET.</p>
<p>the application that I am dealing with also allows developers to plugin JavaScript into various event handlers for client side validation, etc.. What is the best way for me to localize my JavaScript messages and strings... | <p>A basic JavaScript object is an associative array, so it can easily be used to store key/value pairs. So using <a href="http://www.json.org" rel="noreferrer">JSON</a>, you could create an object for each string to be localized like this:</p>
<pre><code>var localizedStrings={
confirmMessage:{
'en/US':'Ar... | <p>The <a href="http://msdn.microsoft.com/en-us/library/bb398935.aspx" rel="nofollow noreferrer"><code>MSDN</code> way of doing it</a>, basically is:</p>
<blockquote>
<p>You create a separate script file for each supported language and culture. In each script file, you include an object in JSON format that contains ... | 12,959 |
<p>When debugging my VS2005 project, I get the following error when I attempt to step into the function that returns the <em>vScenarioDescriptions</em> local variable it's struggling with...</p>
<p><em><a href="http://people.ict.usc.edu/~crotchett/images/symbolnotdefined.JPG" rel="nofollow noreferrer">image no longer ... | <p>Is the module compiled with optimizations turned on? </p>
<p>If so, the <code>vScenarioDescription</code> may not actually not actually exist in memory. In VS2008 I don't get a messagebox error, the variable simply doesn't show up in the 'Locals' window, and if I try to watch it, the Watch windows says:</p>
<bloc... | <p>It might be a namespace issue. Try adding <code>namespace::</code> before your symbol in the debugger watch window, if the symbols you're trying to watch are inside a namespace.</p>
| 44,010 |
<p>I have a solution in Visual Studio 2005(professional Edition) which in turn has 8 projects.I am facing a problem that even after i set the Command Arguments in the Project settings of the relevant project, it doesnt accept those command line arguments and it shows argc = 1, inspite of me giving more than 1 command a... | <p>Hmm.. Are you sure the specified project is set as the start project (right click > set as startup project) ??</p>
<p>Oh, and obviously you need to be in the correct configuration mode ^_^</p>
<p>(Notice it can be changed to <em>debug | build | all configurations</em> )</p>
| <p>Are you sure you are setting the command arguments on the same configuration (Debug|Release) you are debugging? As far as I remember command arguments are per configuration.</p>
| 4,956 |
<p>I am making a game in C++ and am having problems with my derived class. I have a base class called GameScreen which has a vitrual void draw() function with no statements. I also have a derived class called MenuScreen which also has a virtual void draw() function and a derived class from MenuScreen called TestMenu ... | <p>If gsScreens is a list of objects instead of a list of pointers (as your code suggests), then you're not storing what you think you're storing in it.</p>
<p>What's happening is that -- instead of putting a TestMenu into the list, you're actually constructing a new MenuScreen using the compiler-generated copy constr... | <p><a href="https://stackoverflow.com/questions/88558/c-derived-class-problems#88620">Curt</a> is absolutely correct, but I'd just like to throw a little more information at it.</p>
<p>This problem (storing base-class objects, rather than pointers) is sometimes called "slicing".</p>
<p>Also, I tend to make use of the... | 11,421 |
<p>I was printing an object and it started to drag so I stopped it.</p>
<p>Went to move the Z-axis up so I could clear the bed and Z-axis would not budge.
I switched the printer off and manually turned the motors to get the Z up.
Cleared the bed, switched on and homed the printer. When it came to home the Z, BLTouch de... | <p>extruder clicking means you're getting backed up, grinding.</p>
<ul>
<li>Make the hotend hotter so you can melt filament 3X faster than expected; most materials have quite a range; aim high.</li>
<li>Slow down the cooling fan; a lot of them can cool the hotend.</li>
<li>You have a silicone boot on the nozzle? that w... | <p>Changing "Flow" will affect whole print. So even if it helped for the middle part (I doubt), the next it would ruin the print on sides by overextrusion. However: <strong>if sides are printed ok, then why the middle couldn't?</strong> Because walls are printed slower? Indeed, the under-extrusion may quickly... | 1,841 |
<p>The following code was produced by a consultant working for my group. I'm not a C++ developer (worked in many languages, though) but would like some independent opinions on the following code. This is in Visual Studio C++ 6.0. I've got a gut reaction (not a good one, obviously), but I'd like some "gut reactions" ... | <p>hmm. I think </p>
<pre><code>CString strColHeader;
strColHeader.Replace(",", "\\,")
</code></pre>
<p>would do just as well.</p>
<p>I don't like the code, I tend to break from the while loop instead of having an unnecessary bool 'continue' flag. That goes double when he could have used <code>while (occurenceInd !... | <p>Looks alright, if a bit, I dunno, hack. Better to use the library, but I wouldn't go and rewrite this routine.</p>
| 26,181 |
<p>I have seen some declaration of a union inside a struct as follows. Example code given below.</p>
<p>My questions is does it help in any memory savings(typical use for which a union is used for)? I do not see the benefit. </p>
<pre><code>typedef struct
{
int x1;
unsigned int x2;
ourstruct1 ov1;
our... | <p>Hmm. Well, the example above seems a little strange to me--the usual reason for a union is to have two different symbolic paths into the same storage (by bytes, by words, etc). However, the example you've given has only one member of the union.</p>
<p>The only thing I can think is that the code is written with an... | <p>It would seem to me that the union isn't actually used here. I've never seen a lone struct inside a union like that either. Strange.</p>
| 30,999 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.