instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>In particular, wouldn't there have to be some kind of function pointer in place anyway? </p>
| <p>Non virtual member functions are really just a syntactic sugar as they are almost like an ordinary function but with access checking and an implicit object parameter.</p>
<pre><code>struct A
{
void foo ();
void bar () const;
};
</code></pre>
<p>is basically the same as:</p>
<pre><code>struct A
{
};
void fo... | <p>There's no need for function pointers as it cant change during the runtime.</p>
| 12,678 |
<p>I have an application that writes information to file. This information is used post-execution to determine pass/failure/correctness of the application. I'd like to be able to read the file as it is being written so that I can do these pass/failure/correctness checks in real time.</p>
<p>I assume it is possible to ... | <p>Could not get the example to work using <code>FileChannel.read(ByteBuffer)</code> because it isn't a blocking read. Did however get the code below to work:</p>
<pre><code>boolean running = true;
BufferedInputStream reader = new BufferedInputStream(new FileInputStream( "out.txt" ) );
public void run() {
while( ... | <p>I've never tried it, but you should write a test case to see if reading from a stream after you have hit the end will work, regardless of if there is more data written to the file.</p>
<p>Is there a reason you can't use a piped input/output stream? Is the data being written and read from the same application (if s... | 2,613 |
<p>I've inherited a ASP/VB6 code base (not my forte... yet) and I'm trying tease it apart to figure out the cause on an error message I'm receiving when running the app.</p>
<p>I've traced it back through an event that is being raised in on of my classes. Is there away in windows I can search the bulk of the code base... | <blockquote>
<p>But there's got to be some way in the IDE to do it... right?</p>
</blockquote>
<p>No. There are some plugins for the IDE, such as the <a href="http://www.mztools.com/" rel="nofollow noreferrer">MZ Tools</a> that <em>might</em> help. Otherwise, just use the <code>find</code> tool from the Windows comm... | <p>I have a large legacy code-base in VB6 which needs maintenance from time to time and I have used Microsoft Desktop Search on my local copy to help find variable and method names across the code files.</p>
<p>Also <a href="http://www.interlog.com/~tcharron/grep.html" rel="nofollow noreferrer">Grep</a> is available f... | 33,013 |
<p>I noticed that one edge (which is also the starting point of the print) is always bigger than the other three. Additionally, the walls do not have the same thickness as well. The wall thickness (starting from the thick edge) starts very thin and gets thicker till reaching the thick edge again. Does anyone have a clu... | <p>As Fernando suggests, the problem is likely with your source file. One easy way to verify this is to slice twice, rotating the STL by 90 degrees. If both prints produce fat/thin sides in the same dimension on the print bed, then it's a printer problem. If the fat side rotated with the STL orientation, then the ST... | <p>As Fernando suggests, the problem is likely with your source file. One easy way to verify this is to slice twice, rotating the STL by 90 degrees. If both prints produce fat/thin sides in the same dimension on the print bed, then it's a printer problem. If the fat side rotated with the STL orientation, then the ST... | 906 |
<p>Are there any tools available for calculating the <strong>average number of lines of code per method</strong>?</p>
<p>I want to know the average size of each method, not just the total number of lines in the project. The per method count will allow me to measure how simple each method is.</p>
<p>This will be calcu... | <p>short fast and dirty : grep for ";", count the number of lines, this will give you an estimate of the number of statements.</p>
| <p>I am not sure if it does that, but searching, after your previous post, what is cyclomatic complexity, I went to the related Wikipedia page which pointed to <a href="http://www.geocities.com/sivaram_subr/codeanalyzer/description.htm" rel="nofollow noreferrer" title="Code Analyzer">Code Analyzer</a>.
There they say:<... | 12,594 |
<p>I have been trying to read a picture saved in Access DB as a OLE object in a PictureBox in a C# windows Application.</p>
<p>The code that does this is presented below:</p>
<pre><code> string connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Rajesh\SampleDB_2003.mdb;";
OleDbConnection oC... | <p>Unfortunately I have no good answer for you, but I can tell you that when I tried, I got the same results. Sometimes skipping the first 78 bytes of the byte array worked, sometimes it didn't.</p>
<p>This is because the OLE Object datatype stores some kind of header in the field, so that Access knows what type of OL... | <p>Your bytestream is corrupted somehow, becouse I tried the exact method of yours but filled the byte array with PNG data from a file instead.</p>
<p>I would suggest creating two streams, one from the database, and one from the file that was the source of the image in the database. Then compare them byte by byte. If ... | 26,792 |
<p>When my browser renders the following test case, there's a gap below the image. From my understanding of CSS, the bottom of the blue box should touch the bottom of the red box. But that's not the case. Why?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div cla... | <p>Inline elements are vertically aligned to the baseline, not the very bottom of the containing box. This is because text needs a small amount of space underneath for descenders - the tails on letters like lowercase 'p'. So there is an imaginary line a short distance above the bottom, called the baseline, and inline... | <p>Remove the line break before the tag, so that it directly follows the tag with no blanks between it.</p>
<p>I don't know why, but for the Internet Explorer, this works.</p>
| 15,736 |
<p>I have a circular, statically allocated buffer in C, which I'm using as a queue for a <strike>depth</strike> breadth first search. I'd like have the top N elements in the queue sorted. It would be easy to just use a regular qsort() - except it's a circular buffer, and the top N elements might wrap around. I could, o... | <p>I think you need to take a big step back from the problem and try to solve it as a whole - chances are good that the semi-sorted circular buffer is not the best way to store your data. If it is, then you're already committed and you will have to write the buffer to sort the elements - whether that means performing ... | <p>How about somthing like this example here. This example easely sorts a part or whatever you want without having to redefine a lot of extra memory.
It takes inly two pointers a status bit and a counter for the for loop.</p>
<pre><code>#define _PRINT_PROGRESS
#define N 10
BYTE buff[N]={4,5,2,1,3,5,8,6,4,3};
BYTE *a =... | 35,616 |
<p>On a Use Case diagram can you show things that an actor <strong>cannot</strong> do, for example because they won't have permissions to do it?</p>
<p>Or is it just implied due to the fact that they won't have a line joining them to the particular use case?</p>
| <p>If the Use Case you are diagramming is the case where an actor attempts to do something that is not permitted and is then denied, then yes, I would show it.</p>
<p>Otherwise, I would stick to only including things that are actually part of the use case.</p>
| <p>You might model Role actors that can do the task. You could then have another use case that has the original actor attempting to acquire the given Role.</p>
| 23,323 |
<p>Using reflection, I need to load 2 different versions of the same assembly. Can I load the 2 versions in 2 different AppDomains in the same process? </p>
<p>I need to do some data migration from the old version of the app to the new version.
Please let me know if this is possible or should I use 2 separate process... | <p>If you are doing it at design time (which you indicate you are not) this should help you: </p>
<p><a href="http://blogs.msdn.com/abhinaba/archive/2005/11/30/498278.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/abhinaba/archive/2005/11/30/498278.aspx</a></p>
<p>If you are doing it dynamically through reflec... | <p>If you are doing it at design time (which you indicate you are not) this should help you: </p>
<p><a href="http://blogs.msdn.com/abhinaba/archive/2005/11/30/498278.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/abhinaba/archive/2005/11/30/498278.aspx</a></p>
<p>If you are doing it dynamically through reflec... | 8,248 |
<p>What is the functional equivalent of <a href="http://msdn.microsoft.com/en-us/netframework/aa663324.aspx" rel="noreferrer">Windows Communication Foundation</a> in Java 6?</p>
| <p>WCF offers several communication options. A nice presentation is <a href="http://www.davidchappell.com/articles/white_papers/WCF_Diversity_v1.0.docx" rel="noreferrer">this white paper</a> by David Chappel. There the following options are described:</p>
<ul>
<li>Interoperable Communication using SOAP and WS-*</li>
<... | <p><a href="http://ws.apache.org/axis/" rel="nofollow noreferrer">Apache Axis</a> is a good start for the web service part. If you need the messaging queue check out <a href="http://qpid.apache.org/" rel="nofollow noreferrer">Apache Qpid</a> other then that you will probably need to ask about the exact problem you are ... | 35,083 |
<p>Given the following, how could I insert rows in my db? (Or what should I correct in my schema?)</p>
<p>Models:</p>
<pre><code>class Item < ActiveRecord::Base
has_many :tran_items
has_many :transactions, :through => :tran_items
end
class TranItem < ActiveRecord::Base
... | <p>(edit: the model name "Transaction" may cause you some problems due to ActiveRecord::Transactions. <a href="https://rails.lighthouseapp.com/projects/8994/tickets/993-having-column-named-transaction-in-a-model-leads-to-weird-behavior" rel="nofollow noreferrer">There is a lighthouse ticket</a>.)</p>
<p>Your schema is... | <p>If I understood correctly.</p>
<pre><code>item = Item.new(:name => "item")
item.transactions.build(:name => "transaction")
item.save!
</code></pre>
| 36,237 |
<p>I've seen this syntax a couple times now, and it's beginning to worry me,</p>
<p>For example:</p>
<pre><code>iCalendar iCal = new iCalendar();
Event evt = iCal.Create<Event>();
</code></pre>
| <p>It's a Generic Method, Create is declared with type parameters, and check this links for more information:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/ms379564(vs.80).aspx" rel="nofollow noreferrer">An Introduction to C# Generics</a></li>
<li><a href="https://learn.microsoft.com/en-us/dotnet/csha... | <p>This syntax is just applying generics to a method. It's typically used for scenarios where you want to control the return type of the method. You will find this kind of syntax a lot in code that uses a IoC framework.</p>
| 39,321 |
<p>How do I rewrite a URL in ASP.NET?</p>
<p>I would like users to be able to go to</p>
<pre><code>http://www.website.com/users/smith
</code></pre>
<p>instead of</p>
<pre><code>http://www.website.com/?user=smith
</code></pre>
| <p>Try the Managed Fusion Url Rewriter and Reverse Proxy:</p>
<p><a href="http://urlrewriter.codeplex.com" rel="noreferrer">http://urlrewriter.codeplex.com</a></p>
<p>The rule for rewriting this would be:</p>
<pre><code># clean up old rules and forward to new URL
RewriteRule ^/?user=(.*) /users/$1 [NC,R=301]
# rew... | <p>I have used an httpmodule for url rewriting from <a href="http://www.urlrewriting.net/" rel="nofollow noreferrer">www.urlrewriting.net</a> with great success (albeit I believe a much earlier, simpler version)</p>
<p>If you have very few actual rewriting rules then url mappings built in to .NET 2.0 are probably an e... | 2,444 |
<p>I want to use a signals/slots library in a project that doesn't use QT. I have pretty basic requirements: </p>
<ol>
<li>Connect two functions with any number of parameters.</li>
<li>Signals can be connected to multiple slots.</li>
<li>Manual disconnection of signal/slot connection.</li>
<li>Decent performance - the... | <p>First, try with boost::signal anyway. Don't assume it will not be fast enough until you try in your specific case that is your application</p>
<p>If it's not efficient enough, maybe something like <a href="http://www.codeproject.com/KB/cpp/FastDelegate.aspx" rel="nofollow noreferrer">FastDelegate</a> will suit your... | <p>An another option can be <a href="https://github.com/yigityuce/YSignalSlot" rel="nofollow">YSignalSlot</a>. I used it. I think it is pretty good.</p>
| 46,967 |
<p>I have an <a href="https://en.wikipedia.org/wiki/Microsoft_Office#Windows_versions" rel="nofollow noreferrer">Office 2007</a> (specifically <a href="https://en.wikipedia.org/wiki/Microsoft_Outlook#Outlook_2007" rel="nofollow noreferrer">Outlook 2007</a>) add in created in Visual Studio 2008.</p>
<p>When I... | <p>You are not required to sign EXE files, but you need to sign DLL files for deployment. Your Office add-in is in the form of a DLL file, so it must be signed. Your Windows Forms project is linked into an EXE file, hence it does not need to be signed.</p>
<p>See the relevant MSDN page, <a href="http://msdn.microsoft.... | <p>While you don't have to sign the manifest any more with Windows Forms, <a href="http://en.wikipedia.org/wiki/Windows_Presentation_Foundation" rel="nofollow noreferrer">WPF</a> and console applications, <a href="http://en.wikipedia.org/wiki/Visual_Studio_Tools_for_Office" rel="nofollow noreferrer">VSTO</a> solutions ... | 28,392 |
<p>I'm inserting multiple records into a table A from another table B. Is there a way to get the identity value of table A record and update table b record with out doing a cursor?</p>
<pre><code>Create Table A
(id int identity,
Fname nvarchar(50),
Lname nvarchar(50))
Create Table B
(Fname nvarchar(50),
Lname nvarcha... | <p>Use the ouput clause from 2005:</p>
<pre><code>DECLARE @output TABLE (id int)
Insert into A (fname, lname)
OUTPUT inserted.ID INTO @output
SELECT fname, lname FROM B
select * from @output
</code></pre>
<p>now your table variable has the identity values of all the rows you insert.</p>
| <p>MBelly is right on the money - But then the trigger will always try and update table B even if that's not required (Because you're also inserting from table C?).</p>
<p>Darren is also correct here, you can't get multiple identities back as a result set. Your options are using a cursor and taking the identity for ea... | 12,155 |
<p>I'm an old (but not too old) Java programmer, that decided to learn C++. But I have seen that much of C++ programming style, is... well, just damn ugly!</p>
<p>All that stuff of putting the class definition in a header file, and the methods in a different source file- Calling functions out of nowhere, instead of us... | <p>In addition to what others have said here, there are even more important problems:</p>
<p>1) Large translation units lead to longer compile times and larger
object file sizes.</p>
<p>2) Circular dependencies! And this is the big one. And it can almost
always be fixed by splitting up headers and source:</p>... | <p>I worry from the tone of your question that you may be reading some bad C++ code in learning C++. Well-written code is usually not ugly in any language. As a starting point, you might try the <a href="http://www.parashift.com/c++-faq-lite/index.html" rel="nofollow noreferrer">online C++ FAQ</a>, especially the cha... | 48,745 |
<p>I have two STL containers that I want to merge, removing any elements that appear more than once. For example:</p>
<pre><code>typedef std::list<int> container;
container c1;
container c2;
c1.push_back(1);
c1.push_back(2);
c1.push_back(3);
c2.push_back(2);
c2.push_back(3);
c2.push_back(4);
container c3 = u... | <p>For an unordered lists, your set trick is probably one of the best. It each insert should be O(log n), with N inserts required, and traversing will be O(n), giving you O(N*log n).
The other option is to run std::sort on each list individually and then walk through them in parallel using <a href="http://msdn.microso... | <p>Use the <a href="https://en.cppreference.com/w/cpp/algorithm/set_union" rel="nofollow noreferrer">std::set_union algorithm</a> from the STL. You'll need to sort your input lists first though -- or create copies of your input lists, sort them, then use std::set_union.</p>
| 35,585 |
<p>What is Lazy Loading?</p>
<p>[Edit after reading a few answers]
Why do people use this term so often? </p>
<p>Say you just use a ASP/ADO recordset and load it with data or ADO.NET Datasource for a gridview.</p>
<p>I guess I should have asked why people use the term Lazy Loading, what "other" types are their?</p>
| <p>It's called lazy loading because, like a lazy person, you are putting off doing something you don't want to. The opposite is Eager Loading, where you load something right away, long before you need it.</p>
<p>If you are curious why people might use lazy loading, consider an application that takes a LOOOOONG time t... | <p>According to geeksforgeeks, Lazy loading is a software design pattern where the initialization of an object occurs only when it is actually needed and not before to preserve the simplicity of usage and improve performance.</p>
<p><a href="https://www.geeksforgeeks.org/lazy-loading-design-pattern/" rel="nofollow no... | 5,693 |
<p>Yesterday I tried to get started with Java RMI. I found this sun tutorial (<a href="http://java.sun.com/docs/books/tutorial/rmi/index.html" rel="nofollow noreferrer">http://java.sun.com/docs/books/tutorial/rmi/index.html</a>) and started with the server implemantation. But everytime I start the pogram (the rmiregist... | <p>Grant of all permissions to all code is a really bad. Any RMI client could do what it wanted as logged in user. In general try to restrict permissions as much as reasonable, particularly when you don't know where the code has come from.</p>
<p>Back to the question...</p>
<pre><code>-Djava.rmi.server.codebase=file:... | <p>I think the exception is actually coming out of rmiregistry. This part of the stack trace is what makes me think so. The stub for rmiregistry is receiving the exception and passing it back up as the result of the attempt to rebind.</p>
<pre>
at sun.rmi.transport.StreamRemoteCall.<b>exceptionReceivedFromServer</... | 21,696 |
<p>Just found this out the hard way. I wanted to pop up a FontDialog to allow the user to choose a font.. one of those familiar dialogs..</p>
| <p><strong>Not all of them have equivalents.</strong><br>
The FontDialog for instance doesnt.. (grumble grumble). This page has the complete lowdown.. posting since it may be useful just as a mental note.
<a href="http://msdn.microsoft.com/en-us/library/ms750559.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com... | <p>I know a team working on a WPF application for a couple of years by now, and their feedback is that WPF is still a no match to WinForms when it comes to complicated controls (advanced data grids, tree views and the like). Basic controls are ok though.</p>
| 14,598 |
<p>Just looking at ways of getting named constants in python.</p>
<pre><code>class constant_list:
(A_CONSTANT, B_CONSTANT, C_CONSTANT) = range(3)
</code></pre>
<p>Then of course you can refer to it like so: </p>
<pre><code>constant_list.A_CONSTANT
</code></pre>
<p>I suppose you could use a dictionary, using st... | <p>For 2.3 or after:</p>
<pre><code>class Enumerate(object):
def __init__(self, names):
for number, name in enumerate(names.split()):
setattr(self, name, number)
</code></pre>
<p>To use:</p>
<pre><code> codes = Enumerate('FOO BAR BAZ')
</code></pre>
<p><code>codes.BAZ</code> will be 2 and so on. </p>
<... | <p>In Python, strings are immutable and so they are better for constants than numbers. The best approach, in my opinion, is to make an object that keeps constants as strings:</p>
<pre><code>class Enumeration(object):
def __init__(self, possibilities):
self.possibilities = set(possibilities.split())
de... | 23,924 |
<p>When uninstalling my application, I'd like to configure the <a href="http://en.wikipedia.org/wiki/WiX" rel="noreferrer">Wix</a> setup to remove all the files that were added <strong>after the original installation</strong>. It seems like the uninstaller removes only the directories and files that were originally ins... | <p>Use <a href="http://wixtoolset.org/documentation/manual/v3/xsd/wix/removefile.html" rel="noreferrer">RemoveFile element</a> with On="<strong>uninstall</strong>". Here's an example:
</p>
<pre><code><Directory Id="CommonAppDataFolder" Name="CommonAppDataFolder">
<Directory Id="MyAppFolder" Name="My">
... | <p>Not an WIX expert, but could a possible (simpler?) solution to this be to run the <a href="http://wix.sourceforge.net/manual-wix3/qtexec.htm" rel="noreferrer">Quiet Execution Custom Action</a> which is part of the built in extensions of WIX?</p>
<p>Could run the <a href="http://www.computerhope.com/rmdirhlp.htm" re... | 23,809 |
<p>I have an asp.net ascx control file and I have put the control on an aspx page. The aspx page has a button in which when I press enter on the keyboard, I want it to fire the event handler for the button. Is there a way to set this?</p>
<p>I am using a master page with a button already on it, so now when I press t... | <p>DefaultButton also works in panels, so you can set a default button in each panel and have the Enter key click the button in whichever panel currently has focus.</p>
| <p>Just a small note:
You cannot use the 'defaultButton' attribute if your button is a LinkButton, it doesn't work for that, taken from here:
<a href="http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlform.defaultbutton.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.... | 45,649 |
<p>I have a big list of global variables that each have their own setup function. My goal is to go through this list, call each item's setup function, and generate some stats on the data loaded in the matching variable. However, what I'm trying now isn't working and I need help to make my program call the setup functio... | <p>It's because MAKE-SYMBOL returns an uninterned symbol. You should use INTERN instead.</p>
| <p>I'd either use INTERN or (possibly, you'd have to profile to be 100% sure it's helpful) a helper function that does the string concatenation and the initial find, then caches the result in a hashtable (keyed off the original symbol). That may be faster than a pure INTERN/CONCATENATE solution, would potentially gener... | 37,633 |
<p>I am trying to figure out how to wire up Auto Bed Leveling (ABL) on my Ender 3 using the optocoupler and inductive proximity sensor below. </p>
<p>I cannot figure out how to wire it all together, all the tutorials I have found are for 2 and 3 wire per side of the optocoupler.</p>
<p><a href="https://i.stack.imgur... | <p>Connecting is pretty straightforward like the other modules, difference is an extra input lead.</p>
<p>From e.g. <a href="https://www.desertcart.ae/products/92694483-noyito-optocoupler-isolation-mos-fet-10-a-dc-2-7-27-v-high-power-field-effect-tube-driver-module-0-20-khz-pwm-switch-control-board-development-board-m... | <p>This is a bit of an <em>addendum</em> to 0scar's answer, as I didn't want to edit it in to his post.</p>
<p>For completion, the sensor's internal schematic is on the side of the sensor itself<sup>1</sup>:</p>
<p><a href="https://i.stack.imgur.com/DbsjD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.c... | 1,290 |
<p>I'm building a .NET client application (C#, WinForms) that uses a web service for interaction with the database. The client will be run from remote locations using a WAN or VPN, hence the idea of using a web service rather than direct database access.</p>
<p>The issue I'm grappling with right now is how to handle d... | <p>I don't think you want your web service to talk directly to the database. You probably want your service to interact with some type of business components who in turn interact with a data access layer. Any concurrency exceptions can be passed from the DAL up to the business layer where they can be handled so that ... | <p>If your collisions occur infrequently enough that they can be resolved manually, a simple solution is to add an update trigger that copies a row's pre-update values to an audit table. This way the most recent write is the "winner", but no data is ever lost to an overwrite, and an administrator can restore an earlie... | 23,463 |
<p>Where is a good place to get started learning how to use jQuery? It seems to be all the rage nowadays. I know some basics of JavaScript but I'm by no means an expert.</p>
| <p>Officially from jQuery
<a href="http://docs.jquery.com/Tutorials" rel="noreferrer">http://docs.jquery.com/Tutorials</a></p>
<p>Or try anything on this site that compiles a bunch of jQuery learning material:</p>
<p><a href="http://www.noupe.com/tutorial/51-best-of-jquery-tutorials-and-examples.html" rel="noreferrer... | <p>There are a lot of them out there, google it, and the jQuery official site itself has a huge list of tutorials and excellent documentation with working examples. If that's not enough, try <a href="http://jqueryfordesigner.com" rel="nofollow noreferrer">http://jqueryfordesigner.com</a>, <a href="http://bassistance.de... | 20,376 |
<p>My main browsers (FF and Chrome) are both configured for a 12 pixel font. In both browsers the font picker shows a font preview, and in both they are the same size and a comfortable size for reading web sites. My IE doesn't allow me to set font size, but seems to default to something a little bit larger than Chrom... | <p>Most browsers - if not all of them - set the default font size to 16px. Many websites use relative font sizing too. This will cause you a problem if your browser's font size is lower than this.</p>
<p>Consider the case where you have a default font size of 16px in your browser. When the website font is 1.0em, it wi... | <p>Setting a font to a % or an em measurement is <strong>not</strong> a dumb thing, in fact it is W3C recommended!</p>
| 43,654 |
<p>I have an internal enterprise app that currently consumes 10 different web services. They're consumed via old style "Web References" instead of using WCF.</p>
<p>The problem I'm having is trying to work with the other teams in the company who are authoring the services I'm consuming. I found I needed to capture the... | <p>This seems to be a common question, as I just asked it and was told to look <a href="https://stackoverflow.com/questions/300674/getting-raw-soap-data-from-a-web-reference-client-running-in-aspnet">here</a>.</p>
<p>You don't have to edit the generated <code>Reference.cs</code>. You can reference the extension in yo... | <p>I used the following code is an example of how I captured SOAP requests in a application written a while back.</p>
<pre><code><System.Diagnostics.Conditional("DEBUG")> _
Private Sub CheckHTTPRequest(ByVal functionName As String)
Dim e As New UTF8Encoding()
Dim bytes As Long = Me.Context.R... | 7,782 |
<p>Hello I was writing a Regular Expression (first time in my life I might add) but I just can't figure out how to do what I want. So far, so good since I already allow only Letters and spaces (as long as it's not the first character) now what I'm missing is that I don't want to allow any numbers in between the charact... | <p>OK, what you need is:</p>
<pre><code>/^[a-zA-Z][\sa-zA-Z]*$/
</code></pre>
<p>This matches:</p>
<pre><code>^ - start of line
[a-zA-Z] - any letter
[\sa-zA-Z]* - zero or more letters or spaces
$ - the end of the line
</code></pre>
<p>If you want to ensure that it also ends in a letter then ... | <p>If you only want to allow letters and spaces, then what you have is almost correct:</p>
<pre><code>/^[a-zA-Z][\sa-zA-Z]*$/
</code></pre>
<p>The <code>$</code> at the end signifies the end of the string.</p>
<p><em>Edited to correct answer, thanks to @Alnitak</em></p>
| 37,020 |
<p>I am creating an application which displays some messages and its directions in the DataGridView. I would like to replace some columns content with pictures. For example I would like to replace number 0 which represents the incoming call with a green arrow (some .jpg image).</p>
<p>Does anyone know how this could b... | <p>We stored the images in the resource file as BMP files. Then, we handle the CellFormatting event in the DataGridView like this:</p>
<pre><code> private void messageInfoDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
// Is this the correct column? (It's actually a D... | <p>GridViews have the ability to use an image field as opposed to a data bound field. This sounds like it would do the trick.</p>
| 32,788 |
<p>I'm not sure how "tests first" works and I'd like to hear arguments about when and why one would take this approach.</p>
<p>I hear that it's often recommended to write tests and mock things before writing a single line of implementation. However, I can't help but think that it doesn't fit every situation.
For inst... | <p>The over-arching rule is: Do the riskiest items first.</p>
<p>Doing the test-cases first is, implicitly, arguing that the riskiest part of the coding is miscommunications and misunderstandings of the interfaces and behaviour of the objects that are being created.</p>
<p>For many projects, that may well be true, an... | <p>I find that writing tests first does not work so well when I'm still construction the "story" of my code. It is hard to write tests when I'm unsure what the interfaces look like. I might write stub code to flesh out the classes and interfaces without thinking about tests. But I try to get to tests as quick as possib... | 41,312 |
<p>The interop library is slow and needs MS Office installed.
Many times you don't want to install MS Office on servers.</p>
<p>I'd like to use <a href="http://en.wikipedia.org/wiki/Apache_POI" rel="nofollow noreferrer">Apache POI</a>, but I'm on .NET.</p>
<p>I need only to extract the text portion of the files, not... | <p>For all MS Office versions:</p>
<ul>
<li>You could use the third-party components like <a href="http://www.textcontrol.com/" rel="nofollow noreferrer">TX Text Controls</a> for Word and <a href="http://www.tmssoftware.com/site/flexcelnet.asp" rel="nofollow noreferrer">TMS Flexcel Studio</a> for Excel</li>
</ul>
<p>... | <p>OpenOffice.</p>
<p>You can program against it and have it do a lot for you, without spending the money on a license for the server, or have the vulnerability associated with it on your server.</p>
| 18,476 |
<p>I'm looking for something that will monitor Windows directories for size and file count over time. I'm talking about a handful of servers and a few thousand folders (millions of files).</p>
<p>Requirements:</p>
<ul>
<li>Notification on X increase in size over Y time</li>
<li>Notification on X increase in file coun... | <p>You might want to take a look at <a href="http://www.codeplex.com/polymon" rel="nofollow noreferrer">PolyMon</a>, which is an open source systems monitoring solution. It allows you to write custom monitors in any .NET language, and allows you to create custom PowerShell monitors. </p>
<p>It stores data on a SQL S... | <p><a href="http://sourceforge.net/projects/dirviewer/" rel="nofollow noreferrer">http://sourceforge.net/projects/dirviewer/</a> -- DirViewer is a light pure java application for directory tree view and recursive disk usage statistics, using JGoodies-Looks look and feel similar to windows XP.</p>
| 22,161 |
<p>Building a 3-D printer is obviously a huge undertaking.</p>
<p>Does anyone know of any reasonably cheap guides to build my own 3-D printer?</p>
| <p>Building a 3-D printer is actually very easy, assuming that you are electronically and mechanically competent, and there are a whole bunch of websites devoted to doing just that. The principal of which would be the <a href="http://reprap.org/wiki/Main_Page" rel="noreferrer">RepRapWiki</a>.</p>
<p>There are a number... | <p>If you just want to build your own, get a kit. There are several out there. Most kits take from 1-5 days to complete depending on the kit.</p>
<p>If you want to design your own is quite a different story. The effort is totally dependent on how much you want to do yourself. My guess is the statement that you don... | 638 |
<p>Is it possible to use a converter within a style? For instance I am trying to create a styled <code>TextBlock</code> whose text resizes based on the <code>ActualHeight</code> property of the <code>TextBlock</code>. The resizing would be done via a converter.</p>
| <p>Yes, this is possible. For example:</p>
<pre><code><Style TargetType="TextBlock">
<Setter Property="FontSize">
<Setter.Value>
<Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}">
<Binding.Converter>
<MyConve... | <p>I managed to get something similar to work by using:</p>
<pre><code><Setter Property="Text">
<Setter.Value>
<Binding Path="CompanyName">
<Binding.Converter>
<conv:UppercaseConverter/>
</Binding.Converter>
</Binding>
</Setter.Value>
<... | 49,647 |
<p>I can reset FPU's CTRL registers with this:</p>
<p><a href="http://support.microsoft.com/kb/326219" rel="nofollow noreferrer">http://support.microsoft.com/kb/326219</a></p>
<p>But how can I save current registers, and restore them later?</p>
<p>It's from .net code..</p>
<p>What I'm doing, is from Delphi calling ... | <pre><code>uses
SysUtils;
var
SavedCW: Word;
begin
SavedCW := Get8087CW;
try
Set8087CW($027f);
// Call .NET code here
finally
Set8087CW(SavedCW);
end;
end;
</code></pre>
| <p>Same function you use to change them: <code>_controlfp()</code>. If you pass in a mask of 0, the current value won't be altered, but it <em>will</em> be returned - save it, and use a second call to <code>_controlfp()</code> to restore it later.</p>
| 23,239 |
<p>If I create an application on my Mac, is there any way I can get it to run on an iPhone without going through the app store?</p>
<p>It doesn't matter if the iPhone has to be jailbroken, as long as I can still run an application created using the official SDK. For reasons I won't get into, I can't have this program ... | <h1>Official Developer Program</h1>
<p>For a standard iPhone you'll need to pay the US$99/yr to be a member of the developer program. You can then use the adhoc system to install your application onto up to 100 devices. The developer program has the details but it involves adding UUIDs for each of the devices to your ... | <p>*Changes/Notes to make this work for <strong>Xcode 3.2.1</strong> and <strong>iPhone SDK 3.1.2</strong></p>
<p>Manual Deployment over WiFi</p>
<p>2) Be sure to restart Xcode after modifying the Info.plist</p>
<p>3) The "uicache" command is not found, using killall -HUP SpringBoard worked fine for me.</p>
<p>Othe... | 5,813 |
<p>This is a little confusing to explain, so bear with me here...</p>
<p>I want to set up a system where a user can send templated emails via my website, except it's not actually sent using my server - it instead just opens up their own local mail client with an email ready to go. The application would fill out the bo... | <p>The way I'm doing it now is basically like this:</p>
<p>The HTML:</p>
<pre><code><textarea id="myText">
Lorem ipsum...
</textarea>
<button onclick="sendMail(); return false">Send</button>
</code></pre>
<p>The Javascript:</p>
<pre><code>function sendMail() {
var lin... | <p>Send request to <a href="http://mandrillapp.com" rel="nofollow">mandrillapp.com</a>:</p>
<pre><code>var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
console.log(xhttp.responseText);
}
}
xhttp.open('GET', 'https://ma... | 34,097 |
<p>I'm trying to create a css reset that targets only my control. So the HTML will look something like this:</p>
<pre><code><body>
<img class="outterImg" src="sadkitty.gif" />
<div id="container" class="container">
<img class="innerImg" src="sadkitty.gif" />
<div class="subContai... | <p>The selector
<code>.innerImg img</code>
refers to an img element <em>inside</em> an element with the class innerImg. There's nothing like that in your document.</p>
<p>What you probably want there is <code>img.innerImg</code> .</p>
<p>Beyond that, there is a short calculation for <a href="http://www.w3.org/TR/css... | <p>I suspect this results in close to what you wanted. </p>
<pre><code>img
{
border: solid 3px red;
width: 50px;
}
.container .innerImg, .container div
{
border: solid 3px blue;
width: 100px;
}
.container .subContainer
{
border: none;
}
.subContainer .innerImg
{
border: sol... | 43,401 |
<p>I am looking for a CMS that would be incredibly user-friendly and would have the following features:</p>
<ul>
<li>really simple message board (no login required)</li>
<li>family tree</li>
<li>story telling area</li>
<li>photo section</li>
<li>news section</li>
</ul>
<p>Is there anything out there like this that is... | <p>I can understand your stipulation that your users (family) shouldn't have to sign up - but without a sign-in, your site will be a free-for-all for spammers, hackers and other bored Internet denizens. </p>
<p>That said, my suggestion is to use WordPress for a front end - register your family members yourself, and us... | <p>I've setup <a href="http://www.cmsmadesimple.org/" rel="nofollow noreferrer">CMS Made Simple</a> a couple times now. It's all PHP and you can edit it to your heart's content. Give it a try.</p>
| 4,504 |
<p>I'm looking for best practices for performing strict (whitelist) validation/filtering of user-submitted HTML.</p>
<p>Main purpose is to filter out XSS and similar nasties that may be entered via web forms. Secondary purpose is to limit breakage of HTML content entered by non-technical users e.g. via WYSIWYG editor... | <p>I've tested all exploits I know on HTML Purifier and it did very well. It filters not only HTML, but also CSS and URLs.</p>
<p>Once you narrow elements and attributes to innocent ones, the pitfalls are in attribute content – <code>javascript:</code> pseudo-URLs (IE allows tab characters in protocol name - <code>jav... | <p>The W3C has a big open-source package for validating HTML available here:</p>
<p><a href="http://validator.w3.org/" rel="nofollow noreferrer">http://validator.w3.org/</a></p>
<p>You can download the package for yourself and probably implement whatever they're doing. Unfortunately, it seems like a lot of DOM parse... | 24,257 |
<p>I'm trying to create Excel 2007 Documents programmatically. Now, there are two ways I've found:</p>
<ul>
<li>Manually creating the XML, as outlined in <a href="https://stackoverflow.com/questions/150339/generating-an-excel-file-in-aspnet#150368">this post</a></li>
<li>Using a Third Party Library like <a href="http:... | <p>You could try using the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&DisplayLang=en" rel="noreferrer">Office Open XML SDK</a>. This will allow you to create Excel files in memory using say a <code>MemoryStream</code> and much more easily than generating a... | <p>I used to generate <a href="http://msdn.microsoft.com/en-us/library/aa223586(office.11).aspx" rel="nofollow noreferrer">Wordprocessing Markup</a> documents using a library of functions for creating the correct XML for tables and paragraphs.</p>
<p>I then just changed the MIME type for the Response header to be a wo... | 18,493 |
<p>How can I programmatically generate keypress events from Javascript code running in Safari? It looks like WebKit is using the DOM level 3 model for creating keyboard events from Javascript, and the DOM level 3 keyboard event model does not support the keypress event. Is there another way that I can use?</p>
<p>I'... | <p>Use the TextEvent (introduced by DOM3). Since you're looking to generate keypress events, I'm guessing you're working with characters. In the code below, textToInsert is a string, and textarea the element I'm dispatching the event to.</p>
<pre><code>var eventObject = document.createEvent('TextEvent');
eventObject.i... | <p><a href="http://docs.jquery.com/Events/keypress#fn" rel="nofollow noreferrer">http://docs.jquery.com/Events/keypress#fn</a></p>
<p>In other words, you attach a keypress event to some element. Using an element with the ID of "someid", for example:</p>
<pre><code><script language="text/javascript" src="jquery.js"... | 44,949 |
<p>Like most developers, I'm a business developer, which in essence consists of slapping a UI onto some back-end data store. (We all know there's a lot more to it than that, but that's usually what it boils down to.)</p>
<p>I understand that game development is very different from business development, but I'm having ... | <p>I'm in game development but came from business development long ago. Game development is very rigorous in mathematics if you work on the physics or graphics side. Even AI can need quite a bit of mathematics for the low-level stuff. The hardware usually takes care of a lot of the polygon manipulation math as far as d... | <p>Performance is really the difference, from what I can tell. </p>
<p>Technologywise, games are usually Windows/C++ driven.</p>
| 25,757 |
<p>I'm writing a report view of an audit trail, and I need to display this in a .jsp. What's the "best" way to get the data from the database to the screen?</p>
<p>We're using Spring for dependency injection, Data Access Objects, and Hibernate.
I can use hibernate or straight jdbc for this report.</p>
<p>If I load al... | <p>It seems like this is a natural place to use pagination of your Hibernate results -- run the query at the Servlet level, and paginate results in a way similar to how this person describes:</p>
<p><a href="http://blog.hibernate.org/Bloggers/Everyone/Year/2004/Month/08/Day/14#pagination" rel="nofollow noreferrer">htt... | <p>Just use paging and only load a certain number of rows on the page at a time.</p>
| 12,144 |
<p>Why must <code>Type.Equals(t1, t2)</code> be used to determine equivalent types, and not the equality operator (e.g. for VB.NET, <code>t1 = t2</code>)? </p>
<p>It seems inconsistent with other parts of the .NET API.</p>
<p>Example in VB.NET:</p>
<p><code>If GetType(String) = GetType(String) Then
Debug.Print(... | <p>Given the way types are loaded, that surprises me. Where did you hear this from?</p>
<p>The <a href="http://msdn.microsoft.com/en-us/library/3ahwab82.aspx" rel="nofollow noreferrer">docs for System.Type.Equals(Type)</a> suggest that it's comparing via the <a href="http://msdn.microsoft.com/en-us/library/system.type... | <p>Looking at the source code in Reflector, I can't see how Type.Equals(t1,t2) would be handled any differently than t1 = t2. (There is actually no Type.Equals; it will actually call Object.Equals).</p>
<p>In C#, T1 == T2 works just fine.</p>
| 36,931 |
<p>I'm not sure if the title is very clear, but basically what I have to do is read a line of text from a file and split it up into 8 different string variables. Each line will have the same 8 chunks in the same order (title, author, price, etc). So for each line of text, I want to end up with 8 strings.</p>
<p>The fi... | <p>The best way is to not use a StringTokenizer at all, but use String's <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#split(java.lang.String)" rel="nofollow noreferrer">split</a> method. It returns an array of Strings, and you can get the length from that.</p>
<p>For each line in your file y... | <p>Is this a CSV or similar file by any chance? If so, there are libraries to help you, for example <a href="http://commons.apache.org/sandbox/csv/" rel="nofollow noreferrer">Apache Commons CSV</a> (link to alternatives on their page too). It will get you a String[] for each line in the file. Just check the array size ... | 29,255 |
<p>If I write Java software for a BlackBerry, can it be decompiled using freely available tools similar to <a href="http://www.red-gate.com/products/reflector/" rel="nofollow noreferrer">.NET Reflector</a>, or is it a more elaborate process?</p>
| <p>Software you write for any language, any platform, can be decompiled. It doesn't matter what code mangling (obfuscation) tools you use, it can be decompiled.</p>
<p>Any attempt to worry about this is going to be a waste of time. Just like DRM ;p</p>
<p>But the real point is, and I wish I had the link to the discus... | <p>Pretty much all software can be decompiled. The question is only the amount of involvement and resources required to pull it off.</p>
| 49,603 |
<p>What exactly are the advantages and disadvantages to using a register-based virtual machine versus using a stack-based virtual machine?</p>
<p>To me, it would seem as though a register based machine would be more straight-forward to program and more efficient. So why is it that the JVM, the CLR, and the Python VM ... | <p>Implemented in hardware, a register-based machine is going to be more efficient simply because there are fewer accesses to the slower RAM. In software, however, even a register based architecture will most likely have the "registers" in RAM. A stack based machine is going to be just as efficient in that case.</p>
<... | <p>Stack based VMs are easier to generate code for.</p>
<p>Register based VMs are easier to create fast implementations for, and easier to generate highly optimized code for.</p>
<p>For your first attempt, I recommend starting with a stack based VM.</p>
| 19,840 |
<p>For a requirement i was asked to export information into a custom entity that was created in MS CRM 4.0. I am trying to do this programmatically and I have not found a single code that actually accomplishes this. I wrote code to check if a certain value for a field exists in the entity but creating a new entity seem... | <p>To create a custom entity from code, you need to use the MetadataService web service. The 'CreateEntity' method is used to create custom entities.</p>
<p>The CRM SDK for v4.0 shows you how:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/cc156288.aspx" rel="nofollow noreferrer">CreateEntity Message (Metad... | <p>Whats wrong with using the import from CSV function within MSCRM 4.0? It caters for custom entities (3.0 didn't) and allows good mapping functions and saving of the mappings?</p>
| 31,932 |
<p>To do the equivalent of Python list comprehensions, I'm doing the following:</p>
<pre><code>some_array.select{|x| x % 2 == 0 }.collect{|x| x * 3}
</code></pre>
<p>Is there a better way to do this...perhaps with one method call?</p>
| <p>If you really want to, you can create an Array#comprehend method like this:</p>
<pre><code>class Array
def comprehend(&block)
return self if block.nil?
self.collect(&block).compact
end
end
some_array = [1, 2, 3, 4, 5, 6]
new_array = some_array.comprehend {|x| x * 3 if x % 2 == 0}
puts new_array... | <p>I think the most list comprehension-esque would be the following:</p>
<pre><code>some_array.select{ |x| x * 3 if x % 2 == 0 }
</code></pre>
<p>Since Ruby allows us to place the conditional after the expression, we get syntax similar to the Python version of the list comprehension. Also, since the <code>select</cod... | 39,994 |
<p>I am using URLDownloadToFile to retrieve a file from a website. Subsequent calls return the original file rather than an updated version. I assume it is retrieving a cached version.</p>
| <p>Call DeleteUrlCacheEntry with the same URL just prior to calling URLDownloadToFile.
You will need to link against Wininet.lib</p>
| <p>Could you add a harmless query parameter to the end of your URL?</p>
<p><a href="https://stackoverflow.com/?CacheBuster=1020am">https://stackoverflow.com/?CacheBuster=1020am</a></p>
| 10,104 |
<p><strong>Background</strong></p>
<p>I am capturing video using the video4linux 2 spec. It is captured using a C program in real-time. I also have a Java frontend that can run both locally and remotely. The remote side was easy, I just compress the images to JPEG and ship them over a mini-http server to the client... | <p>Unless you use a <code>Socket</code>, you're going to have to use JNI to hook into a more primitive IPC mechanism.</p>
<p>Given that you've got a memory buffer containing the video data, you may be able to use the "shared memory" APIs to get access to that memory from within your JVM. Have a look at the man page f... | <p>You could look into using JNI to expose the native memory. See the JNI APIs around Direct Byte Buffers.</p>
<p>Once you expose your native memory like this in Java, copy the bytes from the DirectByteBuffer into Java byte[] arrays, and it should be much faster than your socket approach.</p>
| 35,154 |
<p>I have inherited an old crusty <code>PHP application</code>, and I'd like to refactor it into something a little nicer to deal with, but in a gradual manner. In perl's CPAN, there is a series of classes around Class::DBI that allow you to use database rows as the basis for objects in your code, with the library gene... | <p>It's now defunct but <a href="http://phpdbi.sourceforge.net/web/" rel="nofollow noreferrer">phpdbi</a> is possibly worth a look. If you're willing to let go of some of your caveats (the framework one), I've found that <a href="http://www.phpdoctrine.org/" rel="nofollow noreferrer">Doctrine</a> is a pretty neat way o... | <p>The right thing to is to access the database via an abstraction layer in a way such if you change your RDBMS or how you implemented that access, you only have to modify this layer while all the rest of your application remains untouched. </p>
<p>To do this, to free your application from knowing how to deal with the... | 2,973 |
<p>What tools are available for creating in process COM servers in Java?</p>
| <p><a href="http://j-integra.intrinsyc.com/" rel="nofollow noreferrer">J-Integra</a> is the most comprehensive, complete solution you will probably find for using COM and Java together. The software has been used by many commercial products, big and small, to integrate COM and Java (both directions).</p>
| <p>Another alternative is <a href="http://www.teamdev.com/comfyj/index.jsf" rel="nofollow noreferrer">JNI Wrapper/ComfyJ</a> - it allows you to either generate Java proxy classes or use IDispatch. You can also trap and broadcast events (IConnectionPoint) and implement COM servers.</p>
| 22,908 |
<p>Stack Overflow has a subversion version number at the bottom:</p>
<blockquote>
<p>svn revision: 679</p>
</blockquote>
<p>I want to use such automatic versioning with my <code>.NET Web Site/Application</code>, Windows Forms, WPD projects/solutions.</p>
<p>How do I implement this?</p>
| <p>Looks like Jeff is using <a href="https://web.archive.org/web/20090130045625/http://confluence.public.thoughtworks.org/display/CCNET/What+is+CruiseControl.NET" rel="nofollow noreferrer">CruiseControl.NET</a> based on some leafing through the podcast transcripts. This seems to have automated deployment capabilities f... | <p><code>$rev</code> and others like it are revisions for the individual files, so they won't change unless the file changes. The number on the webpage is (most likely, I'm assuming here) the svn revision number for the whole project. That is different than the file revisions, which others have been pointing to.</p>
<... | 2,262 |
<p>I'd like to have a link in my ASP.NET web site that authenticated users click to download a windows app that is already pre-configured with their client ID and some site config data. My goal is no typing required for the user during the client app install, both for the user friendliness, and to avoid config errors ... | <p>The way the FogBugz screenshot setup tool does this is that it appends a 256 byte block at the end of the setup program at the moment it is downloaded. In other words, the download script spits out all the bytes from setup.exe and then an extra 256 with the url for the FogBugz server, plus any padding.</p>
<p>Wind... | <p>If it helps RegexBuddy does this also.</p>
| 5,634 |
<p>I need a way to determine whether the computer running my program is joined to any domain. It doesn't matter what specific domain it is part of, just whether it is connected to anything. I'm coding in vc++ against the Win32 API.</p>
| <p>Straight from Microsoft: </p>
<p><a href="http://support.microsoft.com/kb/179891" rel="noreferrer">How To Determine If a Windows NT/Windows 2000 Computer Is a Domain Member</a></p>
<p>This approach uses the Windows API. From the article summary:</p>
<blockquote>
<p>This article describes how to
determine if a... | <p>what about from the name of the computer?</p>
<p><strong>edit:</strong> this was a crapy 'answer' from way back. What I meant was cheching for the form <code>domain\name</code> in the computer name. That of course implies that you do know the name of the domain, it does not solves the issue of just knowing if the c... | 25,260 |
<p>In visual studio 2008, when we press Ctrl+F5, the ASP.NET Development Server is launched to simulate a Web Server. I'm wondering what server does it simulate? IIS6 or IIS7? Is it possible to customize what server it simulate?</p>
| <p>It doesn't simulate a server as such, it runs on a server based on cassini that is written in .net and has source code available. I suppose it's more similar to IIS6 in that it does not support the IIS7 integrated pipeline feature. You can always choose to have VS use II6 or IIS7 if it's installed (depending on wh... | <p>Sorry, a question, not an answer:
What are the server differences between IIS6 and II7 that matter to your code?</p>
<p>For ASP.NET development, the web server itself is somewhat ASP.NET neutral. It forwards the request to the .NET framework, so THAT's the part that matters.</p>
<p>More info here:
<a href="http:... | 35,827 |
<p>How can I transform a website to be able to handle multi language (example : english, french, spanish)?</p>
<p>I do not like the resource file because I feel limited and it's pretty long to build the list. Do you have any suggestion?</p>
<h2>Update</h2>
<p>For the moment the best way we found is to use an XML file a... | <p>Implicit localization (on the Visual Studio - Tools menu - Generate Local Resources) is about as easy as it can be. Write your pages in your default language, pick the menu option, and your resource files are created and can be sent to someone to translate. </p>
<p>The resx file is just xml, so if the translation c... | <p>Another solution I am using is to create the language folders which contain the aspx pages containing all the required text in that particular language. </p>
<p>The only problem here is how can you inject as little code as possible into those replicating pages. I am using a controller pattern here to do this, and t... | 22,845 |
<p>Lately I've been working on applications that are relatively data-oriented. In general, they tend to be editors for data represented by classes that are related in odd ways. I've been handling it by having a <code>UserControl</code> for each type of object and as the selection changes the program displays the appr... | <p>I find <a href="http://www.martinfowler.com/eaaDev/uiArchs.html" rel="nofollow noreferrer">this article</a> by Martin Fowler to be an excellent overview of a variety of UI architectures. Hope it helps :)</p>
| <p>I accepted @Luke H's answer because it ultimately led me to several resources that are pretty decent.</p>
<ul>
<li>Martin Fowler's books look top-notch and are in my queue.</li>
<li><a href="http://codebetter.com/blogs/jeremy.miller/archive/2007/07/25/the-build-your-own-cab-series-table-of-contents.aspx" rel="nofol... | 14,226 |
<p>3/10/2008 = 1822556159</p>
<p>2/10/2008 = 1822523391</p>
<p>1/10/2008 = 1822490623</p>
<p>30/09/2008 = 1822392319</p>
<p>29/09/2008 = 1822359551</p>
<p>This is all the information that I know at the current time. </p>
<p>Dates increment by 32768 except when changing month when the increment is 32768 x 2 (65536... | <p>September 30th 2008</p>
<pre><code>1822392319 = 0x6c9f7fff
0x6c = 108 = 2008 (based on 1900 start date)
0x9 = 9 = September
0xf7fff - take top 5 bits = 0x1e = 30
</code></pre>
<p>October 1st 2008</p>
<pre><code>1822490623 = 0x6ca0ffff
0x6c = 108 = 2008
0xa = 10 = October
0x0ffff - take top 5 bits = 0x01 = 1
</c... | <p>32768 is 2^15; they're reserving 15 bits for the days, which I don't think divides evenly into any useful combination of hours, minutes, and/or seconds.</p>
| 35,046 |
<p>This is a tricky one and I've always relied on techniques, such as permission-based emails (i.e. only sending to people you have permission to send to) and not using blatantly <em>spamish</em> terminology.</p>
<p>Of late, some of the emails I send out programmatically have started being shuffled into people's spam ... | <p>Use email authentication methods, such as <a href="http://en.wikipedia.org/wiki/Sender_Policy_Framework" rel="nofollow noreferrer">SPF</a>, and <a href="https://help.ubuntu.com/community/Postfix/DKIM" rel="nofollow noreferrer">DKIM</a> to prove that your emails and your domain name belong together, and to prevent sp... | <p>To allow <strong>DMARC</strong> checks for SPF to pass and also be <strong>aligned</strong> when using sendmail, make sure you are setting the envelope sender address (<code>-f</code> or <code>-r</code> parameter) to something that matches the domain in the <code>From:</code> header address.</p>
<h2>With PHP:</h2>
<... | 2,286 |
<p>I like putting shortcuts of the form "g - google.lnk" in my start menu so google is two keystrokes away. Win, g.</p>
<p>My eight or so most frequent applications go there.</p>
<p>I also make links to my solution files I am always opening "x - Popular Project.lnk"</p>
<p>Are there any better ways to automate openi... | <p><a href="http://www.autohotkey.com/" rel="nofollow noreferrer">AutoHotkey</a> is a reasonably good program for implementing windows key shortcuts. You might instead define WIN + G to be "open browser to google" which gives you a better response time (don't have to wait for start menu to popup, etc)</p>
<p>There ar... | <p>For shortcuts I use <strong>Launchy</strong></p>
<p>For macros I use <strong>AutoHotKey</strong></p>
<p>Others will suggest <strong>SlickRun</strong> for shortcuts also.</p>
| 6,608 |
<p>I have this ListBox which is bound to an ObservableCollection. Each object in the list implements an interface called ISelectable </p>
<pre><code>public interface ISelectable : INotifyPropertyChanged
{
event EventHandler IsSelected;
bool Selected { get; set; }
string DisplayText { get; }
}
</code></pre>... | <p>You could also accomplish this by data binding ListBoxItem.IsSelected to your Selected property. The idea is to set the binding for each of the ListBoxItems as they are created. This can be done using a style that targets each of the ListBoxItems generated for the ListBox.</p>
<p>This way when an item in the ListBo... | <p>I think you should fire the propertyChanged event when the select has changed. Add this code to the object that implements ISelectable. You'll end up with something like: </p>
<pre><code>private bool _Selected;
public bool Selected
{
get
{
return _Selected;
... | 33,725 |
<p>I'm building a auto updater and I need to know what kind of upload speeds people get on a 56K modem?</p>
| <p>Theoretically 33.6 kbit/s upload = 4.2 kB/s[1].</p>
<p>From own experience, I would say half of that :)</p>
<p>[1] <a href="http://en.wikipedia.org/wiki/ITU-T_V-Series_Recommendations#Simultaneous_transmission_of_data_and_other_signals" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/ITU-T_V-Series_Recommen... | <p>According to <a href="http://en.wikipedia.org/wiki/Modem" rel="nofollow noreferrer">Wikipedia</a>, the top (theoretical) speed is 48kbit/s. This is assuming v.92, which a large percentage of users will not have.</p>
| 31,141 |
<p>I'm trying to install the Python Imaging Library 1.1.6 for Python 2.6. After downloading the installation executable (Win XP), I receive the following error message:</p>
<p>"Application failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem"</p>
<p>Any... | <p>It looks like an SxS ("side-by-side") issue. Probably the runtime libraries PIL is linked against are missing. Try installing a redistributable package of a compiler which was used to build PIL.</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?familyid=200B2FD9-AE1A-4A14-984D-389C36F85647&display... | <p>I am shooting in the dark: could it be <a href="http://effbot.org/zone/python-register.htm" rel="nofollow noreferrer">this</a>?</p>
| 41,639 |
<p>When adding an EditItemTemplate of some complexity (mulitple fields in one template), and then parsing the controls from the RowUpdating event, the controls that were manually entered by the user have no values. My guess is there is something going on with when the data is bound, but I've had instances where simply ... | <p>Did you turn off ViewState?
Did you add control programmatically in the template? If so, did you create them at the correct stage?</p>
| <p>You should be able to use the GridViewUpdateEventArgs to retrieve the inputted value, for example: </p>
<pre><code>TextBox txtValue = gvwSettings.SelectedRow.FindControl("txtValue") as TextBox;
</code></pre>
<p>I have used that syntax before and it works like a charm.</p>
| 17,995 |
<p>I've <code>rm</code>'ed a 2.5gb log file - but it doesn't seemed to have freed any space.</p>
<p>I did:</p>
<pre><code>rm /opt/tomcat/logs/catalina.out
</code></pre>
<p>then this:</p>
<pre><code>df -hT
</code></pre>
<p>and <code>df</code> reported my <code>/opt</code> mount still at 100% used.</p>
<p>Any sugge... | <p>Restart tomcat, if the file is in use and you remove it, the space becomes available when that process finishes.</p>
| <p>Is the rm journaled/scheduled? Try a 'sync' command for force the write.</p>
| 43,096 |
<p>Is there a way to install all versions of all browsers on one machine?</p>
| <p>I use virtual machines to do different browser version configurations. I'm assuming you want to test different version of IE, Firefox etc.</p>
<p>If you automate your testing at any point the virtual machines are also handy for having a way to store many different configurations for testing on one machine.</p>
| <p>Yes. I have IE8 Beta2, FF3, Chrome Beta, and Safari 3.1.2 with the applicable developer plugins.</p>
| 34,457 |
<p>How do I check to see if a variable is a number, or contains a number, in UNIX shell?</p>
| <pre><code>if echo $var | egrep -q '^[0-9]+$'; then
# $var is a number
else
# $var is not a number
fi
</code></pre>
| <pre><code>a=123
if [ `echo $a | tr -d [:digit:] | wc -w` -eq 0 ]
then
echo numeric
else
echo ng
fi
</code></pre>
<blockquote>
<p>numeric</p>
</blockquote>
<pre><code>a=12s3
if [ `echo $a | tr -d [:digit:] | wc -w` -eq 0 ]
then
echo numeric
else
echo ng
fi
</code></pre>
<blockquote>
<p>ng</p>
</b... | 39,909 |
<p>Does anybody here have positive experience of working with MS SQL Server 2005 from Rails 2.x?</p>
<p>Our developers use Mac OS X, and our production runs on Linux. For legacy reasons we should use MS SQL Server 2005.</p>
<p>We're using ruby-odbc and are running into various problems, too depressing to list here.... | <p>Have you considered using JRuby? Microsoft has a <a href="http://msdn.microsoft.com/en-us/data/aa937724.aspx" rel="nofollow noreferrer">JDBC driver for SQL Server</a> that can be run on UNIX variants (it's pure Java AFAIK). I was able to get the 2.0 technology preview working with JRuby and Rails 2.1 today. I haven'... | <p>I would strongly suggest you weigh up migrating from the legacy database. You'll probably find yourself in a world of pain pretty quickly. From experience, Rails and legacy schemas don't go too well together either.</p>
<p>I don't think there's a "nice solution" to this one, I'm afraid.</p>
| 9,272 |
<p>I'm still learning Grails and seem to have hit a stumbling block.</p>
<p><strong>Here are the 2 domain classes:</strong></p>
<pre><code>class Photo {
byte[] file
static belongsTo = Profile
}
class Profile {
String fullName
Set photos
static hasMany = [photos:Photo]
}
</code></pre>
<p... | <p>As it is a Set, if you want the first element, you will have to go:</p>
<pre><code>profileInstance.photos.toArray()[0].id
</code></pre>
<p>or</p>
<pre><code>profileInstance.photos.iterator().next()
</code></pre>
| <p>My guess is you need to set the content type of the response stream. Something like:</p>
<pre><code>response.ContentType = "image/jpeg"
</code></pre>
<p>This may or may not need to be before you stream to the response stream (can't imagine that it would matter). I'd just put it before the outputStream line in yo... | 32,393 |
<p>I am running a query on Sybase ASE that produces a <code>ResultSet</code> that I then traverse and write the contents out to a file. Sometimes, this will throw a <code>NullPointerException</code>, stating that the <code>ResultSet</code> is <code>null</code>. However, it will do this after printing out one or two rec... | <p>I hope you will be doing it well, I mean after calling <em>rs.next()</em>. </p>
<p>According to the specs. the ResultSet object should never be <em>null</em>, in any case. Even if no records found. Posting the code snippet and the stack trace would definitely help us in giving you a better answer.</p>
<p><strong>E... | <p>try wrap the stuff for accessing the data like :</p>
<p>if(rs!=null && rs.next())
{</p>
<p>// read the stuff</p>
<p>}</p>
<p>if still persists will advice to check the read value for null itself.</p>
| 49,324 |
<p>Whenever I try to add a new project to my SourceSafe repository it creates 3 folders with the same name nested within each other. There is only one folder on my drive yet in Sourcesafe there are 3??</p>
<p>Can anyone suggest what may be causing this?</p>
<p>Thanks</p>
| <p>If you drag and rop a new project folder into VSS and do a recursive add then that's just how it works. Otherwise you have to create your own root project folder in VSS and add each file one at a time to VSS by hand. </p>
| <p>well, that problem comes due to visual studio. because visual stuio by default save solution file in the my documents/...../.../vs 2008/projects/ location and that address is also saved in the .sln file.</p>
<p>that's why every time you get latest within visual stuio it try to creat same strucute and make another c... | 15,562 |
<p>I am trying to do some string concatenation/formatting, but it's putting all the parameters into the first placeholder.</p>
<p><strong>Code</strong></p>
<pre><code>function CreateAppPoolScript([string]$AppPoolName, [string]$AppPoolUser, [string]$AppPoolPass)
{
# Command to create an IIS application pool
$A... | <p>Lose the parentheses and commas. </p>
<p>Calling your function as:</p>
<pre><code>$s = CreateAppPoolScript "name" "user" "pass"
</code></pre>
<p>gives:</p>
<pre class="lang-none prettyprint-override"><code>cscript adsutil.vbs CREATE "w3svc/AppPools/name" IIsApplicationPool
cscript adsutil.vbs SET "w3svc/AppPool... | <p>Paul's right.<br>
In PowerShell, function parameters are not enclosed in parenthesis. (Method parameters still are.)<br>
Your initial call was just passing one big array to the function, rather than the three separate parameters you wanted.</p>
| 4,277 |
<p>I have a PHP script that initialises an image gallery. It loops through all images, checks if they are thumbnailed and watermarks them.</p>
<p>My shared hosting account only lets me have 30 seconds of execution per script, as set in the php.ini settings. I can't change that.</p>
<p>What can I do to get round this?... | <p>three ideas:</p>
<ol>
<li><p>you could offload this to a script that runs on the server (PHP CLI perhaps?) and have your current script check the progress (still running! check back later!).</p></li>
<li><p>if javascript is ok in your environment, perhaps you could make ajax calls to handle this as well. the first ... | <p>What about some kind of task list, for example:</p>
<ol>
<li>First script makes a list of images that need thumbnails or watermarking</li>
<li>Second script checks this list and does the first 5 or so (however many can be done in the time limit) and removes them from the list</li>
<li>Have the script in step 2 retu... | 23,820 |
<p>I am looking for a good way to consistently test my web applications from the end users point of view. I have all kinds of ways to check to make sure my code is working behind the scenes. I can't count the number of times that I make a change to a piece of code, test it and it works fine and then deploy it only to h... | <p>I thin you need to investigate <a href="http://selenium.openqa.org/" rel="nofollow noreferrer">Selenium</a>. We use it to do automated UI testing throughout our solution, and it is cross browser and cross platform.</p>
<p>You can use the <a href="http://selenium-ide.openqa.org/" rel="nofollow noreferrer">Selenium I... | <p>Have a look at <a href="http://teststack.github.com/TestStack.Seleno/" rel="nofollow noreferrer">Seleno</a>, which abstracts Selenium / Browser interaction into C# Page Objects which represent the pages of your site. More details in <a href="https://stackoverflow.com/a/14153528/169334">this answer</a>.</p>
| 11,712 |
<p>I'm a newbie when it comes to SQL. When creating a stored procedure with parameters as such:</p>
<pre><code>@executed bit,
@failure bit,
@success bit,
@testID int,
@time float = 0,
@name varchar(200) = '',
@description varchar(200) =... | <p>A better approach would be to change the CommandText to just the name of the SP, and the CommandType to StoredProcedure - then the parameters will work much more cleanly:</p>
<pre><code>cmd.CommandText = "insert_test_result";
cmd.CommandType = CommandType.StoredProcedure;
</code></pre>
<p>This also allows simpler ... | <p>If you aren't using named parameters, MSSQL takes the parameters in the order received (by index). I think there's an option for this on the cmd object.</p>
<p>so your SQL should be more like </p>
<pre><code>EXEC [dbo].insert_test_result
@executed = @executed,
@failure = @failure,
@success = @success,
@testID =... | 18,748 |
<p>The in-house application framework we use at my company makes it necessary to put every SQL query into transactions, even though if I know that none of the commands will make changes in the database. At the end of the session, before closing the connection, I commit the transaction to close it properly. I wonder if ... | <p>Databases often preserve either a before-image journal (what it was before the transaction) or an after-image journal (what it will be when the transaction completes.) If it keeps a before-image, that has to be restored on a rollback. If it keeps an after-image, that has to replace data in the event of a commit.</... | <p>Since you've not done any DML, I suspect there'd be no difference between a COMMIT and ROLLBACK in Oracle. Either way there's nothing to do.</p>
| 24,123 |
<p>We are in the process of designing a simple service-oriented architecture using WCF as the implementation framework. There are a handful of services that a few applications use. These services are mostly used internally, so a basic authentication and authorization scheme (such as Windows-based) is enough.</p>
<p>We... | <p>I have done something very similar to this. What you can do is expose an endpoint with a single operation.</p>
<p>That operation would look something like</p>
<pre><code>[OperationContract(Namespace="www.fu.com", Action="*")]
void CallThis(Message msg);
</code></pre>
<p>Have your clients use a proxy that is inte... | <p>Check out <a href="https://stackoverflow.com/questions/1213781/is-is-possible-to-relay-a-wcf-service-from-another-server">this SO question</a> where one of the responses suggests .NET 4's RoutingService. Very nice addition to WCF.</p>
| 48,106 |
<p>We're starting a new facebook app (incidentally in Rails), and are faced with the decision to use FBML or to use IFrames. It seems like in the past the consensus generally was that FBML was the better way to go, as it made things more inherently Facebook looking, however it seems now like things on the iFrame side a... | <p>I have been developing a facebook app for the past several months, and recently switched our canvas page from FBML to an IFrame. The main reason for doing so has to do with these posts and features:</p>
<p><a href="http://www.insidefacebook.com/2008/09/30/lead-facebook-engineer-recommends-developers-use-iframes-for... | <p>Using FBML gives you much deeper integration with Facebook as a whole.</p>
| 27,056 |
<p>I'm processing some data files that are supposed to be valid UTF-8 but aren't, which causes the parser (not under my control) to fail. I'd like to add a stage of pre-validating the data for UTF-8 well-formedness, but I've not yet found a utility to help do this.</p>
<p>There's a <a href="http://www.w3.org/2005/01/y... | <p>You can use GNU iconv:</p>
<pre><code>$ iconv -f UTF-8 your_file -o /dev/null; echo $?
</code></pre>
<p>Or with older versions of iconv, such as on macOS:</p>
<pre><code>$ iconv -f UTF-8 your_file > /dev/null; echo $?
</code></pre>
<p>The command will return 0 if the file could be converted successfully, and ... | <p>You can also use <a href="https://linux.die.net/man/1/recode" rel="nofollow noreferrer"><code>recode</code></a>, which will exit with an error if it tries to decode UTF-8 and encounters invalid characters.</p>
<pre class="lang-bash prettyprint-override"><code>if recode utf8/..UCS < "$FILE" >/dev/null 2>&am... | 14,051 |
<p>For part of my application I have a need to create an image of a certain view and all of its subviews.</p>
<p>To do this I'm creating a context that wraps a bitmap with the same-size as the view, but I'm unsure how to draw the view hierarchy into it. I can draw a single view just be setting the context and explicit... | <p>I found that writing the drawing code myself was the best way to:</p>
<ul>
<li>deal with potential transparency issues (some of the other options do add a white background to the whole image)</li>
<li>performance was much better</li>
</ul>
<p>The code below is not perfect, because it does not deal with scaling iss... | <p>You can use <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSBitmapImageRep_Class/Reference/Reference.html#//apple_ref/occ/instm/NSBitmapImageRep/initWithFocusedViewRect:" rel="nofollow noreferrer" title="-[NSBitmapImageRep initWithFocusedViewRect:]"><code>-[NSBitmapImageRep... | 3,566 |
<p>When I call a static method like:</p>
<pre><code>Something.action();
</code></pre>
<p>Since a instance isn't created how long will the Class of the static method be held in memory?</p>
<p>If I call the same method will the Class be reloaded for each call since no instance exists?</p>
<p>And are only individual s... | <p>Unless you have configured garbage collection of permgenspace, the class stays in memory until the vm exits. The full class is loaded with all static methods.</p>
| <p>The <em>Something</em> class should get loaded when the caller class will be loaded. And it stays there until the exit of the VM as krosenvold said.</p>
| 38,234 |
<p>Given the key for some registry value (e.g. HKEY_LOCAL_MACHINE\blah\blah\blah\foo) how can I:</p>
<ol>
<li>Safely determine that such a key exists.</li>
<li>Programmatically (i.e. with code) get its value.</li>
</ol>
<p>I have absolutely no intention of writing anything back to the registry (for the duration of my... | <p><strong>Here is some pseudo-code to retrieve the following:</strong></p>
<ol>
<li>If a registry key exists</li>
<li>What the default value is for that registry key</li>
<li>What a string value is</li>
<li>What a DWORD value is</li>
</ol>
<p><strong>Example code:</strong></p>
<p>Include the library dependency: Adv... | <pre><code>#include <windows.h>
#include <map>
#include <string>
#include <stdio.h>
#include <string.h>
#include <tr1/stdint.h>
using namespace std;
void printerr(DWORD dwerror) {
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAG... | 5,422 |
<p>During coding I frequently encounter this situation:</p>
<ol>
<li>I have several objects (<code>ConcreteType1</code>, <code>ConcreteType2</code>, ...) with the same base type <code>AbstractType</code>, which has abstract methods <code>save</code> and <code>load</code> . Each object can (and has to) save some specif... | <p>If you can't simply use serialization, then I would still definitely pull the object loading logic out of the base class. Your instinct is correct, leading you to correctly identify a <a href="http://en.wikipedia.org/wiki/Code_smell" rel="nofollow noreferrer">code smell</a>. The base class shouldn't need to chang... | <p>There are better ways, but let's take a step back and look at it conceptually. What are all objects doing? Loading and Saving. When you get the object from memory, you really don't to have to care whether it gets its information from a file, a database, or the windows registry. You just want the object loaded. ... | 37,333 |
<p>I am using ngen.exe (the .Net Native Image Generator) version 2.0.50727.312. Is this the latest version? If not, where can I download the latest version? This <a href="http://msdn.microsoft.com/en-us/library/6t9t5wcf.aspx" rel="noreferrer"><strong>page</strong></a> on msdn does not appear to have a link to a downloa... | <p>The .NET Runtime itself has been upgraded with what amounts to a "service pack" in the 3.5 version. If you have .NET 3.5 installed on that box, you are running the latest version of NGEN, even if the version number is 2.0.50727. Check out this article for more details:</p>
<p><a href="http://www.danielmoth.com/Bl... | <p>ngen.exe is stored in framework installation path</p>
<p>C:\Windows\Microsoft.NET\Framework\v2.0.50727
or
C:\Windows\Microsoft.NET\Framework\v1.1.4322</p>
<p><a href="http://msdn.microsoft.com/en-us/library/6t9t5wcf(VS.80).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/6t9t5wcf(VS.80).aspx</a></p>
| 45,266 |
<p>My team is developing a new service oriented product with a web front-end. In discussions about what technologies we will use we have settled on running a JBoss application server, and Flex frontend (with possible desktop deployment using Adobe AIR), and web services to interface the client and server.</p>
<p>We'v... | <p>There won't be much difference between EJB3 and Spring based on Performance. We chose Spring for the following reasons (not mentioned in the question):</p>
<ul>
<li>Spring drives the architecture in a direction that more readily supports unit testing. For example, inject a mock DAO object to unit test your business... | <p>I think EJB is a good component technology but not a good framework.Spring is the best framework available as of today.So i should consider Spring as the best implementation of JEE in the sense of a framework and my recommendation is to use spring in every project which gives us the flexibility to integrate with an... | 9,400 |
<p>I try to add an addons system to my Windows.Net application using Reflection; but it fails when there is addon with dependencie.<br><br>
Addon class have to implement an interface 'IAddon' and to have an empty constructor.<br>
Main program load the addon using Reflection:</p>
<pre><code>Assembly assembly = Assembl... | <p>If <em>MyTools.dll</em> is located in the same directory as <em>Addon.dll</em>, all you need to do is call <code>Assembly.LoadFrom</code> instead of <code>Assembly.LoadFile</code> to make your code work. Otherwise, handling the <code>AppDomain.AssemblyResolve</code> event is the way to go.</p>
| <p>Couple of options:</p>
<ol>
<li>You can attach to <code>AppDomain.AssemblyResolve</code> to help the CLR resolve the assembly.</li>
<li>You could look into isolating add-ins into their own <code>AppDomain</code> (see <code>System.AddIn</code> namespace and <a href="http://www.codeplex.com/clraddins" rel="nofollow n... | 21,969 |
<p>Can anybody suggest a good book/paper/website/background reading about universal codes for integers and especially Fibonacci code (in the sense of <a href="http://en.wikipedia.org/wiki/Fibonacci_code" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Fibonacci_code</a>)? Thanks!</p>
<p><strong>Edit:</strong> T... | <p>One paper found with <a href="http://scholar.google.com" rel="nofollow noreferrer">Google Scholar</a> : </p>
<ul>
<li><a href="http://radio-1.ee.dal.ca/~ilow/4540/readings/DataCompression.pdf" rel="nofollow noreferrer">Data compression</a> (DA Lelewer, DS Hirschberg - ACM Computing Surveys (CSUR), 1987)</li>
</ul>
... | <p>One paper found with <a href="http://scholar.google.com" rel="nofollow noreferrer">Google Scholar</a> : </p>
<ul>
<li><a href="http://radio-1.ee.dal.ca/~ilow/4540/readings/DataCompression.pdf" rel="nofollow noreferrer">Data compression</a> (DA Lelewer, DS Hirschberg - ACM Computing Surveys (CSUR), 1987)</li>
</ul>
... | 38,202 |
<p>I have to deal with very large text files (2 GBs), it is mandatory to read/write them line by line. To write 23 millions of lines using ofstream is really slow so, at the beginning, I tried to speed up the process writing large chunks of lines in a memory buffer (for example 256 MB or 512 MB) and then write the buff... | <p>A 2GB file is pretty big, and you need to be aware of all the possible areas that can act as bottlenecks:</p>
<ul>
<li>The HDD itself</li>
<li>The HDD interface (IDE/SATA/RAID/USB?) </li>
<li>Operating system/filesystem </li>
<li>C/C++ Library </li>
<li>Your code</li>
</ul>
<p>I'd start by doing some measurements:... | <p>If you are going to buffer the file yourself, then I'd advise some testing using unbuffered I/O (setvbuf on a file that you've fopened can turn off the library buffering).</p>
<p>Basically, if you are going to buffer yourself, you want to disable the library's buffering, as it's only going to cause you pain. I don'... | 33,646 |
<p>Best practices recommend not installing Sql Server to run as SYSTEM. What is the bare minumum you need to give the user account you create for it?</p>
| <p>By default, SQL Server 2005 installation will create a security group called SQLServer2005MSSQLUser$ComputerName$MSSQLSERVER with the correct rights. You just need to create a domain user or local user and make it a member of that group. </p>
<p>More details are available in the SQL Server Books Online: <a href="ht... | <p>Typically I create a Domain User with only the specific rights on the network which I will require the server to have (i.e. to write to the network backup drive), I then add the account to local power users or local administrators depending on what needs to be done on the machine, however this isn't required. I've ... | 8,220 |
<p>For my customer I occasionally do work in their live database in order to fix a problem they have created for themselves, or in order to fix bad data that my product's bugs created. Much like Unix root access, it's just dangerous. What lessons should I learn ahead of time?</p>
<p>What is the #1 thing you do to be... | <p>Three things I've learned the hard way over the years...</p>
<p>First, if you're doing updates or deletes on live data, first write a SELECT query with the WHERE clause you'll be using. Make sure it works. Make sure it's correct. Then prepend the UPDATE/DELETE statement to the known working WHERE clause.</p>
<p>Yo... | <p><strong>Make sure your query has a <code>WHERE</code> parameter specified</strong></p>
<p>I was once mid-way through a complex update, got distracted, and finished the query early, forgetting the "where" clause. Then I got that sinking feeling, watching a half-second query rumble on for 3.. The several hours afterw... | 20,342 |
<p>Which component to use to play mp3 files from streams/files and also to know the lenght in seconds of that mp3 stream?</p>
| <p>You can also use the components at <a href="http://www.mitov.com" rel="nofollow noreferrer">www.mitov.com</a> which has an Audio suite that can handle this type of file.</p>
| <p>I use <a href="http://symmetrica.net/newac/" rel="nofollow noreferrer">NewAc</a> components for audio conversion and filtering, it can play MP3 and several others formats.</p>
| 43,341 |
<p>One of my DBs have grown closer to permitted size.</p>
<p>Inorder to find out the table containing the max data, i used the following query:</p>
<pre><code>exec sp_MSforeachtable @command1="print '?' exec sp_spaceused '?'"
</code></pre>
<p>It returned the culprit table comprising the max data.</p>
<p>As a next s... | <p>This will give you a list of rows by size, just set @table and @idcol accordingly (as written it'll run against the Northwind sample)</p>
<pre><code>declare @table varchar(20)
declare @idcol varchar(10)
declare @sql varchar(1000)
set @table = 'Employees'
set @idcol = 'EmployeeId'
set @sql = 'select ' + @idcol +' ,... | <p>Maybe something like this will work </p>
<pre><code>delete table where id in
(
select top 100 id
from table
order by datalength(event_text) + length(varchar_column) desc
)
</code></pre>
<p>(since you are dealing with an event table its probably a text column you are looking at ordering on so the data... | 14,002 |
<p>If a "WITH NOLOCK" query hint is used on a View in SQL Server, does it propagate that hint to the view definition itself, even if NOLOCK is NOT used for the raw tables in the View definition? The reason to need this is that sometimes the support staff wants to do huge time-consuming queries but would rather not forc... | <p>Yes, NOLOCK will propagate to the tables used by the view definition (at least in SQL Server 2005).</p>
<p>See <a href="http://msdn.microsoft.com/en-us/library/ms187373(SQL.90).aspx" rel="noreferrer">Table Hints</a> in MSDN:</p>
<blockquote>
<p>In SQL Server 2005, all lock hints are propagated to all the tables ... | <p>Just to supplement Rory's excellent answer. </p>
<p>He writes "Yes, NOLOCK will propagate to the tables used by the view definition <strong><em>(at least in SQL Server 2005)</em></strong>."</p>
<p>In fact this will work in SQL 2000 as well.
<a href="http://msdn.microsoft.com/en-us/library/aa258253(SQL.80).aspx" r... | 40,131 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.