instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Assume that I have programs <code>P0</code>, <code>P1</code>, ...<code>P(n-1)</code> for some <code>n > 0</code>. How can I easily redirect the output of program <code>Pi</code> to program <code>P(i+1 mod n)</code> for all <code>i</code> (<code>0 <= i < n</code>)?</p>
<p>For example, let's say I have a pro... | <p>After spending quite some time yesterday trying to redirect <code>stdout</code> to <code>stdin</code>, I ended up with the following method. It isn't really nice, but I think I prefer it over the named pipe/fifo solution.</p>
<pre><code>read | { P0 | ... | P(n-1); } >/dev/fd/0
</code></pre>
<p>The <code>{ ... }... | <p>I doubt sh/bash can do it.
ZSH would be a better bet, with its MULTIOS and coproc features.</p>
| 6,146 |
<p>I just installed 'Visual C# 2008 Express Edition' and 'Visual Web Developer 2008 Express Edition' on my Vista machine. Previously I have been running these in Win XP. When launching the software, starting a new project and trying to build it I get warnings like "The referenced component 'System' could not be found."... | <p>Problem solved. I used the most radical solution I could come up with - a clean Vista install. Somehow reinstalling Visual Studio does not include all essential steps. First time the software is launched it configures itself. Something must have gone wrong the first time and when the procedure was done again it trie... | <p>Are you launching via "Run As Administrator"? It's possible the permissions on your .Net framework directories aren't what they should be.</p>
| 12,221 |
<p>I have an scheduled agent that is trying to access a database on another server. When it runs I get an error 4063 - Database ...databasename... has not been opened yet.</p>
<p>The servers is listed in the ACL as manager.</p>
<p>What are some other possible causes for this errors?</p>
| <p>Does the other server trust the server executing the agent? Check the server document -> Security -> Trusted servers.</p>
| <p>It's possible to get a handle to a database without opening it. If you try and call most methods without opening it first then you will get that error. The most likely explanation though is that you don't have access to open it.</p>
<p>What id signed the agent? Probably not the server. The agent will run with t... | 24,784 |
<p>I'm working on a game where I create a random map of provinces (a la Risk or Diplomacy). To create that map, I'm first generating a series of semi-random points, then figuring the Delaunay triangulations of those points. </p>
<p>With that done, I am now looking to create a Voronoi diagram of the points to serve a... | <p>The Voronoi diagram is just the dual graph of the Delaunay triangulation. </p>
<ul>
<li>So, the edges of the Voronoi diagram are along the perpendicular bisectors of the edges of the Delaunay triangulation, so compute those lines. </li>
<li>Then, compute the vertices of the Voronoi diagram by finding the intersec... | <p>Each of your Delaunay triangles contains a single point of the Voronoi diagram. </p>
<p>You can compute this point by finding the intersection of the three <a href="http://www.mathopenref.com/bisectorperpendicular.html" rel="nofollow noreferrer">perpendicular bisectors</a> for each triangle.</p>
<p>Your Voronoi di... | 11,084 |
<p>Using Firebug v1.20b7 with Firefox v3.0.1 I use firebug a lot for web devlopment.</p>
<p>I have very often the problem that Firebug won't show its web console for seeing the <code>POSTs</code> and <code>GETs</code>. I can view all the other tabs, including the NET tab that gives me a lot of the same information tha... | <p>There is a limitation in firebug (or rather, in firefox iteself), which will be fixed in one of the newer Firefox releases.</p>
<p>The bug is caused by the fact that firebug needs to send data <em>a second time</em> to monitor what's going on in the connection.</p>
<p>There's now a special API hook in the firefox ... | <p>Well, 1.20b7 is technically a <em>beta</em> version of Firebug. :)</p>
<p>I've had problems with certain features off and on, but a restart of Firefox seems to fix it more often than not.</p>
| 2,759 |
<p>I'm building an app that authors would (hopefully) use to help them, uh.. <em>author</em> things.</p>
<p>Think of it like a wiki but just for one person, but cooler. I wish to make it as accessible as possible to my (potential) adoring masses, and so I'm thinking about making it a web-app.</p>
<p>It certainly does... | <p>There is an additional option, and that is to use the new HTML5 offline application features, namely the Application Cache, Client-Side Databases, and Local Storage APIs.</p>
<p>Currently I believe that Safari is the only shipping browser to support any of these, and i believe it only supports the client side datab... | <p>My suggestion, as you pointed above, is to use a Wiki system to solve your problem. Now the question could be: Wich one?</p>
<p>You can use <a href="http://trac.edgewall.org/" rel="nofollow noreferrer">Trac</a>, it is very simple and you can customize its GUI. But, if you prefer something more advanced please use <... | 20,891 |
<p>I have an executable (compiled by someone else) that is hitting an assertion near my code. I work on the code in Visual C++ 2003, but I don't have a project file for this particular executable (the code is used to build many different tools). Is it possible to launch the binary in Visual C++'s debugger and just tell... | <p>Without the PDB symbols for that application you're going to have a tough time making heads or tails of what is going on and where. I think any source code information is going to be only in that PDB file that was created when whoever built that application.</p>
<p>This is assuming that the PDB file was EVER create... | <p>Short of any other answers, I would try attaching to the executable process in Visual Studio, setting a break point in your code and when you step into the process you don't have source to, it should ask for a source file.</p>
| 5,095 |
<p>An html template is compiled into the application as a resource. A <strong>fragment</strong> of the HTML template looks like:</p>
<pre><code><A href="%PANELLINK%" target="_blank">
<IMG border="0" src="%PANELIMAGE%" style="%IMAGESTYLE%">
</A><BR>
%CAPTIONTEXT%
</code></pre>
<p>i like it l... | <p>My reputation points in this game already being low gives me the freedom to tell you quite plainly that you, sir or madame, are in serious need of XSLT. Failing this (and you probably will) you need to look at <a href="http://dotnetstories.wordpress.com/2008/11/21/xml-literals-and-visual-basic-90/" rel="nofollow nor... | <p>1.) Don't use comments, you'll send useless data to the browser wasting bandwidth and encountering <a href="http://www.positioniseverything.net/explorer/dup-characters.html" rel="nofollow noreferrer">BUGs in IE</a>.</p>
<p>2.) Would this not be better as some sort of method? (I'm not familiar with C#) but something... | 49,188 |
<p>Pretty sure this question counts as blasphemy to most web 2.0 proponents, but I do think there are times when you could possibly <em>not</em> want pieces of your site being easily ripped off into someone else's arbitrary web aggregator. At least enough so they'd need to be arsed to do it by hand if they really want... | <p>Consider that everything that the scraper can't read, search engines can't read either. With that been said, you could inject content into your document via Javascript after the page has loaded.</p>
| <p>Just load all your HTML via AJAX calls and the HTML will not "appear" to be in the DOM to most screen scrapers.</p>
| 16,872 |
<p>I've got a web application working using VB and Ajax. I'm using updatepanels to avoid the irritating "flicker" on postbacks to the server. </p>
<p>I would like to have a button control defined within the updatepanel itself (tried moving it outside and got some catastrophic error, so left it there) that makes the c... | <p>If you get rid of the UpdatePanels do things work as expected with PostBacks? Chances are something in your Page_Load or other event higher up the chain are "resetting" things in some way before it gets to your click event. Could this be the case?</p>
| <p>I have run into this before and resolved it, I just can't remember how. I will try to find my old code and get back to you. one thought, do you have EnablePartialRendering enabled in your scriptmanager? maybe try wrapping both containers in a third panel.</p>
| 6,621 |
<p>Can someone provide an explanation of variable scope in JS as it applies to objects, functions and closures? </p>
| <h3>Global variables</h3>
<p>Every variable in Javascript is a named attribute of an object. For example:-</p>
<pre><code>var x = 1;
</code></pre>
<p>x is added to the global object. The global object is provided by the script context and may already have a set of attributes. For example in a browser the global o... | <p>Functions introduce a scope. You can declare functions inside other functions, thereby creating a nested scope. The inner scope can access the outer scope, but the outer can not access the inner scope.</p>
<p>Variables are bound to a scope, using the <strong>var</strong> keyword. All variables are implicitly bound ... | 12,514 |
<p>I'm sending an email using the dotnet framework. Here is the template that I'm using to create the message:</p>
<pre><code>Date of Hire: %HireDate%
Annual Salary: %AnnualIncome%
Reason for Request: %ReasonForRequest%
Name of Voluntary Employee: %FirstName% %LastName%
Total Coverage Applied For: %EECoverageAmount%... | <p>Start every line with 2 spaces and outlook will be "tricked" into keeping your formatting.</p>
<p>So change</p>
<pre><code>Date of Hire: %HireDate%
Annual Salary: %AnnualIncome%
Reason for Request: %ReasonForRequest%
Name of Voluntary Employee: %FirstName% %LastName%
Total Coverage Applied For: %EECoverageAmount... | <p>Change your line termination from crlf to either cr or lf. </p>
<p>I suspect that the top of the email uses only cr (or lf), and Outlook expects the rest of the email to follow the same format. </p>
| 30,749 |
<p>Why is it that when I use a converter in my binding expression in WPF, the value is not updated when the data is updated.</p>
<p>I have a simple Person data model:</p>
<pre><code>class Person : INotifyPropertyChanged
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
</code></pr... | <p><strong>(see edits below; latest: #2)</strong></p>
<p>It isn't updating because your <code>Person</code> object is not capable of notifying anything that the value of <code>FirstName</code> or <code>LastName</code> has changed. <a href="https://stackoverflow.com/questions/159088/dependencyproperty-and-databinding">... | <p>I haven't check it but can you also try the following</p>
<pre><code><TextBlock Text="{Binding Path=/, Converter={StaticResource personNameConverter}}" />
</code></pre>
| 21,078 |
<p>Wouldn't it be better to mount lead screws with the motor on top and the bottom end unconstrained? Compared to the conventional way (motor on the bottom) the lead screw would be under constant tension rather than compression and any misalignment would always be "pulled straight" and in this way minimize z-... | <p>The motor is mounted in a fixed position no matter if it's on top or bottom.
You can imagine the lead screw as a rod hanging down and supporting the bed in the Z direction only, because all of the XY rigidity comes from the Liner rails the bed is attached to it works just as well if the stiff rod is under compressio... | <p>The motor is mounted in a fixed position no matter if it's on top or bottom.
You can imagine the lead screw as a rod hanging down and supporting the bed in the Z direction only, because all of the XY rigidity comes from the Liner rails the bed is attached to it works just as well if the stiff rod is under compressio... | 2,017 |
<p>I am creating an installer for an ASP.Net website using WiX. How do you set the ASP.Net version in IIS using WiX?</p>
| <p>We use this:</p>
<p>First determine the .Net framework root directory from the registry:</p>
<pre><code><Property Id="FRAMEWORKROOT">
<RegistrySearch Id="FrameworkRootDir" Root="HKLM"
Key="SOFTWARE\Microsoft\.NETFramework"
Type="directory" Name="InstallRoot" />
</P... | <ul>
<li><p>First find the correct .NET version folder. Use DirectorySearch/FileSearch to perform search.</p></li>
<li><p>Use the above path to call aspnet_regiis.exe and set the version for the webapp from a custom action.</p>
<p><code>aspnet_regiis.exe -s W3SVC/1/ROOT/SampleApp1</code></p></li>
</ul>
| 19,766 |
<p>It appears that using perldoc perl gives the list of, e.g. perlre, perlvar, etc.</p>
<p>Is this the best place to find the list of what's available as an overview or tutorial or reference manual section? Is there another, better list?</p>
| <pre><code>perldoc perltoc
</code></pre>
<p>is a bit more verbose about the various documentation files. If you want a list of core modules, try</p>
<pre><code>perldoc perlmodlib
</code></pre>
| <p>That should be a good start. You can also find the same information online: <a href="http://perldoc.perl.org/perl.html" rel="nofollow noreferrer">http://perldoc.perl.org/perl.html</a>. </p>
<p>I'm not sure what you mean by better. There's a ton of good information at <a href="http://www.perl.com/" rel="nofollow ... | 10,989 |
<p>I am adding a service reference to one of my projects in Visual Studio 2008. On the "Service Reference Settings" screen I am selecting the default option which says "Reuse types in all referenced assemblies". I have referenced the project for which I want to reuse a type. That type is being passed in as a paramete... | <p>I've answered my own question (I think). What I was trying to do was use a service reference to point to an existing ASP.NET web service, but reusing types is not supported for old school web services. It only works with WCF services. So I took the plunge and converted my web service to a true WCF service and now ... | <p>I had a similar problem until I defined the following attribute in the code so that the namespace of the objects related to the service contract were set to the same namespace as the commonly referenced types.</p>
<pre><code>[assembly: ContractNamespace("YOUR_NAMESPACE_HERE")]
</code></pre>
| 16,229 |
<p>I need to count and check how much of some images is placed in folder od web server.
Example- images get names from <code>user_id</code>, and on example I have <code>user_id 27</code>, and my images are:</p>
<pre><code>27_1.jpg, 27_2.jpg, 27_3.jpg, ...
</code></pre>
<p>How to check and write to database this thing... | <p>Once you know your path you can use IO.Directory.GetFiles() method.</p>
<pre><code>IO.Directory.GetFiles("\translated\path","27_*.jpg").Count()
</code></pre>
<p>will give you what you're looking for.</p>
| <p>Using the System.IO namespace, you can do something like this</p>
<pre><code>public File[] GetUserFiles(int userId)
{
List<File> files = new List<File>();
DirectoryInfo di = new DirectoryInfo(@"c:\folderyoulookingfor");
foreach(File f in di.GetFiles())
{
if(f.ToString().StartsWith(use... | 12,653 |
<p>This code throws up the compile error given in the title, can anyone tell me what to change?</p>
<pre><code>#include <iostream>
using namespace std;
int main(){
int myArray[10][10][10];
for (int i = 0; i <= 9; ++i){
for (int t = 0; t <=9; ++t){
for (int x = 0;... | <p>You are subscripting a three-dimensional array <code>myArray[10][10][10]</code> four times <code>myArray[i][t][x][y]</code>. You will probably need to add another dimension to your array. Also consider a container like <a href="http://www.boost.org/doc/libs/1_37_0/libs/multi_array/doc/index.html" rel="noreferrer">Bo... | <p>I just forgot to put <code>[]</code> to the function parameter with array data type like this:</p>
<p> Instead of this:</p>
<pre class="lang-cpp prettyprint-override"><code>void addToDB(int arr) {
// code
}
</code></pre>
<p>✅ Do this:</p>
<pre class="lang-cpp prettyprint-override"><code>void addToDB(int arr[]) {... | 47,500 |
<p>I'm changing my site to show friendly URLs like this:</p>
<pre><code>www.example.com/folder/topic
</code></pre>
<p>Works fine!</p>
<p>But when I add a parameter to the URL:</p>
<pre><code>www.example.com/folder/topic?page=2
</code></pre>
<p><code>$_GET</code> stops working. It doesn't recognise the parameter at... | <p>If it's a mod_rewrite problem, which it sounds like, you could add the <code>[QSA]</code> flag to your mod_rewrite rule, to append the query string to the rewritten URL instead of throwing it away.</p>
<p>Your rule will end up looking like:</p>
<p><code>RewriteRule from to [QSA]</code></p>
| <p>If you want to make your PHP URLs "friendly" you need to use something like Apache's mod_rewrite. Google something like "apache mod_write friendly url" and you will get plenty of articles on the subject.</p>
| 20,593 |
<p>By default the SQL Server comes with the Langauge set to "English (United States)", setting the date format to mm/dd/yy instead of the date format I want it in, which is Australian and has a date format such as dd/mm/yy.</p>
<p>Is there an option in the Server Management Studio / Configuration tools where I can set... | <p>You can set the default language/locale of each user from SQL Management Studio (look under the Security folder). </p>
<p>And override this for a specific connection using the SET LANGUAGE command (or SET DATEFORMAT if you just want to change the date format).</p>
<p>You can also set the default language (used fo... | <p>have no idea what is the format in "down under" </p>
<p>dd/mm/yyyy hh:mm:ss ?</p>
<p>if yes, that date is the British/French annotation, so all you need to do is:</p>
<pre><code>INSERT INTO hello VALUES convert(datetime, @Date + ' 00:00:00', 103)
</code></pre>
<p>or </p>
<pre><code>INSERT INTO hello VALUES conv... | 25,531 |
<p>We are looking for a WYSIWYG editor control for our windows application (vb.net or c#) so that users can design HTML emails (to send using the SMTP objects in the dot net framework) before sending.</p>
<p>Currently all the available editors we can find have one of the following issues:</p>
<ol>
<li><p>They rely on... | <p>I also needed a WYSIWYG editor for a Windows Forms project that I was working on. I wrote about the items that I found <a href="http://ellisweb.net/2007/03/wysiwyg-editing-of-html-in-a-windows-forms-control/" rel="nofollow noreferrer">here</a>. Eventually, I ended up using something that I found on CodeProject: <a h... | <p>Instead of searching for an HTML editor, consider the option of a RichText editor (which can be much easier to create) and then convert the final text into a HTML document.</p>
<p>Provided you are required to use a minimal set of features (bold / italics etc) both the creation of the RT editor and the conversion of... | 3,004 |
<p>Playing with log4net, I have seen the possibility to use a per-thread stack of context labels called the NDC. </p>
<p>The labels pushed on this stack are displayed in a PatternLayout by specifying the <code>%x</code> or the <code>%ndc</code> format parameter.</p>
<p>The usage is something like: </p>
<pre><code>IL... | <p>In a server application such as ASP.NET.</p>
<p>For example, you can push information about the current request on to the NDC.</p>
| <p><code>NDC.Push</code> has been deprecated. The preferred way now (<code>ThreadContext.Stacks["NDC"]</code>) is this:</p>
<pre class="lang-cs prettyprint-override"><code>var disposable = ThreadContext.Stacks["NDC"].Push("context");
try
{
Log.Info("begin"); // optional, but nice
...
}
finally
{
Log.Info("end");... | 43,352 |
<p>What's the simplest way to join one or more arrays (or ArrayLists) in Visual Basic?</p>
<p>I'm using .NET 3.5, if that matters much.</p>
| <p>This is in C#, but surely you can figure it out...</p>
<pre><code>int[] a = new int[] { 1, 2, 3, 4, 5 };
int[] b = new int[] { 6, 7, 8, 9, 10 };
int[] c = a.Union(b).ToArray();
</code></pre>
<p>It will be more efficient if instead of calling "ToArray" after the union, if you use the IEnumerable given instead.</p>
... | <p>You can take a look at this thread that's titled <em><a href="https://stackoverflow.com/questions/59217/merging-two-arrays-in-net">Merging two arrays in .NET</a></em>.</p>
| 27,137 |
<p>in my flex application, I created a Tilelist. In this Tilelist, I am using an ItemRenderer to create a box consisting of an image and an VSlider in each tile. </p>
<p>The tile need to be dragable when you click on the image, but not dragable when you slide the slider. How can I achieve this ? I have been scratching... | <p>I found a solution to my problem, however it may not be the best one.</p>
<p>Using this : </p>
<pre><code> public var overImage:Boolean = false;
public function checkAllow(evt:DragEvent):void {
if(overImage == false)
{
evt.preventDefault()
}
... | <pre><code> if(event.target is ScrollThumb )
{
return;
}
</code></pre>
<p>problem solved by returning the scrollThumb property of sroller in imageDragStart method...</p>
<p>BackGround:My TileList is provided with mouseDown ="event.currentTarget.addEventListener(MouseEvent.MOUSE... | 35,731 |
<p>I have a class with both a static and a non-static interface in C#. Is it possible to have a static and a non-static method in a class with the same name and signature?</p>
<p>I get a compiler error when I try to do this, but for some reason I thought there was a way to do this. Am I wrong or is there no way to hav... | <p>No you can't. The reason for the limitation is that static methods can also be called from non-static contexts without needing to prepend the class name (so MyStaticMethod() instead of MyClass.MyStaticMethod()). The compiler can't tell which you're looking for if you have both. </p>
<p>You can have static and non... | <p>You can have static and instance method with the same name, as long as their declaration differs in the number or type of parameters. It's the same rule on how you can have two instance methods with the same name in a class.</p>
<p>Though technically, in the case of static vs. instance method, they already differ b... | 19,365 |
<p>I've seen some nice screenshot popups around the web, do you know of any library to do that? I could write my own, but... if there's something free I can save time.</p>
<p>Thanks!</p>
| <p>Sounds like you want a lightbox.</p>
<p>jQuery lightbox gets my vote.</p>
<p><a href="http://leandrovieira.com/projects/jquery/lightbox/" rel="nofollow noreferrer">http://leandrovieira.com/projects/jquery/lightbox/</a></p>
<p>Dead simple - no point me writing examples, its all there on the site.</p>
| <p>You didn't say whose website you want thumbnails from, or how many thumbnails. Look at Alexa's service:</p>
<p><a href="http://aws.amazon.com/ast/" rel="nofollow noreferrer">http://aws.amazon.com/ast/</a></p>
| 42,601 |
<p>I've had my first go at writing a DLL in Delphi. So far so good. By using a typelib I've been able to pass Widestrings to and from the DLL without difficulty.</p>
<p>What's curious at the moment is that I'm using VB6 as the testbed, and every time I run a test within the IDE, the program runs and then the IDE proce... | <pre><code>result := PWideString(s);
</code></pre>
<p>You are returning pointer to a local variable here. It immediately becomes invalid.</p>
| <p>I just got thoroughly straightened out on this one, thanks to Rob Kennedy on news:comp.lang.pascal.delphi.misc</p>
<p>He said, amongst other things that:</p>
<ol>
<li>This DLL does not need ShareMem, SysUtils, or Classes. </li>
<li>You've taken a WideString and told the compiler that it's really a pointer to a Wid... | 23,533 |
<p>I'm looking for an OSX (or Linux?) application that can recieve data from a webcam/video-input and let you do some image processing on the pixels in something similar to c or python or perl, not that bothered about the processing language.</p>
<p>I was considering throwing one together but figured I'd try and find ... | <p>If you're willing to do a little coding, you want to take a look at QTKit, the QuickTime framework for Cocoa. QTKit will let you easity set up an input source from the webcam (intro <a href="http://developer.apple.com/quicktime/qtkit.html" rel="nofollow noreferrer">here</a>). You can also apply Core Image filters to... | <p>Found a cross platform tool called 'Processing', actually ran the windows version to avoid further complications getting the webcams to work.</p>
<p>Had to install quick time, and something called gVid to get it to work but after the initial hurdle coding seems like C; (I think it gets "compiled" into Java), and it... | 27,995 |
<p>I have a project where I am taking some particularly ugly "live" HTML and forcing it into a formal XML DOM with the HTML Agility Pack. What I would like to be able to do is then query over this with Linq to XML so that I can scrape out the bits I need. I'm using the method described <a href="http://vijay.screaming... | <p>Using <code>LocalName</code> should be okay. I wouldn't consider it a hack at all if you don't care what namespace it's in. </p>
<p>If you know the namespace you want and you want to specify it, you can:</p>
<pre><code>var ns = "{http://www.w3.org/1999/xhtml}";
var x = xDoc.Root.Descendants(ns + "div");
</code></... | <p>I think your Google-fu fails you:</p>
<p><a href="http://www.google.com.au/search?hl=en&q=linq+xml+namespaces" rel="nofollow noreferrer">http://www.google.com.au/search?hl=en&q=linq+xml+namespaces</a></p>
| 22,168 |
<p>I have seen the references to VistaDB over the years and with tools like SQLite, Firebird, MS SQL et. al. I have never had a reason to consider it.</p>
<p>What are the benefits of paying for VistaDB vs using another technology? Things I have thought of:<br>
1. Compact Framework Support. SQLite+MSSQL support the C... | <p>The VistaDB client runtime is free. The runtime will never "expire at 3am" as you put it. Only the developer tools are licensed in that manner. You need 1 license per developer, simple. We even offer a really inexpensive Lite version with no Visual Studio tools.</p>
<p><b>Some other benefits</b></p>
<p><strong... | <p>I hadn't seen VistaDB before, it does look pretty cool.</p>
<p><b>Update:</b> Received a comment from someone from VistaDB - their update model is only for getting new versions. Your old ones won't stop working if your license expires, which is good to know.</p>
<p>Keeping the original post here as IMHO the warnin... | 7,899 |
<p>I'm familiar with some of the basics, but what I would like to know more about is when and why error handling (including throwing exceptions) should be used in PHP, especially on a live site or web app. Is it something that can be overused and if so, what does overuse look like? Are there cases where it shouldn't be... | <p>One thing to add to what was said already is that it's paramount that you record any errors in your web application into a log. This way, as Jeff "Coding Horror" Atwood suggests, you'll know when your users are experiencing trouble with your app (instead of "asking them what's wrong"). </p>
<p>To do this, I recomme... | <p>You can also use Google Forms to catch and analyse exceptions, without having to maintain a database or publicly accessible server. There is a tutorial <a href="http://www.brighthub.com/hubfolio/matthew-casperson/articles/56351.aspx" rel="nofollow noreferrer">here</a> that explains the process.</p>
| 16,259 |
<p><img src="https://farm4.static.flickr.com/3199/3099078396_a3c4924c81_o.gif" alt="alt text"></p>
<p>On the left you will notice the google logo rendered by IE, I drew a black line at the top and bottom of the G which extends into the FF windows which rendered the same exact logo yet the FF version renders the image ... | <p>I just created a composite image of screenshots of the Google image in IE, Firefox & Chrome and they're all in perfect register (top 2 images at 30% opacity).</p>
<p>I believe it has to be a custom zoom you've got set in one of your browsers. Check IE's zoom at the right of the status bar, for example. </p>
<p... | <p>Is text rendering any different? Might be that you have zoomed the page in FF (or IE)?</p>
<p>Can try Ctrl-0 to reset zoom sizing (works in both), I have a logitech mouse with a free spinning wheel, so this happens to me quite a bit when I forget the scroll wheel is still spinning and hit the Ctrl key. Plenty other... | 46,666 |
<p>I'm trying to use prototype and scriptaculous to hide and display a div element but the function (below) to take advantage of the prototype setStyle property isn't working and I'm not sure what the problem is.</p>
<pre><code><script type="text/javascript" language="javascript">
function bodyOnload() {
... | <p><a href="https://stackoverflow.com/questions/366251/#366297">maxnk</a> already covered the main issue.</p>
<p>But, Prototype recommends using the <a href="http://www.prototypejs.org/api/document/observe" rel="nofollow noreferrer"><code>dom:loaded</code></a> event instead of <code>window.onload</code>:</p>
<pre><co... | <p>Great! it now works. You know this is an example in a book I was trying to learn from. The author neglected this very important part just as he misleadingly said that the best way to reference the effects library in scriptaculous is like so:</p>
<pre><code><script type="text/javascript" src="javascripts/prototyp... | 47,809 |
<p>I could probably write this myself, but the specific way I'm trying to accomplish it is throwing me off. I'm trying to write a generic extension method similar to the others introduced in .NET 3.5 that will take a nested IEnumerable of IEnumerables (and so on) and flatten it into one IEnumerable. Anyone have any i... | <p>Here's an extension that might help. It will traverse all nodes in your hierarchy of objects and pick out the ones that match a criteria. It assumes that each object in your hierarchy <strong>has a collection property</strong> that holds its child objects.</p>
<h2>Here's the extension:</h2>
<pre><code>/// Traverse... | <p>Basicly, you need to have a master IENumerable that is outside of your recursive function, then in your recursive function (Psuedo-code)</p>
<pre><code>private void flattenList(IEnumerable<T> list)
{
foreach (T item in list)
{
masterList.Add(item);
if (item.Count > 0)
{
... | 17,096 |
<p>Is it possible to forward declare an standard container in a header file? For example, take the following code:</p>
<pre><code>#include <vector>
class Foo
{
private:
std::vector<int> container_;
...
};
</code></pre>
<p>I want to be able to do something like this:</p>
<pre><code>namespace std... | <p>Declaring <code>vector</code> in the <code>std</code> namespace is <strong>undefined behavior</strong>. So, your code might work, but it also might not, and the compiler is under no obligation to tell you when your attempt won't work. That's a gamble, and I don't know that avoiding the inclusion of a standard C++ he... | <p>I don't think so because the compiler would have no way of knowing how much space to allocate for the <code>container_</code> object. At best you could do:</p>
<pre><code>std::vector<int> *container_;
</code></pre>
<p>and new it in the constructor, since the compiler knows the size of a pointer.</p>
| 39,551 |
<p>Can someone explain the pros and cons of it and any math involved with it?</p>
| <p>For 2D:
You do not need any math for this problem, you need only a custom bitblit-routine. You will blit collision candidates into a hidden surface by painting their collisionmasks onto this surface and checking, if the pixels you just want to draw are (pixel != 0) . Then you will have a collision. Of course, you sh... | <p>taking about OpenGL and the texture-case: you could precalculate a bit matrix for the image and test if two pixels are overlapping.</p>
| 20,862 |
<p>I have below a list of text, it is from a popular online game called EVE Online and this basically gets mailed to you when you kill a person in-game. I'm building a tool to parse these using PHP to extract all relevant information. I will need all pieces of information shown and i'm writting classes to nicely break ... | <p>I'd probably go with a state machine approach, reading each line in sequence and dealing with it depending on the current state.</p>
<p>Some lines, like "Dropped items:" change the state, causing you to interpret following lines as items. While in the "reading involved parties" state you'd be adding each line to an... | <p>You might be interested in <a href="http://pear.php.net/package/PHP_LexerGenerator" rel="nofollow noreferrer">http://pear.php.net/package/PHP_LexerGenerator</a></p>
<p>(Yes, it's alpha. Yes, I haven't used it myself. Yes, you need to know/learn the lexer syntax. Why do I suggest it? Just curious what your experienc... | 42,125 |
<p>I'm having an error where I am not sure what caused it.</p>
<p>Here is the error:</p>
<pre><code>Exception Type: OperationalError
Exception Value:
(1054, "Unknown column 'user_id' in 'field list'")
</code></pre>
<p>Does anyone know why I am getting this error? I can't figure it out. Everything seems to be... | <p>You'll have to show your models to get real help, but it looks like your Idea table doesn't have a user_id column? Did you modify the SQL table structure?</p>
| <p>Yes, I dropped the tables and it all worked great. However, you have to actually go into the database and DROP them. "manage.py flush" or "manage.py reset appname" won't do it by themselves.</p>
<p>-Nick O</p>
| 37,433 |
<p>I'm trying to replace every multiline import inside a Python source file.. So, the source goes like</p>
<pre><code>from XXX import (
AAA,
BBB,
)
from YYY import (
CCC,
DDD,
EEE,
...
)
...other instructions...
</code></pre>
<p>and I'd like to get something like</p>
<pre><code>from XXX import AAA,... | <p>Ummm... what's wrong with Python?</p>
<pre><code>lineIter= iter(aFile)
for aLine in lineIter:
if aLine.startswith("import"):
if aLine.endswith("("):
for aModule in lineIter:
if aModule.endwith(")"):
break
print "import", aModule.strip()
... | <p>For posterity, here is a somewhat polished version of S.Lott's script (I'd have posted it as a comment, but it's too long ^^; ).. This version preserves indentation and produces a result closer to my example.</p>
<pre>
lineIter=iter(aFile)
for aLine in lineIter:
s = aLine.strip()
if s.startswith("from ") an... | 48,042 |
<p>Is there any performance advantage to using lists over dictionaries over tuples in Python?</p>
<p>If I'm optimising for speed, is there any reason to prefer one over another?</p>
| <p>Rich,</p>
<p>Lists and dicts are beasts suitable for different needs. Make sure you don't use lists for linear searches where dicts hashes are perfect, because it's way slower. Also, if you just need a list of elements to traverse, don't use dicts because it will take much more space than lists.</p>
<p>That may so... | <p>See the following.</p>
<ul>
<li><a href="https://stackoverflow.com/questions/172720/speeding-up-python">Speeding Up Python</a></li>
<li><a href="https://stackoverflow.com/questions/178045/when-should-you-start-optimising-code">When should you start optimising code</a></li>
<li><a href="https://stackoverflow.com/que... | 39,801 |
<p>What does the following expression return in Java?</p>
<pre><code>Math.max(Float.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
</code></pre>
<p>I saw this question in a website and the answer is <code>Double.POSITIVE_INFINITY</code>. I'm not sure about this answer as how can we compare 2 infinities? Can someone c... | <p>Float.POSITIVE_INFINITY returns float and Double.POSITIVE_INFINITY returns double.</p>
<p>There is no method called Math.max(float, double).
only Math.max(float, float) and Math.max(double, double)</p>
<p>Therefore when the method is called Math.max(float, double), it converts the float argument to double and so t... | <p>The question of whether, mathematically speaking, you can compare infinities is best left to the more mathematically literate here. But I think that in the case of Float.POSITIVE_INFINITY vs Double.POSITIVE_INFINITY it's simply the case that Double is bigger than Float and the POSITIVE_INFINITY constants are simply ... | 42,845 |
<p>Where can I find some Automator video tutorials ?</p>
<p>Thanks</p>
| <p>After some deep search on google I found this:</p>
<p><a href="http://automator.us/leopard/video/index.html" rel="nofollow noreferrer">http://automator.us/leopard/video/index.html</a></p>
<p>I hope it helps.</p>
| <p>There are some good at <a href="http://www.pixelcorps.tv/macbreak_dev" rel="nofollow noreferrer">MacBreak Dev</a> with Sal Soghoian. This are the numbers 5, 7 and 9-12. Also 13 contains a little bit Automator stuff.</p>
| 47,910 |
<p>Using VS 2008, here is my COM object</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace TestCom
{
[Guid("9E5E5FB2-219D-4ee7-AB27-E4DBED8E123E")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[... | <p>I'm going to answer my own question, hopefully to spare others the hours of tedious drudgery I have just endured.</p>
<p>If you get this, it <B>is</B> because the .NET based COM assembly can't find the .NET framework</p>
<p>The solution is simple. Create a file containing the following</p>
<pre><code><?xml ver... | <p>This works for me from VBA... I tried it using Word & Excel 2003 (SP3).</p>
<p>I'm not sure what you mean by "production" machine. Because this is a "client" application and must be executed on the client using Excel.</p>
<p>If you're automating Excel on the server and triggering this "interop" through a VBA... | 49,136 |
<p>I need to create an installer program that will do install the following:</p>
<ol>
<li>ASP.Net Website </li>
<li>Windows Service</li>
<li>SQL Express if it isn't installed
and the user doesn't have a SQL
Server</li>
<li>Dundas Charts</li>
<li>ASP.Net AJAX v.1.0</li>
<li>ReportViewer control (for 2.0 Framework)</li>... | <p>You can use <a href="http://wix.sourceforge.net/" rel="nofollow noreferrer">WiX</a></p>
| <p>I used WiX. I banged my head against the wall for a few days, then got the hang of it. The WiX mailing list is key if you have never worked with WiX before.</p>
| 15,968 |
<p>In IIS I can configure my custom error pages.<br>
For each HTTP Error code I can say where to go. Several codes have a number of "sub" codes available. For example 404 has a regular 404, 404;1, 404;2 and so on..</p>
<p>What are they for? When are they returned? Should I make custom pages for these errors? Can I som... | <p>401 - Access denied. IIS defines several different 401 errors that indicate <strong>a more specific cause of the error</strong>. These specific error codes are displayed in the browser but are not displayed in the IIS log:</p>
<ul>
<li>401.1 - Logon failed.</li>
<li>401.2 - Logon failed due to server configuration.... | <p><a href="http://blog.crowe.co.nz/archive/2005/08/26/231.aspx" rel="nofollow noreferrer">This blog article</a> appears to explain a lot of this. Perhaps it can be of help? At the very least, it explains the meaning of the 'sub-codes'.</p>
| 33,658 |
<p>I'm currently on chapter 4 of Real World Haskell, and I'm trying to wrap my head around <a href="http://book.realworldhaskell.org/read/functional-programming.html#x_E9" rel="noreferrer">implementing foldl in terms of foldr</a>.</p>
<p>(Here's their code:)</p>
<pre><code>myFoldl :: (a -> b -> a) -> a ->... | <pre><code>zip2 xs ys = foldr step done xs ys
where done ys = []
step x zipsfn [] = []
step x zipsfn (y:ys) = (x, y) : (zipsfn ys)
</code></pre>
<p>How this works: (foldr step done xs) returns a function that consumes
ys; so we go down the xs list building up a nested composition of
functions tha... | <p>A simple approach:</p>
<pre><code>lZip, rZip :: Foldable t => [b] -> t a -> [(a, b)]
-- implement zip using fold?
lZip xs ys = reverse.fst $ foldl f ([],xs) ys
where f (zs, (y:ys)) x = ((x,y):zs, ys)
-- Or;
rZip xs ys = fst $ foldr f ([],reverse xs) ys
where f x (zs, (y:ys)) = ((x,y):zs, ys)
... | 29,103 |
<p>I have an application that has to deal with getting "special" characters in its URL (like &, +, %, etc). When I'm sending a request to the application using these characters (of course I'm sending them escaped) I'm getting "Bad Request" response code with the message "ASP.NET detected invalid characters in the U... | <p>I ran into the same problem (creating an IHttpHandler that needed to receive requests with special characters in the URL). I had to do two things to fix it:</p>
<ol>
<li><p>Create the following DWORD registration entry with a value of 1: <code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\VerificationCompatibility... | <p>You can set validateRequest to false in the pages section of the web.config. Maybe that works for HttpHandlers as well?</p>
| 36,510 |
<p>What's the best way to take some plain text (not PHP code) which contains PHP-style variables, and then substitute in the value of the variable. This is kinda hard to describe, so here's an example.</p>
<pre><code>// -- myFile.txt --
Mary had a little $pet.
// -- parser.php --
$pet = "lamb";
// open myFile.txt and... | <p>Regex would be easy enough. And it would not care about things that <code>eval()</code> would consider a syntax error.</p>
<p>Here's the pattern to find PHP style variable names.</p>
<pre><code>\$\w+
</code></pre>
<p>I would probably take this general pattern and use a PHP array to look up each match I've found (... | <p>You could use <a href="http://www.php.net/strtr" rel="nofollow noreferrer">strtr</a>:</p>
<pre><code>$text = file_get_contents('/path/to/myFile.txt'); // "Mary had a little $pet."
$allVars = get_defined_vars(); // array('pet' => 'lamb');
$translate = array();
foreach ($allVars as $key => $value) {
$trans... | 35,896 |
<p>I'm looking at Rails development as a backend to a Flex application and am trying to figure out the communication layer between the Rails app and the Flash Player. All of the things I am finding suggest using SOAP web services to communicate.</p>
<p>However, Flash supports AMF which is nice and fast (and native). ... | <p>There is <a href="http://www.themidnightcoders.com/weborb/rubyonrails/" rel="nofollow noreferrer">WebORB</a> or <a href="http://code.google.com/p/rubyamf/" rel="nofollow noreferrer">RubyAMF</a> which you can use to respond in AMF from Rails, the approaches are a bit different for each one so it depends on your needs... | <p>There's a Rails plugin called <a href="http://www.themidnightcoders.com/weborb/rubyonrails/index.htm" rel="nofollow noreferrer">WebORB for Ruby on Rails</a> which uses remoting with AMF. </p>
| 9,593 |
<p>How can I get programmatic access to the call stack?</p>
| <p>Try <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.stacktrace.aspx" rel="noreferrer">System.Diagnostics.StackTrace</a>.</p>
| <p>The right way is to use the <code>StackTrace</code> and <code>StackFrame</code> classes. Throwing an exception just to get the stack trace is completely misusing exceptions.</p>
| 3,436 |
<p>I'm sure this problem has been solved before and I'm curious how its done. I have code in which, when run, I want to scan the contents of a directory and load in functionality.</p>
<p>Specifically, I am working with a scripting engine that I want to be able to add function calls to. I want the core engine to provid... | <p>It depends on the platform. On win32, you call <code>LoadLibrary</code> to load a DLL, then get functions from it with <code>GetProcAddress</code>. On Unixy platforms, the equivalents are <code>dlopen</code> and <code>dlsym</code>.</p>
| <p>You can use the POSIX dlopen/dlsym/dlerror/dlclose functions in Linux/UNIX to dynamically open shared libraries and access the symbols (including functions) they provide, see the <a href="http://linux.die.net/man/3/dlopen" rel="nofollow noreferrer">man page</a> for details.</p>
| 26,048 |
<p>For a particular project I have, no server side code is allowed. How can I create the web site in php (with includes, conditionals, etc) and then have that converted into a static html site that I can give to the client?</p>
<p>Update: Thanks to everyone who suggested wget. That's what I used. I should have specifi... | <p>If you have a Linux system available to you use <a href="http://www.gnu.org/software/wget/" rel="noreferrer">wget</a>:</p>
<pre><code>wget -k -K -E -r -l 10 -p -N -F -nH http://website.com/
</code></pre>
<p>Options</p>
<ul>
<li>-k : convert links to relative</li>
<li>-K : keep an original versions of files witho... | <p>I do it on my own web site for certain pages that are guaranteed not to change -- I simply run a shell script that could be boiled to (warning: bash pseudocode):</p>
<pre><code>find site_folder -name \*.static.php -print -exec Staticize {} \;
</code></pre>
<p>with Staticize being:</p>
<pre><code># This replaces .... | 9,210 |
<p>Do developers have to put certain/extra elements in the feed's XML file or attributes in the hyperlink for the browser to recognize that it's a feed that can be subscribed to? Or do browsers do that automatically as long as the XML validates?</p>
<p>(showing users that "Subscribe to this feed using..." interface in... | <p>Most modern browsers are intelligent enough to inspect an XML data source and HTTP headers and determine if it represents a syndication feed (typically formatted as Atom or RSS). However, there are a couple of things you can do to improve auto-discovery of syndication feeds within a web site and when dynamically gen... | <p>The feed isn't just XML, but should follow a format such as <a href="http://en.wikipedia.org/wiki/ATOM" rel="nofollow noreferrer" title="Wikipedia on ATOM">ATOM Syndication Format</a> or <a href="http://en.wikipedia.org/wiki/RSS_(file_format)" rel="nofollow noreferrer" title="Wikipedia on RSS">RSS</a>.</p>
<p>The b... | 38,140 |
<p>I'm testing the basics for exchanging rest messages between a asp.net mvc site and a WCF 3.5 service.
The service is built using the template found in the WCF REST Starter Kit found on codeplex.
I would like to exchange json messages using jquery.
The REST Singleton service is working properly and it also provide ex... | <p>"PUT" and "DELETE" are not supported by all browsers according to jQuery</p>
<blockquote>
<p>The type of request to make ("POST" or
"GET"), default is "GET". Note: Other
HTTP request methods, such as PUT and
DELETE, can also be used here, but
they are not supported by all
browsers.</p>
</blockquote>
<p... | <p>The PUT and DELETE verbs are not enabled on all servers. You need to place these verbs in a X-HTTP-Method-Override header. The valeu is taken from the header and substituted for a normal POST jsut before the request is processed.</p>
<p>The jQuery jREST Plugin can help you with this. If you are using WCF, you will ... | 40,998 |
<p>To make a JavaScript class with a public method I'd do something like:</p>
<pre><code>function Restaurant() {}
Restaurant.prototype.buy_food = function(){
// something here
}
Restaurant.prototype.use_restroom = function(){
// something here
}
</code></pre>
<p>That way users of my class can:</p>
<pre><code... | <p>You can do it, but the downside is that it can't be part of the prototype:</p>
<pre><code>function Restaurant() {
var myPrivateVar;
var private_stuff = function() { // Only visible inside Restaurant()
myPrivateVar = "I can set this here!";
}
this.use_restroom = function() { // use_restro... | <p>Private functions cannot access the public variables using module pattern</p>
| 7,942 |
<p>Recently a friend and I were talking about securing stored procedure code in a SQL server database. </p>
<p>From distant memory, I'm pretty certain that "with encryption" is incredibly easily broken in all versions of SQL Server, however he said it has been greatly improved in SQL 2005. As a result I have not ser... | <p>It can be used to hide your code from casual observers, but as you say: it's easily circumvented.</p>
<p>It really can't be any other way, since the server needs to decrypt the code to execute it. It's DRM, basically, and fails for the same reason as all the other DRM does - you can't simultaneously hide the data, ... | <p>Yes, it's easily broken. I had a situation this past week where I had to decrypt several sprocs that a former developer had encrypted for a client of mine. After decrypting it, which took a moderate effort, I wouldn't rely on that for any means of protecting intellectual property, passwords, user ids. Anything reall... | 7,404 |
<p>I want to copy a DLL file from PC to vs.net`s pocket pc 2003 simulator, so i use the shared folder of the simulator, but i can not see the dll file in file list of simulator.</p>
<p>How to do it, please ?</p>
| <p>Add it to the project's primary output.</p>
| <p>Suggestion: if you need to use an external DLL to be copied along with your code, add a reference to the DLL, and in its properties pane on Visual Studio make sure that Copy Local is set to True. That might accomplish what you're trying to do.</p>
| 13,806 |
<p>I'm searching for a way of developing a MethodInterceptor which prints the caller class.</p>
<p>Is there any way of getting the caller object into the method interceptor?</p>
| <p>This might work, declare an exception and then use it to get a look at the stack at the time when your method is intercepted:</p>
<pre><code>
Throwable t = new Throwable();
StackTraceElement[] elements = t.getStackTrace();
String calleeMethod = elements[0].getMethodName();
String callerMethodName = elements[1].get... | <p>You could do something crude with generating a stack trace and inspecting it, but that is ugly</p>
| 36,922 |
<p>I'm quite used to my IDE setup in Delphi 7, where I have my comments rendered in italics.</p>
<p>This doesn't appear to be possible in VS2008. There's only an option for bold font, not italics.</p>
<p>Is there some kind of registry hack or font magic I can perform to get it to work? The font I'm using is Consolas,... | <p>If you have a font editor, you can change an italic font to pretend it's bold. <a href="http://damieng.com/blog/2007/07/11/italic-syntax-highlighting-in-visual-studio-2005" rel="nofollow noreferrer">Here's an example of it.</a> (For VS 2005, but it should work all the same.)</p>
| <p>Unfortunately not...not sure why they don't let you do that.</p>
<p>You can, however, change the font for just comments. So you could make it something different which will make it stand out more.</p>
<p>You may even be able to make a custom version of the font you use that is by default italic and then set that ... | 3,625 |
<p>Have you refactored from an <a href="http://martinfowler.com/eaaCatalog/activeRecord.html" rel="nofollow noreferrer">ActiveRecord</a> to a <a href="http://martinfowler.com/eaaCatalog/dataMapper.html" rel="nofollow noreferrer">DataMapper</a> pattern? What conditions prompted the switch? I'm primarily interested in we... | <p>I really do like the ActiveRecord pattern for its simplicity. However, I have been moving away from it for larger web apps. I find that as an ActiveRecord based project becomes more complex the ActiveRecord objects become large and laden with too much code. </p>
<p>By introducing a Repository pattern (essentially... | <p>I wrote an integrated build system sitting on top of PDE-Build using <a href="http://camping.rubyforge.org/" rel="nofollow noreferrer">camping</a>. I initially used ActiveRecord, but I needed non-blocking thread-safe access to the database, so I switched to using Data Mapper.</p>
<p>I had my fair share of grief fro... | 21,894 |
<p>given a matrix of distances between points is there an algorithm for determining a set of n-dimensional points that has these distances? (or at least minimises the error) </p>
<p>sort of like a n-dimensional version of the turnpike problem.</p>
<p>The best I can come up with is using multidimensional scaling.</p>
| <p>You are on the right track with multi-dimensional scaling (MDS), but MDS is impractical for large datasets, as its time complexity is quadratic in the number of points. You may want to look at FastMap, which has linear time complexity and is better suited to indexing. See:</p>
<blockquote>
<p>Christos Faloutsos... | <p>I can't edit the original, because I don't have enough rep, but I've tried to restate the problem here.</p>
<p>The OP has an input NxN matrix of distances. He wants to create an output array, size N, of N-dimensional coordinates representing points, where the distance between each point is stored in the input matri... | 22,007 |
<p>In the code below</p>
<pre><code>For i = LBound(arr) To UBound(arr)
</code></pre>
<p>What is the point in asking using <code>LBound</code>? Surely that is always 0.</p>
| <p>Why not use <code>For Each</code>? That way you don't need to care what the <code>LBound</code> and <code>UBound</code> are.</p>
<pre><code>Dim x, y, z
x = Array(1, 2, 3)
For Each y In x
z = DoSomethingWith(y)
Next
</code></pre>
| <p>This is my approach:</p>
<pre><code>dim arrFormaA(15)
arrFormaA( 0 ) = "formaA_01.txt"
arrFormaA( 1 ) = "formaA_02.txt"
arrFormaA( 2 ) = "formaA_03.txt"
arrFormaA( 3 ) = "formaA_04.txt"
arrFormaA( 4 ) = "formaA_05.txt"
arrFormaA( 5 ) = "formaA_06.txt"
arrFormaA( 6 ) = "formaA_07.txt"
arrFormaA( 7 ) = "formaA_08.txt... | 2,450 |
<p>Are there any tools to have a more robust clipboard type feature in windows?</p>
<p>I am using vs.net 2008 (if it has it built-in and I don't know about it?)</p>
<p>I used to have this tool where I created lots of items in my clipboard that I could access using short-cuts, but I forgot that name of that app!</p>
... | <p>I use <a href="http://www.bluemars.org/clipx/" rel="nofollow noreferrer">ClipX</a></p>
<p>Very stable and low footprint.</p>
| <p>There is one called <a href="http://www.xrayz.co.uk/purchase/get-it-free" rel="nofollow noreferrer">ClipCache</a> which does something similar to what you describe here. At any rate, I recommend it.</p>
| 25,222 |
<p>There's an MSDN article <a href="http://msdn.microsoft.com/en-us/library/aa919730.aspx" rel="nofollow noreferrer">here</a>, but I'm not getting very far:</p>
<pre><code>p = 139;
g = 5;
CRYPT_DATA_BLOB pblob;
pblob.cbData = sizeof( ULONG );
pblob.pbData = ( LPBYTE ) &p;
CRYPT_DATA_BLOB gblob;
gblob.cbData = si... | <p>It may be that it just doesn't like the very short keys you're using.</p>
<p>I found <a href="http://msdn.microsoft.com/en-us/library/aa381969.aspx" rel="nofollow noreferrer">the desktop version of that article</a> which may help, as it has a full example.</p>
<p>EDIT:</p>
<p>The OP realised from the example that... | <p>It looks to me that <code>KP_P</code>, <code>KP_G</code>, <code>KP_Q</code> are for DSS keys (Digital Signature Standard?). For Diffie-Hellman it looks like you're supposed to use <code>KP_PUB_PARAMS</code> and pass a <code>DATA_BLOB</code> that points to a <code>DHPUBKEY_VER3</code> structure.</p>
<p>Note that the... | 10,221 |
<p>I have an application where I open a log file for writing. At some point in time (while the application is running), I opened the file with Excel 2003, which said the file should be opened as read-only. That's OK with me.</p>
<p>But then my application threw this exception:</p>
<blockquote>
<p>System.IO.IOExcept... | <p>Here is a logger which will take care of sync locks. (You can modify it to fit to your requirements)</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Owf.Logger
{
public class Logger
{
private static object syncContoller = string.Empty;
... | <p>How do you write the log? Have your own open/close or use some thirty party product?</p>
<p>I thing that the log is opened and locked only when it writes something. Once the data writing is finished, the code closes the file and, of course, releases the lock</p>
| 43,218 |
<p>What is the best way to print stuff from c#/.net?</p>
<p>The question is in regard to single pages as well as to reports containing lots of pages. </p>
<p>It would be great to get a list of the most common printing libs containing the main features and gotchas of each of them.</p>
<p>[Update] for standard windows... | <p>For reports, I use the RDLC control.</p>
<p>For everything else, I use the inherent printing objects within .NET.</p>
<p><strong>Edit</strong>
The inherent printing objects are all found in the System.Drawing.Printing namespace. When you use the PrintDialog or the PrintPreviewDialog in a WinForms (or WPF) applicat... | <p>It depends a lot on the requirements of your application.</p>
<p>Even though it isn't the perfect tool (really far from that), Crystal Reports tends to be a good choice.
It gives you the option of getting data directly from a Database or, if you already have a list of objects you want to print, you can pass them to... | 48,532 |
<p>What are the basic necessities needed to build a 3d printing machine.</p>
<ul>
<li>Workforce</li>
<li>Technology</li>
<li>Money</li>
<li>etc.</li>
</ul>
<p>I'm an undergrad and my friends and I would like to make a printer for a project. We wanted to get an idea of the prerequisites for this work. </p>
| <p>Prints could end up on tray for couple of reasons. </p>
<ul>
<li>Vacuum force on early layers - Usually you should lose pieces on the center of platform
<ul>
<li>Put holes or channels on platform</li>
<li>Very slow speed on early layers</li>
<li>Use smaller platform</li>
<li>Use tilt mechanism</li>
<li>Use larger ... | <p>I also had issues with the first layer sticking to the build plate and I did not want to sand the plate. As most people will mention you need to make sure that your plate is perfectly level and the z height is right (lots of friction on the paper). You also need the correct exposure times for your resin and the firs... | 647 |
<p>I'm currently using the Yahoo YUI javascript library in a couple of my projects. </p>
<p>However, I'm a little concerned about three things. First, they laid off 10% of their employees. Second, their stock price keeps falling: especially after ignoring the MS takeover earlier this year. Third, what if someone d... | <p>Yahoo is a major company that won't end in the next couple of year.</p>
<p>The Yahoo! library is open source so you will have other people to continue to improve it IF Yahoo would go bankrupt.</p>
<p>No technology is 100% safe for 10 years perspective, I think you aren't in danger with it.</p>
<p>In 10 years Java... | <p>jQuery is for coding, YUI is for learning.
jQuery is more widespread than YUI because it is easy to sprinkle it on web pages that need simple DOM manipulations and basic AJAX or animations.
YUI is an extremely popular library that has historically been a favorite of more advanced developers and application builders.... | 37,184 |
<p>Let's say I have to implement a piece of T-SQL code that must return a table as result. I can implement a table-valued function or else a stored procedure that returns a set of rows. What should I use?</p>
<p>In short, what I want to know is: </p>
<p><strong>Which are the main differences between functions and sto... | <p>If you're likely to want to combine the result of this piece of code with other tables, then obviously a table-valued function will allow you to compose the results in a single SELECT statement.</p>
<p>Generally, there's a hierarchy (View < TV Function < Stored Proc). You can do more in each one, but the abil... | <p>Stored procedures are pre compiled queries which executes faster and saves from the sql injections. They can return 0 or N values. We can perform DML operations inside the stored procedures. We can use functions inside the procedures and can use functions in the select query.
Functions are used to return any value a... | 21,460 |
<p>I have a requirement to build a very simple streaming server. It needs to be able to capture video from a device and then stream that video via multicast to several clients on a LAN. </p>
<p>The capture part of this is pretty easy (in C#) thanks to a library someone wrote with DirectShow.Net (<a href="http://www.co... | <p>There are no filters available that you can plug and use.</p>
<p>You need to do three things here:</p>
<ol>
<li>Compress the video into MPEG2 or MPEG4</li>
<li>Mux it into MPEG Transport Stream</li>
<li>Broadcast it</li>
</ol>
<p>There are lots of codecs available for part 1, and some devices can even output comp... | <p>To achieve that you need to setup/write some kind of video streaming server.</p>
<p>I've used <a href="http://www.fathsoft.com/videocapx.html" rel="nofollow noreferrer">VideoCapX</a> for the same purpose on my project. The documentation and support is not top notch, but it's good enough. It's using WMV streaming te... | 47,137 |
<p>I have a subroutine that takes a filehandle as an argument. How do I make a filehandle from a file path specified on the command line? I don't want to do any processing of this file myself, I just want to pass it off to this other subroutine, which returns an array of hashes with all the parsed data from the file.... | <p>Command line arguments are available in the predefined <code>@ARGV</code> array. You can get the file name from there and use <code>open</code> to open a filehandle to it. Assuming that you want read-only access to the file, you would do it this way:</p>
<pre><code>my $file = shift @ARGV;
open(my $fh, '<', $file... | <p>Am I missing something or are you just looking for the open() call?</p>
<pre><code>open($fh, "<$ARGV[0]") or die "couldn't open $ARGV[0]: $!";
do_something_with_fh($fh);
close($fh);
</code></pre>
| 22,955 |
<p>How do I tokenize the string:</p>
<pre><code>"2+24*48/32"
</code></pre>
<p>Into a list:</p>
<pre><code>['2', '+', '24', '*', '48', '/', '32']
</code></pre>
| <p>It just so happens that the tokens you want split are already Python tokens, so you can use the built-in <code>tokenize</code> module. It's almost a one-liner; this program:</p>
<pre class="lang-py prettyprint-override"><code>from io import StringIO
from tokenize import generate_tokens
STRING = 1
print(
list(
... | <p>i'm sure Tim meant </p>
<pre><code>splitter = re.compile(r'([\D])').
</code></pre>
<p>if you copy exactly what he has down you only get the <code>digits</code> not the <code>operators</code>.</p>
| 11,427 |
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/72264/how-can-a-c-windows-dll-be-merged-into-a-c-sharp-application-exe">How can a C++ windows dll be merged into a C# application exe?</a> </p>
</blockquote>
<p>Is anybody aware of a program that can pack sever... | <p>Have a look at <strike>Thinstall</strike> <a href="http://www.vmware.com/products/thinapp/overview.html" rel="nofollow noreferrer">ThinApp</a></p>
| <p>MoleBox Pro does exactly what you want, but it is shareware, and, unless you buy a full version, packed executables will show a Dialog Box at startup, saying something like "This file was packed by a trial version of MoleBox, please do not distribute it"</p>
<p>You can downliad it here: <a href="http://www.brothers... | 43,717 |
<p>I was reading a review of the new Intel Atom 330, where they noted that Task Manager shows 4 cores - two physical cores, plus two more simulated by Hyperthreading.</p>
<p>Suppose you have a program with two threads. Suppose also that these are the only threads doing any work on the PC, everything else is idle. What... | <p>Linux has quite a sophisticated thread scheduler which is HT aware. Some of its strategies include:</p>
<p>Passive Loadbalancing: If a physical CPU is running more than one task the scheduler will attempt to run any new tasks on a second physical processor.</p>
<p>Active Loadbalancing: If there are 3 tasks, 2 on... | <p>The chance that the OS will dispatch 2 active threads to the same core is <strong>zero</strong> unless the threads were tied to a specific core (thread affinity).</p>
<p>The reasons behind this are mostly HW related:</p>
<ul>
<li>The OS (and the CPU) wants to use as little power as possible so it will run the task... | 47,022 |
<p>I'm looking for a program that I can install on a Mac that will tell me how many bytes I download each day, and store that info in such a way that I could later view the results.</p>
<p>Limiting by ports (80, 443, 21, 22) would be awesome as well.</p>
<p>Does such a thing exist?</p>
| <p><a href="http://www.wireshark.org/" rel="nofollow noreferrer">Wireshark</a> might be of interest to you.</p>
| <p>Type 'man tcpdump' in a terminal.</p>
| 18,673 |
<p>There is a SqlServer2000 Database we have to update during weekend.</p>
<p>It's size is almost 10G.</p>
<p>The updates range from Schema changes, primary keys updates to some Million Records updated, corrected or Inserted.</p>
<p>The weekend is hardly enough for the job.</p>
<p>We set up a dedicated server for t... | <p>Although dropping excess indexes may help, you need to make sure that you keep those indexes that will enable your upgrade script to easily find those rows that it needs to update.</p>
<p>Otherwise, make sure you have plenty of memory in the server (although SQL Server 2000 Standard is limited to 2 GB), and if need... | <p>What exactly does this "custom made program" look like? i.e. how is it talking to the data? Minimising the amount of network IO (from a db server to an app) would be a good start... typically this might mean doing a lot of work in TSQL, but even just running the app on the db server might help a bit...</p>
<p>If th... | 41,827 |
<p>I have authentication mode set to forms in my asp.net web.config but am still getting a windows login prompt when i browse to the website.</p>
<p>Could authentication mode be set elsewhere, in IIS for example? My site runs on IIS 6.</p>
<p>Thanks.</p>
| <p>This could be because the permissions on the folder that is being served is not allowed to be accessed by the user running the web site</p>
| <p>I have had issues where the authentication was set to forms and the directory security was set to allow anonymous, but some resources (images in my particular case) did not have the proper permissions to allow the anonymous user to read them.</p>
<p>The effect is that the user was prompted to login so that the grap... | 25,457 |
<p>I'm trying to use some extension methods that I use to apply consistent formatting to DateTime and Int32 - which works absolutely fine in code behind, but I'm having issues with databinding.</p>
<p>I get:</p>
<pre><code>'System.DateTime' does not contain a definition for 'ToCustomShortDate'
</code></pre>
<p>for</... | <p>Found the issue! I was including the namespace correcly as I thought - but the real issue was that the app was only INCLUDING the .NET 3.5 assemblies and not being compiled using the 3.5 compiler, was missing some entries from web.config which I realised when I created an empty project and tried it (successfully) in... | <p>You should remove the assembly name from the import namespace...</p>
<p>I guess your extension method is located in an namespace called Formatting.</p>
<pre><code>namespace Formatting
{
public static class DateTimeExtender
{
public static string ToCustomShortDate(this DateTime date)
{
... | 38,670 |
<p>Are htaccess redirects any slower/put any more strain on Apache than redirects in configuration files? Also, how big can a number of redirects in htaccess get before they start decreasing performance?</p>
| <p>Yes, it slows the server because it has to access the file each time a resource in that directory or any subdirectory thereof is accessed.</p>
<p>The amount of redirects is not relevant, because the main performance hit is the file access itself. This within reasonable constraints (ie a 5 Kb htaccess file will take... | <p>Using a .htaccess file is slower than using a configuration file - a .htaccess file is parsed whenever a request is made to a directory it affects - this allows for changing the file without restarting the server. Since a configuration file is parsed only once at server start, it's faster.</p>
<p>The amount of dire... | 25,672 |
<p>I need to simple way to allow an end user to restart tomcat from a web page served from apache on the same box.</p>
<p>We're trying to make it easy for our QC department to deploy a new version of our webapp to apache. We're using samba, but we need an easy way for them to stop / start the tomcat server before/afte... | <p>Like Skip said, but don't run the CGI as root. Instead, have the CGI call sudo. You can give your web server permission to run <code>/etc/init.d/tomcat restart</code> only in the sudoers file.</p>
<p>I've actually done this at work; the relevant part of the CGI looks like this:</p>
<pre><code>#!/usr/bin/perl
use C... | <p>I would use a CGI script. Set it up to run as root and call '/etc/init.d/tomcat restart' (or however you restart tomcat on your box).</p>
| 45,528 |
<p>I'd like to display 100 floating cubes using <code>DirectX</code> or <code>OpenGL</code>.</p>
<p>I'm looking for either some sample source code, or a description of the technique. I have trouble getting more one cube to display correctly.</p>
<p>I've combed the net for a good series of tutorials and although they... | <p>You say you have enough trouble getting one cube to display... so I am not sure if you have got one to display or not.</p>
<p>Basically... put your code for writing a cube in one function, then just call that function 100 times.</p>
<pre><code>void DrawCube()
{
//code to draw the cube
}
void DisplayCubes()
{
... | <p>This answer isn't just for OP's question. It also answers a more general question - displaying many cubes <em>in general</em>.</p>
<h3>Drawing many cube meshes</h3>
<p>This is probably the most naive way of doing things. We draw the same cube mesh with many different transformation matrices:</p>
<pre class="lang-cpp... | 2,349 |
<p>I want to translate xml documents with a certain schema into another schema. I know both the old and new schemas... </p>
<p>I am planning to use python's xml.dom library , and translate line by line.</p>
<p>Any ideas on how to go about it ? Any tools or libraries in other languages that might make this easier/mor... | <p>You could craft an XSLT to do this work for you. XSLT is specifically designed for the translation of XML data into some other text-based format, including XML. For more information on XSLT, I recommend <a href="http://www.w3schools.com/xsl/default.asp" rel="nofollow noreferrer">W3 Schools</a>.</p>
| <p>XSLT is the "recommended" way of doing it. However, you could probably do it faster with your python xml dom if you are familiar with python. Learning XSLT is a good idea though. I have to do this myself and I will be doing it with perl.</p>
| 46,129 |
<p>Beside the obvious person to person instant message chat, What else have you used a Jabber server's functionality to enable?</p>
<p>Edit: links to working code to really show it off are particularly useful - and will be more likely to be voted up.</p>
| <p>There are unlimited uses for XMPP/Jabber.</p>
<p>Take any message/data you want to send somewhere else and you can use jabber. Run a centralised logging service for distributed services? You can jabber the massage.
You want to check if your services/programs are running? XMPP presence will tell you. If you add cust... | <p>I've always thought XMPP would be a good way to deliver SNMP data. OIDs are really painful, much of the system is insecure, and the SNMP traps never work quite like you want them to. With an XMPP server in the middle and a smart component to make some choices, you can use it to send out jabber or other notificatio... | 14,004 |
<p>I'm creating a web application for work where the user has to enter the name of the person that requested the job. I'd like to create a simple AJAX auto-suggest dropdown so they don't need to type the entire name. On the backend, the database will provide suggestions based on previous entries. The website is buil... | <p>Since you are using CakePHP 1.1 I suggest you check out the Manual portion that deals with <a href="http://book.cakephp.org/view/316/Helpers" rel="nofollow noreferrer">Helpers</a></p>
<p>If you go down to 'AJAX', you can see you can do something like this in your controller:</p>
<pre><code>function autocomplete ()... | <p>You can't go wrong with jQuery. <a href="http://nodstrum.com/2007/09/19/autocompleter/" rel="nofollow noreferrer">http://nodstrum.com/2007/09/19/autocompleter/</a></p>
| 27,114 |
<p>I'm attempting to use extension methods to add an operater overload to the C# <code>StringBuilder</code> class. Specifically, given <code>StringBuilder</code> <code>sb</code>, I'd like <code>sb += "text"</code> to become equivalent to <code>sb.Append("text")</code>.</p>
<p>Here's the syntax for creating an extensi... | <p>This is not currently possible, because extension methods must be in static classes, and static classes can't have operator overloads. But the <a href="https://github.com/dotnet/csharplang/issues/192" rel="noreferrer">feature is being discussed for <em>some</em> future release of C#</a>. Mads talked a bit more about... | <p>Its possible to rigg it with a wrapper and extensions but impossible to do it properly. You end with garbage which totally defeats the purpose.
I have a post up somewhere on here that does it, but its worthless.</p>
<p>Btw
All numeric conversions create garbage in string builder that needs to be fixed. I had to wr... | 20,803 |
<p>Is there any chance of installing Reporting Services 2008 against an instance of SQL Server 2000? The docs clearly state that only SQL Server 2005 or 2008 are supported, but I thought I should ask anyway, for ways to bypass this limitation.</p>
<p>I should mention that I am not talking about the data source for my ... | <p>No, the reportserver and reportservertempdb REQUIRE 2005 or 2008. You could source data for your reports from a 2000 instance, but your reporting services databases need to be 2005 or 2008.</p>
<p>see: <a href="http://msdn.microsoft.com/en-us/library/ms157285.aspx" rel="nofollow noreferrer">http://msdn.microsoft.co... | <p>I have no idea if this would work, however reporting services also depends on the SQL Server Agent service (for subscriptions) as well as the relational databases, so both would need to be compatible. If you have Reporting Services 2008 then you (or your organisation) must own a SQL Server 2008 license of some sort,... | 48,889 |
<p>A recent article on <a href="http://arstechnica.com/news.ars/post/20080923-study-confirms-users-are-idiots.html" rel="nofollow noreferrer">Ars Technica</a> discusses a recent study performed by the Psychology Department of North Carolina State University, that showed users have a tendency to do whatever it takes to ... | <p>I try to design applications to be robust in the face of accidents -- either slips (inadvertent operations, such as clicking in the wrong place) or mistakes (cognitive errors, such as clicking Ok vs. Cancel on a dialog). Some ways to do this are:</p>
<ol>
<li>infinite (or at least multi-step) undo / redo</li>
<li>... | <p>First of all, stupid should hurt, but usually it doesn't so...</p>
<p>The next best thing is including an icon that tries to convey the severity of the issue. Some percentage of those who won't read might change their habit if the dialog's icon seems ominous. Some percentage won't read it regardless.</p>
| 15,226 |
<p>When a user clicks a link to download a file on my website, they go to <a href="http://viewsourcecode.org/viewsource/homebrew.php" rel="noreferrer">this PHP file</a> which increments a download counter for that file and then header()-redirects them to the actual file. I suspect that bots are following the download l... | <p>robots.txt: <a href="http://www.robotstxt.org/robotstxt.html" rel="noreferrer">http://www.robotstxt.org/robotstxt.html</a></p>
<p>Not all bots respect it, but most do. If you really want to prevent access via bots, make the link to it a POST instead of a GET. Bots will not follow POST urls. (I.E., use a small form ... | <p>You can also detect malicious bots, which wouldn't respect robots.txt using <a href="http://www.bad-behavior.ioerror.us/" rel="nofollow noreferrer">http://www.bad-behavior.ioerror.us/</a>.</p>
| 29,158 |
<p>I've recently discovered that it's possible to place .net assemblies on SQL Server >=2005 servers so that .net functions can be called in T/SQL statements.</p>
<p>I wondered what uses people found for these and how they perform?</p>
| <p>The first general purpose use for the CLR in SQL 2005 I created was a SQL 2005 assembly that has a variety of functions that perform string operations and pattern matches using regular expressions. The native string functions in SQL 2005 can be augmented so that you can validate common formats like phone numbers or ... | <p>I found it to be very useful. </p>
<p>I used this possibility to extend MSSQL2005 XML related functions. </p>
<p>If I remember correctly you can even introduce your own data types.</p>
| 6,076 |
<p>The following code has a simple binding which binds the Text of the TextBlock named MyTextBlock to TextBox's Text and ToolTip property using the exact same Binding notation:</p>
<pre><code><StackPanel>
<TextBlock x:Name="MyTextBlock">Foo Bar</TextBlock>
<TextBox Text="{Binding Elemen... | <p>ToolTips in WPF can contain anything, not just text, so they provide a ContentStringFormat property for the times you just want text. You'll need to use the expanded syntax as far as I know:</p>
<pre><code><TextBox ...>
<TextBox.ToolTip>
<ToolTip
Content="{Binding ElementName=myTextBlock... | <p>The following is a wordy solution but it works. </p>
<pre><code><StackPanel>
<TextBox Text="{Binding Path=., StringFormat='The answer is: {0}'}">
<TextBox.DataContext>
<sys:Int32>42</sys:Int32>
</TextBox.DataContext>
<TextBox.ToolTip>
<ToolTip C... | 23,961 |
<p>The server.xml which controls the startup of Apache Tomcat's servlet container contains a debug attribute for nearly every major component. The debug attribute is more or less verbose depending upon the number you give it, zero being least and 99 being most verbose. How does the debug level affect Tomcat's speed w... | <p>You certainly don't want to modify your Business Logic just to make your tests look better. Good news however, there is a way to accomplish this that is not difficult, but not as easy as passing in a format specifier.</p>
<p>Try to think of your Fit Fixture as a service boundary between FitNesse and your applicatio... | <p>I'm not sure what the "polution" is. Either the requirement is that your Business Object returns a value expressed as a percentage, in which case your business object should offer that -OR- you are testing the true value of the response as float, which you have now. </p>
<p>Trying to get fitnesse to massage the v... | 12,760 |
<p>I have a class that stores a serialized value and a type. I want to have a property/method returning the value already casted:</p>
<pre><code>public String Value { get; set; }
public Type TheType { get; set; }
public typeof(TheType) CastedValue { get { return Convert.ChangeType(Value, typeof(_Type)); }
</code></p... | <p>It's possible if the class containing the property is generic, and you declare the property using the generic parameter:</p>
<pre><code>class Foo<TValue> {
public string Value { get; set; }
public TValue TypedValue {
get {
return (TValue)Convert.ChangeType(Value, typeof(TValue));
... | <p>I don't believe the example you've given here is possible. The type of CastedValue has to be defined at compile time, which means it can't depend on a runtime value (the value of the TheType property).</p>
<p>EDIT: Brannon's solution has some good ideas for how to handle this using a generic function rather than a ... | 34,124 |
<p>When you assign a date to a named SQL parameter Hibernate automatically converts it to GMT time. How do you make it use the current server timezone for all dates?</p>
<p>Lets say you have a query:</p>
<pre><code>Query q = session.createQuery("from Table where date_field < :now");
q.setDate("now", new java.util.... | <p>As it turned out Hibernate doesn't convert dates to GMT automatically, it just cuts off time if you use <code>query.setDate()</code>, so if you pass "2009-01-16 12:13:14" it becomes "2009-01-16 00:00:00". </p>
<p>To take time into consideration you need to use <code>query.setTimestamp("date", dateObj)</code> instea... | <p>In Hibernate 6, using jakarta.persistence, it is</p>
<p><code>query.setParameter("now", new Date(), TemporalType.DATE );</code></p>
| 37,197 |
<p>So I just love it when my application is working great in Firefox, but then I open it in IE and... Nope, please try again.</p>
<p>The issue I'm having is that I'm setting a CSS display property to either <code>none</code> or <code>table-cell</code> with JavaScript.</p>
<p>I was initially using <code>display: block... | <p>A good way of solving this setting the <code>display</code> value to <code>''</code>:</p>
<pre><code><script type="text/javascript">
<!--
function toggle( elemntId ) {
if (document.getElementById( elemntId ).style.display != 'none') {
document.getElementById( elemntId ).style.display = 'none';
... | <p>I tried everything and the only way I found that was all cross browser was to use Javascript / Jquery. This is a clean lightweight solution: <a href="http://www.ddrewdesign.com/blog/jquery-vertical-align-function" rel="nofollow">click here</a></p>
| 30,963 |
<p>When I'm writing some tight loop that needs to work fast I am often bothered by thoughts about how the processor branch prediction is going to behave. For instance I try my best to avoid having an if statement in the most inner loop, especially one with a result which is not somewhat uniform (say evaluates to true o... | <p>Branch prediction is pretty darned good these days. But that doesn't mean the penalty of branches can be eliminated.</p>
<p>In typical code, you probably get well over 99% correct predictions, and yet the performance hit can still be significant. There are several factors at play in this.</p>
<p>One is the simple ... | <p>One thing I recently found (on a TI DSP) is that trying to avoid branches can sometimes generate more code than the branch prediction cost.</p>
<p>I had something like the following in a tight loop:</p>
<pre><code>if (var >= limit) { otherVar = 0;}
</code></pre>
<p>I wanted to get rid of the potential branch, ... | 36,852 |
<p>Assume I have an "images" folder directory under the root of my application. How can I, from within a .css file, reference an image in this directory using an ASP.NET app relative path. </p>
<p>Example:</p>
<p>When in development, the path of <strong>~/Images/Test.gif</strong> might resolve to <strong>/MyApp/Ima... | <p>Unfortunately Firefox has a stupid bug here... the paths are relative to the path of the page, instead of being relative to the position of the CSS file. Which means if you have pages in different positions in the tree (like having Default.aspx in the root and Information.aspx in the View folder) there's no way to h... | <p>Inside of the .css file you can use relative paths; so in your example, say you put your css file in ~/Styles/mystyles.css. You can use url(../Images/Test.gif) as an example.</p>
| 11,495 |
<p>I've been wondering, what is the point of clog? As near as I can tell, clog is the same as cerr but with buffering so it is more efficient. Usually stderr is the same as stdout, so clog is the same as cout. This seems pretty lame to me, so I figure I must be misunderstanding it. If I have log messages going out to t... | <blockquote>
<p>Is it possible to redirect clog, cerr, cout, stdin, stdout, and/or stderr?</p>
</blockquote>
<p>Yes. You want the <a href="http://www.cplusplus.com/reference/iostream/ios/rdbuf.html" rel="noreferrer"><code>rdbuf</code></a> function.</p>
<pre><code>ofstream ofs("logfile");
cout.rdbuf(ofs.rdbuf());
co... | <h2>Basic Logger</h2>
<pre><code>#define myerr(e) {CriticalSectionLocker crit; std::cerr << e << std::endl;}
</code></pre>
<p>Used as <code>myerr("ERR: " << message);</code> or <code>myerr("WARN: " << message << code << etc);</code></p>
<p>Is very effective.</p>
<p>Then do:</p>
... | 7,562 |
<p>How do you convert between hexadecimal numbers and decimal numbers in C#?</p>
| <p>To convert from decimal to hex do...</p>
<pre><code>string hexValue = decValue.ToString("X");
</code></pre>
<p>To convert from hex to decimal do either...</p>
<pre><code>int decValue = int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber);
</code></pre>
<p>or </p>
<pre><code>int decValue = Convert.T... | <p>An extension method for converting a byte array into a hex representation. This pads each byte with leading zeros.</p>
<pre><code> /// <summary>
/// Turns the byte array into its Hex representation.
/// </summary>
public static string ToHex(this byte[] y)
{
StringBuilder sb = ... | 9,984 |
<p>I have just bought a Creality CR-10 Smart 3D printer, and - as part of the rite of passage of newbies - I am struggling with getting a usable initial layer. Whilst trying to make sense of what I was seeing in the net and correlating it with what I was experiencing with my printer, I thought to check the printer's cr... | <p>I don't think it's because of Cura. You can try if it still works with the older version.</p>
<p>Otherwise, clean your print bed with isopropanol before printing to remove residues or level again. Without pictures of the condition of the print bed or the first layer, it is difficult to help.</p>
| <p>Have tried all the possible answers and found the older version of Cura works better with the Chiron. The printer is 3 months old, bed is cleaned after each print.</p>
<p>I then tried the new Cura version again but with glue for adhesion, that works. It seems that it is changing the bed temperature, and using a l... | 2,100 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.