instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>A k-ary necklace of length n is an ordered list of length n whose items are drawn from an alphabet of length k, which is the lexicographically first list in a sort of all lists sharing an ordering under rotation.</p>
<p>Example:
(1 2 3) and (1 3 2) are the necklaces of length 3 from the alphabet {1 2 3}.</p>
<p>Mo... | <p>The FKM algorithm for generating necklaces. PLT Scheme. Not so hot on the performance. It'll take anything as an alphabet and maps the internal numbers onto whatever you provided. Seems to be correct; no guarantees. I was lazy when translating the loops, so you get this weird mix of for loops and escape continuation... | <p>I would do a two step process. First, find each combination of n elements from the alphabet. Then, for each combination, pick the lowest value, and generate all permutations of the remaining items.</p>
<p>Edit: Here is some code. It assumes that the input list is already sorted and that it contains no duplicates... | 32,901 |
<p>So I have run up against this problem a few times:</p>
<p>I have some object in my 3D Scene Graph which is a child of some other object. Lets call them c (Child) and p (Parent).</p>
<p>c's position is defined relative to p. Thus c may have a position (1,0,0) but of course, due to p having some other position, say ... | <p>Converting coordinates in a child's coordinate system to the global coordinate system is one of the things that is needed to actually render the scene graph, so this is a reasonable thing to want.</p>
<p>How you accomplish this will depend on the graphics library you are using. Often each node in the scene graph w... | <p>IMHO, it's more usual for parent objects to know about their children, than the other way around. Which is right for you depends on whether the child needs to know its own position, or whether it's some other external tree traversal algorithm that needs to know it.</p>
<p>Also, I don't think rotation can be handle... | 45,716 |
<p>Currently I have a table that I search upon 4 fields, FirstName, LastName, MiddleName, And AKA's. I currently have a <strong>CONTAINSTABLE</strong> search for the rows and it works. Not well but it works. Now <strong>I want to make the First Name weighted higher and middle name lower.</strong></p>
<p>I found the co... | <p>The key to manipulating the rankings is to use a union. For each column you use a separate select statement. In that statement, add an identifier that shows from which column each row was pulled then. Insert the results into a table variable, then you can manipulate the ranking by sorting on the identifier or mul... | <p>I assume the data returned is joined to other tables within your schema? I would develop your own RANK based on columns from associated data to the full text index. This also provides a guaranteed level of accuracy in the RANK value.</p>
| 39,993 |
<p>I have been looking at <a href="http://jquery.com/demo/thickbox/" rel="nofollow noreferrer">jQUery thickbox</a> for showing modal dialogs with images, it is great. But now I have the need to display a hidden div of content that contains an iFrame in a similar fashion, with a link to open the content. So I'd have s... | <p>Thickbox supports that. See inline content demo at <a href="http://jquery.com/demo/thickbox/" rel="noreferrer">http://jquery.com/demo/thickbox/</a></p>
| <p>I have an extension to jQueryUI's dialog that uses an iFrame as it's base view... it adjusts a few defaults (like adding an OK/Cancel button) but should be a decent base for what you need. I know this is an old question, but just wanting to make people aware of it.</p>
<p><a href="http://plugins.jquery.com/project... | 25,858 |
<p>this wiki page gave a general idea of how to convert a single char to ascii <a href="http://en.wikibooks.org/wiki/Ruby_Programming/ASCII" rel="noreferrer">http://en.wikibooks.org/wiki/Ruby_Programming/ASCII</a></p>
<p>But say if I have a string and I wanted to get each character's ascii from it, what do i need to d... | <p>The <code>c</code> variable already contains the char code!</p>
<pre><code>"string".each_byte do |c|
puts c
end
</code></pre>
<p>yields</p>
<pre><code>115
116
114
105
110
103
</code></pre>
| <pre><code>"a"[0]
</code></pre>
<p>or</p>
<pre><code>?a
</code></pre>
<p>Both would return their ASCII equivalent.</p>
| 17,356 |
<p>I have <code>www.example.com</code> and also <code>store.example.com</code>.
(Yes they are subdomains of the same parent domain)</p>
<p><code>store.example.com</code> is on ASP.NET 1.1</p>
<p><code>www.example.com</code> is on ASP.NET 3.5</p>
<p>I want to know what options are available for sharing 'session' data... | <p>If you want to share sessions between different apps there are a few things you need to do.</p>
<p>First you'll need to run the session state in SQL mode.
At this point I found out that the SQL session state takes the machine key and your _appDomainAppId to generate a key for your app to access it's own session da... | <p>Here is how you would do it in PHP:</p>
<p><a href="http://php.dtbaker.com.au/post/keeping_cookies_across_multiple_sub_domains.html" rel="nofollow noreferrer">http://php.dtbaker.com.au/post/keeping_cookies_across_multiple_sub_domains.html</a></p>
| 30,513 |
<p>We currently send an email notification in plain text or html format. Our environment is C#/.NET/SQL Server.</p>
<p>I'd like to know if anyone recommends a particular solution. I see two ways of doing this:</p>
<ul>
<li>dynamically convert current email to pdf using a third party library and sending the pdf as a... | <p>You can use <a href="http://itextsharp.sourceforge.net/" rel="nofollow noreferrer">iTextSharp</a> to convert your html pages to pdf. Here's an example:</p>
<pre><code>class Program
{
static void Main(string[] args)
{
string html =
@"<html>
<head>
<meta http-equiv=""Content-Type"" c... | <p><a href="http://itextsharp.sourceforge.net/" rel="nofollow noreferrer">iText-Sharp</a><br>
Works very much like the java version, and has both great documentation and multiple books available.</p>
| 47,696 |
<p>Is std::string size() a O(1) operation?</p>
<p>The implementation of STL I'm using is the one built into VC++</p>
| <p>If you're asking if MSVC's implementation of string::size() has constant complexity, then the answer is yes. But <a href="https://stackoverflow.com/questions/256033/is-stdstring-size-a-o1-operation#256081">Don Wakefield</a> mentioned Table 65 in 23.1 of the C++ Standard where it says that the complexity of <code>si... | <pre><code>size_type __CLR_OR_THIS_CALL size() const
{ // return length of sequence
return (_Mysize);
}
</code></pre>
<p>So it eventually might be like this, but you can never be sure.</p>
| 31,949 |
<p>I have just installed the Krypton Toolkit 3.0.6 from component Factory.
I find that in the create new Project Dialog Box , Krypton Form does not show up as an option. I am sure it used to show up ( and I have actually used it in an earlier version of krypton toolkit).But after the new install it does not.</p>
| <p>For the sake of completeness and accuracy , I am posting the actual code for inheriting from a krypton form.</p>
<pre><code>public partial class Form1 : ComponentFactory.Krypton.Toolkit.KryptonForm
</code></pre>
| <p>The "New Krypton Form" used to show up not inside the "new project" dialog, but inside the "new item" dialog. (e.g. right-click on project, Add New Item)</p>
<p>But I don't see it there either. Phil may have removed this from the installer.</p>
<p>In any case, just add a regular Form, then make it derive from Kryp... | 25,105 |
<p>Is it possible to set the size of a checkbox using CSS or HTML across browsers? </p>
<p><code>width</code> and <code>size</code> work in IE6+, but not with Firefox, where the checkbox stays 16x16 even if I set a smaller size.</p>
| <p>It's a little ugly (due to the scaling up), but it works on most newer browsers:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>input[type=checkbox]
{
/* Double-si... | <p>You can change the height and width in the code below</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.checkmark {
position: absolute;
top: 0;
left: 0;
h... | 39,485 |
<p>Running <code>rake db:migrate</code> followed by <code>rake test:units</code> yields the following:</p>
<pre><code>rake test:functionals
(in /projects/my_project)
rake aborted!
SQLite3::SQLException: index unique_schema_migrations already exists: CREATE UNIQUE INDEX "unique_schema_migrations" ON "ts_schema_migratio... | <p>In SQLite, index name uniqueness is enforced at the database level. In MySQL, uniqueness is enforced only at the table level. That's why your migrations work in the latter and not the former: you have two indexes with the same name on different tables.</p>
<p>Rename the index, or find and rename the other <code>u... | <p>Try to search if your schema.rb file does not contain other declarations that create an index with the same name: <code>unique_schema_migrations</code></p>
| 24,658 |
<p>I'm writing a utility to export evernote notes into Outlook on a schedule. The Outlook API's need plain text, and Evernote outputs a XHTML doc version of the plain text note. What I need is to strip out all the Tags and unescape the source XHTML doc embedded in the Evernote export file.</p>
<p>Basically I need to t... | <p>I would use a regular expression to strip out all the HTML tags, this one is pretty basic, I am sure if you may be able to tweak it if it doesn't work as you exactly want.</p>
<p><code>Regex.Replace("<div>your html in here</div>",@"<(.|\n)*?>",string.Empty)</code>;</p>
| <p>As far as I know there isn't anything to do that specific job but you might want to look at using XSLT or walking through an IXPathNavigable.</p>
| 29,996 |
<p>When creating a new object that is mapped to one of my SQL Server tables, LINQ inserts a new record into the table when I call SubmitChanges. I want to prevent this, but still need my new object.</p>
<p>I know about the custom methods, but is there anyway to disable this behaviour so that it just updates existing ... | <p>You could always create a stored procedure which doesn't do anything and allocate that to the insert role - it's a real hack but it'll get the job done!</p>
<p>I would suggest that perhaps the fact that this issue is coming up indicates that there's something wrong with the approach you're taking in referencing thi... | <p>Can you not prevent it at the server side? Connect as a role which doesn't have insert access. Sooner or later, that's going to be the most bulletproof way of preventing inserts, I suspect.</p>
| 24,504 |
<p>The <code>PropertyGrid</code> control is very useful for editing objects at run-time. I'm using it as follows:</p>
<pre><code>Form form = new Form();
form.Parent = this;
form.Text = "Editing MyMemberVariable";
PropertyGrid p = new PropertyGrid();
p.Parent = form;
p.Dock = DockStyle.Fill;
p.SelectedObject = _MyMemb... | <p>This isn't very elegant, but it solved the issue I was having when someone updates / changes the order of a collection from a property grid:</p>
<pre><code>propertyGrid1.PropertyValueChanged += (o, args) => PropertyGridValueChanged();
propertyGrid1.LostFocus += (sender, args) => PropertyGridValueChanged();
</... | <p>I did some research and even reproduced the problem, however the solution I found won't help you, but I'm hoping the information may help another person help you.</p>
<p>Here goes</p>
<p>The problem is easily reproducable by creating a new windows form project, adding a property grid and a listbox to the form and ... | 35,777 |
<p>I was just working on fixing up exception handling in a .NET 2.0 app, and I stumbled onto some weird issue with <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.application.threadexception.aspx" rel="nofollow noreferrer">Application.ThreadException</a>.</p>
<p>What I want is to be able to catch... | <p>This question is more usefully phrased and answered here: </p>
<p><a href="https://stackoverflow.com/questions/347502/why-does-the-inner-exception-reach-the-threadexception-handler-and-not-the-actual">Why does the inner exception reach the ThreadException handler and not the actual thrown exception?</a></p>
| <p>According to the MSDN documentation:</p>
<p><em>When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.</em> </p>
<pre><code> Public Overridable Function GetBaseException() As Exception
Dim innerException As Exception = Me.InnerException
... | 8,653 |
<p>I want to link to bookmark on a page (mysite.com/mypage.htm#bookmark) AND visually highlight the item that was bookmarked (maybe having a red border). Naturally, there would be multiple items bookmarked. So that if someone clicked on #bookmark2 then <em>that</em> other area would be highlighted). </p>
<p>I can s... | <p>In your css you need to define </p>
<pre class="lang-css prettyprint-override"><code>a.highlight {border:1px solid red;}
</code></pre>
<p>or something similar</p>
<p>Then using jQuery, </p>
<pre><code>$(document).ready ( function () { //Work as soon as the DOM is ready for parsing
var id = location.hash.sub... | <p>I guess if you could store this information with JavaScript and cookies for the functionality of remembering the bookmarks and even add a splash of Ajax if you wanted to interact with a database.</p>
<p>CSS would only be able to do styling. You would have to give the bookmarked anchor a class found in your CSS file... | 7,788 |
<p>When I try this with a generic class where this.value is T:</p>
<pre><code>if (this.value.GetType() == typeof(int))
{
((int)this.value)++;
}
else
{
throw new InvalidOperationException
("T must be an int to perform this operation");
}
</code></pre>
<p>I get a compile-time error: "Cannot convert ... | <p>Unfortunately, it is very hard to convince the compiler about specific T implementations. One (nasty) approach is to cast to object in the middle (note this will box and unbox value-types):</p>
<pre><code>int i = (int)(object)this.value;
i++;
this.value = (T)(object)i;
</code></pre>
<p>Ugly but it works. In .NET 3.5... | <p>I don't think I understand what you are after. If you are requiring that something be a specific type, then you probably shouldn't use Generics. You could, it just seems silly. This will do what you are asking, but I don't recommend it.</p>
<pre><code>namespace GenericsOne
{
using System;
class Program
{
... | 20,798 |
<p>This</p>
<pre><code>SELECT * FROM SOME_TABLE WHERE SOME_FIELD LIKE '%some_value%';
</code></pre>
<p>is slower than this</p>
<pre><code>SELECT * FROM SOME_TABLE WHERE SOME_FIELD = 'some_value';
</code></pre>
<p>but what about this?</p>
<pre><code>SELECT * FROM SOME_TABLE WHERE SOME_FIELD LIKE 'some_value';
</cod... | <p>There is a clear difference when you use bind variables, which you should be using in Oracle for anything other than data warehousing or other bulk data operations.</p>
<p>Take the case of:</p>
<pre><code>SELECT * FROM SOME_TABLE WHERE SOME_FIELD LIKE :b1
</code></pre>
<p>Oracle cannot know that the value of :b1 ... | <p>1) % and = are intended to be used in different scenarios.
Even though we can search with exact value in like clause and get the desired result, one should still be using = in all such scenarios. Therefore whenever we have exact value to be searched we always should be using =.</p>
<p>2) performance of like and = ... | 16,274 |
<p>I can't seem to set a ContentTemplate for a ComboBoxItem. There reason I'm trying to do this is I want to have 2 appearances for my data in the combo box. When the combo box is open (menu is down) I want a text box (with the name of the image) and an image control below it. When I select the item I want the combo bo... | <p>The ComboBox.ItemTemplate is just a convenient way to set the ComboBoxItem.ContentTemplate. So your code above basically tries to set the ComboBoxItem.ContentTemplate twice.</p>
<p>As Jobi pointed out, you could try to use just a custom Style. You can safely exclude the ContentPresenter, if you always know the type... | <p>You can achieve this with just ItemsContainerStyle. Add your TextBlock and Image instead of the ContentPresenter. Add the VisualStateManager and toggle the Visibility of the Image control based on the Selected State of the VSM. </p>
| 34,154 |
<p>Are there ways except CAPTCHAs for web apps like <a href="http://pastie.org" rel="nofollow noreferrer">pastie.org</a> or <a href="http://p.ramaze.net" rel="nofollow noreferrer">p.ramaze.net</a>? CAPTCHAs take too long for a small paste for my taste.</p>
| <p>You could try <a href="http://haacked.com/archive/2007/09/11/honeypot-captcha.aspx" rel="nofollow noreferrer">Honeypot CAPTCHAs</a>. Essentially, you hide some form fields using CSS. Your users will never fill out the fields because they won't see them, but spam bots who don't support CSS will fill them out. On the ... | <p>What about something like Phil Haacks <a href="http://haacked.com/archive/2007/09/11/honeypot-captcha.aspx" rel="nofollow noreferrer">invisible captcha</a>?</p>
| 27,329 |
<p>I've read a lot about the pros and cons of sizing with either relative or absolute font sizes. Fixed sizes don't zoom in IE6 but that's not much of an issue these days. Accessibility is important, but I assume that all good accessibility software is built to deal with these issues?</p>
<p>I guess it mainly comes do... | <p>According to <a href="http://developer.yahoo.com/yui/fonts/" rel="nofollow noreferrer">YUI Font CSS</a>, </p>
<blockquote>
<p>Always use percentages as the units
because they render more consistently
than ems, and because they allow
user-initiated resizing (unlike
pixels).</p>
</blockquote>
<p>Relative f... | <p>The only big reason valid is that a lot of people is still using IE6. Just this.
Probably could be a good thing, at the end of 2008, to give no more attention at IE6. But is difficult to ignore IE6. I work as web designer/devolper for a big company in Italy, and many of ours employes or clients, in their work compu... | 37,424 |
<h1> 1st phase</h1>
<p>I have a problem shutting down my running JBoss instance under Eclipse since I changed
the JNDI port of JBoss. Of course I can shut it down from the console view but not with
the stop button (it still searches JNDI port at the default 1099 port). I'm looking
forward to any solutions. Than... | <p>OK, what you have to do is File->New->Other->Server, and set up your JBoss server there. It will then appear in Preferences->JBossTools->Servers.</p>
<p>Convoluted.</p>
| <p>In MyEclipse server configuration, you find the field "Optional Shutdown Argument", which is filled with the default value </p>
<pre><code>--shutdown
</code></pre>
<p>Change it to </p>
<pre><code>-s jnp://localhost:11099 --shutdown
</code></pre>
<p>Edited:</p>
<p>Sorry, this answer is related to MyEclipse. Howe... | 20,902 |
<p>I'm currently working on project with Haskell, and have found myself some trouble. I'm supposed to read and insert into a list each line in a "dictionary.txt" file, but I can't seem to do so. I've got this code:</p>
<pre><code>main = do
let list = []
loadNums "dictionary.txt" list
loadNums location list = ... | <p>In the line where the error happens, Haskell is expecting "IO a", but you are giving it a []. Simplifying things a lot, on a do block on the IO monad, every line is either:</p>
<ul>
<li>Something which returns a value of the "IO a" type; the value of the "a" type within it is discarded (so the "a" is often "()")</l... | <p>Unless this is for homework or something, there's no reason to use so much effort. Reuse is lazy!</p>
<pre><code>getLines = liftM lines . readFile
main = do
list <- getLines "dictionary.txt"
mapM_ putStrLn list
</code></pre>
<p>But as you seem to still be learning Haskell, it is important for you to u... | 26,521 |
<p>Yesterday, I was reading 3dprinting.meta and read a suggestion that (which I rephrase as) we should ask questions for the purpose of bringing answers inside our tent.</p>
<p>I spent some time thinking about questions I have been asked by friends who purchased FDM machines and were starting to undertake their own de... | <p><strong>TL;DR</strong> The <em>answer</em> that this question was looking for can be covered in 4 or 5 basic points, without much ambiguity. The question is therefore not fundamentally <em>too broad</em>, but could maybe be made a bit more specific.</p>
<p>Too broad seems a bit of a mis-assessment, but I think it's... | <p>The "Have you googled this" comment was a little like the comments that we used to see, and which, of late, we fortunately haven't seen much of (please see <a href="https://3dprinting.meta.stackexchange.com/questions/134/post-closing-issues/263#263">my answer</a> to <a href="https://3dprinting.meta.stackexchange.com... | 56 |
<p>How can I use a database and PHP sessions to store a user's shopping cart? I am using CodeIgniter, if that helps.</p>
<p>Example code would also be nice.</p>
| <p>I would recommend that you look at <a href="http://codeigniter.com/user_guide/libraries/sessions.html" rel="nofollow noreferrer">the CodeIgnitor Session Class</a>.</p>
<p>Additionally, you could look at <a href="http://shiflett.org/articles/storing-sessions-in-a-database" rel="nofollow noreferrer">Chris Shiflett's ... | <p>how about this ;
- when guest add one item product in the cart</p>
<pre><code> function addCartItem($item_id, $qty)
{
$basket = $this->session->userdata('basket');
if(!$basket)
{
$this->session->set_userdata('basket', array($item_id => $qty));
}
else
{
## get ... | 40,831 |
<p>I am working with web Dynpro java..
I have created a stateless session bean wherein I have created business methods for inserting and retrieving records from my dictionary table.
My table has two fields of <code>java.sql.Date</code> type
The web service that i have created is working fine for <code>insertRecords()... | <p>Did you try getTimestamp() instead of getDate()? What is the error you get when you attempt to get it as a date?</p>
| <p>I use another approach.</p>
<p>I create in addition to the bean, also the services, where I create functions that contains the query to manipulate the DB tables.</p>
<p>Now, in the Java Wb Dynpro I put something like this:</p>
<pre><code>try {
ctx = new InitialContext();
Object o = ctx
... | 18,310 |
<p>I need to pass a regex substitution as a variable:</p>
<pre><code>sub proc {
my $pattern = shift;
my $txt = "foo baz";
$txt =~ $pattern;
}
my $pattern = 's/foo/bar/';
proc($pattern);
</code></pre>
<p>This, of course, doesn't work. I tried eval'ing the substitution:</p>
<pre><code>eval("$... | <blockquote>
<p>I need to pass a regex substitution as a variable</p>
</blockquote>
<p>Do you? Why not pass a code reference? Example:</p>
<pre><code>sub modify
{
my($text, $code) = @_;
$code->($text);
return $text;
}
my $new_text = modify('foo baz', sub { $_[0] =~ s/foo/bar/ });
</code></pre>
<p>In ge... | <p>You're right - you were very close:</p>
<pre><code>eval('$txt =~ ' . "$pattern;");
</code></pre>
| 15,217 |
<p>I'd like to be able to toggle easily between two values for "maximum number of parallel project builds" in Visual Studio 2008 (in Tools->Options->Projects and Solutions->Build and Run). (When I'm planning on doing concurrent work I'd like to reduce it from 4 to 3.) I'm not too well versed in writing macros for the I... | <p>It appears to be impossible, according to the MSDN page for <em><a href="http://msdn.microsoft.com/en-us/library/ms165642.aspx" rel="nofollow noreferrer">Determining Names of Property Items in Tools Options Pages </a></em></p>
<p>If it <em>was</em> possible, it would have been something like this:</p>
<pre><code>D... | <p>This appears to now be possible in VS2010. I'm no VB programmer, but here's what I got to work:</p>
<pre><code>Sub EditConcurrentBuilds()
Dim p As EnvDTE.Properties = DTE.Properties("Environment", "ProjectsAndSolution")
Dim item As EnvDTE.Property = p.Item("ConcurrentBuilds")
Dim text As String = Input... | 20,406 |
<p>Do you know any documentation about the rules of using update sites? I have managed the last 2 and a half years the update site of our company, and these are the problems I have to address:</p>
<ul>
<li>Not all projects use the same eclipse version. We had projects that used eclipse 2.1 (WSAD), eclipse 3.0 (RAD 6),... | <p>I suggest to put everything on one web server and deploy the packages for each version of Eclipse to a different URL:</p>
<p><a href="http://your.server/eclipse-3.3/site.xml" rel="nofollow noreferrer">http://your.server/eclipse-3.3/site.xml</a><br>
<a href="http://your.server/eclipse-3.4/site.xml" rel="nofollow nor... | <p>You should probably be using features and categories, segmented by eclipse version.</p>
<pre><code>|
+-WSAD-2-1 Category
| |
| +- Checkstyle 3.1 Feature
| |
| `- Team Checkstyle configuration for Checkstyle 3.1
|
`-Eclipse-3-4 Category
|
+- Checkstyle 4.4 Feature
|
`- Tema Checkstyle conf... | 42,123 |
<p>I'm using ASP.NET Membership and noticed there isn't a method in the <a href="http://msdn.microsoft.com/en-us/library/system.web.security.roles_members.aspx" rel="nofollow noreferrer">Roles class</a> to <em>modify</em> a role (its name for instance), only to create and delete them.</p>
<p>Is it possible or it's not... | <p>There is no direct way to change a role name in the Membership provider.</p>
<p>I would get the list of users that are in the role you want to rename, then remove them from the list, delete the role, create the role with the new name and then Add the users found earlier to the role with the new name.</p>
<pre><cod... | <p>Renaming a Role in the ASP.NET Membership model programatically would be a Bad Thing™, because the Role names are used in the configuration file to define permissions. If there were a programmatic way to change the Role name (which persisted the change to the database), you would immediately break any Role-bas... | 35,682 |
<p>I am coming from the SQL server world where we had uniqueidentifier. Is there an equivalent in oracle? This column will be frequently queried so performance is the key.</p>
<p>I am generating the GUID in .Net and will be passing it to Oracle. For a couple reasons it cannot be generated by oracle so I cannot use seq... | <pre><code>CREATE table test (testguid RAW(16) default SYS_GUID() )
</code></pre>
<p><a href="http://preferisco.blogspot.com/2007/02/unique-ids-for-multi-master-replication.html" rel="noreferrer">This blog</a> studied the relative performance.</p>
| <p>The general practice using Oracle is to create an artificial key. This is a column defined as a number. It is populated via a sequence. It is indexed/constrained via a primary key definition.</p>
| 18,578 |
<p>I've often heard criticism of the lack of thread safety in the Swing libraries. Yet, I am not sure as to what I would be doing in my own code with could cause issues:</p>
<p>In what situations does the fact Swing is not thread safe come into play ?</p>
<p>What should I actively avoid doing ?</p>
| <ol>
<li><p>Never do long running tasks in response to a button, event, etc as these are on the event thread. If you block the event thread, the ENTIRE GUI will be completely unresponsive resulting in REALLY pissed off users. This is why Swing seems slow and crusty. </p></li>
<li><p>Use Threads, Executors, and SwingWor... | <p>Here's a pattern for makng swing thread-freindly.</p>
<p>Sublass Action (MyAction) and make it's doAction threaded.
Make the constructor take a String NAME.</p>
<p>Give it an abstract actionImpl() method.</p>
<p>Let it look like.. <strong>(pseudocode warning!)</strong></p>
<pre><code>doAction(){
new Thread(){
... | 22,033 |
<p>When accessing an object in a DataTable retrieved from a database, are there any reasons not to cast the object into your desired type, or are there reasons to use convert? I know the rule is cast when we know what data type we're working with, and convert when attempting to change the data type to something it isn'... | <p>I would always cast, for the reasons you state. The gotchas I'm aware of that you need to handle are:</p>
<ol>
<li><p>You obviously need to be able to handle DBNulls (e.g. by testing with Convert.IsDBNull)</p></li>
<li><p>In the case of ExecuteScalar I believe you need to check for null as well as DBNull.</p></li>... | <p>Both <code>CAST</code> and <code>CONVERT</code> are used to explicitly to convert an expression of one data type to another. However, with <code>CONVERT</code> you can specify the <strong>format</strong> style as well.</p>
<p>Syntax for CAST:</p>
<pre><code>CAST ( expression AS data_type [ (length ) ])
</code></pr... | 21,992 |
<p>What's the easiest and most robust way of altering the .NET DateTimePicker control, to allow users to enter <code>null</code> values?</p>
| <p>You don't need to modify it to do this. </p>
<p>The <code>DateTimePicker</code> in .net actually has a checkbox built-in. </p>
<p>Set the <code>ShowCheckBox</code> property to <code>true</code>.</p>
<p>Then you can use the <code>Checked</code> property to see if the user has entered a value. </p>
<p><a href="htt... | <p>I posted my long way around solution, which has some findings in the code comments about the peculiar issues with this control:</p>
<p><a href="http://social.msdn.microsoft.com/forums/en-US/winforms/thread/f1f8cc0a-0ac9-4a3e-9ba4-9af495e8ff58/" rel="nofollow">DateTime Picker null value</a></p>
| 36,073 |
<p>I have X interfaces to Y computers that communicate over a public network (Think colleges and libraries). I am researching common industry standard techniques for encrypting the data that goes between us.</p>
<p>I know there is SSL, but I'd rather find a simple technique that is a "purchase once, install infinite" ... | <p>There are quite a few resources on the web about that. Basically it turns around the KeyPairGenerator class.</p>
<p>See <a href="http://www.informit.com/articles/article.aspx?p=170967&seqNum=4" rel="noreferrer">http://www.informit.com/articles/article.aspx?p=170967&seqNum=4</a> for an example program.</p>
| <p>Normally, you use public key encryption to encrypt a symmetric key, in part because public key encryption is very slow. Typically, you'd send the recipient the following, so that they can decrypt your message:</p>
<ol>
<li>The symmetric key, encrypted with the recipient's public key.</li>
<li>Parameters for the alg... | 43,955 |
<p>I have a HTML table issue that I'd like to understand better.</p>
<p>Let's assume that I have a 3 row HTML</p>
<pre><code><table>
<tr>
<td style="text-align:right;">A1</td>
<td>A2</td>
</tr>
<tr>
<td style="text-align:right;">... | <p>If your question ends up with 2 tables, with the original like this:</p>
<pre><code><table>
<tr>
<td style="text-align:right;">A1</td>
<td>A2</td>
</tr>
<tr>
<td style="text-align:right;">B1</td>
<td>B2</td>
</tr>
</table&g... | <p>I think I know what you mean, is the second part of your question based on:</p>
<pre><code><table>
<tr>
<td style="text-align:right;">A1</td>
<td>A2</td>
</tr>
<tr>
<td style="text-align:right;">B1</td>
<td>B2</td>
</tr>
<... | 47,446 |
<p>I'm currently working on a project that requires encrypted data be passed between WCF hosts. As I understand it there are only 2 ways to ensure that data passed over WCF is secure. </p>
<ol>
<li>Using Certificates</li>
<li>Using a Domain (or having the same username and password on every machine on the network)</li... | <p>Encryption requires a key. Keys are usually implemented as certificates. If you own both sides of the communication, you can create your own certificate for free without having to go buy one from a trusted root authority.</p>
| <p>If you are using a http endpoint, you can use a secure transport such as https.</p>
| 7,345 |
<p>Do you refactor your SQL first? Your architecture? or your code base?
Do you change languages? Do you throw everything away and start from scratch? [Not refactoring]</p>
| <p>I'm adding unit testing to a large, legacy spaghetti codebase. </p>
<p>My approach is, when asked to solve a problem, I try to create a new wrapper around the part of the code-base which is relevant to my current task. This new wrapper is developed using TTD (writing the test first). Some of the time calling <em>in... | <p>This really depends on the state of the codebase... are there massive classes? one class with mega-methods? Are the classes tightly coupled? is configuration a burden?</p>
<p>Considering this, I suggest reading <a href="https://rads.stackoverflow.com/amzn/click/com/0131177052" rel="nofollow noreferrer" rel="nofollo... | 9,187 |
<p>I'm working on a toolkit (sort of a live-CD Lisp-in-a-Box) for people new to Common Lisp, and I want to make sure it is broadly satisfying. What is attractive to you about Lisp? What do/did/would you need to get you started and keep you interested?</p>
<p>What I have so far: SBCL 10.22, Emacs 22.3, SLIME, and LT... | <p>My suggestion is to include an HTTP server like <a href="http://www.weitz.de/hunchentoot/" rel="nofollow noreferrer">Hunchentoot</a> and a popular web framework. I suspect that most people that want to learn Lisp these days do so because of reading Paul Graham, and wanting to mimic his success at building Viaweb, so... | <p>I think the idea of including tutorials is an excellent one.</p>
<p>In addition to the ones already stated, there is both the easiest book for newbies on lisp (A Gentle Introduction to Symbolic Computation) and several <strong>excellent</strong> websites hiding out there on the web that people should know about. He... | 47,062 |
<p>I've been somewhat spoiled using Eclipse and java. I started using vim to do C coding in a linux environment, is there a way to have vim automatically do the proper spacing for blocks? </p>
<p>So after typing a { the next line will have 2 spaces indented in, and a return on that line will keep it at the same inde... | <p>These two commands should do it:</p>
<pre><code>:set autoindent
:set cindent
</code></pre>
<p>For bonus points put them in a file named .vimrc located in your home directory on linux</p>
| <p>Try:</p>
<p>set sw=2</p>
<p>set ts=2</p>
<p>set smartindent</p>
| 12,321 |
<p>If I have a stl file is there a good way to estimate how long it will take to print on a given printer? I know there are a lot of things that go into print speed, such as the speed of the printer, the size of the print, etc. I was wondering if anyone knows of perhaps an application that you could enter your printer'... | <p>All commonly used slicers (e.g., Cura, Slic3r, Simplify3D,...) give an estimation of the print time.</p>
<p><a href="https://i.stack.imgur.com/cPaM6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cPaM6.png" alt="Example of print time estimation in Cura"></a></p>
<p><a href="https://i.stack.imgu... | <p>I use Repetier software with the Cura slicer and the print time estimate tends to be about 10 % longer than the actual print.</p>
| 889 |
<p>I need some information about localization. I am using .net 2.0 with C# 2.0 which takes care of most of the localization related issues. However, I need to manually draw the alphabets corresponding to the current culture on the screen in one particular screen.</p>
<p>This would be similar to the Contacts screen in ... | <p>In native code there's LOCALE_SSCRIPTS for GetLocaleInfoEx() (Vista & above) that shows you what scripts are expected for a locale. There isn't a similar concept for .Net at this time.</p>
| <p>Chinese has thousands of characters, so it might not be feasible to show all the characters in their character set. There's no native concept of 'alphabet' in Chinese, and I don't think Chinese has a syllabary like Japanese does. </p>
<p>Pinyin (Chinese written in roman alphabet) can be used to represent the Chines... | 31,479 |
<p>How do I get the battery status on an iPhone?</p>
| <pre><code>UIDevice *myDevice = [UIDevice currentDevice];
[myDevice setBatteryMonitoringEnabled:YES];
float batLeft = [myDevice batteryLevel];
int i=[myDevice batteryState];
int batinfo=(batLeft*100);
NSLog(@"Battry Level is :%d and Battery Status is :%d",batinfo,i);
switch (i)
{
case UIDeviceBatteryStateUnplugg... | <p>Now that the 3.1 SDK is released look for the Getting the Device Battery State section in UIDevice's documentation. It is abunch of battery* properties. </p>
| 42,808 |
<p>Is it possible to design a heat block without cartridge heater?</p>
<p>My idea is to build a very small heat block to increase/decrease the heat as fast as possible. The resistance of the heat block will be used. The current to this block is 500mA and is set constant with a circuit. The voltage will be set with pwm... | <p>I have a Kill-A-Watt meter so I got a pretty good measurement for you with my Anet A6. Like Petar said each model is different but this should give you a idea. When heating both the nozzle and heat bed the printer consumes 160 W of power, once to temp it backs down to 9 W (it also uses 9 W when just "... | <p>To answer the underlying (X-Y) question, yes it is possible to power a small 3D printer from a battery pack. <a href="https://www.3ders.org/articles/20171005-naomi-sexycyborg-wu-3d-prints-on-the-go-with-awesome-wearable-3d-printer.html" rel="nofollow noreferrer">This Article</a> describes a printer built by Naomi Wu... | 832 |
<p>when i point my browser to <code>http://localhost/phpmyadmin</code>, instead of showing me its front page, it comes up with save as dialog.</p>
<p>I'm running:
Apache/2.2.3 (Debian) PHP/5.2.0-8+etch13 Server </p>
<p>I've reinstalled both apache2 and php5.
After re-install i don't have httpd.conf file, how can i ge... | <p>Did you configure the php extension to send an http header?</p>
<p>In httpd.conf:
AddType application/x-httpd-php .php</p>
<p>EDIT<br>
The file is not necessarily named <code>httpd.conf</code>, that's just the default name. Try searching for other configuration files in the Apache directory -- the extension proba... | <p>I dont know anything about this but... does someone knows a way in javascript to download selected files, for example I select through checkboxes 2 files, and then I click on a button in order to download these 2 files choosing the route where i will save the archives</p>
| 41,032 |
<p>I am writing a simple checkers game in Java. When I mouse over the board my processor ramps up to 50% (100% on a core).</p>
<p>I would like to find out what part of my code(assuming its my fault) is executing during this.</p>
<p>I have tried debugging, but step-through debugging doesn't work very well in this cas... | <p>This is called "profiling". Your IDE probably comes with one: see <a href="http://java-source.net/open-source/profilers" rel="nofollow noreferrer">Open Source Profilers in Java</a>.</p>
| <p>Or use JUnit test cases and a code coverage tool for some common components of yours. If there are components that call other components, you'll quickly see those executed many more times. </p>
<p>I use Clover with JUnit test cases, but for open-source, I hear EMMA is pretty good.</p>
| 11,557 |
<p>How do I get a human-readable file size in bytes abbreviation using .NET?</p>
<p><strong>Example</strong>:
Take input 7,326,629 and display 6.98 MB</p>
| <p>This may not the most efficient or optimized way to do it, but it's easier to read if you are not familiar with log maths, and should be fast enough for most scenarios.</p>
<pre><code>string[] sizes = { "B", "KB", "MB", "GB", "TB" };
double len = new FileInfo(filenam... | <p>1-liner (plus the prefixes constant)</p>
<pre class="lang-cs prettyprint-override"><code>const String prefixes = " KMGTPEY";
/// <summary> Returns the human-readable file size for an arbitrary, 64-bit file size. </summary>
public static String HumanSize(UInt64 bytes)
=> Enumerable
.R... | 35,645 |
<p>I want to capture the output of an exe file as an png or jpg image, i mean the display of that exe.
Is there any command on windows to capture and save as image of an exe output or any other idea that i can do this.</p>
| <p>There is always the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Robot.html" rel="nofollow noreferrer">Robot</a> class in Java. That may be helpful. Check out <a href="https://stackoverflow.com/questions/58305/java-is-there-a-way-to-take-a-screenshot-using-java-and-save-it-to-some-sort-of">this slight... | <p>Alt-PRTSC, then open an image editor and paste.</p>
| 44,590 |
<p>I have a web page where I'd like to remap Ctrl+N to a different behavior. I followed YUI's example of register Key Listeners and my function is called but Firefox still creates a new browser window. Things seem to work fine on IE7. How do I stop the new window from showing up?</p>
<p>Example:</p>
<pre><code>var kl... | <p>The trick is the 'fn' function is whack.</p>
<p>Experimentally, you can see that the function type for fn takes two parameters. The first param actually contains the TYPE of event. The second one contains... and this is screwy: an array containing the codepoint at index 0 and the actual event object at index 1.</p>... | <p>I'm just guessing here but I don't think it can be done.</p>
<p>If it's possible it definitely shouldn't be. Generic keyboard shortcuts are something you should not mess with. What's next? Hook the window close button to open a new window...</p>
| 20,061 |
<p>I want to have my PHP application labeled with the revision number which it uses, but I don't want to use <a href="http://en.wikipedia.org/wiki/CruiseControl" rel="nofollow noreferrer">CruiseControl</a> or update a file and upload it every time. How should I do it?</p>
| <p>SVN keywords is not a good solution. As others pointed out adding $Revision$ in a file only affects <strong>the specific file</strong>, which may not change for a long time.</p>
<p>Remembering to "edit" a file (by adding or removing a blank line) before every commit is pointless. You could as well just type the rev... | <p>Another possibility to do this is to run a cron that executes the steps described in the "Deploy Process" (assuming it is a *nix/FreeBSD server).</p>
| 13,665 |
<p>When I print with PLA, I get a perfect first layer.</p>
<p>However, when I print with PETG, the first layer looks like this:</p>
<p><a href="https://i.stack.imgur.com/pceRa.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/pceRa.jpg" alt="enter image description here"></a></p>
<p>I've read all the info th... | <blockquote>
<p>One thought I had, does PETG need a different clearance between the nozzle and the bed than PLA?</p>
</blockquote>
<p>Short answer: "Yes, for some it does".</p>
<hr>
<p>The results from your image are typically seen when the initial layer height for PETG is too small. PETG likes an additional gap o... | <p>When I print with PETG, my bed is 80 °C for first 2 layers then I drop it to 65 °C</p>
<p>Extruder temp first two layers 240-250 °C and then drop to 225-230 °C.</p>
| 1,486 |
<p>I been experimenting with the different methods for representing a hierarchical structures in memory that would allow for simple and efficient transversal both up and down to discover ancestor and descendant relationships. Does anyone have any suggestions or examples of the options that I have? Is there a collecti... | <p>So you want a <a href="http://en.wikipedia.org/wiki/Tree_%28data_structure%29" rel="nofollow noreferrer">Tree</a>? <a href="http://www.google.co.uk/search?q=c%23+tree&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-GB:official&client=firefox-a" rel="nofollow noreferrer">FGI</a></p>
| <p>How about making your own node that looks something like:</p>
<pre><code> class Node<T> {
public T Item;
public LinkedList<T> Children;
}
</code></pre>
<p>Then apply Node recursively, as needed</p>
| 41,066 |
<p>I'm attempting to use TinyXML to read and save from memory, instead of only reading and saving files to disk.</p>
<p>It seems that the documnent's parse function can load a char *. But then I need to save the document to a char * when I'm done with it. Does anyone know about this?</p>
<p><strike>Edit: The printing... | <p>Here's some sample code I am using, adapted from the <a href="http://www.grinninglizard.com/tinyxmldocs/classTiXmlPrinter.html" rel="noreferrer">TiXMLPrinter</a> documentation:</p>
<pre><code>TiXmlDocument doc;
// populate document here ...
TiXmlPrinter printer;
printer.SetIndent( " " );
doc.Accept( &print... | <p>Don't quite get what you are saying; your question is not clear. I'm guessing you are wanting to load a file into memory so that you can pass it to the document parse function. In that case, the following code should work.</p>
<pre><code>#include <stdio.h>
</code></pre>
<p>The following code reads a file i... | 13,566 |
<p>I need to create a custom membership user and provider for an ASP.NET mvc app and I'm looking to use TDD. I have created a User class which inherits from the MembershipUser class, but when I try to test it I get an error that I can't figure out. How do I give it a valid provider name? Do I just need to add it to ... | <p>The configuration to add to your unit test project configuration file would look something like this:</p>
<pre><code> <connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="<connection string>" providerName="System.Data.SqlClient"/>
<... | <p>Yes, you need to configure it in your configuration file (probably not web.config for a test library, but app.config). You still use the section and within that the section to do the configuration. Once you have that in place, you'll be able to instantiate your user and go about testing it. At which point you'l... | 10,238 |
<p>I have a script which will be run interactively by non-technical users. The script writes status updates to STDOUT so that the user can be sure that the script is running OK.</p>
<p>I want both STDOUT and STDERR redirected to the terminal (so that the user can see that the script is working as well as see if there ... | <p>Use "tee" to redirect to a file and the screen. Depending on the shell you use, you first have to redirect stderr to stdout using</p>
<pre><code>./a.out 2>&1 | tee output
</code></pre>
<p>or</p>
<pre><code>./a.out |& tee output
</code></pre>
<p>In csh, there is a built-in command called "s... | <p>Here is a solution working for bash by redirection, by combining the solution of "kvantour, MatrixManAtYrService" and "Jason Sydes":</p>
<pre><code>#!/bin/bash
exec 1> >(tee x.log) 2> >(tee x.err >&2)
echo "test for log"
echo "test for err" 1>&2
</co... | 47,423 |
<p>Have you ever tried this before?</p>
<pre><code>static void Main(string[] args)
{
int x = 10;
x = x++;
Console.WriteLine(x);
}
</code></pre>
<p>Output: 10.</p>
<p>but for </p>
<pre><code>static void Main(string[] args)
{
int x = 10;
x++;
Console.WriteLine(x);
}
</code></pre>
<p>Output: 1... | <p>X++ will increment the value, but then return its old value. </p>
<p>So in this case:</p>
<pre><code>static void Main(string[] args)
{
int x = 10;
x = x++;
Console.WriteLine(x);
}
</code></pre>
<p>You have X at 11 just for a moment, then it gets back to 10 because 10 is the return value of (x++). </p>... | <p>The result of the assignment</p>
<pre><code>x = x++;
</code></pre>
<p>is undefined in C and C++<s>, and I would guess the same with C# too. </p>
<p>So, the actual sequence of operations that occurs depends on how the compiler decides to implements it, there's no guarantee whether the assignment or the increment w... | 27,940 |
<p>Is there an existing application or library in <em>Java</em> which will allow me to convert a <code>CSV</code> data file to <code>XML</code> file? </p>
<p>The <code>XML</code> tags would be provided through possibly the first row containing column headings.</p>
| <p>Maybe this might help: <a href="http://jsefa.sourceforge.net/quick-tutorial.html" rel="noreferrer">JSefa</a></p>
<p>You can read CSV file with this tool and serialize it to XML.</p>
| <p>This may be too basic or limited of a solution, but couldn't you do a <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split(java.lang.String)" rel="nofollow noreferrer"><code>String.split()</code></a> on each line of the file, remembering the result array of the first line to generate the XM... | 2,257 |
<p>On Unix, is there any way that one process can change another's environment variables (assuming they're all being run by the same user)? A general solution would be best, but if not, what about the specific case where one is a child of the other?</p>
<p>Edit: How about via gdb?</p>
| <p>Via gdb:</p>
<pre><code>(gdb) attach process_id
(gdb) call putenv ("env_var_name=env_var_value")
(gdb) detach
</code></pre>
<p>This is quite a nasty hack and should only be done in the context of a debugging scenario, of course.</p>
| <p>If your unix supports the /proc filesystem, then it's trivial to READ the env - you can read the environment, commandline, and many other attributes of any process you own that way. Changing it... Well, I can think of a way, but it's a BAD idea.</p>
<p>The more general case... I don't know, but I doubt there's a ... | 25,117 |
<p>Why do I get following error when trying to start a ruby on rails application with <pre>mongrel_rails start</pre>?</p>
<pre>
C:\RailsTest\cookbook2>mongrel_rails start
** WARNING: Win32 does not support daemon mode.
** Daemonized, any open files are closed. Look at log/mongrel.pid and log/mongr
el.log for info.
*... | <p>You already have a process listening on port 3000 (the default port for mongrel).</p>
<p>Try:</p>
<pre><code>mongrel_rails start -p 3001
</code></pre>
<p>and see whether you get a similar error.</p>
<p>If you're trying to install more than one Rails app, you need to assign each mongrel to a separate port and edi... | <p>On Windows, I found two possible ways for fixing this issue:</p>
<ol>
<li>Work around: Start the mongrel web server in another port</li>
<li>Solution: Find the ruby.exe process in your task manager and finish it</li>
</ol>
| 15,289 |
<p>I have two related question regarding Scrum.</p>
<p>Our company is trying to implement it and sure we are jumping over hoops.</p>
<p>Both question are about "done means Done!"</p>
<p>1) It's really easy to define "Done" for tasks which are/have
- clear test acceptance criterias
- completely standalone
- tested a... | <p>For the first part " architecture design - refactoring - some utility classes development" These are never "done" because you do them as you go. In pieces.</p>
<p>You want to do just enough architecture to get the first release going. Then, for the next release, a little more architecture.</p>
<p>Refactoring is... | <p>"Should I allocate special task for debug/fix/system integrations and etc?"</p>
<p>Not the same way you did with a waterfall methodology where nothing really worked.</p>
<p>Remember, you're building and testing incrementally. Each sprint is tested and debugged separately.</p>
<p>When you get to a release candida... | 18,132 |
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/25458/how-costly-is-net-reflection">How costly is .NET reflection?</a> </p>
</blockquote>
<p>I am currently in a programming mentality that reflection is my best friend. I use it a lot for dynamic loading of co... | <p>Reflection requires a large amount of the type metadata to be loaded and then processed. This can result in a larger memory overhead and slower execution. According to <a href="http://www.west-wind.com/WebLog/posts/351.aspx" rel="noreferrer">this article</a> property modification is about 2.5x-3x slower and method i... | <p>One thing that can sometimes bite you when using reflection is not updating calls using reflection when doing refactoring. Tools like resharper will prompt you to update comments and strings when you change a method name, so you can catch most of them that way, but when you're calling methods that have been dynamic... | 27,698 |
<p>I am designing a simple internal framework for handling time series data.
Given that LINQ is my current toy hammer, I want to hit everything with it.</p>
<p>I want to implement methods in class TimeSeries (Select(), Where() and so on) so that I can use LINQ syntax to handle time series data</p>
<p>Some things are ... | <p><code>Union</code> sounds like the right way to go - no query expression support, but I think it expresses what you mean.</p>
<p>You might be interested in looking at the Range-based classes in <a href="http://pobox.com/~skeet/csharp/miscutil" rel="nofollow noreferrer">MiscUtil</a> which can be nicely used for time... | <p><code>Union</code> sounds like the right way to go - no query expression support, but I think it expresses what you mean.</p>
<p>You might be interested in looking at the Range-based classes in <a href="http://pobox.com/~skeet/csharp/miscutil" rel="nofollow noreferrer">MiscUtil</a> which can be nicely used for time... | 29,890 |
<p>I have 2 tables. Table1 has fields A, B, C, D and Table2 has fields A, B. Field A and B of both tables have same record type. I would like to grab the records from both tables of fields A and B as single result.</p>
<p>Is there any Query or Function in PHP+MySql?</p>
<p>Thanks...</p>
| <p>I assume MySql does this:</p>
<p>select a,b from table1 where your_criteria=test_value
union
select a,b from table2 where your_criteria=test_value</p>
| <p>There's a union clause in SQL that does what you want:</p>
<pre><code>select a,b from table1
where <where-clause>
union all select a,b from table2
where <where-clause>
</code></pre>
<p>or, if you want all fields (spaces for table2):</p>
<pre><code>select a,b,c,d from table1
where <where... | 21,289 |
<p>I have been having some general problems with <a href="http://tinymce.moxiecode.com/" rel="nofollow noreferrer">TinyMCE</a> inside Opera. Some of these include:</p>
<ul>
<li>the save button produces an error</li>
<li>when submitting to a popup with an entire form, including TinyMCE, nothing gets posted to the popup... | <p>TinyMCE is not the only rich text editor for web. You could even try a <a href="http://www.wymeditor.org" rel="nofollow noreferrer">what you mean editor</a> or some Flash based solution.</p>
| <p>I recommend <a href="http://www.ckeditor.com" rel="nofollow">CKEditor</a>, it works like a charm on Opera and is also very configurable and powerful. I also had some issues with TinyMCE using the latest Opera to date (v12.15).</p>
| 34,406 |
<p>I am working on an email polling solution, for a multi-user system. So users can send emails on their respective ids and it would be polled and inserted to a db.</p>
<p>There are two options that I am considering:</p>
<ol>
<li>Perl/Unix based email pollers..</li>
<li>A java based poller.</li>
</ol>
<p>What would ... | <p>Instead of polling, why don't you forward the mail to a process? Depending on the mail server you use, you can do that as an alias or even in the .forward file.</p>
| <p>I've nothing much to add to this, but there's currently a project at google code to rebuild iwantsandy.com as open source. </p>
<p>It's at:<br>
<a href="http://code.google.com/p/sandysback/" rel="nofollow noreferrer">http://code.google.com/p/sandysback/</a></p>
<p>I'm definitely going to be watching this to see ho... | 42,898 |
<p>This is a shared hosting environment. I control the server, but not necessarily the content. I've got a client with a Perl script that seems to run out of control every now and then and suck down 50% of the processor until the process is killed.</p>
<p>With ASP scripts, I'm able to restrict the amount of time the... | <p>On a UNIX-style system, I would use a signal handler trapping ALRM events, then use the alarm function to start a timer before starting an action that I expected might timeout. If the action completed, I'd use alarm(0) to turn off the alarm and exit normally, otherwise the signal handler should pick it up to close e... | <p>Googling for "iis cpu limit" gives these hits: </p>
<p><a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/38fb0130-b14b-48d5-a0a2-05ca131cf4f2.mspx?mfr=true" rel="nofollow noreferrer">http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/38fb0130-b14b-48d5-a0a2-... | 10,076 |
<p>I have a canvas element defined statically in the html with a width and height. If I attempt to use JavaScript to resize it dynamically (setting a new width and height - either on the attributes of the canvas or via the style properties) I get the following error in Firefox:</p>
<blockquote>
<p>uncaught exception... | <p>You didn't publish your code, and I suspect you do something wrong. it is possible to change the size by assigning width and height attributes using numbers:</p>
<pre><code>canvasNode.width = 200; // in pixels
canvasNode.height = 100; // in pixels
</code></pre>
<p>At least it works for me. Make sure you don't ass... | <p>Prototypes can be a hassle to work with, and from the <code>_PROTO</code> part of the error it appears your error is caused by, say, <code>HTMLCanvasElement.prototype.width</code>, possibly as an attempt to resize all the canvases at once.</p>
<p>As a suggestion, if you are trying to resize a number of canvases at ... | 42,878 |
<p>I'm new to database indexing, if I have 2 columns in a table that are good choices for indexing like for example,</p>
<pre><code>[Posts](
[PostID] [int] IDENTITY(1,1) NOT NULL,
[UserName] [nvarchar](64) NOT NULL,
[ApplicationType] [smallint] NOT NULL,
...
)
</code></pre>
<p>in this case PostID woul... | <p>Keep in mind the telephone-book rule for compound indexes: the phone book is effectively indexed by last-name, first-name. It's a compound index. </p>
<p>If you search for people named "Smith, John" then it's helpful that the first-name is part of the index. Once you find the entries with last-name "Smith" then... | <p>IIRC, the rule of thumb is that an index can is used only for lookups that use all columns from some point and to the left. For example, an index on columns (a,b,c,d) could be used if you query on (a), (a,b), (a,b,c) or (a,b,c,d) but not on (a,c) for example.</p>
<p>This is a result of the way indexes are built; th... | 48,768 |
<p>I use AutoHotKey for Windows macros. Most commonly I use it to define hotkeys that start/focus particular apps, and one to send an instant email message into my ToDo list. I also have an emergency one that kills all of my big memory-hogging apps (Outlook, Firefox, etc).</p>
<p>So, does anyone have any good AHK ma... | <p>Very simple and useful snippet:</p>
<pre><code>SetTitleMatchMode RegEx ;
; Stuff to do when Windows Explorer is open
;
#IfWinActive ahk_class ExploreWClass|CabinetWClass
; create new folder
;
^!n::Send !fwf
; create new text file
;
^!t::Send !fwt
; open 'cmd' in the current directory
... | <p>There are tons of good ones in the AutoHotKey Forum:</p>
<p><a href="http://www.autohotkey.com/forum/forum-2.html&sid=8149586e9d533532ea76e71e8c9e5b7b" rel="nofollow noreferrer">http://www.autohotkey.com/forum/forum-2.html&sid=8149586e9d533532ea76e71e8c9e5b7b</a></p>
<p>How good? really depends on what you... | 12,392 |
<p>I need to copy several tables from one DB to another in SQL Server 2000, using C# (VS 2005). The call needs to be parameterized - I need to be able to pass in the name of the database to which I am going to be copying these tables.</p>
<p>I could use DTS with parameters, but I can't find any sample code that does ... | <p>For SQL Server 7.0 and 2000, we have SQLDMO for this. For SQL Server 2005 there is SMO. This allows you do to pretty much everything related to administering the database, scripting objects, enumerating databases, and much more. This is better, IMO, than trying a "roll your own" approach.</p>
<p>SQL 2000:
<a href="... | <p>If the destination table is being dropped every time then why not do SELECT INTO? Doesn't seem like a kludge at all. </p>
<p>If it works just fine and ticks all the requirements boxes why create a days worth of work growing code to do exactly the same thing?</p>
<p>Let SQL do all the heavy lifting for you.</p>
| 21,034 |
<p>I had an idea I was mulling over with some colleagues. None of us knew whether or not it exists currently.<br><br>
The Basic Premise is to have a system that has 100% uptime but can become more efficient dynamically.<br><br></p>
<blockquote>
<p><strong>Here is the scenario:</strong><br><br> * So we hash out a s... | <p>I believe this idea to be an interesting theoretical debate, but not very practical for the following reasons:</p>
<ol>
<li>To make sure the new version of the code works well, you need to have superb automatic tests, which is a goal that is very hard to achieve and one that many companies fail to develop. You can ... | <p>I don't think code will learn to be better, by itself. However, some runtime parameters can easily adjust onto optimal values, but that would be just regular programming, right?</p>
<p>About the on-the-fly change, I've shared the wondering and would be building it on top of Lua, or similar dynamic language. One cou... | 8,538 |
<p>What is a good, secure, method to do backups, for programmers who do research & development at home and cannot afford to lose any work?</p>
<p>Conditions:</p>
<ol>
<li><p>The backups must ALWAYS be within reasonably easy reach.</p></li>
<li><p>Internet connection cannot be guaranteed to be always available.</p... | <p>usb hard disk + <a href="http://samba.anu.edu.au/rsync/" rel="nofollow noreferrer">rsync</a> works for me</p>
<p>(see <a href="http://www.itefix.no/i2/node/10650" rel="nofollow noreferrer">here</a> for a Win32 build)</p>
| <p>My vote goes to dirvish (for linux). It uses rsync as backend but is very easy to configure.
It makes automatic, periodically and differential backups of directories. The big benefit is, that it creates hardlinks to all files not changed since the last backup. So restore is easy: Just copy last created directory bac... | 13,849 |
<p>I've got a couple simple Windows Forms apps that I'd like to add crash reporting to. Something that will give me info on what crashes are happening on user's machines (wrt my app, of course), including stack traces, logs, and screenshots, and a UI component for asking the user whether they want to upload it, etc. My... | <p>Wumpus (aka Jeff Atwood) published some cool exception handling stuff years ago (it may have even been .net 1.1 days) but it is quite good and easy to use (and will convert to newer version of .net with success.) I am using it with an app I am writing...and since you get full source you can extend it easily.</p>
<... | <p>Take a peek at <a href="http://code.google.com/p/elmah/" rel="nofollow noreferrer">Elmah</a> (Error Logging Modules and Handlers) - an application-wide error logging facility that is completely pluggable. It can be dynamically added to a running ASP.NET web application, or even all ASP.NET web applications on a mach... | 47,237 |
<p>In a windows MSVC6.0 compiler, if there is a workspace with one project in it, what files would be in the <strong>Header Files</strong> folder and what files would be in the <strong>External Dependencies</strong> folder?</p>
<p>I thought those files which are explicitly included (#include <*.h> are to be in t... | <p>Header files listed as external dependencies are not analysed and available in the class view tab. Moving a file from external dependencies to header files includes it into the class view.</p>
| <p>After looking at the structure of header files and #include *.h in the workspace i found following:</p>
<p>1.) Those files which are not explicitly added to the Projects <strong>Header Files</strong> folder, but are nonetheless included using the #include directive, by different header and source files, are added t... | 26,073 |
<p>Is there a best-practice or common way in JavaScript to have class members as event handlers?</p>
<p>Consider the following simple example:</p>
<pre><code><head>
<script language="javascript" type="text/javascript">
ClickCounter = function(buttonId) {
this._clickCount = 0;
... | <pre><code>ClickCounter = function(buttonId) {
this._clickCount = 0;
var that = this;
document.getElementById(buttonId).onclick = function(){ that.buttonClicked() };
}
ClickCounter.prototype = {
buttonClicked: function() {
this._clickCount++;
alert('the button was clicked ' + this._clic... | <p>I like to use <code>unnamed</code> functions, just implemented a navigation Class which handles this correctly:</p>
<pre><code>this.navToggle.addEventListener('click', () => this.toggleNav() );
</code></pre>
<p>then <code>this.toggleNav()</code> can be just a function in the <code>Class</code>.</p>
<p>I know I us... | 28,357 |
<p>I am at my wits end with this problem. I start a print and the skirt goes down fine, then the outline of the parts go down fine (usually) and then when it goes to fill in the first layer, it will always get stuck to the hotend at some point and rip apart the layer. </p>
<p>Any ideas on how to solve this?</p>
<ul>
... | <p><strong>Step Zero:</strong> is always to check/adjust the bed level - if the height over the bed varies while putting down the first layer, it's hard to ever get first layer settings that work.</p>
<p><strong>Step One:</strong> is to adjust your first layer settings - height, temperature, extrusion width until you ... | <p>Try lowering your first layer temp to 205°C, and apply a gluestick to the bed before you print anything. By lowering the temp, this allows th plastic to cool faster, and doesn't risk the plastic sticking to the nozzle as much. Applying the glue stick will help the print to stick to the buildplate better, lowering th... | 626 |
<p>I am inside the IDE and I can run all the unit tests in a file but is there any way to run all test in a project or solution at once?</p>
| <p>Right click on the project or solution in the VS solution-explorer and choose 'Run Unit Tests' Or go to the Resharper menu, choose Unit-Testing and choose one of the options from there.</p>
| <p>It may be that your unit tests are not fully detected within Unit Test explorer. In that case, restarting Visual Studio helped resolve that problem.</p>
| 43,439 |
<p>I'm working on an editor for files that are used by an important internal testing tool we use. The tool itself is large, complicated, and refactoring or rewriting would take more resources than we are able to devote to it for the forseeable future, so my hands are tied when it comes to large modifications. I must ... | <p>If A, B, C and D have nothing in common then adding a base class won't really get you anything. It will just be an empty class and in effect will be the same as object.</p>
<p>I'd just create an ErrorItem class without the generics, make Item an object and do some casting when you want to use the objects referenced... | <p>If A, B, C and D have nothing in common then adding a base class won't really get you anything. It will just be an empty class and in effect will be the same as object.</p>
<p>I'd just create an ErrorItem class without the generics, make Item an object and do some casting when you want to use the objects referenced... | 7,784 |
<p>I need to display external resources loaded via cross domain requests and make sure to only display "<em>safe</em>" content. </p>
<p>Could use Prototype's <a href="http://www.prototypejs.org/api/string/stripScripts" rel="noreferrer">String#stripScripts</a> to remove script blocks. But handlers such as <code>onclick... | <p>Update 2016: There is now a <a href="https://github.com/google/closure-library/blob/master/closure/goog/html/sanitizer/htmlsanitizer.js" rel="noreferrer">Google Closure</a> package based on the Caja sanitizer.</p>
<p>It has a cleaner API, was rewritten to take into account APIs available on modern browsers, and int... | <p>I recommend cutting frameworks out of your life, it would make things excessively easier for you in the long term.</p>
<p>cloneNode: Cloning a node copies all of its attributes and their values but <strong>does <em>NOT</em> copy event listeners</strong>.</p>
<p><a href="https://developer.mozilla.org/en/DOM/Node.cl... | 37,774 |
<p>What's better for DSL: TCL or Lisp?
What can you say about Java(C#)-TCL binding versus Lisp(Scheme)?
What DSL tool is applicable for .Net development? (excepting Microsoft DSL tools)</p>
| <p>If you want easy access to the JVM, you can use Clojure.</p>
<p>Please note that you can design the DSL any way you want, you are not forced to let any "lispy" syntax shine through. My favourite example is in the Common Lisp standard: the extended LOOP syntax is as unlispy as it gets, and it is, in fact, a DSL fo... | <p>Even Lisp seems to have some weird commands like CDR (if you're not coming from a non LIST oriented language) TCL has some "weird" stuff to. You have to consider which syntax fits to your brain most. </p>
<p>e.g. if you have no problem with a very sparse syntax and assigning variables with set, that take TCL, ich y... | 40,938 |
<p>I am trying to share DTO's from my datalayer assembly between the client and WCF service. This works using svcutil, but doesn't work when using VS2008. VS2008 generates it's own DTO objects whereas svcutil uses the shared data type.</p>
<p>The svcutil parameters I used are:</p>
<pre><code>"C:\Program Files\Micro... | <p>Just use <code>ClientFactory<T></code>.</p>
<p>You don't really need either svcutil nor a service reference. The code which they generate is only a bloated wrapper around ClientFactory that adds virtually no functionality.</p>
| <p>If you avoid using a service reference, and just include a reference to the the svcutil generated code then this should avoid this issue. Our DTO's are in shared assemblies.</p>
| 36,335 |
<p>I have a number of stored procs which I would like to all run simultaneously on the server. Ideally all on the server without reliance on connections to an external client.</p>
<p>What options are there to launch all these and have them run simultaneously (I don't even need to wait until all the processes are done... | <p>Is SSIS an option for you? You can create a simple package with parallel Execute SQL tasks to execute the stored procs simultaneously. However, depending on what your stored procs do, you may or may not get benefit from starting this in parallel (e.g. if they all access the same table records, one may have to wait ... | <p>At one point I did some architectural work on a product known as <a href="http://www.roomsolutions.net/insurance-software/data-warehouse/acumen-advantage.aspx" rel="nofollow noreferrer">Acumen Advantage</a> that has a warehouse manager that does this.</p>
<p>The basic strategy for this is to have a control DB with ... | 19,701 |
<p>I'm looking for digital low pass filter code/library/class for a .net windows forms project, preferably written in c, c++ or c#. I probably need to set the number of poles, coefficients, windowing, that sort of thing. I can't use any of the gpl'd code that's available, and don't know what else is out there. Any sugg... | <p>Here is a Butterworth Low Pass filter I wrote for a recent project. </p>
<p>It has some magic numbers as constants that was given to me. If you can figure out how to create the magic numbers with your poles, coefficients, etc, then this might be helpful.</p>
<pre><code>using System;
using System.Collections.Gene... | <p>Ok, I found out how to get the coefficients you used. I downloaded Octave for windows and ran the butter command (as in MatLab) like this:</p>
<p>[b,a] = butter(3, .4, 'low')</p>
<p>Now I can use this code with other fs and fc parameters.</p>
| 44,789 |
<p>I have to continue to support VB6 applications. I've got both VB6 (Visual Studio 6) installed and Visual Studio 2008 as well. Can I read and write to VB6 projects while in Visual Studio 2008? Will it damage or destroy my VB6 application? It would be very cool if I could free up a lot of space and get rid of V... | <p>Visual Studio 2008 can't compile VB6 applications. You could use it as a text editor only (though it will offer you the VB.NET IntelliSense, not VB6). However, you need Visual Studio 6 to be able to build your application.</p>
| <p>If you remove VB6 you won't be able to build your VB6 apps? VS2002/3/5/8 doesn't know how to compile VB6 projects.</p>
| 15,891 |
<p>Is there a way to cancel a pending operation (without disconnect) or set a timeout for the boost library functions?</p>
<p>I.e. I want to set a timeout on blocking socket in boost asio?</p>
<p>socket.read_some(boost::asio::buffer(pData, maxSize), error_);</p>
<p>Example: I want to read some from the socket, but I... | <p>When this question was asked, I guess ASIO did not have any example on how to accomplish what the OP needed, that is to timeout a blocking operation such as a blocking socket operation. Now there exists examples to show you exactly how to do this. the example seems long, but that is because it is WELL commented. It ... | <p>On *nix, you'd use alarm() so your socket call would fail with EINTR</p>
| 37,234 |
<p>Im trying to get Trac upp and running on my IIS/w2008 server using this FAQ: <a href="http://trac.edgewall.org/wiki/TracOnWindowsIisAjp" rel="nofollow noreferrer">TracOnWindowsIisAjp</a></p>
<p>Everything upp until "3. Install Tomcat AJP Connector for IIS" works ok.
I then define my directories as : C:\wwwroot\trac... | <p>The best approach is probably to add the Seam library to your existing project, and then gradually refactor your code to take advantage of Seam's features. To do this, work through the <a href="http://docs.jboss.com/seam/2.1.1.GA/reference/en-US/html/" rel="nofollow noreferrer">Seam manual</a> and refactor your code... | <p>This seems to be part of the solution:</p>
<p><a href="http://www.mastertheboss.com/en/seam/63-jboss-seam-tutorial-1.html" rel="nofollow noreferrer">http://www.mastertheboss.com/en/seam/63-jboss-seam-tutorial-1.html</a></p>
| 39,144 |
<p>I'm having a little problem and I don't see why, it's easy to go around it, but still I want to understand. </p>
<p>I have the following class :</p>
<pre><code>public class AccountStatement : IAccountStatement
{
public IList<IAccountStatementCharge> StatementCharges { get; set; }
public AccountStat... | <p>This code:</p>
<pre><code>public AccountStatement()
{
new AccountStatement(new Period(new NullDate().DateTime,newNullDate().DateTime), 0);
}
</code></pre>
<p>is undoubtedly not what you wanted. That makes a second instance of AccountStatement and does nothing with it.</p>
<p>I think what you meant was this in... | <p>You are calling a parameter-less constructor so AddStatementCharge is never initialized. Use something like:</p>
<pre><code>var accountStatement = new AccountStatement(period, accountId) {
StartDate = new Date(2007, 1, 1),
EndDate =... | 15,558 |
<p>I am encountering a problem with this ID3 printer using ABS -- at some point during the print the print head displaces on the y-axis by 2-3 centimeters. I cannot pinpoint how or why it is doing this. It has displaced in the positive Y direction and in the negative Y direction on separate runs of the same piece (whic... | <p>This has happened to me in the past and here are a few things that I determined could have been the cause:</p>
<ul>
<li>Limit Switch triggered. My coworker was able to repeat the issue by manually triggering a limit switch during the print. Somehow, this seemed to cause the relative axis to shift on his MakerBot Re... | <p>In my case the solution was to use <a href="https://en.wikipedia.org/wiki/Slic3r" rel="nofollow noreferrer">Slic3r</a> instead of <a href="https://en.wikipedia.org/wiki/Ultimaker#History" rel="nofollow noreferrer">Cura</a>. Cura has some issues.</p>
| 239 |
<p>I've heard the term MVC (Model View Controller) tossed about with a ton of Buzz lately, but what really is it?</p>
| <p>You might want to take a look at what Martin Fowler has to say about MVC, MVP and UI architectures in general at <a href="http://martinfowler.com/eaaDev/uiArchs.html" rel="noreferrer">Martin Fowlers site</a>. </p>
| <p>MVC is a way to partition a user interface element into 3 distinct concepts. The model is the data on which the interface operates. The view is how the element is represented visually (or maybe audibly?). The controller is the logic that operates on the data.</p>
<p>For example, if you have some text you want to... | 15,781 |
<p>Suppose you have output like this:</p>
<pre><code>Word1 Word2 Word3 Word4
</code></pre>
<p>Where the number of spaces between words is arbitrary. I want to break it into an array of words.</p>
<p>I used the following code:</p>
<pre><code>string[] tokens =
new List<String>(input.Sp... | <p>He already mentions string.Split(). What he's missing is StringSplitOptions.RemoveEmptyEntries:</p>
<pre><code>string[] tokens = input.Split(new char[] { ' ' },
StringSplitOptions.RemoveEmptyEntries);
</code></pre>
| <p>I would use a regex for the split with "\w+" for the pattern.</p>
| 44,427 |
<p>I am using the <strong>AjaxControlToolkit</strong> in VS2005, and it works fine. I do have some issues though, when I go to some pages I have, then click back, I get this JavaScript error:</p>
<blockquote>
<p>'AjaxControlToolkit' is undefined</p>
</blockquote>
<p>I have searched MSDN forums, and google, and trie... | <p>I got this problme fixed but not by setting CombineScripts="false" but by using the solution described <a href="http://forums.asp.net/post/4431011.aspx">in this post</a>. </p>
<p>There have been some changes in the latest version, due to which you have to use <code>Sys.Extended.UI.BehaviorBase</code> instead of <co... | <p>Is that a javascript error?</p>
<p>I suppose it has to do with back-button support in the toolkit.</p>
<p>And undefined errors mostly occurs because somehow the script that contains "AjaxControlToolkit" doesn't gets properly loaded.</p>
<p>Thing that come to mind:</p>
<ul>
<li>The order scripts get loaded, does ... | 12,270 |
<p>We have a SaaS application requirement to allow a user responsible for building a CMS site to define up to 10 custom fields in a form.
As part of this field definition we want to add a field validation option which we will store (and apply at runtime) as a reg-ex.</p>
<p>Are there any tools, code samples or simila... | <p>I really like regexbuddy
<a href="http://www.regexbuddy.com/" rel="nofollow noreferrer">http://www.regexbuddy.com/</a></p>
<p>expresso is really good to, and will generate c# code
<a href="http://www.ultrapico.com/Expresso.htm" rel="nofollow noreferrer">http://www.ultrapico.com/Expresso.htm</a></p>
<p>both will sh... | <p>Expresso:</p>
<blockquote>
<p><a href="http://www.codeproject.com/KB/dotnet/expresso.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/dotnet/expresso.aspx</a></p>
</blockquote>
<p>There is also an advanced (commercial) version (<a href="http://www.ultrapico.com/Expresso.htm" rel="nofollow noreferrer... | 44,382 |
<pre><code>while (xxx) {
timeout.tv_sec=TIMEOUT;
timeout.tv_usec=0;
FD_ZERO(&set);
FD_SET(sd,&set);
switch (select(FD_SETSIZE,&set,NULL,NULL,&timeout))
xxxxx
}
</code></pre>
<p>works fine, however</p>
<pre><code>FD_ZERO(&set);
FD_SET(sd,&set);
while (xxx) {
time... | <p>select modifies its arguments. You really do have to re-initialize it each time.</p>
<p>If you're concerned about overhead, the cost of processing the complete FD_SET in the kernel is somewhat more significant than the cost of FD_ZERO. You'd want to only pass in your maximum fd, not FD_SETSZIZE, to minimize the ker... | <p>That's the way select works. It works best, and makes more sense, if you have more than one socket. That's kind of the point: you are selecting across many sockets. If you want to read from one socket, just read or recv it.</p>
| 36,301 |
<p>Is there a way to automatically apply a theme/template/style to all controls of the targettype, so I don't have to specify Template=..., Style=... on all controls?</p>
| <p>I thought there was a way to do this by just omitting the x:Key attribute, but that doesn't seem to work anymore. Based on some googling it seems to me like you're best best is to create a custom control library of your own that has a themes/generic.xaml file that defines your custom styles. Then you can use your ow... | <p>Einarl: Right now there isn't a way to "cascade" control templates/styles in Silverlight 2 core. That is to say that you can't set a style/control template for TextBox and expect all TextBoxes to pick it up. It is definitely something the team is looking into for future versions.</p>
| 22,060 |
<p>is it possible to develop DLL for both win32 console and MFC GUI. If yes please explain.</p>
<p>What i want to do is to create dll that contains certain API's for both win32 console and MFC GUI.</p>
| <p>Yes - native dlls are structured in exactly the same way when used with console and MFC applications.</p>
<p>The easiest way to do what you want is to create a new plain Win32 project in visual studio, and in application settings set the Application Type to DLL. Select the export symbols checkbox, and the project w... | <p>There is no reason we cannot do this. You can do it either the traditional dllexport, dllimport way or you can just create a COM dll.</p>
| 40,917 |
<p>I am developing a WebPart (it will be used in a SharePoint environment, although it does not use the Object Model) that I want to expose AJAX functionality in. Because of the nature of the environment, Adding the Script Manager directly to the page is not an option, and so must be added programmatically. I have at... | <p>I was able to get this to work by using the Page's Init event:</p>
<pre><code>protected override void OnInit(EventArgs e)
{
Page.Init += delegate(object sender, EventArgs e_Init)
{
if (ScriptManager.GetCurrent(Page) == null)
{
S... | <p>I had this similar problem and found the best way was to add a global ScriptManager to the masterpage then in the code behind you can add to it by:</p>
<pre><code>ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference(virtualPath));
</code></pre>
| 22,244 |
<p>I've found mention of a data application block existing for ODBC, but can't seem to find it anywhere. If i didn't have a copy of the Access DB application block I wouldn't believe it ever existed either.</p>
<p>Anyone know where to download either the DLL or the code-base from?</p>
<p>--UPDATE: It is NOT include... | <p>Which version of .net are you interested in using the ODBC block on?</p>
<p>The Enterprise library has a Data Access component. It is useful on SQL, Oracle, and ODBC. Just set a different provider name in the .config file
EX: </p>
<p><add name="MyConnection" connectionString="Dsn=Datasource;uid=UserID;pwd=Pa... | <p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=F63D1F0A-9877-4A7B-88EC-0426B48DF275&displaylang=en" rel="nofollow noreferrer">http://www.microsoft.com/downloads/details.aspx?FamilyId=F63D1F0A-9877-4A7B-88EC-0426B48DF275&displaylang=en</a></p>
<p>pretty sure its in there</p>
| 16,282 |
<p>I have a production server running with the following flag: -<strong>XX:+HeapDumpOnOutOfMemoryError</strong></p>
<p>Last night it generated a java-38942.hprof file when our server encountered a heap error. It turns out that the developers of the system knew of the flag but no way to get any useful information from ... | <p>If you want a fairly advanced tool to do some serious poking around, look at <a href="http://www.eclipse.org/mat/" rel="noreferrer">the Memory Analyzer project</a> at Eclipse, contributed to them by SAP.</p>
<p>Some of what you can do is mind-blowingly good for finding memory leaks etc -- including running a form o... | <p>If you want to do a custom analysis of your heapdump then there's:</p>
<ul>
<li><strong>JVM Heap Dump Analysis library</strong> <a href="https://github.com/aragozin/heaplib/tree/master/hprof-heap" rel="nofollow noreferrer">https://github.com/aragozin/heaplib/tree/master/hprof-heap</a></li>
</ul>
<p>This library is f... | 22,484 |
<p>I have an .Net MVC application which runs fine if I use the build in Visual Studio Webserver. If I use the projects property pages to switch to IIS as the webserver and create a virtual directory for my project, any request I send to the server results in a "Directory listing denied" failure.</p>
<p>Does anyone kno... | <h3>With current logging frameworks, the question is moot</h3>
<p>Current logging frameworks like slf4j or log4j 2 don't require guard statements in most cases. They use a parameterized log statement so that an event can be logged unconditionally, but message formatting only occurs if the event is enabled. Message con... | <p>As much as I hate macros in C/C++, at work we have #defines for the if part, which if false ignores (does not evaluate) the following expressions, but if true returns a stream into which stuff can be piped using the '<<' operator.
Like this:</p>
<pre><code>LOGGER(LEVEL_INFO) << "A String";
</code></pre>... | 13,140 |
<p>I'm working on a database design for groups hierarchy used as the foundation of a larger system. Each group can contain other groups, and also 'devices' as leaf objects (nothing goes below device).</p>
<p>The database being used is MS SQL 2005. (Though working in MS SQL 2000 would be a bonus; a solution requiring M... | <p>I'd recommend you actually construct the easiest-to-maintain way (the "standard" parent/child setup) and run at least some basic benchmarks on it.</p>
<p>You'd be surprised what a database engine can do with the proper indexing, especially if your dataset can fit into memory.</p>
<p>Assuming 6 attributes per group... | <p>Pre-order Tree Traversal is very handy. You can make it robust by keeping the traversal numbers up to date with triggers. </p>
<p>A similar technique which I have used is to keep a separate table of (ancestor_id, descendant_id) which lists all ancestors and descendants. This is nearly as good as pre-order traver... | 13,795 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.