instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>i know how to import an sql file via the cli:</p>
<pre><code>mysql -u USER -p DBNAME < dump.sql
</code></pre>
<p>but that's if the dump.sql file is local. how could i use a file on a remote server?</p>
| <p>You didn't say what network access you have to the remote server.</p>
<p>Assuming you have SSH access to the remote server, you could pipe the results of a remote mysqldump to the mysql command. I just tested this, and it works fine:</p>
<pre><code>ssh remote.com "mysqldump remotedb" | mysql localdb
</code></pre>
... | <p>I'd use <a href="http://www.gnu.org/software/wget/" rel="nofollow noreferrer">wget</a> to either download it to a file or pipe it in.</p>
| 30,839 |
<p>How to wait in a bash script for several subprocesses spawned from that script to finish, and then return exit code <code>!=0</code> when any of the subprocesses ends with code <code>!=0</code>?</p>
<p>Simple script:</p>
<pre><code>#!/bin/bash
for i in `seq 0 9`; do
doCalculations $i &
done
wait
</code></pre>
... | <p><a href="https://www.gnu.org/software/bash/manual/html_node/Job-Control-Builtins.html#index-wait" rel="noreferrer"><code>wait</code></a> also (optionally) takes the <code>PID</code> of the process to wait for, and with <code>$!</code> you get the <code>PID</code> of the last command launched in the background.
Modif... | <p>I'm thinking maybe run <code>doCalculations; echo "$?" >>/tmp/acc</code> in a <em>subshell</em> that is sent to the background, then the <code>wait</code>, then <code>/tmp/acc</code> would contain the exit statuses, one per line. I don't know about any consequences of the multiple processes appending to the a... | 46,428 |
<p>In general I think I can convey most programming related concepts quite well.<br>
Yet, I still find it hard to summarise the relationship between Fields, Classes and Packages.</p>
<p><br>
<strong>How do You summarise "Fields", "Classes" and "Packages" and "Their Relationship" ?</strong></p>
| <p>I've faced a similar problem since I taught C, C++, and Java.
Here is what I do:</p>
<p>First, I keep packages separately and explain them in the end.</p>
<p>Ideally, in my opinion, students should first learn about ADTs, preferably in C. They have the struct, they have the separate operations on it. Fields are th... | <p>The way I describe it is:</p>
<ul>
<li>Objects are collections of slots, slots holding data are fields, slots holding code are methods. Public slots are on the outside of the object, private slots are on the inside. Methods should be mostly public because an object offers services to clients, fields should be priva... | 17,449 |
<p>I'm printing with anycubic i3 mega on an ultrabase bed. When I first got the printer the prints were easy to remove from the bed after it cools down, I didn't need to put any extra effort. However after I used 70% isopropyl to clean it it seems I removed some kind of extra coating as all next prints were sticking to... | <p>Heating PLA even to 60°C will make it pliable and may affect dimensional accuracy; 100°C is likely to make that severe. Being stuck to the bed and thus constrained by it might help some, but I think it's a bad idea.</p>
<p>If your PLA is hard to remove, you probably have bed leveling issues. PLA should remove easily... | <p>You did exactly the right thing:</p>
<ol>
<li>look,</li>
<li>see,</li>
<li>think,</li>
<li>evaluate and adapt</li>
<li>test</li>
<li>Back to 1. or continue to 7.</li>
<li>Solution found and applied!</li>
</ol>
<p>Congrats!
Johan</p>
<p>Ps: I use the tape in paper, used to mask before paint jobs, I was not that keen ... | 1,698 |
<p>I have a string that contains the representation of a date. It looks like: </p>
<p><strong>Thu Nov 30 19:00:00 EST 2006</strong></p>
<p>I'm trying to create a Date object using SimpleDateFormat and have 2 problems. </p>
<p>1.) I can't figure out the pattern to hard-code the solution into the SimpleDateFormat cons... | <p>The format to pass to SimpleDateFormat could be looked up at <a href="http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html" rel="noreferrer">http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html</a></p>
<pre><code>new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy")
</code></pre>
<... | <p>Are you just asking for the pattern for that given date? If so, I think this should do it:</p>
<pre><code>"EEE MMM d HH:mm:ss z yyyy"
</code></pre>
<p>Or are you trying to take any formatted date, and infer the format, and parse it?</p>
| 6,547 |
<p>I have a UserControl (Composite control) that can be shown as the following pseudo XAML code:</p>
<pre><code><UserControl>
<DockPanel>
<TextBox />
<Button />
</DockPanel>
</UserControl>
</code></pre>
<p>I use this custom control in a bunch of places and style some of... | <p>There are a number of ways to do this, but I would suggest exposing your own property on your user control and binding to that inside your user control. For example:</p>
<pre><code><UserControl x:Name="_root" ...>
...
<Button Background="{Binding ButtonBackground, ElementName=_root}"/>
</User... | <p>I agree with Kent. There are a number of ways that you can solve this problem.</p>
<p>But what about just using a Style in the UserControl to set the Background of the TextBox? Is there any special reason that the following wouldn't work for you?</p>
<pre><code><UserControl
x:Class="StackOverflowQuestion.Us... | 21,461 |
<p>What is the difference between overflow:hidden and display:none?</p>
| <p>Example:</p>
<pre><code>.oh
{
height: 50px;
width: 200px;
overflow: hidden;
}
</code></pre>
<p>If text in the block with this class is bigger (longer) than what this little box can display, the excess will be just hidden. You will see the start of the text only.</p>
<p><code>display: none;</code> will just ... | <p>Let's say you have a <code>div</code> that measures 100 x 100px</p>
<p>You then put a whole bunch of text into it, such as it overflows the div. If you use <code>overflow: hidden;</code> then the text that fits into the 100x100 will not be displayed, and will not affect layout.</p>
<p><code>display: none</code> is... | 16,082 |
<p>I installed mediawiki on my server as my personal knowledge base. Sometimes I copy some stuff from Web and paste to my wiki - such as tips & tricks from somebody's blog. How do I make the copied content appear in a box with border?</p>
<p>For example, the box at the end of this blog post looks pretty nice:<br>
... | <pre><code><blockquote style="background-color: lightgrey; border: solid thin grey;">
Det er jeg som kjenner hemmeligheten din. Ikke et pip, gutten min.
</blockquote>
</code></pre>
<p>The blockquotes are better than divs because they "explain" that the text is actually a blockqoute, and not "just-some-text... | <p>Set a width in the pre tag, and it will wrap.</p>
<pre><code><pre width="80%">
</code></pre>
| 15,914 |
<p>The following will cause infinite recursion on the == operator overload method</p>
<pre><code> Foo foo1 = null;
Foo foo2 = new Foo();
Assert.IsFalse(foo1 == foo2);
public static bool operator ==(Foo foo1, Foo foo2) {
if (foo1 == null) return foo2 == null;
return foo1.Equals(foo2);
... | <p>Use <code>ReferenceEquals</code>:</p>
<pre><code>Foo foo1 = null;
Foo foo2 = new Foo();
Assert.IsFalse(foo1 == foo2);
public static bool operator ==(Foo foo1, Foo foo2) {
if (object.ReferenceEquals(null, foo1))
return object.ReferenceEquals(null, foo2);
return foo1.Equals(foo2);
}
</code></pre>
| <p>You can try to use an object property and catch the resulting NullReferenceException. If the property you try is inherited or overridden from Object, then this works for any class.</p>
<pre><code>public static bool operator ==(Foo foo1, Foo foo2)
{
// check if the left parameter is null
bool LeftNull = fal... | 9,943 |
<p>How do I generate friendly URLs within the ASP.NET MVC Framework? For example, we've got a URL that looks like this:</p>
<pre>http://site/catalogue/BrowseByStyleLevel/1</pre>
<p>The 1 is Id of the study level (Higher in this case) to browse, but I'l like to reformat the URL in the same way StackOverflow does it.</p>... | <p>There are two steps to solve this problem. First, create a new route or change the default route to accept an additional parameter:</p>
<pre><code>routes.MapRoute( "Default", // Route name
"{controller}/{action}/{id}/{ignoreThisBit}",
new { controller = "Home",
... | <p>you have a route on the global.asax</p>
<pre><code> routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = ""}
// Parameter defaults )
</code></... | 26,802 |
<p>I have a C++ assembly with both managed and umanaged code compiled to
a DLL. It is correctly imported into the project references as I can
see all my classes and their members with the Object Browser.</p>
<p>The problem is with the XAML Design view. In my XAML code I want to
make a data bind with my C++ assembly s... | <p>This is probably happening because the ide cannot load one of the unmanaged dll's. You may have to move them into the windows/system32.</p>
| <p>Very helpful, thanks for this insight.</p>
<p>My solution is to copy the DLLs into the output directory using a Post-Build event.
Here's how
1. Project Properties / Build Events
2. Set Post-build event command line:</p>
<p>copy path_to_dependent_dlls .</p>
<p>Oh, and I find that a VStudio restart is required f... | 35,159 |
<p>Given an <code>InputStream</code> called <code>in</code> which contains audio data in a compressed format (such as MP3 or OGG), I wish to create a <code>byte</code> array containing a WAV conversion of the input data. Unfortunately, if you try to do this, JavaSound hands you the following error:</p>
<pre><code>java... | <p>The problem is that the most AudioFileWriters need to know the file size in advance if writing to an OutputStream. Because you can't provide this, it always fails. Unfortunatly, the default Java sound API implementation doesn't have any alternatives.</p>
<p>But you can try using the AudioOutputStream architecture f... | <p>This is very simple...</p>
<pre><code>File f = new File(exportFileName+".tmp");
File f2 = new File(exportFileName);
long l = f.length();
FileInputStream fi = new FileInputStream(f);
AudioInputStream ai = new AudioInputStream(fi,mainFormat,l/4);
AudioSystem.write(ai, Type.WAVE, f2);
fi.close();
f.delete();
</code></... | 24,210 |
<p>I can't directly add ChartFrame object to my Jframe object with .add(Component) method. And it's not possible to cast from ChartFrame to JComponent. Casting ChartFrame to Component from java.awt library is also impossible. </p>
<p>How can I add ChartFrame to JFrame the other way?</p>
| <p>ChartFrame is an independent JFrame, suitable as an isolated window.
If you want to use it as a component, ChartPanel may be a better solution.</p>
| <p>That would mean inserting a JFrame within another JFrame.</p>
<p>A possible solution would be to use a <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/internalframe.html" rel="nofollow noreferrer">JDesktopPane</a> </p>
<pre><code>JDesktopPane desktop = ...
JFrame frame = ...
frame.setContentPa... | 37,495 |
<p>So, I'm working under the assumption that we have typed languages because we make a lot of mistakes... so typing is one way to have the compiler do a lot of checks for us and help us out a bit (please let me know if it is my assumptions that's incorrect).</p>
<p>However, if we introduce casting to a typed language,... | <p>The bottom line is that <strong>strong typing lets the compiler check things for you</strong> and <strong>casting lets you override the strong typing when necessary.</strong></p>
| <p>When you cast, you explicitly ask the compiler to relax its otherwise strong typing. This allows you to have compile-time checking in 99% of the cases, yet still mix types when absolutely necessary.</p>
<p>Regardless, it is possible for the compiler to find "bad" casts at compile time - ones that have no chance of ... | 21,799 |
<p>I have a small gallery of thumbnails. When I place my mouse pointer over a thumbnail image I'd like to have a full size image pop up in a div in the top right of the screen. I've seen this done using just CSS and I'd like to go down that route rather than use javascript if possible.</p>
| <p><a href="http://meyerweb.com/eric/css/edge/popups/demo2.html" rel="noreferrer">Pure CSS Popups2</a>, from the same site that brings us Complexspiral. Note that this example is using actual navigational links as the rolled-over element. If you don't want that, it may cause some stickiness regarding versions of IE.</p... | <p>Eric Meyer's <a href="http://meyerweb.com/eric/css/edge/popups/demo2.html" rel="nofollow noreferrer">Pure CSS Popups 2</a> demo sounds similar enough to what you want.</p>
| 13,387 |
<p>I'm designing an algorithm to do the following: Given array <code>A[1... n]</code>, for every <code>i < j</code>, find all inversion pairs such that <code>A[i] > A[j]</code>. I'm using merge sort and copying array A to array B and then comparing the two arrays, but I'm having a difficult time seeing how I can ... | <p>So here is O(n log n) solution in java.</p>
<pre><code>long merge(int[] arr, int[] left, int[] right) {
int i = 0, j = 0;
long count = 0;
while (i < left.length || j < right.length) {
if (i == left.length) {
arr[i+j] = right[j];
j++;
} else if (j == right.len... | <p>The number of inversions in an array is half the total distance elements must be moved in order to sort the array. Therefore, it can be computed by sorting the array, maintaining the resulting permutation p[i], and then computing the sum of abs(p[i]-i)/2. This takes O(n log n) time, which is optimal.</p>
<p>An al... | 43,817 |
<p>MySQL specifies the row format of a table as either fixed or dynamic, depending on the column data types. If a table has a variable-length column data type, such as TEXT or VARCHAR, the row format is dynamic; otherwise, it's fixed.</p>
<p>My question is, what's the difference between the two row formats? Is one mor... | <p>The difference really only matters for MyISAM, other storage engines do not care about the difference.
<strong>EDIT :</strong> Many users commented that InnoDB does care: <a href="https://dev.mysql.com/doc/refman/5.7/en/innodb-row-format.html" rel="nofollow noreferrer">link 1 by steampowered</a>, <a href="http://www... | <p>Fixed should be faster and more secure than dynamic, with the drawback of having a fixed char-lenght.
You can find this information here: <a href="http://dev.mysql.com/doc/refman/5.0/en/static-format.html" rel="nofollow noreferrer">http://dev.mysql.com/doc/refman/5.0/en/static-format.html</a></p>
| 17,733 |
<p>I had my 3D printer powered by dual 24 V PSUs wired in parallel and my heatbed was wired into the main using a SSR to help power it. I replaced the two PSUs with a single Corsair 750 W ATX. My printer runs smoother and there's much less wiring clutter to deal with but now no matter what the heatbed will not heat up.... | <p>You indicated that you were using 24 volts, implying you have a 24 volt bed. ATX power supplies do not have 24 volt outputs. The highest is 12 volts which would heat up the bed, but not fast or probably to full temperature.</p>
| <p>voltage = current x resistance</p>
<p>An ATX PSU is designed to only allow approximately 16 amps per pair of YELLOW and BLACK wires. The yellow is 12 V and the black is GND. If your bed were rated at 24 V then its resistance would be higher than that of the 12 V bed. The best solution for you would be to get a 12 V ... | 1,747 |
<p>Task: implement paging of database records suitable for different RDBMS. Method should work for mainstream engines - MSSQL2000+, Oracle, MySql, etc.</p>
<p>Please don't post RDBMS specific solutions, I know how to implement this for most of the modern database engines. I'm looking for the universal solution. Only t... | <p>There would have been a universal solution if SQL specifications had included paging as a standard. The requirement for any RDBMS language to be called an RDBMS language does not include paging support as well. </p>
<p>Many database products support SQL with proprietary extensions to the standard language. Some of ... | <p>SubSonic can do this for you if you if you can tolerate Open Source...
<a href="http://subsonicproject.com/querying/webcast-using-paging/" rel="nofollow noreferrer">http://subsonicproject.com/querying/webcast-using-paging/</a></p>
<p>Other than that I know NHib does as well</p>
| 8,705 |
<p>How would I go about writing some code to allow access to a Java class in my webapp from the command line.</p>
<p>E.g. I have a java class with command line interface, that can runs code in the context of the webapp, with access to the DB etc. I want to log on the machine hosting my WARred app in tomcat and be able... | <p>Do you just want to run class files that just so happen to be bundled in the WAR, or do you want ot interact with the actual, running WAR instance? If the former, then the WAR is just a normal Jar file and you can execute classes in that just like any other other Jar file.</p>
<p>If you want to interact with the ru... | <p>A suggestion:
Your command line interface class should accept an InputStream as it's input and provide an OutputStream (it can't hardcode output to System.out and input to System.in) that it's output will be written to. Then you'll have to write a server class that listens for connections on a certain port. When a... | 13,416 |
<p>I would like to implement a telnet server in C. How would I proceed with this? Which RFCs should I look at? This is important to me, and I would appreciate any help.</p>
| <p>For very basic telnet (just telnet to a port and echo bytes), there's not much to do. Read from a socket, process it (in an echo server, do nothing), spit back a result. You could implement a simple MUD-style server without knowing anything in any RFCs.</p>
<p>But if you're really concerned about RFCs, RFC 854 mi... | <p>Knowing how the socket API works internally is very useful, because it is often exported with very minor changes by higher level languages.</p>
<p>That said, you might want to use the event loop support provided by <a href="http://gtk.org" rel="nofollow noreferrer">GLib</a> and use the related networking library <a... | 33,556 |
<p>I'm extending the functionality of a class with a subclass, and I'm doing some dirty stuff that make superclass methods dangerous (app will hang in a loop) in the context of the subclass. I know it's not a genius idea, but I'm going for the low-hanging fruit, right now it's gonna save me some time. Oh it's a dirty j... | <p>Just re-implement the unsafe method in your subclass and have it do nothing or throw an exception or re-implement it as safe, just as long as the new implementation doesn't call the unsafe superclass method.</p>
<p>For the C++ crew in here: Objective C doesn't let you mark methods as private. You can use its catego... | <p>If you create the methods in your superclass as "private" then the subclass has no possible way of calling them. I'm not familiar with Objective C, but every other object oriented language I've seen has the "private" qualifier. </p>
| 41,962 |
<p>I know about using a -vsdoc.js file for <a href="http://en.wikipedia.org/wiki/IntelliSense" rel="nofollow noreferrer">IntelliSense</a>, and the one for jQuery is easy to find. What other JavaScript, Ajax, and DHTML libraries have them and where can I find those files? Also, is there a document which outlines the sp... | <p>An excellent blog posting from Betrand LeRoy on IntelliSense format for JavaScript:
<em><a href="http://weblogs.asp.net/bleroy/archive/2007/04/23/the-format-for-javascript-doc-comments.aspx" rel="nofollow noreferrer">The format for JavaScript doc comments</a></em>.</p>
<p>In a nutshell:</p>
<p>Summary - used to d... | <p>You can find Intellisense for MooTools here: <a href="http://code.google.com/p/mootoolsintellisense/downloads/list" rel="nofollow noreferrer">http://code.google.com/p/mootoolsintellisense/downloads/list</a></p>
| 35,720 |
<p>Ok, this is driving me nuts.</p>
<p>I've done just about everything I can to enable step through debugging of stored procedures of a sql server 2005 database.</p>
<p><a href="http://arjunachith.blogspot.com/2007/05/debugging-stored-procedures-debug.html" rel="noreferrer">http://arjunachith.blogspot.com/2007/05/deb... | <p>What edition of VS2008 are you running? I just checked on Pro and Team System, and I get that option on both; I also have C# Express, and it doesn't give this option. (I don't have Standard, so can't check that one...)</p>
<p>[edit] From the second link you provided (MSDN), on the right-hand side there's a link f... | <p>Just select your connection in Server Explorer and right click on that, and select
<code>Allow SQL/CLR Debugging</code></p>
| 35,837 |
<p>I have a problem with an ASP.NET application that is driving me nuts.</p>
<p>When a user leaves a page inactive for a period of time the session was timing out and error were being thrown due to session variables not being resolvable (I will error trap this anyway but this is not the problem).
I coded a 'defribulat... | <p>This may also happen when iis recycles or terminates the application pool. </p>
<p>You may want to check <a href="http://support.microsoft.com/kb/910439/" rel="noreferrer">Troubleshoot Forms Authentication</a> It could be that the client lost their cookie.</p>
<p>If you manually generate the authentication ticket,... | <p>Thanks for the response guys:
I have already explicitly set slidingExpiration to true in the web.config with no effect.</p>
<p>The timeout values are:
Session: 20 minutes
FormsAuthentication: 60 minutes</p>
<p>I have left the session timeout as is and reduced the FormsAuthentication to 12 minutes for testing. The ... | 39,798 |
<p>First off, this is a question about a desktop application using Windows Forms, not an <a href="http://en.wikipedia.org/wiki/ASP.NET" rel="nofollow noreferrer">ASP.NET</a> question.</p>
<p>I need to interact with controls on other forms. I am trying to access the controls by using, for example, the following...</p>
... | <p>Instead of making the control public, you can create a property that controls its visibility:</p>
<pre><code>public bool ControlIsVisible
{
get { return control.Visible; }
set { control.Visible = value; }
}
</code></pre>
<p>This creates a proper accessor to that control that won't expose the control's wh... | <p>Do your child forms really need to be Forms? Could they be user controls instead? This way, they could easily raise events for the main form to handle and you could better encapsulate their logic into a single class (at least, logically, they are after all classes already).</p>
<p>@Lars: You are right here. Thi... | 3,001 |
<p>How can I get a ASP.NET (inc MVC) application talking to a Flex UI over AMF. I am wanting to push approx 100+ records around at a time and AMF would appear to be the way forward, but there doesn't appear to be anything obvious.</p>
| <p>If you're pressed for time, you can just use the RemoteObject to hit a compiled DLL (like WebORB - its free for .NET, but you need a VS copy above Express to compile your classes that you want to expose to Flex)</p>
<p>and Retrieve the object that way...</p>
<p>Obviously your objects should have a DAL in place or... | <p>One minor correction to the answer above: you can actually use the Express edition to compile your assembly. With WebORB you can simply deploy your DLLs into the /bin folder of the virtual directory and it will take care of enabling your classes as Flex Remoting services. You do not need to implement any special int... | 10,394 |
<p>Looking at the processmodel element in the Web.Config there are two attributes.</p>
<pre><code>maxWorkerThreads="25"
maxIoThreads="25"
</code></pre>
<p>What is the difference between worker threads and I/O threads?</p>
| <p>Fundamentally not a lot, it's all about how ASP.NET and IIS allocate I/O wait objects and manage the contention and latency of communicating over the network and transferring data.</p>
<p>I/O threads are set aside as such because they will be doing I/O (as the name implies) and may have to wait for "long" periods o... | <p>Just to add on to chadmyers...
Seems like I/O Threads was the old way ASP.NET serviced requests, </p>
<blockquote>
<p>"Requests in IIS 5.0 are typically
serviced over I/O threads, or threads
performing asynchronous I/O because
requests are dispatched to the worker
process using asynchronous writes to a
... | 16,621 |
<p>I am getting a 24 V based Ender 3. From the factory, it has an aluminium bed. So I also put this <a href="https://www.amazon.de/gp/product/B071ZQ6VV6/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1" rel="noreferrer">LJ12 A3-4-Z/BX Inductive NPN NO 4 mm</a> with 6-36 V operation current into the box togethe... | <p>The inductive sensors work better when you apply a higher voltage than 5 V. Usually they are rated for 6-36 V, but please do check.</p>
<p>To prevent frying your board when connecting the sensor to (12 or) 24 Volts you could optically isolate the 5 V and the (12 or) 24 V circuit with an OptoCoup... | <p>Another possibility is to create a <a href="https://en.wikipedia.org/wiki/Voltage_divider" rel="nofollow noreferrer">voltage divider</a> circuit. </p>
<blockquote>
<p>In electronics, a voltage divider (also known as a potential divider)
is a passive linear circuit that produces an output voltage (V<sub>out</sub... | 958 |
<p>Is there a way of using an 'OR' operator or equivalent in a PHP switch?</p>
<p>For example, something like this:</p>
<pre><code>switch ($value) {
case 1 || 2:
echo 'the value is either 1 or 2';
break;
}
</code></pre>
| <pre><code>switch ($value)
{
case 1:
case 2:
echo "the value is either 1 or 2.";
break;
}
</code></pre>
<p>This is called "falling through" the case block. The term exists in most languages implementing a switch statement.</p>
| <p>The best way might be if else with requesting. Also, this can be easier and clear to use.</p>
<p>Example:</p>
<pre><code><?php
$go = $_REQUEST['go'];
?>
<?php if ($go == 'general_information'){?>
<div>
echo "hello";
}?>
</code></pre>
<p>Instead of using the functions that won't work well wit... | 25,369 |
<p>I got this bad feeling about how I insert larger amounts of HTML.
Lets assume we got:</p>
<p><code>var html="<table>..<a-lot-of-other-tags />..</table>"</code></p>
<p>and I want to put this into</p>
<p><code>$("#mydiv")</code></p>
<p>previously I did something like</p>
<p><code>var html_obj = ... | <p>innerHTML is remarkably fast, and in many cases you will get the best results just setting that (I would just use append).</p>
<p><strong>However, if there is much already in "mydiv" then you are forcing the browser to parse and render all of that content again (everything that was there before, plus all of your ne... | <p>You mention being interested in alternatives. If you look at the listing of <a href="http://plugins.jquery.com/project/Plugins/category/55" rel="nofollow noreferrer">DOM-related jQuery plugins</a> you'll find several that are dedicated to programatically generating DOM trees. See for instance <a href="http://plugi... | 14,328 |
<p>We have a fairly large .NET solution with multiple executable projects (winforms and command line programs). Currently each of these projects has its own app.config that contains connection strings, mail server settings and the like. As you can imagine it's not that convenient to make a change in every app.config fi... | <p>Create the App.config on your startup project and link statically to it on the other projects.</p>
<p>You can link statically by going to Add->Existing Item, and when clicking the Add button on the File Browser Window, there is a small down arrow on the Add button. Click there and the "Add as link" option will be s... | <p>Personally I would advise against introducing a needless dependency on a .config file from another assembly. Using a custom class with serializing sounds cleaner in this scenario, but you expose yourself to potential versioning problems and you lose the potential advantages offered by app.config (section handlers, e... | 18,618 |
<p>I've got a form inside an <code><asp:Content></code> block that is being submitted to a controller. For one of the controls, I need to get some information from it directly that won't happen automatically by calling <code>UpdateModel()</code>.</p>
<p>However, in the <code>Request.Form</code> dictionary, the ... | <p>FCKEditor is a standard javascript library that also comes wrapped in an ASP.NET control for Webforms. So it would be easier to use the FCKEditor javascript without the ASP.NET control. It will be easier to integrate into MVC that way.</p>
<p>If you must use the ASP.NET control version then you will have these ki... | <p>Are you using a WebForm control? To my knowledge, the default ASP.NET MVC view engine does not mangle control ID's.</p>
| 42,685 |
<p>Let's say I've got two strings in JavaScript:</p>
<pre><code>var date1 = '2008-10-03T20:24Z'
var date2 = '2008-10-04T12:24Z'
</code></pre>
<p>How would I come to a result like so:</p>
<pre><code>'4 weeks ago'
</code></pre>
<p>or</p>
<pre><code>'in about 15 minutes'
</code></pre>
<p>(should support past and fut... | <p>Looking at the solutions you linked... it is actually as simple as my frivolous comment!</p>
<p>Here's a version of the Zach Leatherman code that prepends "In " for future dates for you. As you can see, the changes are very minor.</p>
<pre><code> function humane_date(date_str){
var time_formats = [
... | <p>Heh - I actually wrote a function to do this exact thing yesterday (and it's not on this computer so I'll just have to try to remember it)</p>
<p>I extended the Date prototype class, but this could quite easily just be put into a regular function.</p>
<pre><code>Date.prototype.toRelativeTime = function(otherTime) ... | 20,388 |
<p>We're building an app that stores "hours of operation" for various businesses. What is the easiest way to represent this data so you can easily check if an item is open?</p>
<p>Some options:</p>
<ul>
<li>Segment out blocks (every 15 minutes) that you can mark "open/closed". Checking involves seeing if the "open" b... | <p>store each contiguous block of time as a start time and a duration; this makes it easier to check when the hours cross date boundaries</p>
<p>if you're certain that hours of operation will never cross date boundaries (i.e. there will never be an open-all-night sale or 72-hour marathon event et al) then start/end ti... | <p>There is surely no need to conserve memory here, but perhaps a need for clean and comprehensible code. "Bit twiddling" is not, IMHO, the way to go.</p>
<p>We need a set container here, which holds any number of unique items and can determine quickly and easily whether an item is a member or not. The setup reuires... | 17,195 |
<p>I'm currently working on the <code>Tips.js</code> from <code>mootools</code> library and my code breaks on the line that has those <code>el.$tmp</code>, and console says it's undefined</p>
<p>Can anybody help me?</p>
| <p>in 1.11 (haven't checked in 1.2+) $tmp is a reference to the element itself, created and used internally by the garbage collector:</p>
<pre><code>var Garbage = {
elements: [],
collect: function(el){
if (!el.$tmp){
Garbage.elements.push(el);
el.$tmp = {'opacity': 1};
... | <p>Hmmm. I'm not exactly sure what el.$tmp is a reference to in MooTools but a message stating "console is undefined" is probably because someone was trying to log to the Firebug (or another) console and that object does not exist if you don't have Firebug and friends.</p>
<p>If you don't have http://getfirebug.com'>F... | 20,855 |
<p>I was thinking of implementing shortcut keys in a pet web application, I am developing for me. I am using c# and asp.net. </p>
<p>I have seen very few web-sites( frankly I remember only g-mail), which have shortcut keys. </p>
<p>Has anyone ever implemented shortcut keys for a web application, if yes how to go abou... | <p>Accesskeys are useless, but visit <a href="http://www.cs.tut.fi/~jkorpela/forms/accesskey.html" rel="noreferrer">this site</a> if you insist on using them. Much better to use this than javascript, though the ways of accessing access keys varies across browsers. The advantage of this over ugly Javascript solutions ... | <pre><code>use this javascript on your master page this work using keycode.........
------------------------------------------
var isfocused=false;
document.onkeydown = overrideKeyboardEvent;
document.onkeyup = overrideKeyboardEvent;
var keyIsDown = {};
var get_focused="";
function overrideKeyboardEvent(e){
... | 48,116 |
<p>My experience to write a plugin for Firefox is below zero. Is someone out there who could point me to sample code on how to get this accomplished in C++ with VS2005/8? </p>
<p>What I need to do with JavaScript in the hosting html page is something like this:</p>
<pre><code>var obj = document.getElementById("MyFFPl... | <p>The SDK has basic samples on how to write mozzila plugins which can be downloaded here: <a href="http://mxr.mozilla.org/seamonkey/source/modules/plugin/tools/sdk/" rel="nofollow noreferrer">http://mxr.mozilla.org/seamonkey/source/modules/plugin/tools/sdk/</a></p>
<p>Here is the official mozilla plugin site <a href=... | <p>I highly recommend using Nixysa <a href="http://code.google.com/p/nixysa/" rel="nofollow noreferrer">http://code.google.com/p/nixysa/</a>, which wraps NPAPI. From the site:</p>
<blockquote>
<p>Nixysa is a framework written in
Python to automatically generate glue
code for NPAPI plugins (plugins for
browsers... | 30,533 |
<p>I am trying to take a rather large CSV file and insert it into a MySQL database for referencing in a project. I would like to use the first line of the file to create the table using proper data types and not varchar for each column. The ultimate goal is to automate this process as I have several similar files but t... | <p>Building on <a href="https://stackoverflow.com/questions/173498/using-php-to-take-the-first-line-of-a-csv-file-and-create-a-mysql-table-with-th#173526">Nouveau</a>'s code you could do this</p>
<pre><code>for($i = 0; $i <= count($fieldList); $i++)
{
if (is_numeric($fieldList[$i]))
{
if (strpos($fi... | <p>Using regular expressions will give you a flexible solution. If you need to detect date fields then this is the way to go.</p>
| 20,906 |
<p>We have a large ASP.Net website that has a single css stylesheet which is getting out of control.</p>
<p>I am thinking of using the following strategy (taken from <a href="http://www.techrepublic.com/article/developing-a-css-strategy/5437796/" rel="nofollow noreferrer">http://www.techrepublic.com/article/developing-... | <p>I think the best option is to divide css in:</p>
<p>-layout.css</p>
<p>-content.css</p>
<p>Then if you need other more specific you can add more like an css for the ads: ads.css, or one css for a specific section.</p>
<p>I would also add ie.css for IE css hacks.</p>
<p>I would not speak about creating one css f... | <p>netadictos makes some good points and I would concur. It's easy to seek reasons for more Css but the benefits of keeping them lean are far greater in the longer term.</p>
<p>In addition, have you looked at using themes and skin files within asp.net? The combination of .css and .skin can dramatically reduce the ov... | 42,422 |
<p>I've heard rumors that PHP is planning on introducing a "goto" command. What is it supposed to be doing?</p>
<p>I've tried searching a bit, but haven't found anything awfully descriptive. I understand that it won't be a "<code>GOTO 10</code>"-like command...</p>
| <p>They are not adding a real GOTO, but extending the BREAK keyword to use static labels. Basically, it will be enhancing the ability to break out of <s>switch</s> nested if statements. Here's the concept example I found:</p>
<pre><code><?php
for ($i = 0; $i < 9; $i++) {
if (true) {
break blah;
}... | <p>It <a href="http://wiki.php.net/doc/todo/undocumented#php_5.3" rel="nofollow noreferrer">looks</a> like it's currently in PHP 5.3, but is not fully documented yet. From what I can tell it shares its goto syntax with C, so it should be easy to pick up and use. Just remember Dijkstra's <a href="http://www.cs.utexas.ed... | 3,983 |
<p>The reason I want to do this is to make it easy to parse out instructions that are emailed to a bot, the kind of thing majordomo might do to parse commands like subscribing and unsubscribing. It turns out there are a lot of crazy formats and things to deal with, like quoted text, distinguishing between header and b... | <p>Can't say I have every done exactly what you are talking about, but maybe you should give this a read as it sounds like the author is doing what you describe.</p>
<p><a href="http://mipagina.cantv.net/lem/perl/mime.html" rel="nofollow noreferrer">Parsing MIME & HTML</a></p>
| <p>Some ideas: <a href="http://news.ycombinator.com/item?id=666607" rel="nofollow noreferrer">http://news.ycombinator.com/item?id=666607</a></p>
<p>Here's my incomplete solution, which actually works for my purposes (parsing commands emailed to a bot). I'm keeping it here for reference until there's a definitively b... | 16,492 |
<p>I am printing Eryone 1.75 mm PET on my Kobra Max printer with 80°C bed and 230°C.</p>
<p>I am experiencing this:</p>
<p><a href="https://i.stack.imgur.com/RXv0n.jpg" rel="nofollow noreferrer" title="Possible stringing and over-extrusion"><img src="https://i.stack.imgur.com/RXv0n.jpg" alt="Possible stringing and over... | <p>PETG sticks to brass nozzles <em>really well</em>. Better than it sticks to itself, in many cases. When travelling over already-printed material, especially if the filament is not retracted (Cura calls this kind of travel "combing") or if the material it's travelling over is overextruded and bulging up, th... | <h1>Stringing</h1>
<p>PETG is prone to stringing, even with the best settings. Often, I live with some stringing as strings are easy to clean up while other issues can be introduced by getting totally rid of it.</p>
| 2,208 |
<p>I have a large array with a range of integers that are mostly continuous, eg 1-100, 110-160, etc. All integers are positive.
What would be the best algorithm to compress this?<br/><br/>
I tried the deflate algorithm but that gives me only 50% compression.
Note that the algorithm cannot be lossy.</p>
<p>All numbers ... | <p>We have written recent research papers that survey the best schemes for this problem. Please see:</p>
<p>Daniel Lemire and Leonid Boytsov, Decoding billions of integers per second through vectorization,Software: Practice & Experience 45 (1), 2015.
<a href="http://arxiv.org/abs/1209.2137">http://arxiv.org/abs/1... | <p>If you have series of repeated values RLE is the easiest to implement and could give you a good result. Nontheless other more advanced algorithms that take into account the entrophy such as LZW, which is now patent-free, can usually achive a much better compression.</p>
<p>You can take a look at these and other los... | 35,908 |
<p>I'm working with a third party to integrate some of our systems with theirs and they provide us with a SOAP interface to make certain requests and changes in their connected systems. The problem for me is that they do not supply a WSDL-file for me to work against. If I had a WSDL-file it would be a simple matter jus... | <pre><code>string EndPoints = "http://203.189.91.127:7777/services/spm/spm";
string New_Xml_Request_String = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/200... | <p>I haven't built a SOAP interface without access to a WSDL file, but the format is <a href="http://www.w3.org/TR/wsdl" rel="nofollow noreferrer">fairly well-documented</a>. Your best bet might be to create a simplified WSDL file of your own that reflects what you know of the service you're subscribing to....</p>
<p... | 35,099 |
<p>As a part of database maintenance we are thinking of taking daily backups onto an external/firewire drives. Are there any specific recommended drives for the frequent read/write operations from sql server 2000 to take backups?</p>
| <p>Whatever you do, just don't use USB 1.1.</p>
| <p>The simple fact is that harddrives over a period of time will fail. The best two solutions
I can recommend unfortunately do not avail of using harddrives.</p>
<p>Using a tape backup, granted is slower but you get the flexibility of having the option of offsite backups. It is easy to put a tape in the boot of a car.... | 10,155 |
<p>Is there a way to stop the path showing in a source code tab in Visual Studio 2008?</p>
<p>Currently when developing an ASP.NET site, I get the path from the root plus the filename - truncated when it gets too long. So something like:</p>
<blockquote>
<p>MyDir/MyPage.aspx</p>
</blockquote>
<p>for a short path a... | <p>In XCode 4.5, use the built in <a href="http://developer.apple.com/library/mac/#recipes/xcode_help-source_editor/Analyze/Analyze.html" rel="nofollow noreferrer">Static Analyzer</a>.</p>
<p>In versions of XCode prior to 3.3, you might have to download the static analyzer. These links show you how:</p>
<h2>Use the L... | <p>Obviously you need to understand the basic memory management concepts to begin with. But in terms of chasing down leaks, I highly recommend reading <a href="http://mobileorchard.com/find-iphone-memory-leaks-a-leaks-tool-tutorial/" rel="nofollow">this tutorial on using the Leaks mode in Instruments</a>.</p>
| 20,744 |
<p>I'm trying to make a picture button in the compact framework. I made a usercontrol and added a picturebox. I saw you could over ride the text and font for normal windows forms. but don't seem able to do it for compact. It crashes VS2008. Has anyone done this? </p>
| <p>Consider using the <a href="http://www.opennetcf.com/library/sdf/" rel="nofollow noreferrer">Smart Device Framework</a> from OpenNETCF. Whenever I've tried to do custom UI and the compact framework has let me down, SDF has usually already "fixed" it.</p>
| <p>Thanks, we are already using that to optain the MAC address. I'm really surprised how much was left out of the compact framework.</p>
| 22,318 |
<p>I have an Eclipse RCP app I'm working on. It has some view-specific menus and one of the menu items is an item which I would like to display a tick next to when the corresponding functionality is enabled. Similarly, the next time the item is selected, the item should become unticked to reflect that the corresponding... | <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,005 |
<p>I have a trace setup for SQL Server Profiler to monitor SQL that is executed on a database. I recently discovered that trigger execution is not included in the trace. After looking through available events for a trace, I do not see any that look like they would include trigger execution. Does anyone know how to s... | <p>Stored procedures:
- SP:StmtStarting
- SP:StmtCompleted</p>
| <p>In SQL Server Profiler 2008, when starting/configuring the trace, go to the "Events Selection" tab, click on the "Show all events" checkbox, and then in the list under the Stored Procedures section select the SP:StmtStarting and SP:StmtCompleted events to be included in the trace.</p>
| 19,297 |
<p>There are many techniques to enforce strong passwords on website:</p>
<ul>
<li>Requesting that passwords pass a regex of varying complexity</li>
<li>Setting the password autonomously, so that casual users have a strong password</li>
<li>Letting passwords expire</li>
<li>etc.</li>
</ul>
<p>On the other hands there ... | <p>I don't think it's possible to enforce strong passwords, but there are lots of things you can do to encourage them as much as possible.</p>
<ul>
<li>Rate each password and give the user feedback in the form of a score or a graphical bar, etc.</li>
<li>Set a minimum password score to weed out the <em>awful</em> ones... | <p>I've never seen this done, but it seems like it would work wonderfully: the password creation page could have an expandable list of the,say, the 50 most <a href="http://www.openwall.com/wordlists/" rel="nofollow noreferrer">common passwords</a>, forcing the user to scroll down a bit before typing in their password. ... | 20,282 |
<p>Anyone have any idea? And any open source sofware which also seens to perform this kind of functionality?</p>
| <p>You should ask your hosting service provider, they may have removed it (for some reason).</p>
| <p>I have had the same problem, that the ASP.NET State service disappeared from the Administrative Tools / Services list. And the command "net start aspnet_state" didn't work either.</p>
<p>For me it worked fine after doing a repair on the currently latest .net version. Net 4.0 in my case.</p>
| 17,812 |
<p>After diving into the www, I don't have a clue about the support of vectorial grahics/image by reporting services. It seems to be impossible. We are using Reporting Services with a PDF rendering and we are forced to use raw bitmap into reports. That leads to huge sized reports. We know that dealing with vectorial gr... | <p>No, there are no known ways to insert vector graphics within SQL Reporting Services. Now since RDL 2.0 some support for HTML is supported but I'm not sure if that would include VML or anything adequate for showing graphics.</p>
<p>I have the same need and have been communicating as much as possible with those invol... | <p>There have been problems in the past with SQL Reporting Services and PDF compression. If you are creating serverreports in a version prior to 2005 or localreports in a version prior to 2008 the hugh pdf files could be caused by the compression issue. </p>
<p><a href="http://forums.asp.net/t/1066296.aspx" rel="nofo... | 18,973 |
<p>I'm a beginner in 3d printing, so please bear with me.</p>
<p>I downloaded a zip with about 100 STL files. I now want to pick one or two to print. The names of the stl files are not very helpful so I need to look at them to find the ones I want. I can open all of them one by one using Cura, or Tinkercad, but that is... | <p>Using the search terms, "linux stl viewer," a number of results appear. One of the more promising programs, for Mac, Windows and Linux appears to be <a href="https://github.com/fstl-app/fstl" rel="noreferrer">fast stl viewer</a>, aka fstl. Image from linked site. Instructions included on the linked site to... | <p>Cura's probably your best bet. You can select several STL files and it will open them all, (memory allowing) then try to place them for printing. If they can't fit on your print bed the items get placed off to the side. Clicking on the object will show its name in the lower-left, so you can go rename the file to ... | 2,175 |
<p>My project has some money to spend before the end of the fiscal year and we are considering replacing a Sun-Fire-V490 server we've had for a few years. One option we are looking at is the <a href="http://www.sun.com/servers/coolthreads/overview/index.jsp" rel="nofollow noreferrer">CoolThreads</a> technology. All I... | <p>IIRC The coolthreads technology is referring to the fact that rather than just ramping up the clock speed ever higher to improve performance they are now looking at multiple core processors with hyperthreading effectively giving you loads of processors on one chip. Overall the processing capacity available is higher... | <p>It hit me last night that our core processes aren't multi-threaded, but the machine in question does have a bunch of system processes that are. In particular, it acts as an NFS server. It sounds like running hundreds of processes will benefit from all those cores, as well.</p>
<p>I'll see if we can get a demo uni... | 8,232 |
<p>So this is a question for anyone who has had to integrate the building/compilation of legacy projects/code in a Team Build/MSBuild environment - specifically, Visual Basic 6 applications/projects.</p>
<p><i>Outside</i> of writing a custom build Task (which I am not against) does anyone have any suggestions on how b... | <p>From a quick look, the following code from IO::Socket::INET</p>
<pre><code>sub _get_addr {
my($sock,$addr_str, $multi) = @_;
my @addr;
if ($multi && $addr_str !~ /^\d+(?:\.\d+){3}$/) {
(undef, undef, undef, undef, @addr) = gethostbyname($addr_str);
} else {
my $h = inet_aton(... | <p>Make sure that you have the statement </p>
<pre><code>use IO::Socket::INET;
</code></pre>
<p>At the beginning of your source code. If you leave this out, you are probably getting the error message:</p>
<blockquote>
<p>Can't locate object method "new" via
package "IO::Socket::INET"</p>
</blockquote>
<p>Beyond... | 19,440 |
<pre><code>public static IQueryable<TResult> ApplySortFilter<T, TResult>(this IQueryable<T> query, string columnName)
where T : EntityObject
{
var param = Expression.Parameter(typeof(T), "o");
var body = Expression.PropertyOrField(param,columnName);
var sortExpression = Expression.Lambda(body... | <p>We did something similar (not 100% the same, but similar) in a LINQ to SQL project. Here's the code:</p>
<pre><code>public static IQueryable<T> OrderBy<T>(this IQueryable<T> source, string ordering, params object[] values) {
var type = typeof(T);
var property = type.GetProperty(ordering);
... | <p>Here is my adaptation from <a href="https://stackoverflow.com/users/11098/davy-landman">@Davy Landman</a>'s answer (I wanted an extension method) and I simplified a bit.</p>
<pre><code>public static IQueryable<T> SortBy<T>(this IQueryable<T> source,
String pr... | 39,581 |
<p>I'm working on a project where I'm trying to avoid hard-coding DB IDs in a .NET service-oriented project. There are some instances where I <strong>need</strong> to set ID values through code but I don't want to just hard code the IDs since I've done that before and it lead to DB alignment nightmares when the auto-in... | <p>I've always created a separate assembly that contains the enumerations and any interfaces the client/server need to share. You can then reference it from both the client and the server without leaking any functionality.</p>
| <p>You can define the enums in common library and use it on client as well as server side.
When you pass enum through a web service - it gets converted to string. Write a simple conversion extension method that converts it to appropriate enum. example:</p>
<pre><code>DayOfWeek ConvertToDayOfWeek(this String str)
{
... | 19,387 |
<p>I would like to stress test a win32 application by sending a lot of random keystrokes to it, and I wonder if anyone could point me to some software I could use. Ideally, I should be able to specify which keystrokes can be sent, and control rate (random min/max).</p>
| <p>Have a look at the <a href="http://pages.cs.wisc.edu/~bart/fuzz/" rel="nofollow noreferrer">Fuzz Testing of Application Reliability</a> website of the University of Wisconsin. They did a research study some years ago to test the reliability of desktop software and on that page you find a link to their FTP site provi... | <p>Here's a pseudocode (since you didn't mention the language you're using):</p>
<ul>
<li>Create an array that contains the alphabet from a-z, A-Z, 0-9 (depending on what keys you wish to send)</li>
<li>for i = 0 to NumberOfKeyStrokes</li>
<li>rand() % SizeOfArray</li>
<li>delay for rand() milliseconds (the lower the ... | 29,634 |
<p>I'm coming from a Rails background and doing some work on a ASP.NET project (not ASP MVC). Newbie question: what's the easiest way to make a custom editor for a table of records?</p>
<p>For example: I have a bunch of data rows and want to change the "category" field on each -- maybe a dropdown, maybe a link, maybe ... | <p>You can REALLY cheat nowadays and take a peek at the new Dynamic Data that comes with .NET 3.5 SP1. Scott Guthrie has a blog entry demoing on how quick and easy it'll flow for you here:</p>
<p><a href="http://weblogs.asp.net/scottgu/archive/2007/12/14/new-asp-net-dynamic-data-support.aspx" rel="nofollow noreferrer"... | <p>There are a few controls that will do this for you, with varying levels of complexity depending on their relative flexibility. </p>
<p>The traditional way to do this would be the DataGrid control, which gives you a table layout. If you want something with more flexibility in appearance, the DataList and ListView co... | 3,381 |
<p>Does anybody know of a tool to test OCSP responses? Preferably, something that can be used from a Windows Command-line and/or can be included (easily) in a Java/python program </p>
| <p>Looking a bit more, I think I've found some answers:</p>
<p>a) OpenSSL at the rescue:</p>
<pre><code>openssl ocsp -whatever
</code></pre>
<p>For more info, <a href="http://www.openssl.org/docs/apps/ocsp.html" rel="nofollow noreferrer">http://www.openssl.org/docs/apps/ocsp.html</a></p>
<p>b) <a href="http://www.o... | <p>Can you test it over HTTP as described in the specs in Appendix A? If so, then you can use any web test util. Since you mentioned Java, <a href="http://jakarta.apache.org/jmeter/" rel="nofollow noreferrer">JMeter</a> comes to mind. With JMeter, you can create your java code to do validation, etc and re-use it in ... | 9,695 |
<p>I'm printing part for a chess board from a set on Thingiverse, expanded a little to 50 mm square.
After the 3<sup>rd</sup> layer, I'm seeing what looks like raised ripples, and you can feel them with a finger too. I didn't see this when printing just 4 pieces earlier.
PLA at ~200 °C, bed is PEX/flex s... | <p>Printing some more parts tonight. Looks like solution is better bed "leveling" (tramming, or basically squareness between X, Y, and Z axis). Getting it dialed in to the correct height, 1/4 turn of a bed leveling screw at a time.</p>
<p>Also ordered some metal (stainless steel) shims so we can get and check the bed... | <p>It looks like over-extrusion. When layers are printed with 100% infill, excess material has nowhere to go and these characteristic ripples form.</p>
<p>Always calibrate your extruder. 3D Hubs have a good article on the topic:</p>
<p><a href="https://www.3dhubs.com/talk/t/howto-calibrate-tune-and-fine-tune-your-pri... | 1,387 |
<p>I am presently running several websites and a mail server from my home network. I have a business DSL account with 8 public IP addresses (1 by itself, and 7 in a block). To handle routing/firewall/gateway, I am presently using RRAS, DNS, & DHCP from Windows 2003 running on a ancient (circa 2001) PC -- which I ... | <p>This can't be done on a Linksys router with stock firmware. It can be done if you load a third-party firmware, but there's no GUI (afaik) to accomplish it, so you'll be hacking system shell scripts which is pretty hairy. I would recommend getting a low-power or older PC and installing <a href="http://www.pfsense.c... | <p>Install DD-wrt On your linksys box. I believe this will have everything you need <a href="http://www.dd-wrt.com/site/index" rel="nofollow">link text</a></p>
| 14,887 |
<p>How to programmatically associate a name like COM51 to a physical serial port in Microsoft Windows?</p>
<p>To manually perform the operation I can follow the steps described in<br>
<a href="http://technet.microsoft.com/en-us/library/cc754755.aspx" rel="nofollow noreferrer" title="http://technet.microsoft.com/en-us/... | <p>I don't know any API to achieve that, but you can edit the registry values under HKLM\Hardware\DEVICEMAP\SERIALCOMM</p>
| <p>ComDBClaimPort
<a href="http://msdn.microsoft.com/en-us/library/ms800845.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms800845.aspx</a></p>
<p>That only does part of the job though.</p>
| 16,385 |
<p>I'm looking for a performant, reasonably robust RNG using no special hardware. It can use mathematical methods (Mersenne Twister, etc), it can "collect entropy" from the machine, whatever. On Linux/etc we have a <code>drand48()</code> which generates 48 random bits. I'd like a similar function/class for C++ or C# wh... | <p>For C++, <a href="http://www.boost.org/libs/random/" rel="noreferrer">Boost.Random</a> is probably what you're looking for. It has support for MT (among many other algorithms), and can collect entropy via the <code>nondet_random</code> class. Check it out! :-)</p>
| <p><code>Boost.Random</code> is my first choice for RNG</p>
<p><a href="http://www.boost.org/doc/libs/random" rel="nofollow">http://www.boost.org/doc/libs/random</a></p>
| 2,302 |
<p>I've just put my new server up on an IP address with a domain pointing to it. I need to be able to remote admin it. I've opened the firewall for Remote Desktop and HTTP traffic. Is this going to be secure enough? I guess I should probably rename the administrator user...</p>
| <p>The absolute minimum you should do is change the Remote Desktop port, change the Admin username, and have a very strong admin password.</p>
| <p>Any chance you can set up your server as a VPN endpoint? Then you would only have the VPN ports and the HTTP ports open. When you want to RDP to the server, you would connect to the VPN first and then you're good to go. </p>
<p>Only reason is, if my memory serves me right, RDP traffic is not encrypted.</p>
<p>T... | 4,009 |
<p>I am trying to convert an ASP.NET website into a web application project. The conversion has gone ok I think apart from previously I had 2 xsd files in the App_Code folder. I believe this folder is not used in web applications projects, so where would I put xsd files now.</p>
| <p>I don't think you have to put them anyplace in particular. For the purposes of organization you could create a data directory. If the project is small enough, I leave it in the root.</p>
| <p>You can place the files wherever you want, but you have to be careful that your namespace references are still correct.</p>
<p>I would look at your Root Namespace declaration in the project properties to ensure that it is set to what you expect it to be. Also, you will want to look at the location of your TableAda... | 21,530 |
<p>I have an XP client that is experiencing an issue. My dev box is Vista Home 64. I start up the debugger on the client machine and when i try to run on the dev box, it says 'Unable to debug. Remote debugger doesn't support this version of windows'. </p>
<p>Looks like I'm sol. is there another way to find out how to ... | <p>Turns out the .net framework was hosed on the client. I couldn't get a stacktrace or nothing. Removed and reinstalled .net framework and everything worked great!</p>
<p>Thanks for all the help!</p>
| <p>Are you running the remote debugging monitor (msvcmon.exe) on the remote machine?</p>
<p>Does the version of the monitor match the Visual Studio version you are using on the local machine?</p>
| 48,350 |
<p>I am looking for a way to change the password of a local user account (local Administrator) on a Windows (XP in this case) machine. I have read the <a href="http://www.codeproject.com/KB/threads/Reset-Administrator-Pass.aspx" rel="noreferrer">CodeProject article</a> about one way to do this, but this just doesn't se... | <p>Try the <code>DirectoryEntry</code> class instead of <code>ManagementObject</code> class.</p>
| <p>As Ely noted, you can use the System.DirectoryServices code to accomplish this per <a href="http://msdn" rel="nofollow noreferrer">MSDN</a>:</p>
<pre><code>String myADSPath = "LDAP://onecity/CN=Users,
DC=onecity,DC=corp,DC=fabrikam,DC=com";
// Create an Instance of DirectoryEntry.
DirectoryEntry myDirectoryEn... | 29,065 |
<p>I'm trying to use powershell to configure the account credentials, but I need to grant the account "Log on as a service" right in order for it to work. How can I do this in powershell?</p>
| <p>The Powershell script below will grant the <strong><em>SeServiceLogonRight</em></strong> on the host specified by <em>computerName</em> to the user specified by <em>username</em> (the script is an excerpt from here: <a href="https://gist.github.com/grenade/8519655" rel="noreferrer">https://gist.github.com/grenade/85... | <p>As easy solution in powershell</p>
<p>just run</p>
<pre><code>.".\Add Account To LogonAsService.ps1" "DOMAIN\Account"
</code></pre>
<p><a href="https://gallery.technet.microsoft.com/scriptcenter/Grant-Log-on-as-a-service-11a50893" rel="nofollow noreferrer">https://gallery.technet.microsoft.com/sc... | 40,470 |
<p>How to capture user clicks in a winform application without making the code very complicated? is AOP the answer? How to track instrumentations?</p>
| <p>This does depend rather on your actual requirements.</p>
<p>For a simple/sample/prototype winforms app, I'd suggest basic <a href="http://msdn.microsoft.com/en-us/library/aa983610(VS.71).aspx" rel="noreferrer">WinForms Event Handlers</a>, with the code (providing it's not too heavy) in the handler methods. If code... | <p>The general method for capturing clicks in winforms is handling <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.mouseclick.aspx" rel="nofollow noreferrer">Control.MouseClick</a>. You can also look at <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.mousedown... | 28,715 |
<p>I realize that literally it translates to Java Enterprise Edition. But what I'm asking is what does this really mean? When a company requires Java EE experience, what are they really asking for? Experience with EJBs? Experience with Java web apps? </p>
<p>I suspect that this means something different to different ... | <p>Java EE is actually a collection of technologies and APIs for the Java platform designed to support "Enterprise" Applications which can generally be classed as large-scale, distributed, transactional and highly-available applications designed to support mission-critical business requirements. </p>
<p>In terms of wh... | <p>Seems like Oracle is now trying to do away with JSPs (replace with Faces) and emulate Spring's REST (JAX-RS) and DI.</p>
<p>ref: <a href="https://docs.oracle.com/javaee/7/firstcup/java-ee001.htm" rel="nofollow">https://docs.oracle.com/javaee/7/firstcup/java-ee001.htm</a></p>
<p>Table 2-1 Web-Tier Java EE Technolog... | 13,239 |
<p>I'm trying to make a page in php that takes rows from a database, displays them, and then give the viewer a chance to upvote or downvote a specific entry. Here is a snippet:</p>
<pre><code>echo("<form action=\"vote.php\" method=\"post\"> \n");
echo("<INPUT type=\"hidden\" name=\"idnum\" value=\"".$row[0]."... | <p>Your form tag isn't closed properly. You have <code><form/></code>, but it should be <code></form></code>.</p>
<p>This makes the entire page a form so it sends all the inputs. With a form that is closed properly though, it will only send the inputs within the form tags that the pressed button was in.</p... | <p>Your form is not closed properly. Use <code></form></code> instead of <code><form/></code>.</p>
| 31,862 |
<p>I need a very fast algorithm for the following task. I have already implemented several algorithms that complete it, but they're all too slow for the performance I need. It should be fast enough that the algorithm can be run at least 100,000 times a second on a modern CPU. It will be implemented in C++.</p>
<p>I am... | <p>We know that the absolute best case runtime is O(m+n) this is due to the fact that you at least have to scan over all of the data in order to be able to merge the lists. Given this, your second method should give you that type of behavior. </p>
<p>Have you profiled your second method to find out what the bottleneck... | <p>How about the second method without repeated allocation--in other words, allocate your temporary vector once, and never allocate it again? Or, if the input vectors are small enough (But not constant size), just use alloca instead of malloc.</p>
<p>Also, in terms of speed, you may want to make sure that your code i... | 11,494 |
<p>Is it possible to create a MySQL select statement that uses an expression as x then checks if the value for x is under a certain amount?</p>
<pre><code>SELECT (mytable.field1 + 10) AS x FROM `mytable` WHERE x < 50;
</code></pre>
| <p>no you have to actually do this</p>
<pre><code>SELECT (mytable.field1 + 10) AS x FROM `mytable` WHERE (mytable.field1 + 10) < 50;
</code></pre>
| <p>I store expressions in variables and interpolate them in multiple places for this:</p>
<pre><code>$x_sql = '(mytable.field1 + 10)';
$SQL = "SELECT $x_sql AS x FROM mytable WHERE $x_sql < 50";
</code></pre>
<p>Or if you aren't bothered by the inefficiency, use a HAVING clause:</p>
<pre><code>SELECT (mytable.fie... | 43,399 |
<p>I am writing a quick application myself - first project, however I am trying to find the VBA code for writing the result of an input string to a named cell in Excel.</p>
<p>For example, a input box asks the question "Which job number would you like to add to the list?"... the user would then enter a reference numbe... | <p>You can use the Range object in VBA to set the value of a named cell, just like any other cell.</p>
<pre><code>Range("C1").Value = Inputbox("Which job number would you like to add to the list?)
</code></pre>
<p>Where "C1" is the name of the cell you want to update.</p>
<p>My Excel VBA is a little bit old and crus... | <p>I've done this kind of thing with a form that contains a TextBox.</p>
<p>So if you wanted to put this in say cell <code>H1</code>, then use:</p>
<p><code>ActiveSheet.Range("H1").Value = txtBoxName.Text</code></p>
| 32,096 |
<p>I want to develop a mobile web application using asp.net 3.5 that can be viewed on an iPhone but there is no longer a template in VS2008 to enable mobile development. Can this be done ?</p>
| <p>the iphone uses the "regular" version of your website so developing a "mobile" version would nto accomplish what you're looking for. You should check the browser headers and redirect people to the iPhone version of your site if you detect mobile safari.</p>
<p><a href="http://iphone.facebook.com/" rel="nofollow nor... | <p>The iPhone (at least mine which is the 3G version) have full support for "normal" web apps with Ajax and everything. So mostly any Ajax library would be 100% compatible with the iPhone, at least as long as the Ajax library is focusing on Open Standards and such...</p>
<p>[Shameless-Plug I work with Ra-Ajax]</p>
<p... | 40,971 |
<p>i am looking for opinions if the following problem maybe has a better/different/common solution:</p>
<hr>
<p>I have a database for products which contains the names of the products in english (the default language of this application) and i need translations of the names if available.</p>
<p>Currently i have this... | <p>Looks good to me. The one thing I might change is the way you handle languages: that should probably be a separate table. Thus, you would have:</p>
<pre><code>CREATE TABLE products_l10n
(
product_id serial NOT NULL,
language_id int NOT NULL,
"name" character varying(255) NOT NULL,
CONSTRAINT products_l10n... | <p>Looks decent to me.</p>
<p>Obviously you should put the localized name into a Unicode column, which you could opt to put the English default into an ASCII field (assuming the database supports that). It may be best to just do Unicode throughout and "forget" about it.</p>
| 23,011 |
<p>You may think that this is a coincidence that the topic of my question is similar to the name of the forum but I actually got here by googling the term "stack overflow".</p>
<p>I use the OPNET network simulator in which I program using C. I think I am having a problem with big array sizes. It seems that I am hittin... | <p>It may help if you post some code. Edit the question to include the problem function and the error.</p>
<p>Meanwhile, here's a very generic answer:</p>
<p>The two principal causes of a stack overflow are 1) a recursive function, or 2) the allocation of a large number of local variables.</p>
<p><strong>Recursion<... | <p>You are unlikely to run into a stack overflow with unthreaded compiled C unless you do something particularly egregious like have runaway recursion or a cosmic memory leak. However, your simulator probably has a threading package which will impose stack size limits. When you start a new thread it will allocate a c... | 13,175 |
<p>What is the operator precedence order in Visual Basic 6.0 (VB6)?</p>
<p>In particular, for the logical operators.</p>
| <h3>Arithmetic Operation Precedence Order</h3>
<ol>
<li><code>^</code></li>
<li><code>-</code> (unary negation)</li>
<li><code>*</code>, <code>/</code></li>
<li><code>\</code></li>
<li><code>Mod</code></li>
<li><code>+</code>, <code>-</code> (binary addition/subtraction)</li>
<li><code>&</code></li>
</ol>
<h3>Compa... | <h1><strong>Use parentheses</strong></h1>
<hr>
<p>EDIT: That's my advice for new code! But Oscar is reading someone else's code, so must figure it out somehow. I suggest the VBA manual topic <a href="https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/operator-precedence" rel="nofollo... | 7,893 |
<p>So I have a problem. I checked in my frozen gems and rails even though you aren't supposed to do that. I figured it was easy and wouldn't be that big of a deal anyway. Well, later I updated rails and in doing so deleted all the .svn files in the vendor/rails directories. I have heard that what I really <em>shoul... | <ol>
<li><p>To recover your deleted <code>.svn</code> directories, just run an <code>svn update</code>. They'll come back.</p></li>
<li><p>I just check in exported gems. I use <code>gem unpack <gemname></code> in the <code>vendor/gems</code> directory and <code>svn add</code> and <code>commit</code> from there.... | <p>Disclaimer: I don't know Ruby/Rails, so I don't know what frozen gems are (though I assume they're compiled binaries or tokenized source), but I know Subversion well.</p>
<p>.svn directories only hold Subversion "bookkeeping". There's nothing in there that's unrecoverable.</p>
<p>Deleting your .svn files is not a... | 14,477 |
<p>I have whitespace characters showing in the Visual Studio code editor, and I'd like to remove them.</p>
| <p>Ajryan is correct but depending on your profile this menu item may be obscured. The keyboard shortcut should still work though. <kbd>Ctrl</kbd>+<kbd>R</kbd>,<kbd>Ctrl</kbd>+<kbd>W</kbd></p>
| <p>For <code>Visual Studio 2019</code>:</p>
<ul>
<li>Toggle on/off - Option 1: <kbd>Ctrl</kbd>+<kbd>R</kbd>,<kbd>Ctrl</kbd>+<kbd>W</kbd></li>
<li>Toggle on/off - Option 2: <code>Edit > Advanced > View White Space</code></li>
<li>Change appearance: <code>Tools > Options > Environment > Fonts and Colors &g... | 32,165 |
<p>"Evidence-based scheduling" in FogBugz is interesting, but how do I use it w/ an Agile methodology?</p>
| <p>As <a href="https://stackoverflow.com/questions/55693/how-do-you-use-fogbugz-with-an-agile-methodology#55702">eed3si9n</a> said, if you are consistent in your estimates for EBS, FogBugz will take care of this for you.</p>
<p>As to the more general, how does FogBugz fit with the Agile methodology, your best bet is to... | <p>I asked the FogBugz guys the same thing because in XP for example you'd provide the estimate in IET (ideal engineering time). Their answer was to be consistent in the way you provide the estimate.</p>
| 7,951 |
<p>In C#, (and feel free to answer for other languages), what order does the runtime evaluate a logic statement?</p>
<p>Example:</p>
<pre><code>DataTable myDt = new DataTable();
if (myDt != null && myDt.Rows.Count > 0)
{
//do some stuff with myDt
}
</code></pre>
<p>Which statement does the runtime eva... | <p>C# : Left to right, and processing stops if a non-match (evaluates to false) is found.</p>
| <p>I have heard somewhere that compilers work backwards, but I am unsure how true this is.</p>
| 2,725 |
<p>I'm looking for a free, preferably open source, http <a href="http://en.wikipedia.org/wiki/Image_server" rel="noreferrer">image processing server</a>. I.e. I would send it a request like this:</p>
<pre><code>http://myimageserver/rotate?url=http%3A%2F%2Fstackoverflow.com%2FContent%2FImg%2Fstackoverflow-logo-250.png&... | <p>The <a href="http://imageresizing.net" rel="nofollow">ImageResizing.Net library</a> is both a .NET library and an IIS module. It's an image server or an image library, whichever you prefer. </p>
<p>It's open-source, under an <a href="http://imageresizing.net/licenses/" rel="nofollow">MIT-style license</a>, and is s... | <p>I found <a href="http://www.aspjpeg.com/" rel="nofollow noreferrer">this product</a>, it seems to match my requirements</p>
| 17,699 |
<p>Ok, the more I use LINQ, the more I like it! I recently found myself working in some legacy code at work. It is your classic DataSet and DataTable rich application. Well, when adding a bit of functionality I found myself <em>really</em> wanting to just query the rows of a DataTable for the results I was looking for.... | <p>One other observation; if you aren't using typed datasets, you might also want to know about the <code>Field<></code> extension method:</p>
<pre><code> var customerOrderIds = table.Rows.Cast<DataRow>()
.Where(x => x.Field<string>("CUSTOMER_ID") == customerId)
.Select(x => x.... | <p>Personally since the data table doesn't have the ability to do a select distinct on its own, I'll say that it isn't all that bad.</p>
<p>I would potentially ask though if there was any way to eventually get to using objects rather than data tables, as I think it would be easier for future developers to understand.<... | 32,789 |
<p>Contributing to open source can have many forms: working with issue trackers, patches, further development, documenting, funding, etc. Assuming your company uses open source projects, what is the single most important reason why you're not contributing back to the community?</p>
| <p>We do, we're founded on Open Source - but I guess we're special ;)</p>
<p>Anyway, this is not like a true answer to your question, but rather an answer to the "questions" in the other answers I guess. There are many ways to contribute to Open Source. Sure you can contribute <em>code</em>, but the other thing you ca... | <p>Programmers cost us money, but contributing to open source doesn't generate a cent of revenue.</p>
| 40,946 |
<p>How to optimize queries which are already written?</p>
| <p>Use <a href="http://dev.mysql.com/doc/refman/5.0/en/explain.html" rel="nofollow noreferrer">EXPLAIN</a> to see what's going on - what indexes are being used and so on.</p>
| <p>If you can't change the query then it really depends on what features are available on your database engine of choice. As Ovidiu said you can use indexes and generate usage statistics to see where the bottleneck is.</p>
<p>Otherwise you can employ techniques like materialised views or horizontal partitioning. </p>
... | 31,144 |
<p>I've just learned what ASP.NET MVC is and I'm wondering if the pattern is ever used in Windows Desktop application development? </p>
<p>I'm specifically looking at potentially trying to use it in a Desktop .NET application. </p>
<p>Please forgive me if this question is way out in left field in terms of how MVC is... | <p>The <a href="http://en.wikipedia.org/wiki/Model-view-controller" rel="nofollow noreferrer">Model-View-Controller</a> Pattern works like a dream with "desktop" apps, as you don't have to worry about handling state information.</p>
| <p>I don't rememer where I see a good example of MVC for descktop apps.<br>
It was about a thermometer.<br>
The model was the thermometer it self. A simple POJO with the current state of temperature.<br>
The apps have several views and controllers of the thermometer.<br>
The controllers calls the setters, and the views... | 39,364 |
<p>How can I compare the content of two (or more) large .resx files? With hundreds of Name/Value pairs in each file, it'd be very helpful to view a combined version. I'm especially interested in Name/Value pairs which are present in the neutral culture but are not also specified in a culture-specific version.</p>
| <p>There is a great freeware tool to edit resx files where you can see multiple languages at once and clearly see what is missing or extra - <a href="http://www.zeta-resource-editor.com/index.html" rel="noreferrer">Zeta Resource Editor</a></p>
| <p>You can use a tool like TortoiseSVN's diff (if you're using Windows). Just select both files, right click and then select "diff" from the TortoiseSVN submenu.</p>
| 16,535 |
<p>Where does Internet Explorer store the history data, i.e. the list of URL that have been visited? I am using Windows XP SP3 and IE7. Basically I would like to read the list of URL and make some statistics on how often what pages are visited.</p>
| <p>Internet Explorer seems to keep its history in hidden directories under C:\Documents and Settings\USERNAME\Local Settings\History\History.IE5. Note that some directories in this path are also marked hidden or system. The history's format is opaque, but <a href="http://www.codeproject.com/KB/system/IECache.aspx" re... | <p>It's stored in the registry:</p>
<p>HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TypedURLs</p>
| 23,752 |
<p>I have an application that manages patient demographic information. Along with this data a user can scan a picture of a patient and assign that picture to a patient. When the user clicks the scan button a separate application is opened as a dialog in order to scan the image. When running this on XP everything worked... | <p>I think you will have to make changes to your application to allow the imaging application to take the focus. I'm going to assume that your application launches the imaging application through <code>ShellExecute</code> or <code>CreateProcess</code>. If so, you can get the process handle of the launched process eithe... | <p>You could iterate through all top level HWNDs and identify the scanning application via its window class, then send an appropriate message to raise the window.</p>
| 22,292 |
<p>I'm currently using the default cookies as my single sign on (SSO) but some users are getting strange errors after I push an update. I'm considering moving to active record to store sessions but was wondering how I tell rails that the sessions are in another database?</p>
<p>So if I store sessions via AR in App1DB ... | <p>Rails most certainly <strong>does</strong> support database session storage.</p>
<p>In config/environment.rb, uncomment</p>
<pre><code># config.action_controller.session_store = :active_record_store
</code></pre>
<p>Examining \actionpack-2.2.2\lib\action_controller\session\active_record_store.rb shows that CGI::S... | <p>The rails docs for the session configuration(<a href="http://api.rubyonrails.org/classes/ActionController/SessionManagement/ClassMethods.html#M000312" rel="nofollow noreferrer">http://api.rubyonrails.org/classes/ActionController/SessionManagement/ClassMethods.html#M000312</a>) says that these are the only options: <... | 49,557 |
<p>There seem to be two rival Eclipse plugins for integrating with Maven:
<a href="http://m2eclipse.codehaus.org/" rel="nofollow noreferrer">m2Eclipse</a>
and
<a href="http://code.google.com/p/q4e/" rel="nofollow noreferrer">q4e</a>. </p>
<p>Has anyone recently evaluated or used these plugins?<br>
Why would I choose ... | <p><a href="http://docs.codehaus.org/display/MAVENUSER/Eclipse+Integration" rel="nofollow noreferrer">Side by side comparison table of three maven plugins.</a> </p>
| <p>I have been using m2Eclipse for quiet some time now and have found it to be very reliable. I wasn't aware of q4e until I saw this question so I can't recommend one over the other.</p>
| 6,979 |
<p>I have table employee like,
<br>
employee
(
emp_id int primary key,
emp_name varchar(50),
mngr_id int)</p>
<p>and here mngr_id would either null or contain valid emp_id. This way it form the hierarchy of employees in the organization.</p>
<p>In order to traverse the entire hierarchy I had to write the recursive st... | <p>a fairly simple iterative adjacency list db server side solution: <a href="http://pastie.org/1056977" rel="nofollow noreferrer">http://pastie.org/1056977</a></p>
<pre><code>delimiter ;
drop procedure if exists employee_hier;
delimiter #
create procedure employee_hier
(
in p_emp_id smallint unsigned
)
begin
decl... | <p>Tomalak: " ... I would do the recursion in the presentation layer of my app ... "</p>
<p>This would mean every time the recursion happened another call is sent to the database server from the presentation layer. That would be incredibly slow.</p>
| 27,254 |
<p>I always seem to use Get when working with data (strongly typed or otherwise) from the database and I have never really needed to use Fill although I just as easily could use Fill instead of get when pulling out and updating data.</p>
<p>Can anyone provide guidance as to the implications and gotchas of each method?... | <p>A particular gotcha of Fill, if the table already contains data is that you could get unique index exceptions when, for example, the query returns a row whose primary key is already in the table.</p>
<p>I've worked with a lot of data-bound Windows Forms code where edit controls or a grid on the form is bound to a t... | <p>The only difference is that GetData instantiates a table for you, Fill will fill an existing table.</p>
<p>It depends if you want or need to instantiate the DataTable. I often use Fill when filling a certain table member of a DataSet I already instantiated.</p>
| 20,780 |
<p>I know how to program Console application with parameters, example : myProgram.exe param1 param2.</p>
<p>My question is, how can I make my program works with |, example : echo "word" | myProgram.exe?</p>
| <p>You need to use <code>Console.Read()</code> and <code>Console.ReadLine()</code> as if you were reading user input. Pipes replace user input transparently. You can't use both easily (although I'm sure it's quite possible...).</p>
<p><strong>Edit:</strong></p>
<p>A simple <code>cat</code> style program:</p>
<pre><c... | <p>there is a problem with supplied example.</p>
<blockquote>
<pre><code> while ((s = Console.ReadLine()) != null)
</code></pre>
</blockquote>
<p>will stuck waiting for input if program was launched without piped data. so user has to manually press any key to exit program.</p>
| 24,321 |
<p>I'm having an issue getting validation error messages to display for a particular field in a Django form, where the field in question is a <strong>ModelMultipleChoiceField</strong>.</p>
<p>In the <code>clean(self)</code> method for the Form, I try to add the error message to the field like so:</p>
<pre><code>msg =... | <p>Yeah, it sounds like you're doing it wrong.</p>
<p>You should be using the <a href="http://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-a-specific-field-attribute" rel="nofollow noreferrer">clean_</a> method instead. Read through that whole document, in fact - it's very informative.</p>
| <p>Why are you instantiating an ErrorList and writing to self._errors directly? Calling "raise forms.ValidationError(msg)" takes care of all that already. </p>
<p>And what does your template look like?</p>
| 33,340 |
<p>Having tries to target two of these environments at the same time I can safely say the if you have to use a database etc. you end up having to write unique code for that environment. Have you got a great way to handle this situation?</p>
| <p>If you <em>do</em> find you need to write unique code for an environment, use pythons </p>
<pre><code>import mymodule_jython as mymodule
import mymodule_cpython as mymodule
</code></pre>
<p>have this stuff in a simple module (''module_importer''?) and write your code like this:</p>
<pre><code>from module_importe... | <p>I'm pretty sure you already know this but unfortunately Jython <a href="http://www.jython.org/Project/userfaq.html#is-jython-the-same-language-as-python" rel="nofollow noreferrer">can't load c extension modules.</a></p>
| 7,705 |
<p>I have lots of article store in MS SQL server 2005 database in a table called Articles-</p>
<pre><code>"Articles (ArticleID, ArticleTitle, ArticleContent)"
</code></pre>
<p>Now I want some SP or SQL query which could return me similar Article against any user's input (very much like "Similar Posts" in blogs OR "Re... | <p>Something like this might work, a kind of ranking system. You would probably have to split the string in your application to build a SQL string, but I have used similar to build an effective site search.</p>
<pre><code>Select
Top 10
ArticleID,
ArticleTitle,
ArticleContent
From
Articles
Order By
(Case When ArticleTi... | <p>First of all you need to define what article similarity means.<br>
For example you can associate some meta information with articles, like tags.<br>
To be able to find similar articles you need to extract some features from them, for example you can build full text index.</p>
<p>You can take advantage of full text ... | 6,029 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.