instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I am attempting to POST against a vendor's server using PHP 5.2 with cURL. I'm reading in an XML document to post against their server and then reading in a response:</p>
<pre><code>$request = trim(file_get_contents('test.xml'));
$curlHandle = curl_init($servletURL);
curl_setopt($curlHandle, CURLOPT_POST, TRUE);
cu... | <p>It turns out it's an encoding issue. The app apparently needs the XML in www-form-urlencoded instead of form-data so I had to change:</p>
<pre><code># This sets the encoding to multipart/form-data
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, array('XML'=>$request));
</code></pre>
<p>to</p>
<pre><code># This se... | <p>I did a <code>wc -m test.xml</code> and came back with 743 characters in the XML file and the <code>var_dump</code> on <code>$request</code> comes back with 742 characters so something is getting stripped with <code>trim()</code> (I assume).</p>
<p>I did a:</p>
<pre><code>print "=====" . $request . "=====";
</code... | 3,876 |
<p>In python, under what circumstances is SWIG a better choice than ctypes for calling entry points in shared libraries? Let's assume you don't already have the SWIG interface file(s). <br><br>What are the performance metrics of the two?</p>
| <p>SWIG generates (rather ugly) C or C++ code. It is straightforward to use for simple functions (things that can be translated directly) and reasonably easy to use for more complex functions (such as functions with output parameters that need an extra translation step to represent in Python.) For more powerful interfa... | <p>I have found SWIG to be be a little bloated in its approach (in general, not just Python) and difficult to implement without having to cross the sore point of writing Python code with an explicit mindset to be SWIG friendly, rather than writing clean well-written Python code. It is, IMHO, a much more straightforwar... | 16,447 |
<p>Does anyone know of a way to paste over a visually selected area without having the selection placed in the default register?</p>
<p>I know I can solve the problem by always pasting from an explicit register. But it's a pain in the neck to type <kbd>"</kbd><kbd>x</kbd><kbd>p</kbd> instead of just <kbd>p</kbd></p>
| <p><code>"{register}p</code> won't work as you describe. It will replace the selection with the content of the register. You will have instead to do something like:</p>
<pre><code>" I haven't found how to hide this function (yet)
function! RestoreRegister()
let @" = s:restore_reg
return ''
endfunction
function! s... | <p>try -</p>
<pre><code>:set guioptions-=a
:set guioptions-=A
</code></pre>
| 37,025 |
<p>I'm building an excel template (*.xlt) for a user here, and one of the things I want to do is have it insert the current date when a new document is created (ie, when they double-click the file in windows explorer). How do I do this?</p>
<p><strong>Update:</strong> I should have added that I would prefer not to us... | <p>You could use the worksheet function =TODAY(), but obviously this would be updated to the current date whenever the workbook is recalculated.</p>
<p>The only other method I can think of is, as 1729 said, to code the Workbook_Open event:</p>
<pre><code>Private Sub Workbook_Open()
ThisWorkbook.Worksheets("Sheet1... | <p>To avoid VBA, and if you think your users might follow instructions, you could ask them to copy the date and then paste special->values to set the date so that it won't change in future.</p>
| 6,187 |
<p>If I avoid referencing assemblies that don't exist in the silverlight 2.0 runtime, will the.Net 2.0 library dlls I create with VS2008 work with silverlight <strong>without recompilation</strong> or other alteration?</p>
| <p>No, you will still need to recompile against the Silverlight versions of the assemblies. You can add these files to a Silverlight Class Library project "as link", sharing the same file between both projects so you at least won't have to worry about getting out of sync.</p>
| <p>In addition to creating the files in one project and adding them as links in the other, you might still encounter API difference between the desktop and Silverlight APIs. You can work around those code differences with #if blocks, i.e.</p>
<pre><code>#if SILVERLIGHT
/* some code */
#else // WPF
/* some other code ... | 19,278 |
<p>This question is about App domains and Sessions. Is it possible to have IIS run each User Session in a seperate App Domain. If Yes, Could you please let me settings in the config file that affect this.</p>
<p>Regards,
Anil.</p>
| <p>I assume you mean anonymous types here, e.g. <code>new { Name1=value1, Name2=value2}</code> etc. If so, you're out of luck - anonymous types are normal types in that they're fixed, compiled code. They just happen to be autogenerated.</p>
<p>What you <em>could</em> do is write <code>new { old.Name1, old.Name2, ID=my... | <pre><code>public static string TextBox(this HtmlHelper html, string value, string labelText, string textBoxId, object textBoxHtmlAttributes, object labelHtmlAttributes){}
</code></pre>
<p>This would accept the id value the textbox should have and the label should refer to.
If the consumer now doesn't include the "id"... | 28,928 |
<p>Trying to create a random string, x characters in length using 0-9 and a-z/A-Z and can't seem to find a good example, any ideas?</p>
| <pre><code>Function RandomString(cb As Integer) As String
Randomize
Dim rgch As String
rgch = "abcdefghijklmnopqrstuvwxyz"
rgch = rgch & UCase(rgch) & "0123456789"
Dim i As Long
For i = 1 To cb
RandomString = RandomString & Mid$(rgch, Int(Rnd() * Len(rgch) + 1), 1)
Next... | <p>Use Randomize<br>
Int(Rnd * high bound) + (low bound) will generate a random number<br>
Generate an array with values from asc("a") to asc("z") and from asc("0") to asc("9")<br>
Generate random number between 1 and 26 (10+26) and look it up in array.<br></p>
<p>Don't have VB6 installed anymore.</p>
| 37,288 |
<p>I just completed my first print on my Ender-3 and when the print finalized itself the nozzle didn't elevate itself to clear away from the piece. I watched as the nozzle slowly lowered itself into my print and destroy it. Here is the gcode generated by Slic3r used:</p>
<pre>
; Filament-specific end gcode
G4 ; wait
M... | <p>You are using <strong>incorrect commands</strong> in your end-code for the <strong>incorrect tool</strong> with respect to the print head raise.</p>
<p>Slic3r has no knowledge of the maximum printer height (as in variable <code>max_print_height</code>) because there is <strong>no input field to specify this</strong... | <p>Your print end code should have read something akin to this:</p>
<pre><code>; Filament sy end gcode
G4 ; wait
M221 S100
M106 S0 ; turn off cooling fan
M104 S0 ; turn off extruder
M140 S0 ; turn off bed
; End code
G1 F1800 E-3 ; retract 3 mm
G1 Z30 ; Move print head up 30mm
G28 X0 ; home x and y axis
M84 ; disable ... | 1,203 |
<p>What is the fastest list implementation (in java) in a scenario where the list will be created one element at a time then at a later point be read one element at a time? The reads will be done with an iterator and then the list will then be destroyed.<br>
I know that the Big O notation for get is O(1) and add is O(1... | <p>It depends largely on whether you know the maximum size of each list up front.</p>
<p>If you do, use <code>ArrayList</code>; it will certainly be faster.</p>
<p>Otherwise, you'll probably have to profile. While access to the <code>ArrayList</code> is O(1), creating it is not as simple, because of dynamic resizing.... | <p>I have actually begun to think that any use of data structures with non-deterministic behavior, such as ArrayList or HashMap, should be avoided, so I would say only use ArrayList if you can bound its size; any unbounded list use LinkedList. That is because I mainly code systems with near real time requirements thoug... | 16,390 |
<p>What is the best way to keep an asp:button from displaying it's URL on the status bar of the browser? The button is currently defines like this:</p>
<pre><code><asp:button id="btnFind"
runat="server"
Text="Find Info"
onclick="btnFind_Click">
</asp:button>
</code><... | <p>I use FF so never noticed this, but the link does in fact appear in the status bar in IE..</p>
<p>I dont think you can overwrite it :( I initially thought maybe setting the ToolTip (al la "title") property might do it.. Seems it does not..</p>
<p>Looking at the source, what appears is nowhere to be found, ... | <p>I don't see a link, I see this:</p>
<pre><code>javascript:__doPostBack('btn','');
</code></pre>
<p><strong>EDIT</strong>: Sorry, was looking at a LinkButton, not an ASP:Button. The ASP:Button shows the forms ACTION element like stated. </p>
<p>But, if you are trying to hide the DoPostBackCall, the only way to do... | 8,369 |
<p>I have a mystery on my hands. I am trying to learn managed C++ coming from a C# background and have run into a snag. If I have a project which includes two classes, a base class <strong>Soup</strong> and a derived class <strong>TomatoSoup</strong> which I compile as a static library (.lib), I get unresolved tokens o... | <p>The error you are getting (LNK2020) means the linker can't find a definition for the <code>Abstracts.Soup::heat</code> function anywhere. When you declare the function as <code>virtual void heat(int Degrees);</code> the linker will expect to find the function body defined somewhere.</p>
<p>If you intend not to supp... | <p>I don't have much CLI experience but I think you should be inheriting using public:</p>
<p>public ref class TomatoSoup : <strong>public</strong> Abstracts::Soup</p>
| 46,552 |
<p>I have this Trigger in Postgresql that I can't just get to work (does nothing). For understanding, there's how I defined it:</p>
<pre><code>CREATE TABLE documents (
...
modification_time timestamp with time zone DEFAULT now()
);
CREATE FUNCTION documents_update_mod_time() RETURNS trigger
AS $$
begin
... | <ol>
<li><p>Use the following code within a trigger function, then watch the 'messages' tab in pgAdmin3 or the output in psql:</p>
<pre><code>RAISE NOTICE 'myplpgsqlval is currently %', myplpgsqlval; -- either this
RAISE EXCEPTION 'failed'; -- or that
</code></pre></li>
<li><p>To see which triggers actually get... | <p>You can use 'raise notice' statements inside your trigger function to debug it. To debug the trigger not being called at all is another story.</p>
<p>If you add a 'raise exception' inside your trigger function, can you still do inserts/updates?</p>
<p>Also, if your update test occurs in the same transaction as yo... | 39,413 |
<p>Is there an easy way to convert a string from csv format into a string[] or list? </p>
<p>I can guarantee that there are no commas in the data.</p>
| <p>String.Split is just not going to cut it, but a Regex.Split may - Try this one:</p>
<pre><code>using System.Text.RegularExpressions;
string[] line;
line = Regex.Split( input, ",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");
</code></pre>
<p>Where 'input' is the csv line. This will handle quoted delimiters, and should ... | <pre><code>CsvString.split(',');
</code></pre>
| 9,906 |
<p>When used like this:</p>
<pre><code>import static com.showboy.Myclass;
public class Anotherclass{}
</code></pre>
<p>what's the difference between <code>import static com.showboy.Myclass</code> and <code>import com.showboy.Myclass</code>?</p>
| <p>See <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/language/static-import.html" rel="noreferrer">Documentation</a></p>
<blockquote>
<p>The static import declaration is
analogous to the normal import
declaration. Where the normal import
declaration imports classes from
packages, allowing them to b... | <p>The <code>static</code> modifier after <code>import</code> is for retrieving/using static fields of a class. One area in which I use <code>import static</code> is for retrieving constants from a class.
We can also apply <code>import static</code> on static methods. Make sure to type <code>import static</code> becaus... | 19,618 |
<p>I have a COM SDK written in C++ and I'd like to create documentation for my product. I understand that most people will probably not use C++ for integration with this COM component, but many will. </p>
<p>Which method is best to describe the API, without losing details that a C++ developer would need to know. </p... | <p>If you mean that you are going to write some code that will be using another class. Yes you will need to import those classes using an import statement.</p>
<p>i.e. </p>
<pre><code>package com.boo;
import com.foo.Bar;
public class StackOverflow {
private Bar myBar;
}
</code></pre>
| <pre><code>
public class Example {
public Example(IConverter converter, IScreenFixer screenFixer) {
}
}
</code></pre>
<p><a href="http://en.wikipedia.org/wiki/Facade_pattern" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Facade_pattern</a> ?</p>
| 27,213 |
<p>I have a List of Foo.</p>
<p>Foo has a string property named Bar.</p>
<p>I'd like to use <strong>LINQ</strong> to get a string[] of <strong>distinct</strong> values for Foo.Bar in List of Foo.</p>
<p>How can I do this?</p>
| <p>I'd go lambdas... wayyy nicer</p>
<pre><code>var bars = Foos.Select(f => f.Bar).Distinct().ToArray();
</code></pre>
<p>works the same as what @lassevk posted.</p>
<p>I'd also add that you might want to keep from converting to an array until the last minute. </p>
<p>LINQ does some optimizations behind the scen... | <p>Shouldn't you be able to do something like:</p>
<pre><code>var strings = (from a in fooList select a.Bar).Distinct();
string[] array = strings.ToArray();
</code></pre>
| 6,169 |
<p>What modes are the best?</p>
<p>And any tips or tricks that make developing java in emacs a bit better.</p>
| <p>For anything else than casual Java editing, many people recommend the <a href="http://jdee.sourceforge.net/" rel="noreferrer">Java Development Environment for Emacs.</a></p>
| <p>Java refactoring for emacs:</p>
<p><a href="http://www.xref-tech.com/xrefactory-java/main.html" rel="nofollow noreferrer">http://www.xref-tech.com/xrefactory-java/main.html</a></p>
| 18,937 |
<p>I have compiled code that erroneously tries to add a number and Double.NaN. I'm wondering if it's throwing an exception that's not getting caught? Does anyone know how that situation is handled?<br>
Thanks.</p>
| <p>Adding a number to NaN gives NaN. It isn't expected to cause an exception. I understand that this conforms to IEEE 754.</p>
| <pre><code>public static void main(String args[])
{
Double d = Double.NaN + 1.0;
System.out.println(d);
}
</code></pre>
<p>prints Double.Nan. Can anyone explain the source implementation?</p>
<pre><code> public static final double POSITIVE_INFINITY = 1.0 / 0.0;
public static final double NEGATIVE_INFINITY ... | 47,378 |
<p>I'm looking for a good open source Windows FTP client library with a public domain or BSD-type license. Something that I have access to the source code and I can use it from C++ for Windows applications in a commercial app.</p>
<p>We have used Wininet for years and it's buggy and horrible. The last straw is the I... | <p>You need Ultimate TCP/IP which is now free!</p>
<p><a href="http://www.codeproject.com/KB/MFC/UltimateTCPIP.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/MFC/UltimateTCPIP.aspx</a></p>
<p>You get FTP. HTTP, SMTP, POP and more.</p>
<p>You won't regret it.</p>
| <p>Checkout <a href="http://filezilla-project.org/download.php?type=server" rel="nofollow noreferrer">filezilla server</a> for windows.</p>
| 32,374 |
<p>I have an interface that defines some methods I would like certain classes to implement.</p>
<pre>
public interface IMyInterface
{
MethodA;
MethodB;
}
</pre>
<p>Additionally I would like all classes implementing this interface to be serializable. If I change the interface definition to implement ISerializa... | <p><strong>There does not seem to be a way to do this</strong>, but I wish there were.</p>
<p>Note two things though:</p>
<ul>
<li><p>The <strong>Serializable attribute can not be inherited from a base class</strong>,
even if the base class is marked as
abstract.</p></li>
<li><p>You <strong>don't technically need the... | <p>You could write a custom FxCop rule and validate check-ins against it.</p>
| 47,008 |
<p>I want to use modal pop-up windows in our web app in Ruby on Rails. Note that I don't want to create a new browser window, but a sub-window inside the existing webpage. We've tried things like TinyBox, but there are issues with returning error information from inside the controller. Any good method or tool that w... | <p>There's also <a href="http://prototype-window.xilinus.com/" rel="nofollow noreferrer">prototype-window</a>.</p>
| <p>I have tried several of the ones mentioned above but after twiking it a bit I found that <a href="http://www.methods.co.nz/popup/popup.html" rel="nofollow noreferrer">http://www.methods.co.nz/popup/popup.html</a> works better for me, the only problem is that you have create an error routing similar to the one Rails ... | 19,217 |
<p>I am wondering if this piece of G-code is valid:</p>
<pre><code>G0 (Some comment (Its G0 command)) Y10 Z-5
</code></pre>
<p>I have tested this on my Chinese CNC machine and it strips out the comment and works flawlessly.</p>
<p>The machine processes this as <code>G0Y10Z-5</code> which seems like the correct appro... | <p>This is not universally valid G-code, and how it is handled depends on the implementation. You can use this style of comment on <em>some</em> machines, but not all.</p>
<p>The way parsing used to be implemented in Marlin (a very common 3D printer firmware), it would work fine unless the comment string included a X,... | <p>It looks like comments inside parentheses are not allowed in numerous parsers (ie. Marlin). This seems to be true for most of the 3D printers. Classical CNC milling machines use parentheses without problems.</p>
<p>It should work on Prusa printers as stated in their <a href="https://reprap.org/wiki/G-code#Comments" ... | 964 |
<p>Many times when I read books related to CSS I see things like this "this will not work on some browser", "this hack will work for that browser". </p>
<p>Where I can all information that I need to know the hacks for working for all browsers? </p>
<p>thanks </p>
| <p>I suggest <a href="http://www.quirksmode.org/" rel="nofollow noreferrer">Quirksmode</a>. Very useful resource for web development.</p>
<p>Here is a link for the CSS page on Quirksmode:</p>
<p><a href="http://www.quirksmode.org/css/contents.html" rel="nofollow noreferrer">http://www.quirksmode.org/css/contents.html... | <p>You could start with:</p>
<p><a href="http://www.quirksmode.org/css/contents.html" rel="nofollow noreferrer">CSS contents and browser compatibility</a></p>
<p>And if you're interested in e-mail clients as well as browsers:</p>
<p><a href="http://www.campaignmonitor.com/css/" rel="nofollow noreferrer">Guide to CSS... | 49,617 |
<p>How can I get the BSSID / MAC (Media Access Control) address of the wireless access point my system is connected to using C#?</p>
<p>Note that I'm interested in the BSSID of the WAP. This is different from the MAC address of the networking portion of the WAP.</p>
| <p>The following needs to be executed programmatically:</p>
<pre><code>netsh wlan show networks mode=Bssid | findstr "BSSID"
</code></pre>
<p>The above shows the access point's wireless MAC addresses which is different from:</p>
<pre><code>arp -a | findstr 192.168.1.254
</code></pre>
<p>This is because the access p... | <p>About getting that result from ARP.EXE programmatically:</p>
<p>The Win32 API to get this is in the <a href="http://msdn.microsoft.com/en-us/library/aa366073(VS.85).aspx" rel="nofollow noreferrer">IP Helper</a> group of functions and it is called <a href="http://msdn.microsoft.com/en-us/library/aa365956(VS.85).aspx... | 22,752 |
<p>I don't want to discuss the merits of this approach, just if it is possible. I believe the answer to be "no". But maybe someone will surprise me!</p>
<p>Imagine you have a core widget class. It has a method <code>calculateHeight()</code>, that returns a height. The height is too big - this result in buttons (say) t... | <p>Perhaps you could use Aspect Oriented Programming to trap calls to that function and return your own version instead?</p>
<p>Spring offers some AOP functionality but there are other libraries that do it as well.</p>
| <p>Well, I keep trying to post suggestions, and then I see that they won't work or that you've already mentioned you tried them.</p>
<p>The best solution I can think of is to subclass WindowDisplayFactory, then in the subclass's createView() method, first call super.createView(), then modify the object returned to com... | 49,969 |
<p>When I defragment my XP machine I notice that there is a block of "Unmovable Files". Is there a file attribute I can use to make my own files unmovable?</p>
<p>Just to clarify, I want a way to programmatically tell Windows that a file that I create should be unmovable. Is this possible, and if so, how can I do it?<... | <p>A lot of system files cannot be moved after the system boots, such as the page file and registry database files.</p>
<p><a href="http://technet.microsoft.com/en-us/sysinternals/bb897426.aspx" rel="noreferrer">This utility</a> runs before Windows boots to defragment those files. I have it set to run at every boot, ... | <p>I assume you're using the defragger that comes with Windows. Some commercial ones like DiskKeeper can move some of these files (usually system files). You can try their trial versions.</p>
| 7,543 |
<p>I have a webservice that I'm calling from a windows forms application (both .NET, both in the same solution), and I'd like my webservice to return a custom object from elsewhere in the project - it's a common object that they both share a reference to, as it's in the third project in my solution. When I call the web... | <p>If you are using svcutil.exe to generate a WCF client proxy, you can use /reference on the command-line to specify the assembly containing the common class. Svcutil should reuse that class definition instead of generating new one in the service proxy namespace.</p>
<p>Also, this will work only if your common class ... | <p>I am not sure but when you compile a .NET web service it will create a DLL file which you can try using that for the local. But when I am building service oriented applications, I create different layers within my solution for e.g Data Access Layer, Logic Layer, Service Layer, UI Layer, Controller Layer, and for exa... | 26,665 |
<p>I get the Total length of columns in constraint is too long. erro from the following</p>
<pre><code>sql] Failed to execute: CREATE TABLE GTW_WORKFLOW_MON ( WORKFLOW_NAME VARCHAR(255) NOT
NULL, WORKFLOW_LOADED NUMERIC(20) NOT NULL, ACTIVITY_NAME VARCHAR(255) NOT NULL, FLAGS
INTEGER NOT NULL, MONITOR_NAME VARCH... | <p>Your primary key constraint is 785 bytes (255+20+255+255). If you increase your database page size to 4K it should work, barely. You should also reconsider if you need your columns to be as wide as you are defining them.</p>
<p>I found a discussion group where an engineer, Radhika Gadde, <a href="http://www.iiug.... | <p>Above answer is complete. But thought of adding some helpful links in case someone runs to this issue again.
Pagesize on Informix depends on Operating System. On my recent experience, I found it's 4K on Win 2008, OSX - Lion and 2K on SUSE EL4.
You can find the page size by using 'onstat -D'.</p>
<p>I wrote <a href=... | 20,748 |
<p>What are some standard practices for managing a medium-large JavaScript application? My concerns are both speed for browser download and ease and maintainability of development.</p>
<p>Our JavaScript code is roughly "namespaced" as:</p>
<pre><code>var Client = {
var1: '',
var2: '',
accounts: {
/* 1... | <p>The approach that I've found works for me is having seperate JS files for each class (just as you would in Java, C# and others). Alternatively you can group your JS into application functional areas if that's easier for you to navigate.</p>
<p>If you put all your JS files into one directory, you can have your serve... | <p>Read the code of other (good) javascript apps and see how they handle things. But I start out with a file per class. But once its ready for production, I would combine the files into one large file and minify.</p>
<p>The only reason, I would not combine the files, is if I didn't need all the files on all the page... | 3,620 |
<p>Is it possible to get a list of all instances with a name in a flash movie using actionscript 2. Like an array containing all named text areas, or all movieClip instances etc. I would like to get this so the designer can add or remove text areas etc. and the actionscript can dynamically find these and get the texts ... | <p>@Stein Gauslaa Strindhaug</p>
<p>This is pretty rough, but it should do the trick!</p>
<pre><code>private function traceAllChildren(rootContainer:DisplayObjectContainer):void {
for(var i=0; i < rootContainer.numChildren; i++) {
var item:* = rootContainer.getChildAt(i);
try {
trac... | <p>It's been a while since I did any AS2 coding but perhaps you could use a combination of MovieClip.getInstanceAtDepth() and this.getNextHighestDepth() to find the highest depth in your movie then trace back through each lower depth until you find a getInstanceAtDepth() that corresponds to the clip you are looking to ... | 38,197 |
<p>Does anybody know if there is an SVN:externals property equivalent in TFS2005?</p>
<p><strong>Definition of an SVN External property</strong></p>
<p>Sometimes it is useful to construct a working copy that is made out of a number of different checkouts. For example, you may want different subdirectories to come fro... | <p>There is no equivalent functionality in TFS 2005.</p>
| <p>No - there is no equivalent functionality inherent in TFS - which in my mind is its premier limitation. However, the feature that Martin mentioned, Workspace Templating, implemented in the Oct '08 release of TFS Power Tools does look like it would accomplish something similar - unfortunately it did not exist when we... | 32,681 |
<p>I'm building a new site for my company, and I'm at the stage where I've created the html mockup of the first page. I'm going to use this as a basis for the rest of the site. I'm thinking of organising my stylesheet better now I've got the design looking consistent cross-browser, but I'm wondering how far to go when ... | <p>Coincidentally, A List Apart had an <a href="http://www.alistapart.com/articles/progressiveenhancementwithcss" rel="noreferrer">article</a> covering this today. They recommend separating out into a few main categories, including some you listed (type, layout, color), but going further to include various tricks to ke... | <p>Don't go too much further than that. If you do have to, try and find a way to merge them before production. The biggest issue is that you begin stacking up HTTP requests. It's not so much an issue for the browser but the amount of requests that need to be made for each page. I would say you are at a good point, m... | 27,401 |
<p>I know this is probably on the Internet somewhere but I can't find the answer here on Stackoverflow so I thought I may boost up the knowledge base here a little.</p>
<p>I'm a newbie to Ruby and Rails but my company is getting pretty invested in it so I'm trying to get to know it in a little more detail.</p>
<p>It'... | <p>you can also set the :dependent option to :delete_all. :delete_all will issue a single SQL statement to delete all child records. because of this using :delete_all may give you better performance.</p>
<pre><code>has_many :memberships, dependent: :delete_all
</code></pre>
| <p>It looks like this plugin might give you what you're looking for if you want the cascading deletes reflected in the actual database structure:</p>
<p><a href="http://www.redhillonrails.org/foreign_key_migrations.html" rel="noreferrer">http://www.redhillonrails.org/foreign_key_migrations.html</a></p>
<p>Format for ... | 42,936 |
<p>I’ve just brought my printer back out after a month and it’s first print created a solid block of resin about 1.5 cm deep and the full width and length of the print bed. What could cause this?</p>
<p>My only thought so far is that the FEP film / vat bed is looking a little cloudy even after cleaning. I wondere... | <p>Is the laser (or whatever light source it uses) visible? The cloudy film sounds like a good candidate for light diffusion and thus solidifying the entire resin, but if there are visible components to the light source it may help narrow it down.</p>
<p>If it uses a projector ("LCD") solutions, it may also be that th... | <p>I had an issue with mine. I had a tiny hole that dripped some resin on the LCD screen. I scrapped it off as best I could but there were some serious printing problems on that side. I got a new LCD screen and replaced that and now print jobs that use to work are not printing solid blocks.
I have no luck trying to re... | 1,535 |
<p>I am trying to adapt an existing code to a 64 bit machine. The main problem is that in one function, the previous coder uses a void* argument that is converted into suitable type in the function itself. A short example:</p>
<pre><code>void function(MESSAGE_ID id, void* param)
{
if(id == FOO) {
int real_... | <p>Use <code>intptr_t</code> and <code>uintptr_t</code>.</p>
<p>To ensure it is defined in a portable way, you can use code like this:</p>
<pre><code>#if defined(__BORLANDC__)
typedef unsigned char uint8_t;
typedef __int64 int64_t;
typedef unsigned long uintptr_t;
#elif defined(_MSC_VER)
typedef unsig... | <p>Since <code>uintptr_t</code> is <a href="https://stackoverflow.com/a/1846648/2436175">not guaranteed to be there in C++/C++11</a>, if this is a one way conversion you can consider <code>uintmax_t</code>, always defined in <a href="http://en.cppreference.com/w/cpp/header/cstdint" rel="nofollow noreferrer"><code><c... | 18,473 |
<p>I seem to recall that there is an HTML tag that escapes absolutely everything inside it except the matching closing tag. Kind of like <a href="http://www.htmlref.com/reference/AppA/tag_plaintext.htm" rel="noreferrer"><code><plaintext></code></a> but not fundamentally broken.</p>
| <p><xmp> is the tag you are looking for:</p>
<pre><code><xmp>some stuff <tags></tags> too</xmp>
</code></pre>
<p>But, since it's depricated, the best you can get is <pre>.</p>
| <p>There is also the XML <a href="http://www.w3schools.com/XML/xml_cdata.asp" rel="nofollow noreferrer">CDATA</a>:</p>
<pre><code><![CDATA[stuff that is <tag>never</tag> parsed]]>
</code></pre>
<p>Whether this works in an HTML document is probably up to the browser. However, it should certainly work... | 48,822 |
<p>I would like to read/write encrypted XML files using LINQ to XML. Does anyone know how to use encryption algorithms built into the .NET Framework to encrypt the Stream used by the XDocument object?</p>
<p>I did try it, but you can't set the CryptoStream to Read/Write access. It only support Read or Write, which cau... | <p>The easiest approach is probably an XDocument.Load(), Linq around, then XDocument.Save(). From a quick test app (go easy on non-disposed resources):</p>
<pre><code>XDocument writeContacts = new XDocument(
new XElement("contacts",
new XElement("contact",
new XElement("name", "Patrick Hines"),
... | <p>[update: kudos to Corbin March, who (in the same time) wrote the same, but in code!]</p>
<p>Most streams <em>are</em> one way. I imagine you'd have to:</p>
<ul>
<li>create a <code>CryptoStream</code> reading from the (file etc)</li>
<li>read the data (for example into <code>XDocument</code>)</li>
<li>do your code ... | 33,545 |
<p>What are the pros/cons for including a date field as a part of a primary key?</p>
| <p>Consider a table of parts inventory -- if you want to store the inventory level at the end of each day then a composite primary key on part_id and date_of_day would be fine. You might choose to make that a unique key and add a synthetic primary key, particularly if you have one or more tables referencing it with a f... | <p>Using the date as part of the primary key could make joins on the table significantly slower. I would prefer a surrogate key and then a unique index on the date if need be.</p>
| 44,314 |
<p>I’m trying to have <a href="https://www.thingiverse.com/thing:2576121" rel="nofollow noreferrer">this bracket</a> printed, but I don’t know what settings I should use.</p>
<p><a href="https://i.stack.imgur.com/yTFRkm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yTFRkm.jpg" alt="Google Home Min... | <p>For such a small item and the small load it will carry, even 50 percent is substantial. Keep in mind that one hundred percent infill is not necessarily stronger. If you need to know why, consider a 'net search for "why not use 100% infill" for more detailed information. The primary foundation for not using 100% infi... | <p>You should use PLA at 215 °C (for better layer adhesion) with 35 percent infill and a shell thickness of 2 mm. Shell thickness is what's crucial here, not necessarily infill. The thicker the shell, the stronger the part. This has a much bigger influence on strength than infill does.</p>
| 754 |
<p>If I have an image like the one attached, what’s the best way to create an accurate depth map of it? I have photoshop CC and 3ds Max, but I don’t know what settings work best with Slic3r. There is a plethora of settings and combinations to choose from in either programs. </p>
<p>Did anyone do this before? If so, ca... | <p>From a single image from this perspective (front view) you cannot map the coin surface in detail. There is reported limited success in estimating the depth of single images, but, this is for images with a clear perspective (e.g. like a picture of a room showing the walls and floor at an angle). In order to map the s... | <p>If you have a depth map (a raster file with the height at each point), OpenSCAD has the ability to read the height map and create a 3D object. That 3D object can then be exported as an .STL file, and sliced normally.</p>
<p>I have done this (maybe 3 years ago), and it worked well.</p>
<p>This <a href="http://aggr... | 1,060 |
<p>I have an application running under Windows XP, and I'm accessing the Processor and Memory performance counters. When I try to run the same code and access them on XP Embedded, the counters don't seem to be present. They are present in the image - I can see them all in perfmon. What's the missing piece here?</p>
| <p>Have you added all the WMI components? As far as I know, you need all the WMI components to access the counters!</p>
<blockquote>
<p>The Performance Counter Windows Management Instrumentation (WMI) Provider component provides a bridge between the performance registry interface and the WMI interface. This componen... | <p>Have you added all the WMI components? As far as I know, you need all the WMI components to access the counters!</p>
<blockquote>
<p>The Performance Counter Windows Management Instrumentation (WMI) Provider component provides a bridge between the performance registry interface and the WMI interface. This componen... | 8,064 |
<p>So I've got a big text file which looks like the following:</p>
<pre><code><option value value='1' >A
<option value value='2' >B
<option value value='3' >C
<option value value='4' >D
</code></pre>
<p>It's several hundred lines long and I really don't want to do it manually. The expression t... | <p>In Notepad++ you don't need to use Regular Expressions for this.</p>
<p>Hold down alt to allow you to select a rectangle of text across multiple rows at once. Select the chunk you want to be rid of, and press delete.</p>
| <p>Very simple just Find:</p>
<pre><code><option value value=.*?>
</code></pre>
<p>and Click Replace</p>
| 36,560 |
<p>How can I customise the Site Actions menu to remove or rename 'standard' menu items? Where are the site actions menu items defined? </p>
| <p>The site actions menu is defined in the Siteaction.xml in Template\layouts\editingMenu under the 12 hive. The following link shows how to manually remove items.</p>
<p><a href="http://blog.avanadeadvisor.com/blogs/marcorizzi/archive/2008/07/23/11483.aspx" rel="nofollow noreferrer">Customize Site Actions Menu</a></... | <p>I have used a control that runs javascript to hide the entire site actions menu for users of a certain privelege level. </p>
<p>That approach may be an option if you need to remove items for particular users. </p>
<p>It is not the worlds classiest approach however.</p>
| 31,056 |
<p>I'd like to use the new <b>CMFCListCtrl</b> features with my <b>CListView</b> class (and, of course, the new CMFCHeaderCtrl inside it). Unfortunately, you can't use <i>Attach()</i> or <i>SubclassWindow()</i> because the SysListView32 window is already associated with a CListView object.</p>
<p>Do I have to override... | <p>I'd inherit from <strong>CFormView</strong> and let the <strong>CMFCListCtrl</strong> occupy the complete dialog of the form view.</p>
| <p>CListView doesn't have a lot of functionality. Like you said in the comment above, just derive your own view class from CView, handle WM_SIZE to resize the CMFCListCtrl and you're good to go.</p>
| 20,791 |
<p>I've seen references to curried functions in several articles and blogs but I can't find a good explanation (or at least one that makes sense!)</p>
| <p>Currying is when you break down a function that takes multiple arguments into a series of functions that each take only one argument. Here's an example in JavaScript:</p>
<pre class="lang-js prettyprint-override"><code>function add (a, b) {
return a + b;
}
add(3, 4); // returns 7
</code></pre>
<p>This is a funct... | <p>There is an example of "Currying in ReasonML". </p>
<pre><code>let run = () => {
Js.log("Curryed function: ");
let sum = (x, y) => x + y;
Printf.printf("sum(2, 3) : %d\n", sum(2, 3));
let per2 = sum(2);
Printf.printf("per2(3) : %d\n", per2(3));
};
</code></pre>
| 5,696 |
<p>I am having real trouble trying to get decent answers to my questions from VPS and dedicated hosting provider's sales people. I have a fairly simple set of requirements - how do I select a server spec / package and be confident that I have got it about right? Are there metrics to use - number of Http requests per mi... | <p>You could add all the data you want here about number of users, etc., and you could even make it more quantitative than you have here - it's an impossible question to answer in this way.</p>
<p>The real answer is: profile, profile, profile. You must measure how the application and its database behave to make any ... | <p>You need to profile the load you are expecting. Then, you should choose a provider that can meet your anticipated demand and provide a path for growth. It's a lot easier growing if your colo provider can handle the growth gracefully. </p>
<p>That is, if your project is the biggest one your provider has ever done or... | 41,614 |
<p>How do I page results in SQL Server 2005?</p>
<p>I tried it in SQL Server 2000, but there was no reliable way to do this. I'm now wondering if SQL Server 2005 has any built in method?</p>
<p>What I mean by paging is, for example, if I list users by their username, I want to be able to only return the first 10 reco... | <p>You can use <code>the Row_Number()</code> function.
Its used as follows:</p>
<pre><code>SELECT Row_Number() OVER(ORDER BY UserName) As RowID, UserFirstName, UserLastName
FROM Users
</code></pre>
<p>From which it will yield a result set with a <code>RowID</code> field which you can use to page between.</p>
<pre><c... | <p>I believe you'd need to perform a separate query to accomplish that unfortionately.</p>
<p>I was able to accomplish this at my previous position using some help from this page:
<a href="https://web.archive.org/web/20210510021915/http://aspnet.4guysfromrolla.com/articles/031506-1.aspx" rel="nofollow noreferrer">Pagi... | 2,498 |
<p>I'm using Strawberry Perl which includes MinGW's GCC, I'm also making use of the GNU debugger GDB and Subversion. How can I have a single development environment that would suit this (other than just UltraEdit, the command shell and IE), and how can I further enhance its features?</p>
| <p>I'd have a good look at <a href="http://www.eclipse.org/" rel="noreferrer">Eclipse</a> if I were you! Then have a look at the <a href="http://www.epic-ide.org/" rel="noreferrer">EPIC</a> IDE Plug-in.</p>
<p>Subversion integrates quite nicely with that IDE via <a href="http://tortoisesvn.tigris.org/" rel="noreferrer... | <p>msvc 6 will do the job quite nicely.</p>
<p>my perl is installed at c:\perl\bin so...</p>
<p>under the custom menu, create a new tool.</p>
<p><br>command <strong>c:\perl\bin\perl.exe</strong>
<br>arguments <strong>-w $(FileName)$(FileExt)</strong>
<br>initial directory <strong>$(FileDir)</strong></p>
<p>check ... | 33,368 |
<p>Every time I need to do something <em>N</em> times inside an algorithm using C# I write this code</p>
<pre><code>for (int i = 0; i < N; i++)
{
...
}
</code></pre>
<p>Studying Ruby I have learned about method <em>times()</em> which can be used with the same semantics like this</p>
<pre><code>N.times do
... | <p>A slightly briefer version of <a href="https://stackoverflow.com/questions/177538/any-chances-to-imitate-times-ruby-method-in-c#177551">cvk's answer</a>:</p>
<pre><code>public static class Extensions
{
public static void Times(this int count, Action action)
{
for (int i=0; i < count; i++)
... | <p>If you are using .NET 3.5 then you can use the extension method Each proposed in this article, and use it to avoid classic loop.</p>
<pre><code>public static class IEnumerableExtensions
{
public static void Each<T>(
this IEnumerable<T> source,
Action<T> action)
{
... | 21,390 |
<p>Using the Facebook API, is there a way of getting a friend's phone/cell number? I'm sure I saw an app a while ago that could sync Facebook with your Mac Address Book, but I haven't found anything in the API documentation that allows you to get a friend's number. Is this possible?</p>
<p>Thanks in advance.</p>
| <p>This is how I do optimistic locking in Django:</p>
<pre><code>updated = Entry.objects.filter(Q(id=e.id) && Q(version=e.version))\
.update(updated_field=new_value, version=e.version+1)
if not updated:
raise ConcurrentModificationException()
</code></pre>
<p>The code listed above can be impleme... | <p>To be safe the database needs to support <a href="http://en.wikipedia.org/wiki/Database_transaction" rel="nofollow noreferrer">transactions</a>. </p>
<p>If the fields is "free-form" e.g. text etc. and you need to allow several users to be able to edit the same fields (you can't have single user ownership to the dat... | 41,399 |
<p>I've got a working SOAP::Lite client. It works against an established server, but so far my development server is sending back nothing except a 404. (Which is odd, because I'm not even seeing a connection on the server end.)</p>
<p>The closest parallel that I'm used to is <code>Net::FTP</code>. </p>
<pre><code>my ... | <p>When I look at a complex bit of SQL Code, this is what I do.</p>
<p>First, if it is an update or delete, I add code (if it isn't there and commented out) to make it a select. Never try an update or delete for the first time without seeing the results in a select first. If it is an update, I make sure the select sho... | <p>Query optimizers can handle a lot, including implementing your sub-query as a join. These days, they can even handle non-correlated sub-queries.</p>
<p>Clarity is more important than performance in most cases, and sub-queries are easier to debug.</p>
<p>BTW: why do you use confusing table aliases?</p>
| 49,658 |
<p><img src="https://i.stack.imgur.com/fY6wJ.jpg" alt="Failed first and second layer of print"></p>
<p>I have only been able to get my prints this far. They just can’t stop skipping pulling material up towards the nozzle which then melts pulls of another random bit. At first I thought it was motor skipping, so I stren... | <p>So, contrary to what people were saying, my problem came from my spring that controlled filament flow. There was too much tension and it caused motor skipping. I did get rid of the overlap with the blue tape, but otherwise I had to clamp down my spring and that fixed the issue.</p>
| <p>I would get rid of the blue tape and go with glass and hairspray. Glass gives you more of a flat surface. You are printing with the aluminum build plate which over time c
an warp. The glass with give you a much flatter and level surface to print om. Blue Tape is actually not a great surface to print on. Hairspray us... | 1,221 |
<p>For some reason, Section 1 works but Section 2 does not. When run in the opposite order (2 before 1), Section 1 (Affiliation) is not run at all. All the data is the same.</p>
<pre><code>//Section 1
UserService.DsUserAttributes dsAffiliation = us_service.GetUserAttributeDropDown(systemId, "Affiliation"... | <p>It would certainly seem that either <code>us_service.GetUserAttributeDropDown(systemId, "Country")</code> or <code>dsCountry.tblDropDownValues</code> is throwing an exception. You'll need to walk through with the debugger to see which and why.</p>
| <p>i guess this heavily depends on the "Country" and "Affiliation" objects...there could potentially happen anything. without any exceptions or something similar it's quite hard to remotely debugg this stuff ^^</p>
| 22,160 |
<p>I use <strong>Delphi</strong> for many years, and although I have now moved on to Visual Studio I still fondly remember numbered bookmarks (<kbd>CTRL</kbd>+<kbd>K</kbd>+<kbd>1</kbd> to set bookmark 1, <kbd>CTRL</kbd>+<kbd>Q</kbd>+<kbd>1</kbd> to goto bookmark 1).</p>
<p>Is there a <strong>Visual Studio</strong> equ... | <p><a href="https://marketplace.visualstudio.com/items?itemName=SergeyM.DPack-16348" rel="nofollow noreferrer">DPack</a> can give you numbered bookmarks in VisualStudio.</p>
| <p>I use:</p>
<ul>
<li><kbd>CTRL</kbd>-<kbd>F2</kbd> toggle bookmark</li>
<li><kbd>F2</kbd> next bookmark</li>
<li><kbd>SHIFT</kbd>-<kbd>F2</kbd> previous bookmark</li>
<li><kbd>CTRL</kbd>-<kbd>SHIFT</kbd>-<kbd>F2</kbd> clear all bookmarks</li>
</ul>
<p>BTW, after using Visual Studio for years I just found about a cou... | 5,975 |
<p>I have a spool of translucent PLA filament that doesn't work well with the filament sensor on my Prusa i3 MK3. The translucency trips up the sensor, making it think the filament ran out. I thought I'd create a filament profile in Slic3r and disable the sensor in the "Start G-code" block that gets inserted at the beg... | <p>Following on from Toon's answer, here is a run down of <a href="https://www.youtube.com/channel/UCb8Rde3uRL1ohROUVg46h1A" rel="nofollow noreferrer">Thomas Sanladerer</a>'s excellent
video: <a href="https://www.youtube.com/watch?v=Mbn1ckR86Z8" rel="nofollow noreferrer">3D printing guides: Calibration and why you mig... | <p>Have you correctly calibrated your steps per mm a.k.a. esteps? Tom made a great video about it:</p>
<p><a href="https://www.youtube.com/watch?v=Mbn1ckR86Z8" rel="nofollow noreferrer">3D printing guides: Calibration and why you might be doing it wrong</a></p>
| 903 |
<p>...or are they the same thing? I notice that each has its own Wikipedia entry: <a href="http://en.wikipedia.org/wiki/Polymorphism_(computer_science)" rel="noreferrer">Polymorphism</a>, <a href="http://en.wikipedia.org/wiki/Multiple_dispatch" rel="noreferrer">Multiple Dispatch</a>, but I'm having trouble seeing how t... | <p>Polymorphism is the facility that allows a language/program to make decisions during runtime on which method to invoke based on the types of the parameters sent to that method. </p>
<p>The number of parameters used by the language/runtime determines the 'type' of polymorphism supported by a language. </p>
<p>Singl... | <p>Multiple Dispatch is a kind of polymorphism. In Java/C#/C++, there is polymorphism through inheritance and overriding, but that is not multiple dispatch, which is based on two or more arguments (not just <code>this</code>, like in Java/C#/C++)</p>
| 15,201 |
<p>We currently have quite a few tags about filament:</p>
<ul>
<li><a href="https://3dprinting.stackexchange.com/questions/tagged/filament" class="post-tag" title="show questions tagged 'filament'" rel="tag">filament</a></li>
<li><a href="https://3dprinting.stackexchange.com/questions/tagged/plastic-filament" ... | <p>All filament used in 3D printing is thermoplastic filament, so plastic-filament and thermoplastic-filament are redundant.</p>
| <p>I see a form of hierarchy that could be used.</p>
<p>Depending on the question a higher level tag could be used or a more specific one for specific problems (or both tags even).</p>
<ul>
<li>Filament
<ul>
<li>Plastic Filament
<ul>
<li>ABS</li>
<li>PLA</li>
</ul></li>
<li>Water Soluble
<ul>
<li>PVA</li>
</ul></l... | 13 |
<p>I am recently in charge of an older app written in <code>C#</code> using <code>asp.net 1.1</code>. </p>
<ol>
<li>Are there any resources to guide me in converting the application to a newer version of of the <code>.NET Framework</code>.
<em>My main pause is that there are ton's of customized <code>DataGrids</code... | <p>I had a similar experience, and the only thing that we had to replace was a third-party control that we were using in the 1.1 app, and the vendor had gone out of business an never released a version that worked with .NET 2.0. We ended up replacing it fairly easily with an AJAX Control Toolkit control.</p>
<p>Othe... | <p>Regarding DataGrids - I don't think you have too much to worry about, DataGrids still work in current versions. It's just that going forward, you should use GridViews.</p>
<p>I am sure there are other things you may want to check into though, deeper framework issues. But I don't know enough about those things to sp... | 6,449 |
<p>I have a program that monitors debug messages and I have tried using a TextBox and appended the messages to it but it doesn't scale very well and slows way down when the number of messages gets large. I then tried a ListBox but the scrolling was snapping to the top when appending new messages. It also doesn't allow... | <p>RichTextBox has an AppendText method that is fast.
And it can handle large text well.<br>
I believe it is the best for what you need.</p>
| <p>set the selectedindex of the listbox to the last element to make it scroll to the bottom</p>
<p>also, limit the number of items in the listbox to something reasonable (delete from the top, keep the later items) so you don't chew up all of your memory</p>
| 31,442 |
<p>Is it possible in C# to have a Struct with a member variable which is a Class type? If so, where does the information get stored, on the Stack, the Heap, or both?</p>
| <p>Yes, you can. The pointer to the class member variable is stored <strike>on the stack</strike> with the rest of the struct's values, and the class instance's data is stored on the heap.</p>
<p>Structs can also contain class definitions as members (inner classes).</p>
<p>Here's some really useless code that at lea... | <p>It's probably not a recommended practice to do so: see <a href="http://msdn.microsoft.com/en-us/library/ms229017(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms229017(VS.85).aspx</a></p>
<blockquote>
<p>Reference types are allocated on the heap, and memory management is
handled... | 9,419 |
<p>Wondering how to open many new windows with Javascript. I have found plenty of places on the internet that show you how to open a new browser window with Javascript, but I want to open a new UNIQUE window. For Example.</p>
<p>I have two links on a page. the user clicks on both links and they are both opened in t... | <pre><code>window.open('page.html','WindowTitle','width=400,height=200')
</code></pre>
| <p>Like the previous poster said, you want <code>window.open(...)</code></p>
<pre><code>var WindowObjectReference = window.open(strUrl, strWindowName [, strWindowFeatures]);
</code></pre>
<p><a href="https://developer.mozilla.org/En/DOM/Window.open" rel="nofollow noreferrer">https://developer.mozilla.org/En/DOM/Window... | 39,929 |
<p>I'm sure most of you are writing lots of automated tests and that you also have run into some common pitfalls when unit testing. </p>
<p>My question is do you follow any rules of conduct for writing tests in order to avoid problems in the future? To be more specific: What are the <strong>properties of good unit tes... | <p>Let me begin by plugging sources - <a href="http://pragprog.com/titles/utj/pragmatic-unit-testing-in-java-with-junit" rel="nofollow noreferrer">Pragmatic Unit Testing in Java with JUnit</a> (There's a version with C#-Nunit too.. but I have this one.. its agnostic for the most part. Recommended.)</p>
<p>Good Tests s... | <p>Often unit tests are based on mock object or mock data.
I like to write three kind of unit tests:</p>
<ul>
<li>"transient" unit tests: they create their own mock objects/data and test their function with it, but destroy everything and leave no trace (like no data in a test database)</li>
<li>"persistent" unit test:... | 8,660 |
<p>I am attempting to insert a copy of a row from one table into another table with the same schema, with the addition of one column (a timestamp) to provide a "history" of the first table in MS Sql Server 2005.</p>
<p>So, my query, without the additional column would be:</p>
<pre><code>"SELECT INTO [WebsiteHistory] ... | <p>Be warned. This works, but it is neither <em>nice</em> nor recommendable:</p>
<pre><code>INSERT
WebsiteHistory
SELECT
*,
GETDATE()
FROM
Website
WHERE
Id = @WebsiteId
</code></pre>
<p>This assumes <code>WebsiteHistory</code> has the same structure as <code>Website</code> (you said it has), plus there is o... | <p>Look at the accepted answer for this question: <a href="https://stackoverflow.com/questions/205950/dynamically-look-up-column-names-for-a-table-while-in-an-sql-query">Dynamically look up column names for a table while in an sql query</a></p>
<p>It fetches the names of all the fields in the table to create a query c... | 35,590 |
<p>Which JavaScript library you recommend to use with Java EE + Struts + iBatis ?
Something like Ext JS, Dojo, frameworks that can be easily integrated with Struts.</p>
| <p>There exists a framework that is supposed to tie in nicely with Java Server/Middleware called <a href="http://oss.metaparadigm.com/jsonrpc/" rel="nofollow noreferrer">JSON-RPC</a></p>
<p>However I have never used it and cannot vouch for it.. Aside from that my favourite framework is <em>cough</em> <a href="http://j... | <p>would suggest you go for Struts 2. It has built in dojo and also has options to plugin other libraries like prototype, jquery, gwt, yui, etc.</p>
<p>Should be really handy, since you're using Struts as your web layer..</p>
| 43,378 |
<p>I have a user control that I load into a <code>MainWindow</code> at runtime. I cannot get a handle on the containing window from the <code>UserControl</code>. </p>
<p>I have tried <code>this.Parent</code>, but it's always null. Does anyone know how to get a handle to the containing window from a user control in WPF... | <p>Try using the following:</p>
<pre><code>Window parentWindow = Window.GetWindow(userControlReference);
</code></pre>
<p>The <code>GetWindow</code> method will walk the VisualTree for you and locate the window that is hosting your control.</p>
<p>You should run this code after the control has loaded (and not in the... | <p>Gold plated edition of the above (I need a generic function which can infer a <code>Window</code> within the context of a <code>MarkupExtension</code>:-</p>
<pre><code>public sealed class MyExtension : MarkupExtension
{
public override object ProvideValue(IServiceProvider serviceProvider) =>
new MyWr... | 38,906 |
<p>I have this line of JavaScript and the behavior I am seeing is that the <code>selectedLi</code> instantly disappears without "sliding up". This is not the behavior that I expected.</p>
<p>What should I be doing so that the <code>selectedLi</code> slides up before it is removed?</p>
<pre><code>selectedLi.slideUp("... | <p>Might be able to fix it by putting the call to remove in a callback arg to slideUp? </p>
<p>e.g </p>
<pre><code>selectedLi.slideUp("normal", function() { $(this).remove(); } );
</code></pre>
| <pre><code>selectedLi.slideUp(200, this.remove);
</code></pre>
| 39,661 |
<p>Let's say I 've added a library foo.so.1.1.1 to a path that is included in <code>/etc/ld.so.conf</code>
When I run ldconfig on the system I get the links foo.so.1.1 and foo.so.1 to foo.so.1.1.1</p>
<p>How can I change the behavior to also get the foo.so link to foo.so.1.1.1?</p>
| <p>ldconfig looks inside all shared objects that it finds, to look for the soname. It then creates a link using that soname as the name of the link. It's conventional (but far from universally done) for the soname to be the name and major version of the library, so your library foo.so.1.1 will have a soname of foo.so.1... | <p>Just make the symlink yourself:</p>
<pre><code>ln -s /usr/lib/foo.so.1.1.1 /usr/lib/foo.so
</code></pre>
<p>Note that for applications to use libraries in this manner, they need to be explicitly linked against the unversioned shared object. IE: this is a mechanism to bypass the dynamic loader's version matching s... | 20,250 |
<p>It seems it is general accepted that exception specifications are not helping as much as one thinks. But I wonder if a specification which only uses std::exception might be a good compromise:</p>
<pre><code>void someFunction()
throw ( std::exception );
</code></pre>
<ul>
<li><p>It documents the fact that this ... | <p>Yes but what do you expect to happen when something that is not derived from std::exception is thrown?</p>
<p>Would you like the application to terminate.<br>
No stack unwinding not destructors being called to tidy up the code, just the application exiting.</p>
<p>The difference between Java and C++ exception spec... | <p>I tipically would do this:</p>
<pre><code>void someFunction() /* throw (std::exception) */;
</code></pre>
<p>The only effect of the throw statement in the function declaration is to modify its signature: a pointer to "void x()" and a pointer to "void x() throw y" are two different types.<br>
In this way you are st... | 44,366 |
<p>I have a web application at work that is similar to a ticket working system. Some users enter new issues. Other workers choose and resolve issues. All of the data is maintained in MS SQL server 2005.</p>
<p>The users working to resolve issues go to a page where they can view open issues. Because up to twenty people... | <p>Two things can help mitigate your problem.</p>
<p>First, after-selection notification that the case has been taken is needed regardless of your ajax update time frame. Even checking every second doesn't mean two people cannot click the same case at what they perceive to be the same time. In such cases, one of the u... | <p>I'm missing to see the issue, specially after you mentioned you are already flagging tickets as in progress/being maintained and have a timestamp/version of the item.</p>
<p>Isn't the following enough:</p>
<ol>
<li>User browses the tickets and sees a list of available tickets i.e. this excludes ones that are in th... | 29,561 |
<p>Along the lines of my previous <a href="https://stackoverflow.com/questions/118096/how-can-i-parse-a-comma-delimited-string-into-a-list-caveat">question</a>, how can i join a list of strings into a string such that values get quoted cleanly. Something like:</p>
<pre><code>['a', 'one "two" three', 'foo, bar', """bot... | <p>Using the <code>csv</code> module you can do that way:</p>
<pre><code>import csv
writer = csv.writer(open("some.csv", "wb"))
writer.writerow(the_list)
</code></pre>
<p>If you need a string just use <code>StringIO</code> instance as a file:</p>
<pre><code>f = StringIO.StringIO()
writer = csv.writer(f)
writer.write... | <p>Here's a slightly simpler alternative.</p>
<pre><code>def quote(s):
if "'" in s or '"' in s or "," in str(s):
return repr(s)
return s
</code></pre>
<p>We only need to quote a value that might have commas or quotes.</p>
<pre><code>>>> x= ['a', 'one "two" three', 'foo, bar', 'both"\'']
>... | 14,417 |
<p>I am looking to print an HTD Timing Belt pulley to be used in a laboratory setting that can get <em>very</em> cold for extended periods of time. By "very cold" I mean adjacent metal chambers get cooled with liquid nitrogen to lower than -200 °C. For the purposes of having a threshold temperature tolerance,... | <p>I found <a href="https://www.curbellplastics.com/Research-Solutions/Technical-Resources/Technical-Resources/Plastic-Materials-in-Cryogenic-Environments#:%7E:text=Plastics%20offer%20a%20number%20of,wear%20surfaces%20without%20external%20lubrication." rel="nofollow noreferrer">this article</a> which seems to suggest P... | <p>You could try PETG. PETG labware works down to -70, and there is a video clip where a PET bottle filled with liquid nitrogen that withstands appreciable pressure.
But for whichever material is used, thermal cycling may be a problem.</p>
| 1,967 |
<p>I was once given this task to do in an RDBMS:</p>
<p>Given tables customer, order, orderlines and product. Everything done with the usual fields and relationships, with a comment memo field on the orderline table.</p>
<p>For one customer retrieve a list of all products that customer has ever ordered with product n... | <p>You definitely should be able to do this exercise without doing the work equivalent to a <code>JOIN</code> in application code, i.e. by fetching all rows from both orderlines and products and iterating through them. You don't have to be an SQL wizard to do that one. <strong><code>JOIN</code> is to SQL what a loop ... | <p>SQL queries return results in the form of a single "flat" table of rows and columns. Reporting requirements are often more complex than this, demanding a "jagged" set of results like your example. There is nothing wrong with "going procedural" to solve such requirements, or using a reporting tool that sits on top ... | 43,747 |
<p>I have a site that enables users to upload images which are then re-sized into 4 different sizes.</p>
<p>I'm moving to a new host and I wondered what makes a good spec for handling this task - or should any server spec be able to handle this task. Should I look at more RAM or a better CPU etc...</p>
<p>Images are ... | <p>You don't say how many you are doing per time period, what you are using (GD? ImageMagick? Something else) or the spec and performance of your current server.</p>
<p>However unless you are doing a lot, both of those servers should be way more than fine.</p>
| <p>IF you're just doing development/testing, and maybe just a soft launch - one if fine. If you expect to go live you're going to need to keep tabs on your server load and how many processes you are spawning, as well as how long your actual resize time is for images.</p>
<p>If you expect to handle serious volume in ... | 41,264 |
<p>Semantically speaking, is there an appropriate place in today's websites (late 2008+) where using the bold <code><b></code> and italic <code><i></code> tags are more useful than the more widely used <code><strong></code> and <code><em></code> tags?</p>
| <p>Never. They are removed in XHTML 2.0 as they are presentational tags. CSS should be used to bold/italicise content.</p>
<p><strong>edit:</strong> If you're looking for a purely presentational tag, that's what the <code>SPAN</code> tag with a class and a little CSS is for.</p>
| <p><strong>When writing websites for mobile devices</strong>. They don't always support the 'latest and greatest' standards, are depreciated but not deleted from all modern browsers, and simply take up less space and bandwidth (though in theory the streams are compressed by either the websites or the wireless browser,... | 8,916 |
<p>I have a website where people can upload documents, and view them later at their convenience. I store the binary info along with the mime type in my db, and later just stream the binary content straight to the browser.</p>
<p>This works for for every file type except Office 2007 files. When I try to view the Office... | <p>Check out <a href="http://blogs.msdn.com/vsofficedeveloper/pages/Excel-2007-Extension-Warning.aspx" rel="nofollow noreferrer">this explanation</a> on VS Office Developer.</p>
<p>It gives a registry hack which your users could choose to apply to rid suppress this warning.</p>
| <p>Are you using content-disposition to set a filename as well? It might be an idea to try</p>
| 14,349 |
<p>I'm making a small php website. I find it useful to prototype or layout the pages in a WYSIWYG web page editor.</p>
<p>I'd like to get suggestions on WYSIWIG web page editors that work well in a php development pipeline. Please share your favorites and describe why you like them.</p>
| <p>The only one I've used is Dreamweaver, can't say I liked it that much as the preview it displays wasn't how it actually looked in a browser.</p>
<p>Nvu is supposed to be quite good though.</p>
<p>I prefer just editing in an IDE then viewing in a real browser.</p>
| <p>TinyMCE comes close as a free lightweight dreamweaver alternative which contructs valid XHTML code. The text engine is running at <a href="http://neteditr.com" rel="nofollow noreferrer">netEditr.com</a>. You can also sketchup some PHP code using the code editor there, just select PHP in the syntax for syntax colorin... | 25,331 |
<p>I saw that __VIEWSTATE field gets rendered even though I have set the EnableViewState="false" at the page level. This field is not rendered if I remove runat="server" tag for the form element. Can somebody please explain this?</p>
| <p>The __VIEWSTATE field is also used to store control state, which is not optional. Furthermore, the information contained in the view state is used to validate the postback, if I'm not mistaken (and validation is enabled, which is the default). So as long as you have the form with runat="server", you'll have a viewst... | <p>Tip:
In Asp.net, if you need to strip the __VIEWSTATE out entirely, override the Page.Render method, render the page into a string, and strip out the __VIEWSTATE text out of it.</p>
| 35,869 |
<p>The .NET standard of prefixing an interface name with an I seems to be becoming widespread and isn't just limited to .NET any more. I have come across a lot of Java code that uses this convention (so it wouldn't surprise me if Java used it before C# did). Also Flex uses it, and so on. The placing of an I at the star... | <p>From the Framework Design Guidelines book:</p>
<blockquote>
<p>Interfaces representing roots of a hierarchy (e.g. IList) should also use nouns or noun phrases. Interfaces representing capabilities should use adjectives and adjective phrases (e.g. IComparable, IFormattable).</p>
</blockquote>
<p>Also, from the annota... | <p>The coding standard for Symbian has interfaces (pure abstract C++ classes) denoted with an M rather than an I.</p>
<p>Otherwise, the only other way I have seen of denoting interfaces is through context.</p>
| 27,446 |
<p>As far as I know Hibernate let's you configure entities and collections to be stored in a second-level cache. </p>
<p>When does Hibernate try to read these cached entities from the second-level cache and when does it hit the DB? Does Hibernate only read from the second-level cache when loading entities by calling <... | <p>2nd level cache contains only entities by their ids, so when retrieving an entity by id (i.e. get, load or resolving a proxy implicitly) a 2nd level cache may be accessed. Any other queries (hal, criteria) will bypass the cache and hit the DB - at least as long as no query cache is used as well.</p>
| <p>(Note: the easiest way to answer that type of questions is to turn show_sql on and see what queries Hib generates.)</p>
<p>Sometimes query only return PKs of the records (e.g. for iteration queries) and then Hib can use the cache.</p>
<p>When retrieving linked objects cache can be used too.</p>
<p>I cannot though... | 28,366 |
<p>I just started using TestDriven.NET to debug on my tests, here is my setup</p>
<p>TestDriven.NET 2.17 <br/>
VS 2008 SP1 <br/>
Windows XP <br/></p>
<p>The problem I run into is on exception it keeps stepping into the .NET Framework source code. I checked Tools > Options > Debugging and "Enable .NET Framework sourc... | <p>Blow away your .NET Framework symbols and change your symbol path to something weird, so the debugger can't step through it</p>
| <p>If you step in only when exception happens the solution is simpler:
Go to Debug -> Exceptions and uncheck all the checkboxes.</p>
| 39,646 |
<p>I'm interested in what you find are the best development references for learning and using jQuery. Books, websites, etc. are all welcome.</p>
| <p><a href="http://www.manning.com/bibeault/" rel="noreferrer">jQuery in Action</a>, FTW</p>
| <p>I've found both the <a href="http://docs.jquery.com/Main_Page" rel="nofollow noreferrer">official documentation</a> and the <a href="http://visualjquery.com/" rel="nofollow noreferrer">VisualJQuery</a> references are very solid.</p>
| 29,891 |
<p>I have a multi-user eclipse (3.4) installation with a shared master configuration area.
Users need to override <code>user.name</code> with their full name and the usual method (adding -Duser.name=... to eclipse.ini) is not suitable since the override must be per-user.
I've tried setting user.name in config.ini (insi... | <p>This <a href="http://www.eclipsezone.com/eclipse/forums/t111686.html" rel="nofollow noreferrer">has been reported before</a> indeed.</p>
<p>Why would you not use use a custom eclipse launcher (a script <code>.cmd</code>), which would modify the eclipse.ini, and then call eclipse.exe ?</p>
<p>That script could retr... | <p>I'm a little bit unclear as to your intention.</p>
<p>The System property <code>user.name</code> is significant as it should reflect the username of who ever invoked the JVM.</p>
<p>If you're doing this for display purposes, and you have control of the plugin that is consuming it, then you should probably use your... | 46,873 |
<p>Is there any easy/general way to clean an XML based data source prior to using it in an XmlReader so that I can gracefully consume XML data that is non-conformant to the hexadecimal character restrictions placed on XML?</p>
<p>Note: </p>
<ul>
<li>The solution needs to handle XML
data sources that use character
enc... | <p>It <strong>may not be perfect</strong> (emphasis added since people missing this disclaimer), but what I've done in that case is below. You can adjust to use with a stream.</p>
<pre><code>/// <summary>
/// Removes control characters and other non-UTF-8 characters
/// </summary>
/// <param name="inStr... | <pre><code>private static String removeNonUtf8CompliantCharacters( final String inString ) {
if (null == inString ) return null;
byte[] byteArr = inString.getBytes();
for ( int i=0; i < byteArr.length; i++ ) {
byte ch= byteArr[i];
// remove any characters outside the valid UTF-8 range as... | 4,109 |
<p>Assume a table with the following columns:</p>
<p><code>pri_id</code>, <code>item_id</code>, <code>comment</code>, <code>date</code></p>
<p>What I want to have is a SQL query that will delete any records, for a specific <code>item_id</code> that are older than a given date, BUT only as long as there are more than ... | <p>Something like this should work for you:</p>
<pre><code>delete
from
MyTable
where
item_id in
(
select
item_id
from
MyTable
group by
item_id
having
count(item_id) > 15
)
and
Date < @tDate
</code></pre>
| <p>Is this what you're looking for?</p>
<pre><code>DELETE
[MyTable]
WHERE
[item_id] = 100 and
(SELECT COUNT(*) FROM [MyTable] WHERE [item_id] = 100) > 15
</code></pre>
<p>I'm a MS SQL Server guy, but i think it should work elsewhere.</p>
| 25,841 |
<p>The MediaElement doesn't support rounded corners (radiusx, radiusy). Should I use a VideoBrush on a Rectangle with rounded corners?</p>
| <p>Yeah - In a way you're both asking and answering the question yourself... But that is one of the two options I can think of. The reasons that might be a problem is that you lose some of the features/control you get from the MediaElement control. Another option is to do this:</p>
<ol>
<li>Add your MediaElement to yo... | <p>Using a rounded rectangle and a VideoBrush doesn't lose you any features/control over using a displayed MediaElement - since the element has to be in the Xaml anyway, you can control it using the usual Play/Pause/Stop methods, except that the playback happens in your rectangle. Using a clip region is a little unwiel... | 5,129 |
<p>I'm looking to log unhandled javascript exceptions. Is there an event that fires when an exception isn't caught? I'm looking to catch the exceptions before they cause javascript errors in the browser, but I'd rather not run my entire application inside of a try/catch. Any help would be appreciated. Thanks!</p>
<p>U... | <p>Try using an onerror handler. <a href="https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror" rel="noreferrer">Docs</a> from MDN. This will allow you to do something when an error is detected, but probably won't let you continue in a graceful way that a try/catch block would. Be aware that a... | <p>Try using an onerror handler. <a href="https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror" rel="noreferrer">Docs</a> from MDN. This will allow you to do something when an error is detected, but probably won't let you continue in a graceful way that a try/catch block would. Be aware that a... | 44,097 |
<p>If I load the nextimg URL manually in the browser, it gives a new picture every time I reload. But this bit of code shows the same image every iteration of <code>draw()</code>.</p>
<p>How can I force myimg not to be cached?</p>
<pre><code><html>
<head>
<script type="text/javascript">
... | <p>The easiest way is to sling an ever-changing querystring onto the end:</p>
<pre><code>var url = 'http://.../?' + escape(new Date())
</code></pre>
<p>Some people prefer using <code>Math.random()</code> for that instead of <code>escape(new Date())</code>. But the correct way is probably to alter the headers the web ... | <p>There are actually <strong>two</strong> caches you need to bypass here: One is the regular HTTP cache, that you can avoid by using the correct HTTP headers on the image. But you've also got to stop the browser from re-using an in-memory copy of the image; if it decides it can do that it will never even get to the ... | 19,970 |
<p>Yes, there is a similar question <a href="https://stackoverflow.com/questions/42554/cant-get-my-event-to-fire">here</a>. However, that question doesn't seem to have code attached to it (though it might have at some point; I see answers alluding to code), and the accepted answer (and other advice) on it aren't gettin... | <p>What do you mean by “cfront tool”? Cfront was the first C++ compiler. But since failure to add exception support, <a href="http://en.wikipedia.org/wiki/Cfront" rel="nofollow noreferrer">it has been discontinued</a>. Modern C++ is way beyond the scope of Cfront.</p>
<blockquote>
<p>For any other modern languages?<... | <p>What do you mean by “cfront tool”? Cfront was the first C++ compiler. But since failure to add exception support, <a href="http://en.wikipedia.org/wiki/Cfront" rel="nofollow noreferrer">it has been discontinued</a>. Modern C++ is way beyond the scope of Cfront.</p>
<blockquote>
<p>For any other modern languages?<... | 39,941 |
<p>(Oracle) I have to return all records from last 12 months. How to do that in PL/SQL?</p>
<p>EDIT: Sorry, I forgot to explain, I do have a column of DATA type</p>
| <p>Doing this in PL/SQL is pretty much synonymous with doing it in SQL.</p>
<pre><code>SELECT *
FROM table
WHERE date_column >= ADD_MONTHS(TRUNC(SYSDATE),-12)
</code></pre>
<p>You might like to fiddle around with the TRUNC statement to get exactly the range you want -- I used TRUNC(SYSDATE) which is the same as... | <pre><code>SELECT *
FROM table
WHERE date_column > SYSDATE - 365
</code></pre>
| 15,404 |
<p>I have a products table that contains a FK for a category, the Categories table is created in a way that each category can have a parent category, example:</p>
<pre><code>Computers
Processors
Intel
Pentium
Core 2 Duo
AMD
Athlon
</code></pre>
<p>I need to make... | <p>The best solution for this is at the database design stage. Your categories table needs to be a <em>Nested Set</em>. The article <a href="http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/" rel="nofollow noreferrer">Managing Hierarchical Data in MySQL</a> is not that MySQL specific (despite the tit... | <p>I have done similar things in the past, first querying for the category ids, then querying for the products "IN" those categories. Getting the categories is the hard bit, and you have a few options:</p>
<ul>
<li>If the level of nesting of categories is known or you can find an upper bound: Build a horrible-looking ... | 24,010 |
<p>I am using 2 extruders. Is it possible to use them both at the same time.
Now I can use one at a time but not both at the same time.
Is there a gcode that supports this action?</p>
| <p>To print with 2 extruders simultaneously you need a firmware that supports that. Luckily, there is a firmware called Sailfish that is able to do that. The feature you are looking for is called <code>Ditto</code> printing.</p>
<p>Sailfish firmware is found <a href="http://www.sailfishfirmware.com" rel="nofollow nore... | <p>If you want a ditto printing is not mandatory to have a specific firmware (or g-code), you only need to add extruder to your end effector and - because of electrical power requirements - add further stepper driver for further stepper motor.
Please note that the maximum footprint of your printed object is less than ... | 912 |
<p>I'm working on a project where there is a lot of external service messaging. A good way to describe it in only a slightly "hyperbolas" way would be an application where the system has to send messages to the Flicker API, the Facebook API, and the Netflix API.</p>
<p>To support disconnected scenarios, logging concer... | <p>There is a design pattern called Null Object. A null object is an object that implements a Interface, so it could be used in an scenario like yours. </p>
<p>The important thing about the Null Object is that DON'T return null in places where that could break the system. </p>
<p>The purpose of the Null Object is to ... | <p>I think you may need to clarify your question.
I'm unclear as to whether you are talking about using test doubles in testing without stubbing or testing expectations (so using them as fakes to meet required interfaces) or whether you are talking about using mocks in a production scenario to fill in for services tha... | 47,941 |
<p>I'd like to do the following and can't find an elegant way:</p>
<ol>
<li>Read an XML template into a <code>System.Xml.XmlDocument</code> </li>
<li>Populate it with data from my UI </li>
<li>Transform it with an <code>XSLT</code> I've written </li>
<li>Apply a <code>CSS</code> Stylesheet </li>
<li>Render it to a... | <p>Quick question. Why do you need an Xml template? If you already know the schema before hand, then simply generate the complete Xml in your code. There shouldn't be a need for loading a template file.</p>
| <p>Check out <a href="http://www.hookedonlinq.com/LINQtoXML5MinuteOverview.ashx" rel="nofollow noreferrer">Linq to XML</a> - it's really good way to write and read Xml based data. Easier than the System.Xml.XmlDocument mechanisms.</p>
<p>Given that you are supplying the XSLT and the CSS, why not build the page in XHTM... | 5,878 |
<p>I've created a new C++ project in Visual Studio 2008. No code has been written yet; Only project settings have been changed.</p>
<p>When I compile the project, I receive the following fatal error:</p>
<blockquote>
<p>fatal error LNK1104: cannot open file 'C:\Program.obj'</p>
</blockquote>
| <p>This particular issue is caused by specifying a dependency to a lib file that had spaces in its path. The path needs to be surrounded by quotes for the project to compile correctly.</p>
<p>On the <strong>Configuration Properties -> Linker -> Input</strong> tab of the project’s properties, there is an <strong>... | <p>I was having the same problem , I have just copied the code to new project and started the build .
Some other error started coming.
error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead</p>
<p>To solve this problem again, I have added my one property in the Project project ... | 16,183 |
<p>In C# is there a shorthand way to write this:</p>
<pre><code>public static bool IsAllowed(int userID)
{
return (userID == Personnel.JohnDoe || userID == Personnel.JaneDoe ...);
}
</code></pre>
<p>Like:</p>
<pre><code>public static bool IsAllowed(int userID)
{
return (userID in Personnel.JohnDoe, Personnel... | <p>How about this?</p>
<pre><code>public static class Extensions
{
public static bool In<T>(this T testValue, params T[] values)
{
return values.Contains(testValue);
}
}
</code></pre>
<p>Usage:</p>
<pre><code>Personnel userId = Personnel.JohnDoe;
if (userId.In(Personnel.JohnDoe, Personnel.... | <p>A nice little trick is to sort of reverse the way you usually use .Contains(), like:-</p>
<pre><code>public static bool IsAllowed(int userID) {
return new int[] { Personnel.JaneDoe, Personnel.JohnDoe }.Contains(userID);
}
</code></pre>
<p>Where you can put as many entries in the array as you like.</p>
<p>If the... | 5,293 |
<p>I am currently aware that ASP.NET 2.0 is out and about and that there are 3.x versions of the .Net Framework.</p>
<p>Is it possible to upgrade my ASP.NET web server to version 3.x of the .Net Framework?</p>
<hr>
<p>I have tried this, however, when selecting which version of the .Net framwork to use in IIS (the AS... | <blockquote>
<p>if I install 3.5 and have IIS setup to use 2.0. I will be able to use 3.5 features?</p>
</blockquote>
<p>Yes, that is correct. You have IIS set to 2.0 for both 2.0 and 3.5 sites, as they both run on the same CLR. 3.5 uses a different compile method than 2.0. This is declared in the web.config for the... | <p>The version you are selecting in IIS is the version of the CLR to use. There are only two versions of the CLR. The .NET Framework 3.5 runs on CLR 2.0</p>
| 2,662 |
<p>i have a smallmoney value in db as 25.00 when i read it to .net decmial it became 25.0000 on the asp.net gridview. where did it tack on the extra two digits?</p>
| <p>This is totally a consequence of formatting -
The actual value in the database is simply 25 in both cases. </p>
| <p>It's simply a case of the default precision and display of the various formats. If you want the data to display in a certain format, it's best to be explicit about that format.</p>
| 39,867 |
<p>I basically want to run all JUnit <strong><em>unit</em></strong> tests in my IntelliJ IDEA project (excluding JUnit integration tests), using the static suite() method of JUnit. Why use the static suite() method? Because I can then use IntelliJ IDEA's JUnit test runner to run all unit tests in my application (and ea... | <p>I've written some code to do most of the work. It works only if your files are on the local disk instead of in a JAR. All you need is one class in the package. You could, for this purpose, create a Locator.java class, just to be able to find the package.</p>
<pre><code>public class ClassEnumerator {
public stat... | <p>Spring has implemented an excellent classpath search function in the PathMatchingResourcePatternResolver. If you use the classpath*: prefix, you can find all the resources, including classes in a given hierarchy, and even filter them if you want. Then you can use the children of AbstractTypeHierarchyTraversingFilt... | 21,309 |
<p>Part of the web application I'm working on is an area displaying messages from management to 1...n users. I have a DataAccess project that contains the LINQ to SQL classes, and a website project that is the UI. My database looks like this:</p>
<p>User -> MessageDetail <- Message <- MessageCategory</p>
<p>Mes... | <p>All your LINQ querys should be in a <strong>business logic class</strong>, no change from older methodologies like ADO.</p>
<p>If you are a <strong>purist</strong> you should always return List(of T) from your methods in the business class, in fact, the datacontext should only be visible to the business classes.
Th... | <p>Regardless of LINQ, I think that mixing presentation code with database-relaed code is not a good idea. I would create a simple DB abstraction layer on top of LINQ queries. In my opinion LINQ is just a convenient tool, that doesn't have a serious impact on traditional application design.</p>
| 6,959 |
<p>Is this a leveling problem? or it's because the bed temperature isn't equal in everywhere? </p>
<p>If it's because of leveling, it means the distance between nozzle and bed in this not-sticked corners are lot and should be decrease? </p>
<p>EDIT: material is ABS, and it's recommended temp is 190-230/80-100. But I ... | <p>You can clearly print but there are also some problems it seems.</p>
<p>To see if you're about okay when it comes to leveling, I recommend to activate the 'skirt' in your slicer soft. Slic3r has it and I think most others too, it just makes the printer do a big one-layer all-around 'perimeter' around what is going ... | <p>For ABS, I use kapton tape, 90 degrees for the bed. You can also try acetone/ABS mixture (can be very thin). If you haven't got acetone, clean or new tape so there is no grease on it.</p>
<p>You can also try a higher nozzle temp for the first layer, sometimes that helps.</p>
<p>You can also try lowerimg the nozzle... | 743 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.