instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I have a QGraphicsScene that I want to copy and append to the start of a list. What is the best method of doing this?</p>
<pre><code>QGraphicsScene* m_scene = new QGraphicsScene();
QGraphicsScene* m_DuplicateScene;
QList<QGraphicsScene *>m_list;
</code></pre>
| <p>Doing this would be very complicated because you don't know anything about the children of <code>m_scene</code>. Even if you <code>dynamic_cast</code> and create a <code>clone()</code> function for each type of <code>QGraphicsItem</code>, you still need to remember that other people can subclass <code>QGraphicsItem... | <p>I make a copy of QGraphicsScene's items in my project. I'm using this way. may be helpful.<br/>
I have a class like this:</p>
<pre><code>class DiagramScene : public QGraphicsScene
{
[some datas]
}
</code></pre>
<p>and another class in this like:</p>
<pre><code>class DiagramItem : public QGraphicsItem
{
}
</code><... | 33,621 |
<p>A puzzler from a coworker that I cannot figure out...</p>
<pre><code>update btd.dbo.tblpayroll
set empname = ( select b.Legal_Name
from ( SELECT Legal_Name,
Employee_ID
FROM Com.dbo.Workers
... | <p>I suspect that the optimizer is attempting to apply the where clause of the outer select before the inner select. Presumably it thinks it would be able to do an index lookup on Employee_ID resulting in a faster query in this case. Try:</p>
<pre><code>update btd.dbo.tblpayroll
set empname = ( select Legal_Nam... | <p>Maybe N is considered currency symbol? You can try to replace IsNumeric with</p>
<pre><code>LIKE REPLICATE('[0-9]',/*length of Employee_ID*/)
</code></pre>
<p>or just </p>
<pre><code>LIKE '[0-9]%'
</code></pre>
<p>if letter cannot be in the middle</p>
| 44,023 |
<p>Is there a better way to flash a window in Java than this:</p>
<pre><code>public static void flashWindow(JFrame frame) throws InterruptedException {
int sleepTime = 50;
frame.setVisible(false);
Thread.sleep(sleepTime);
frame.setVisible(true);
Thread.sleep(sleepTime);
... | <p>There are two common ways to do this: use JNI to set urgency hints on the taskbar's window, and create a notification icon/message. I prefer the second way, since it's cross-platform and less annoying.</p>
<p>See <a href="http://java.sun.com/javase/6/docs/api/java/awt/TrayIcon.html" rel="nofollow noreferrer">docume... | <p>Well, there are a few minor improvements we could make. ;)</p>
<p>I would use a Timer to make sure callers don't have to wait for the method to return. And preventing more than one flashing operation at a time on a given window would be nice too.</p>
<pre><code>import java.util.Map;
import java.util.Timer;
import ... | 6,687 |
<p>I have been using C# for a while now, and going back to C++ is a headache. I am trying to get some of my practices from C# with me to C++, but I am finding some resistance and I would be glad to accept your help.</p>
<p>I would like to expose an iterator for a class like this:</p>
<pre><code>template <class T&g... | <p>You may find the following article interesting as it addresses exactly the problem you have posted: <a href="http://www.artima.com/cppsource/type_erasure.html" rel="noreferrer">On the Tension Between Object-Oriented and Generic Programming in C++ and What Type Erasure Can Do About It</a></p>
| <p>This should do what you want:</p>
<pre><code>typedef typename std::vector<T>::iterator MyIterator;
</code></pre>
<p>From <a href="http://www.acceleratedcpp.com/" rel="nofollow noreferrer">Accelerated C++</a>:</p>
<blockquote>
<p>Whenever you have a type, such as <code>vector<T></code>, that depends ... | 18,993 |
<p>I want to apply an XSLT Stylesheet to an XML Document using C# and write the output to a File.</p>
| <p>I found a possible answer here: <a href="http://web.archive.org/web/20130329123237/http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=63" rel="noreferrer">http://web.archive.org/web/20130329123237/http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=63</a></p>
<p>From the article:</p>
<pre>... | <p>I would like to share this small piece of code which reads from Database and transforms using XSLT. On the top I also have used <code>xslt-extensions</code> which makes it little different than others.</p>
<p>Note: <em>This is just a draft code and may need cleanup before using in production.</em></p>
<pre><code>var... | 5,426 |
<p>With all the fuss about opensource projects, how come there is still not a strong standard that enables you to make portable code (I mean in <code>C/C++</code> not <code>Java</code> or <code>C#</code>)
Everyone is kind of making it's own soup.<br><br>
There are even some third party libs like <code>Apache Portable R... | <p>Yes, there is no standard but libraries like <strong>Qt</strong> and <strong>boost</strong> can make your life much easier when you do cross-platform development.</p>
| <p>If you make sure it compiles cleanly with both GCC and MS VC++, it will be little extra effort to port to somewhere else.</p>
| 8,674 |
<p>I am setting up support for users to sign in with client certificates. Unfortunately IIS refuses to acknowledge any certificate not chained to an installed CA (<a href="http://support.microsoft.com/kb/257587" rel="nofollow noreferrer" title="Description of the Server Authentication Process During the SSL Handshake">... | <p>I think the normal way is for you to issue the certificates to them, and then for you to set up IIS to accept your cert as a root.</p>
| <p>I think you can add a new <em>root</em> CA cert via the <code>certmgr</code> command</p>
<pre><code>certmgr --add -c -m Trust <CA_cert_DER_fmt>
</code></pre>
<p>Note: Unlike UNIXes, Windows manages certs for all applications <em>simultaneously</em>, which can have security implications, so beware of that</p>... | 20,626 |
<p>I was thinking of using these styles for easier cell rollover effects in a datagrid, but I can't seem to get these styles working on anything other than the most basic of tag.</p>
<p>Is the <code><a></code> anchor tag the only element in HTML to support styles like hover, active, visited?</p>
| <p>It should work on all elements, but IE6 only supports in on links. I used <a href="http://www.xs4all.nl/~peterned/csshover.html" rel="nofollow noreferrer">whatever:hover</a> to work around that.</p>
| <p>Yes unfortunately anchor is the only tag that supports these styles. </p>
<p>I would recommend the following:
Before coding any of your own JS, try use the JQuery framework, it might save you loads of work. </p>
<p>Another crazy workaround would be to expand the size of the using style to 100% of the parent (cel... | 42,513 |
<p>I need to select a datetime column in a table. However, I want the select statement to return the datetime as a nvarchar with the format DD/MM/YYYY.</p>
| <p>Here is the convert documentation:</p>
<blockquote>
<p><a href="https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql</a></p>
</blockquote>
<p>Looking through that, it looks li... | <pre><code>select convert(nvarchar(10), datefield, 103)
</code></pre>
| 34,381 |
<p>I have a Rails app that lets a user construct a database query by filling out an extensive form. I wondered the best practice for checking form parameters in Rails. Previously, I have had my <code>results</code> method (the one to which the form submits) do the following:</p>
<pre><code>if params[:name] &&... | <p>You could try active_form (<a href="http://github.com/cs/active_form/tree/master/lib/active_form.rb" rel="noreferrer"><a href="http://github.com/cs/active_form/tree/master/lib/active_form.rb" rel="noreferrer">http://github.com/cs/active_form/tree/master/lib/active_form.rb</a></a>) - just ActiveRecord minus the datab... | <h2>Model</h2>
<pre><code>class Person
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :name
attr_accessor :email
validates_presence_of :name,:message => "Please Provide User Name"
validates_presence_of :email,:message => "... | 47,130 |
<p>For the geometry I am making, I want to extrude each face individually along its normal.</p>
<p>This is a standard procedure in 3D modeling software like Blender; see Example 3 <a href="https://blender.stackexchange.com/questions/7365/extrude-faces-along-local-normals">here</a>. </p>
<p>Is this possible in OpenSCA... | <p>Extruding faces is only possible on 2D polygons. From a 3D object you cannot capture the face and extrude it. To extrude "faces" you would need to define the shape of the face and extend it in the third dimension of your choice. This way a 3D shape is created that could be concatenated (joined using e.g. <a href="ht... | <p>Built-in to the language and its CSG model, no - processing the CSG tree is a completely separate phase following execution of the functional language, and there is no way to "read back" anything from the conversion of the model into faces in order to operate on the faces.</p>
<p>However, you can do this if you're ... | 1,462 |
<p>Is there a way to get the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa365527%28v=vs.85%29.aspx" rel="nofollow noreferrer">SearchPath</a> API to not search in c:\windows when using the default search path (passing NULL as the first param)? I can't modify the caller to send in a specific path.</... | <p>According to <a href="http://msdn.microsoft.com/en-us/library/aa365527(VS.85).aspx" rel="nofollow noreferrer">MSDN</a>, there's nothing you can do about this bar changing a system level (HKLM) registry entry (Which is a "bad thing"). The registry change would cause the search order to start with the current working ... | <p>Try <code>SetCurrentDirectory("c:\users\public")</code> and then <code>SearchPath(...)</code>.</p>
| 21,240 |
<p>I'm trying to place this menu on the left hand side of the page:</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-html lang-html prettyprint-override"><code><div class="left-menu" style="left: 123px; top: 355... | <p><code>float</code> is indeed the right property to achieve this. However, the example given by bmatthews68 can be improved. The most important thing about floating boxes is that they <em>must</em> specify an explicit width. This can be rather inconvenient but this is the way CSS works. However, notice that <code>px<... | <p>You should use the float and clear CSS attributes to get the desired effect. </p>
<p>First I defined styles for the called left and right for the two columns in my layout and a style called clearer used to reset the page flow.</p>
<pre>
<style type="text/css">
.left {
float: left;
width: 200px;
}
.ri... | 8,628 |
<p>I need a simple app to edit database tables. Are there any code generators that will generate winforms in c#? I have CodeSmith, are there any templates around that would help in doing this?</p>
| <p>SQL Management Studio.</p>
<p>Serious answer, .NetTiers for codesmith might help you out.</p>
| <p>I assume you're talking about .Net? Have you looked at Visual Studio? SharpDevelop also does this.</p>
| 28,065 |
<p>Assuming the following hypothetical inheritance hierarchy:</p>
<pre><code>public interface IA
{
int ID { get; set; }
}
public interface IB : IA
{
string Name { get; set; }
}
</code></pre>
<p>Using reflection and making the following call: </p>
<pre><code>typeof(IB).GetProperties(BindingFlags.Public | Binding... | <p>I've tweaked @Marc Gravel's example code into a useful extension method encapsulates both classes and interfaces. It also add's the interface properties first which I believe is the expected behaviour.</p>
<pre><code>public static PropertyInfo[] GetPublicProperties(this Type type)
{
if (type.IsInterface)
{
... | <p>this worked nicely and tersely for me in a custom MVC model binder. Should be able to extrapolate to any reflection scenario though. Still kind of stinks that it's too pass</p>
<pre><code> var props = bindingContext.ModelType.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instanc... | 46,797 |
<p>What control type should I use - <code>Image</code>, <code>MediaElement</code>, etc.?</p>
| <p>I couldn't get the most popular answer to this question (above by Dario) to work properly. The result was weird, choppy animation with weird artifacts.
Best solution I have found so far:
<a href="https://github.com/XamlAnimatedGif/WpfAnimatedGif" rel="noreferrer">https://github.com/XamlAnimatedGif/WpfAnimatedGif</a>... | <p>Previously, I faced a similar problem, I needed to play <code>.gif</code> file in your project. I had two choices:</p>
<ul>
<li><p>using PictureBox from WinForms</p></li>
<li><p>using a third-party library, such as WPFAnimatedGif from <a href="http://wpfanimatedgif.codeplex.com/" rel="nofollow">codeplex.com.</a></p... | 25,898 |
<p>For example, I make extensive use of the session in my ASP.NET application but have heard somewhere that objects stored in session can be removed by the system where server memory runs low. Is this true? Is there any session 'callback' functionality to allow you to re-populate scavenged objects? </p>
<p>More genera... | <p>No matter which precautions you use, always assume your Session may disappear and double check:</p>
<pre><code>Dim sessionObj As Object = CType(Session("SessionKey"), Object)
If sessionObj Is Nothing
sessionObj = ReCreateObj()
Session("SessionKey") = sessionObj
End If
object sessionObj = Session["SessionKe... | <p>Sorry, I don't know about the removal of items from session state, but in response to your general question, the most important question is whether you anticipate running your web app on just one web server machine or many.</p>
<p>Typically, you are keeping the session state in the memory of one single machine. Yo... | 37,508 |
<p>I've a small project that I want to share with a few others on a machine that we all have access to. I created a bare copy of the local repo with</p>
<pre><code>git clone --bare --no-hardlinks path/to/.git/ repoToShare.git
</code></pre>
<p>I then moved repoToShare.git to the server.</p>
<p>I can check it out with... | <p>Git installs a bunch of pre-configured hooks in the hooks directory, out of the box they do not execute. If you happen to allow execute on them (Eg. chmod +x) then git will try to run them. The particular error pops up cause the default update is failing to run. To fix, delete the default update hook. </p>
<p>Does ... | <p>I had the same issue as @dragulesq but with a <a href="http://en.wikipedia.org/wiki/Red_Hat_Linux" rel="nofollow noreferrer">Red Hat</a> server.</p>
<p>To be a bit more verbose just put whatever you want as a string in the .git/description file on your local (in my case my Mac OS X); I put <em>website</em> and then... | 24,415 |
<p>How many international languages does the iPhone Simulator support?</p>
<p>Choose: Settings/General/International/Language</p>
<p>Mine only has English listed, but I fear I may have inadvertently stripped out the localisations?</p>
<p><a href="http://i36.tinypic.com/1q50t1.png" rel="noreferrer">iPhone/Settings/Ge... | <p>I reinstalled the SDK/Xcode and got all 40 of them back.</p>
<p>(was 18, but now it's more)</p>
| <p>Mine support 18 languages. Maybe try to reset content and settings...</p>
| 28,419 |
<p>I don´t know why, but my form isn´t calling Form_Load event when it loads.</p>
<p>Any ideas why this might be happening?</p>
| <p>Do you have the event handler set up?</p>
<p>Ultimately, there is going to be a line of code that looks something like this:</p>
<pre><code>this.Load += new System.EventHandler(this.Form1_Load);
</code></pre>
<p>That might be something you code yourself, or is generated by double-clicking the Load event for the f... | <p>go to the btnSave
find "Click"
set "btnSave_Click"
then works</p>
| 29,004 |
<p>Say you have a class who's job it is to connect to a remote server. I want to abstract this class to provide two versions, one that connects through UDP and the other through TCP. I want to build the leanest runtime code possible and instead of using polymorphism I am considering templates. Here is what I'm envision... | <p>This can be best done using a policy for the transport protocol:</p>
<pre><code>template<typename Transport>
class service : Transport {
public:
typedef Transport transport_type;
// common code
void do_something() {
this->send(....);
}
};
class tcp {
public:
void send(....) {... | <p>I think that the main point in choosing amongst polimorphism or template specialization, in this particular case at least, is if you want to choose which behavior to use at run time or at compile time.<br>
If you want to have a udp or a tcp connection based, for example, on a connection string provided the user, the... | 46,450 |
<p>There are examples online with web select boxes that have a huge list of countries and that probably will be good enough for me to use. However, by Murphy's law, there's bound to be some random country that someone is from and isn't on my list (and probably someone else also ran into this and has updated <em>their</... | <p>There are many list of countries, check this <a href="http://en.wikipedia.org/wiki/List_of_countries" rel="nofollow noreferrer">wikipedia article</a>; there you can find some lists like:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/ISO_3166-1" rel="nofollow noreferrer">ISO 3166-1 countries codes</a></li>
<li>... | <p>Much, much easier is to use a web service for this task rather than holding your own data store. This way its updated and you can do things like have country-state ajax dropdown sets. <a href="http://geodata.solutions" rel="nofollow noreferrer">http://geodata.solutions</a> is the best one to use, and it has lots of ... | 43,103 |
<p>I'm trying to perform a once-through read of a large file (~4GB) using Java 5.0 x64 (on Windows XP).</p>
<p>Initially the file read rate is very fast, but gradually the throughput slows down substantially, and my machine seems very unresponsive as time goes on.</p>
<p>I've used ProcessExplorer to monitor the File ... | <p>I very much doubt that you're <em>really</em> getting 500MB per second from your disk. Chances are the data is cached by the operating system - and that the 20MB per second is what happens when it <em>really</em> hits the disk.</p>
<p>This will quite possibly be visible in the disk section of the Vista Resource Man... | <p>You could use JConsole to monitor your app, including memory usage. The 500 MB/sec sounds to good to be true.</p>
<p>Some more information about the implementation and VM arguments used would be helpful.</p>
| 44,478 |
<p>I'm using PowersHell to automate iTunes but find the error handling / waiting for com objects handling to be less than optimal.</p>
<p>Example code</p>
<pre><code>#Cause an RPC error
$iTunes = New-Object -ComObject iTunes.Application
$LibrarySource = $iTunes.LibrarySource
# Get "playlist" objects for main sections... | <p>Here's a function to retry operations, pausing in between failures:</p>
<pre><code>function retry( [scriptblock]$action, [int]$wait=2, [int]$maxRetries=100 ) {
$results = $null
$currentRetry = 0
$success = $false
while( -not $success ) {
trap {
# Set status variables at function scope.
Set-... | <p>Part of your problem might be in how $Track.name is being evaluated. You could try forcing it to fully evaluate the name by using $($Track.name).</p>
<p>One other thing you might try is using the -strict parameter with your new-object command/</p>
| 21,919 |
<p>The following code receives seg fault on line 2:</p>
<pre><code>char *str = "string";
str[0] = 'z'; // could be also written as *str = 'z'
printf("%s\n", str);
</code></pre>
<p>While this works perfectly well:</p>
<pre><code>char str[] = "string";
str[0] = 'z';
printf("%s\n", str);
</code></pre>
<p>Tested with ... | <p>See the C FAQ, <a href="http://c-faq.com/decl/strlitinit.html" rel="noreferrer">Question 1.32</a></p>
<blockquote>
<p><strong>Q</strong>: What is the difference between these initializations?<br>
<code>char a[] = "string literal";</code><br>
<code>char *p = "string literal";</code><br>
My program crashes i... | <p>Segmentation fault is caused when you try to access the memory which is inaccessible. </p>
<p><code>char *str</code> is a pointer to a string that is nonmodifiable(the reason for getting segfault).</p>
<p>whereas <code>char str[]</code> is an array and can be modifiable..</p>
| 19,850 |
<p>I have a Page that has a single instance of a UserControl that itself has a single UpdatePanel. Inside the UpdatePanel are several Button controls. The Click event for these controls are wired up in the code-behind, in the Init event of the UserControl.</p>
<p>I get the Click event for the first button I push, ev... | <p>It seems that adding UseSubmitBehavior="false" to the button definitions has solved my problem. Still don't know why that first button click worked at all.</p>
| <p>In my case, i had a <code>LinkButton</code> within a <code>dgPatients_ItemDataBound</code> event handler that used the <code>PostBackUrl</code> property.</p>
<p>The moment i changed the <code>LinkButton</code> to a <code>HyperLink</code>, the problem went away.</p>
| 21,758 |
<p>One of the bullet point features for Windows Vista Enterprize and Ultimate is the Unix subsystem for windows, which allows you to write posix... stuff? Anyway I'm outa my league talking about it... Anyone use this feature? Or explain it... </p>
<p>I know next to nothing about Unix programming.</p>
| <p>It's probably best not to try to use the Posix subsystem for Windows. It was never really complete and is just a useless marketing tick box.</p>
<p>If you're truly interested in programming stuff for Unix, download one of the many Linux distributions (ie. <a href="http://ubuntu.com" rel="nofollow noreferrer">Ubuntu... | <p>The Posix subsystem in Windows is not only incomplete, but also slower in many cases than the "native" windows functions for the same thing. This is true for I/O for example.</p>
| 3,827 |
<p>We had a performance issue with DataGridViews where the redraw was horridly slow and found the solution <a href="https://stackoverflow.com/questions/118528/horrible-redraw-performance-of-the-datagridview-on-one-of-my-two-screens">Here</a> to create a derived type and enable double buffering on the control.
(Derived ... | <p>I think its best solution:</p>
<pre><code>typeof(DataGridView).InvokeMember(
"DoubleBuffered",
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty,
null,
myDataGridViewObject,
new object[] { true });
</code></pre>
<p>found <a href="https://stackoverflow.com/questions/118528/... | <p>Inheritance is not needed to <a href="http://bitmatic.com/csharp/fixing-a-slow-scrolling-datagridview" rel="nofollow noreferrer">turn on doublebuffering on a datagridview</a>. You can do it with reflection on an existing datagridview.</p>
| 31,484 |
<p>My programming environment includes scripts for setting up my autobuild on a clean machine.</p>
<p>One step uses a vbscript to configure a website on IIS that is used to monitor the build.</p>
<p>On a particular machine I will be running apache on port 80 for a separate task.</p>
<p>I would like my vbscript to se... | <p>No, the GC.Collect() call is asynchronous, you would also need to call this:</p>
<pre><code>System.GC.WaitForPendingFinalizers();
</code></pre>
| <p>Could you mock out an <code>IDisposable</code> interface and expect a call to <code>Dispose</code>? That would at least let you see when the object is actually disposed.</p>
| 30,577 |
<p>How do I make <kbd>Caps Lock</kbd> work like <kbd>Esc</kbd> in Mac OS X?</p>
| <p><strong>Edit:</strong> As described in <a href="https://stackoverflow.com/a/40254864/665488">this answer</a>, newer versions of MacOS now have native support for rebinding <kbd>Caps Lock</kbd> to <kbd>Escape</kbd>. Thus it is no longer necessary to install third-party software to achieve this.</p>
<hr>
<p>Here's m... | <p>Karabiner-Elements
A powerful and stable keyboard customizer for macOS. (freeware)</p>
<p><a href="https://pqrs.org/osx/karabiner/index.html" rel="nofollow noreferrer">https://pqrs.org/osx/karabiner/index.html</a></p>
<p>Worked for me for Mojave to change caps-lock to backspace</p>
| 15,523 |
<p>Tried something like this:</p>
<pre><code>HttpApplication app = s as HttpApplication; //s is sender of the OnBeginRequest event
System.Web.UI.Page p = (System.Web.UI.Page)app.Context.Handler;
System.Web.UI.WebControls.Label lbl = new System.Web.UI.WebControls.Label();
lbl.Text = "TEST TEST TEST";
p.Controls.Add(lbl... | <p>I'm not sure, but I don't think you can use an HttpModule to alter the Page's control tree (please correct me if I'm wrong). You CAN modify the HTML markup however, you'll have to write a "response filter" for this. For an example, see <a href="http://aspnetresources.com/articles/HttpFilters.aspx" rel="nofollow nore... | <p>There have been some changes in how you write HttpModules in IIS7 as compared to IIS6 or 5, so it might be that my suggestion is not valid if you are using IIS7.</p>
<p>If you use the Current static property of the HttpContext you can get a reference to the current context. The HttpContext class has properties for ... | 43,198 |
<p>I'm trying to extract an uploaded zip file and store its contents in the database, one entry per file. The rubyzip library has nearly no useful documentation.</p>
<p>There is an assets table that has key :string (file name) and data :binary (file contents).</p>
<p>I'm using the rubyzip library, and have made it a... | <p>Found an even more simple way: </p>
<pre><code>asset.data = entry.get_input_stream.read
</code></pre>
| <p>It would seem that you can either use the read_local_entry method like this:</p>
<pre><code>asset.data = entry.read_local_entry {|z| z.read }
</code></pre>
<p>Or, you could save the entry with this method:</p>
<pre><code>data = entry.extract "#{RAILS_ROOT}/#{entry.name}"
asset.data = File.read("#{RAILS_ROOT}/#{en... | 29,303 |
<p>For example, I rarely need:</p>
<pre><code>using System.Text;
</code></pre>
<p>but it's always there by default. I assume the application will use more memory if your code contains unnecessary <a href="http://msdn.microsoft.com/en-us/library/aa664764(VS.71).aspx" rel="noreferrer">using directives</a>. But is there... | <p>It won't change anything when your program runs. Everything that's needed is loaded on demand. So even if you have that using statement, unless you actually use a type in that namespace / assembly, the assembly that using statement is correlated to won't be loaded.</p>
<p>Mainly, it's just to clean up for personal ... | <p>The 'using' statement does not affect performance as it is merely a helper in qualifying the names of your identifiers. So instead of having to type, <em>System.IO.Path.Combine(...)</em>, you can simply type, <em>Path.Combine(...)</em> if you have <em>using System.IO</em>.</p>
| 16,494 |
<p>I am embarking on a new RIA project with Java on the backend. I'm the only developer, and the app is a line-of-business application. My current stack looks like this:</p>
<p>MySQL || Spring(JdbcTemplate for data access) || BlazeDS (remoting) || Flex(Cairngorm)</p>
<p>My question is: what changes can I make to impr... | <p><em>Manually coding SQL</em></p>
<p><a href="http://www.hibernate.org/" rel="nofollow noreferrer">Hibernate</a> is an option to cut this out.</p>
<p>One thing that may be of interest is Grails with the available Flex Plugin. It's built on Spring, Hibernate and BlazeDS, so it's all there for you. It was unbelieveab... | <p>You can try <a href="http://www.graniteds.org" rel="nofollow noreferrer">GraniteDS</a>. It's an alternative to BlazeDS, with an actionScript generator, Spring integration (an Spring security), and if you use an JPA implementation, help you with the Lazy Initialization (in a transparent way). </p>
| 39,389 |
<p>I have a fairly small MySQL database (a Textpattern install) on a server that I do not have SSH access to (I have FTP access only). I need to regularly download the live database to my local dev server on demand; i.e., I would like to either run a script and/or have a cron job running. What are some good ways of doi... | <p>Since you can access your database remotely, you can use mysqldump from your windows machine to fetch the remote database. From commandline:</p>
<pre><code>cd "into mysql directory"
mysqldump -u USERNAME -p -h YOUR_HOST_IP DATABASE_TO_MIRROR >c:\backup\database.sql
</code></pre>
<p>The program will ask you for ... | <p>I would create a (Ruby) script to do a <code>SELECT * FROM ...</code> on all the databases on the server and then do a <code>DROP DATABASE ...</code> followed by a series of new <code>INSERT</code>s on the local copy. You can do a <code>SHOW DATABASES</code> query to list the databases dynamically. Now, this assumes... | 6,062 |
<p>I am wondering if there is a tool that allows to track intermittent OutOfMemoryExceptions in C# code.</p>
<p>Ideally, I am looking for something that would detect OOM situation and once it happens, it would allow viewing the content of the managed heap.</p>
<p>I usually use WinDBG + SOS extension to view the heap ... | <p>Take a look at <a href="http://www.jetbrains.com/profiler/index.html" rel="nofollow noreferrer">JetBrains dotTrace Profiler</a>. </p>
| <p>Is it that you want to track this exception or you want to identify the cause? I've use <a href="http://www.automatedqa.com/products/aqtime/" rel="nofollow noreferrer">AQTime</a> to hunt down memory leaks in managed/unmanaged code with a fair amount of success.</p>
| 36,063 |
<p>I have this code inside a class:</p>
<pre><code>void SendStones()
{
int currenthole = hole;
int lastplace = 0;
for(int i=0;i<stns.size();i++)
{
while(1)
{//Calculate new currenthole
if(currenthole == 13) { currenthole = 7; break;}
if(currenthole == 14) { cu... | <p>It looks like hole is a simple int, and you're trying to subscript it. Is that what you mean to do? Where is hole declared?</p>
| <p>Hole is a really big class,<br>
SendStones is a function member in the class.<br>
I won't send the whole file but i can say that <br>
hole[currenthole] is a Hole *hole[14];<br>
It's a big program and project so i sent the related code needed.<br></p>
<p>Here's the code of the ReciveStones function:</p>
<p><br><br>... | 18,009 |
<p>I'm trying to find a way to calculate the intersection between a b-spline and a straight line. So far Google hasn't been much help.</p>
| <p>Your best approach might be to break down your spline into individual line segments and test each line segment for intersection with the line. The spline may intersect the line in more than one point, so you'll also have to decide which one you're interested in.</p>
| <p>Your best approach might be to break down your spline into individual line segments and test each line segment for intersection with the line. The spline may intersect the line in more than one point, so you'll also have to decide which one you're interested in.</p>
| 28,998 |
<p>Kind of a random question...</p>
<p>What I'm looking for is a way to express a cast operation which uses a defined operator of the class instance I'm casting from, and generates a compile-time error if there is not a defined cast operator for the type. So, for example, what I'm looking for is something like:</p>
<... | <p>The code you posted works with the <a href="http://www.comeaucomputing.com/tryitout/" rel="nofollow noreferrer">Cameau compiler</a> (which is usually a good indication that it's valid C++). </p>
<p>As you know a valid cast consists of no more than one user defined cast, so a possible solution I was thinking of was ... | <p>sounds like you want template specialization, something like this would do:</p>
<pre><code>/* general template */
template<typename T1, typename T2> T1 operator_cast(const T2 &x);
/* do this for each valid cast */
template<> LPCTSTR operator_cast(const CString &x) { return (LPCTSTR)x; }
</code>... | 25,752 |
<p>I'm almost certain I know the answer to this question, but I'm hoping there's something I've overlooked.</p>
<p>Certain applications seem to have the Vista Aero look and feel to their caption bars and buttons even when running on Windows XP. (Google Chrome and Windows Live Photo Gallery come to mind as examples.) ... | <p>Here's an article with full code sample on how to use your own custom "chrome" for an application:</p>
<p><a href="https://web.archive.org/web/20200718062913/http://geekswithblogs.net:80/kobush/articles/CustomBorderForms3.aspx" rel="nofollow noreferrer">http://geekswithblogs.net/kobush/articles/CustomBorde... | <p>Nope, I am afraid, there is no other easy way of doing this. </p>
<p>You are on the right track. You will need to create a custom Winform and then proceed as illustrated in this <a href="http://codemaverick.blogspot.com/2007/02/creating-custom-winforms-in-net-20-yes.html" rel="nofollow noreferrer">example</a>.</p>
| 6,394 |
<p>I'm trying to setup a new computer to synchronize with my SVN repository that's hosted with cvsdude.com.</p>
<p>I get this error:</p>
<p>![SVN Error][1] - <em>removed image shack image that had been replaced by an advert</em></p>
<p>Here's what I did (these have worked in the past):</p>
<ol>
<li><p>Downloaded an... | <p>Check you proxy settings in <strong>TortoiseSVN->Settings->Network</strong>.</p>
<p>Maybe they are configured differently than in your web browser.</p>
| <p>For me <a href="https://stackoverflow.com/a/15531448/442580">this was the solution</a>.</p>
<p>The problem was that the SVN server was behind a reverse-proxy (pound). And the reverse proxy had to be told to allow <code>OPTIONS</code>.</p>
| 13,673 |
<p>I want to do something like this from within Eclipse: <a href="http://svn.collab.net/viewvc/svn?view=rev&revision=33845" rel="nofollow noreferrer">http://svn.collab.net/viewvc/svn?view=rev&revision=33845</a></p>
<p>I use Subversive 0.7.5 with the Native JavaHL 1.5.3 (r33570) Connector.</p>
<p>I tried to chan... | <p>Found the command line answer myself:
<a href="http://svnbook.red-bean.com/en/1.4/svn.branchmerge.tags.html" rel="nofollow noreferrer">http://svnbook.red-bean.com/en/1.4/svn.branchmerge.tags.html</a></p>
<pre><code>svn copy some_branch http://server:8080/svn/tags/TagWithChange -m"TagWithChange"
</code></pre>
| <p>I have always used Subclipse <a href="http://subclipse.tigris.org/" rel="nofollow noreferrer">http://subclipse.tigris.org/</a> with eclipse - it is excellent and I think what all other plugins benchmark from.</p>
<p>It has been awhile since i used that particular setup, but subclipse will automatically add a new (n... | 33,310 |
<p>Has anyone noticed that if you retrieve HTML from the clipboard, it gets the encoding wrong and injects weird characters?</p>
<p>For example, executing a command like this:</p>
<pre><code>string s = (string) Clipboard.GetData(DataFormats.Html)
</code></pre>
<p>Results in stuff like:</p>
<pre><code><FONT size=... | <p>In this case it is not so visible as it was in my case. Today I tried to copy data from clipboard but there were a few unicode characters. The data I got were as if I would read a UTF-8 encoded file in Windows-1250 encoding <em>(local encoding in my Windows)</em>.</p>
<p>It seems you case is the same. If you save t... | <p>I don't know what your original source document is, but be aware that Word and Outlook provide several versions of the clipboard in different encodings. One is usually Windows-1252 and another is UTF-8. Possibly you're grabbing the UTF-8 encoded version by default, when you're expecting the Windows-1252 (Latin-1 + S... | 29,551 |
<p>Does anyone knows how to detect printable characters in java?</p>
<p>After a while ( trial/error ) I get to this method:</p>
<pre><code> public boolean isPrintableChar( char c ) {
Character.UnicodeBlock block = Character.UnicodeBlock.of( c );
return (!Character.isISOControl(c)) &&
... | <p>It seems this was the "Font" independent way.</p>
<pre><code>public boolean isPrintableChar( char c ) {
Character.UnicodeBlock block = Character.UnicodeBlock.of( c );
return (!Character.isISOControl(c)) &&
c != KeyEvent.CHAR_UNDEFINED &&
block != null &&
... | <p>I'm not perfectly sure whether I understand your problem. But if you want detect if character can be drawn to Graphics object, and if not print some placeholder char you might find usefull:</p>
<pre><code>Font.canDisplay(int)
</code></pre>
<p>It will check whether font can display specific codepoint (it is more th... | 27,161 |
<p>Assume I have a class foo, and wish to use a std::map to store some boost::shared_ptrs, e.g.:</p>
<pre><code>class foo;
typedef boost::shared_ptr<foo> foo_sp;
typeded std::map<int, foo_sp> foo_sp_map;
foo_sp_map m;
</code></pre>
<p>If I add a new foo_sp to the map but the key used already exists, wil... | <p>First off, your question title says boost::auto_ptr, but you actually mean boost::shared_ptr</p>
<p>And yes, the original pointer will be freed (if there are no further shared references to it).</p>
| <p>Since stackoverflow won't allow me to comment, I'll just answer. :/</p>
<p>I don't see "p" going out of scope, so the object pointed to by it will <em>not</em> be freed. "p" will still point to it.</p>
| 16,943 |
<p>Is there any difference to the following code:</p>
<pre><code>class Foo
{
inline int SomeFunc() { return 42; }
int AnotherFunc() { return 42; }
};
</code></pre>
<p>Will both functions gets inlined? Does inline actually make any difference? Are there any rules on when you should or shouldn't inline code? I o... | <p>Both forms should be inlined in the exact same way. Inline is implicit for function bodies defined in a class definition.</p>
| <p>Note that outside of a class, <code>inline</code> does something more useful in the code: by forcing (well, sort of) the C++ compiler to generate the code inline at each call to the function, it prevents multiple definitions of the same symbol (the function signature) in different translation units. </p>
<p>So if ... | 11,210 |
<p>I've run into a problem trying to return an object that holds a collection of childobjects that again can hold a collection of grandchild objects. I get an error, 'connection forcibly closed by host'.</p>
<p>Is there any way to make this work? I currently have a structure resembling this:</p>
<p>pseudo code:</p>
... | <p>As a note, you need to learn how to use the WCF logging utilities:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms730064.aspx" rel="noreferrer">Logging info.</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms732009.aspx" rel="noreferrer">Config Editor</a> (makes it a snap to setup).</p>
<p>... | <p>did you specify in your service behavior config? it seems like some information is missing in this stacktrace. </p>
<p>can you grab the exception at server side (e.g. in visual studio debug mode or with a logging library like log4net). </p>
<p>have you tried calling some other methods (simple helloworld() e.g.) o... | 24,960 |
<p>We've got a fairly large amount of code that just made the jump to Java 5. We've been using generics in those components targeted at being released in the Java 5 version, but the remaining code is, of course, full of raw types. I've set the compiler to generate an error for raw types and started manually clearing th... | <p>I would suggest ignoring the warnings. Otherwise, you'll be putting a lot of time into updating the legacy code without making any improvements to its functionality. </p>
<p><b>Update:</b> Great comment from <a href="https://stackoverflow.com/users/25920/luke">Luke</a> that I thought should get more visibility:
<... | <p>I don't think it is necessary to update all the old code. Maybe if you could somehow identify which parts of the old code are used frequently, and only update those to use generic types? Or maybe you could only worry when the raw type is returned from a public function? A lot of these cases are probably just priv... | 26,973 |
<p>How do you resolve an NT style device path, e.g. <code>\Device\CdRom0</code>, to its logical drive letter, e.g. <code>G:\</code> ?</p>
<p>Edit: A Volume Name isn't the same as a Device Path so unfortunately <code>GetVolumePathNamesForVolumeName()</code> won't work.</p>
| <p>Hopefully the following piece of code will give you enough to solve this - after you've initialised it, you just need to iterate through the collection to find your match. You may want to convert everything to upper/lower case before you insert into the collection to help with lookup performance.</p>
<pre><code>ty... | <p>Here is refactored version of the solution.</p>
<p>I replaced TChAR with wchar_t because afaik it's not a good idea to use it in most projects.</p>
<pre class="lang-cpp prettyprint-override"><code>std::map<std::wstring, std::wstring> GetDosPathDevicePathMap()
{
// It's not really related to MAX_PATH, but... | 15,470 |
<p>What is the best way to graph scatter plots in C++? </p>
<p>Do you write data to a file and use another tool? Is there a library like matplotlib in Python?</p>
| <p>I always write out data and then using <a href="http://www.gnuplot.info/" rel="noreferrer">gnuplot</a> to create my graphs. It is by far the best way I have found of producing graphs in a variety of formats: eps, png, jpeg, xpm, you name it.</p>
<p><code>gnuplot</code> will do scatter plot very easily. Provided the... | <p><a href="http://www.advsofteng.com/cdcpp.html" rel="nofollow noreferrer">Chart Director</a> has bindings for C++. I've used their .Net libraries, and I've been pretty happy with them. It's a pretty cheap library, and gives you the power to do all sorts of different charts.</p>
| 26,435 |
<p>My stuff is made with several components among which some are written in C. As I would like to add some security features, I am thinking of communicating over an SSL/TLS layer.</p>
<p>Could you advise me some good lib to do this (if possible) ?</p>
| <p>We use <a href="http://axtls.cerocclub.com.au/" rel="nofollow noreferrer">axTLS</a> which works great on both our server (.NET) and our embedded systems (Linux and uClinux). We had problems getting OpenSSL to work well on uClinux.<br>
axTLS is not as feature complete as OpenSSL yet so make sure it meets your require... | <p>I would suggest not spending your time trying to implement an SSL function in your app. Instead, you could just use an existing SSL-tunnel software, which creates an SSL tunnel in front of your existing socket application.</p>
<pre><code>Internet --- [SSLTunnel] --- Your App
</code></pre>
<p>For example, you could... | 22,631 |
<p>Just trying to get my irb sessions to actually list the current line of code, and those around it. Similar to what Perl's -d debugging mode lets you ddo.</p>
| <p>Its because, when you are doing it interactively, your "sourcefile" is std-in. </p>
| <p>Its because, when you are doing it interactively, your "sourcefile" is std-in. </p>
| 41,802 |
<p><a href="http://en.wikipedia.org/wiki/C%2B%2B11" rel="noreferrer">C++11</a> introduces <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2378.pdf" rel="noreferrer">user-defined literals</a> which will allow the introduction of new literal syntax based on existing literals (<code>int</code>, <code>hex... | <p>At first sight, it seems to be simple syntactic sugar.</p>
<p>But when looking deeper, we see it's more than syntactic sugar, as <strong>it extends the C++ user's options to create user-defined types that behave exactly like distinct built-in types.</strong> In this, this little "bonus" is a very interesti... | <p>Line noise in that thing is huge. Also it's horrible to read.</p>
<p>Let me know, did they reason that new syntax addition with any kind of examples? For instance, do they have couple of programs that already use C++0x?</p>
<p>For me, this part:</p>
<pre><code>auto val = 3.14_i
</code></pre>
<p><strong>Does not ... | 29,419 |
<p>I have an html form that a user will fill out and print. Once printed, these forms will be faxed or mailed to a government agency, and need to look close enough like the original form published by said agency that a government bureaucrat doesn't spot that this is a reproduction. The data entered in the form is not... | <p>Three years after this question is posted and this is almost within reach. In fact, it's completely achievable in Firefox 1+, Chrome 1+, Safari 3+ and Opera 15+ using the <a href="http://wiki.csswg.org/spec/css4-ui#dropped-css3-features" rel="noreferrer"><del>CSS3</del></a> <code>appearance</code> property.</p>
<p... | <p>Very simple idea using a table and no Javascript.
Am I being too simplistic?</p>
<pre><code><style type="text/css" media="screen">
#ageBox {display: none;}
</style>
<style type="text/css" media="print">
#ageButton {display: none;}
</style>
<tr><td>Age:</td>
<td id="ag... | 35,309 |
<p>I'm trying to create an in-process unit test for my service to client interactions using net.pipe binding. Like a good WCF service it uses FaultContractAttribute on service operations to expose possible faults <em>(wrapped exceptions)</em> to metadata. I would like to have the client and service endpoints configur... | <p>If the ValidationException class you describe above is the class you are using for faults, it may be the source of your problem. You should derive your fault exceptions from FaultException because it is Serializable. ApplicationException is not.</p>
<p>Wagner is right, you need to decorate your operation definiti... | <p>I got that same error a few days ago.<br>
I solved creating my own class (MyFault) and throwing FaultException from the server and catching those in the client. MyFault has a string member wich is the Exception Message I want the client to see.</p>
<p>I hope I made myself clear... I'll try to look for a nice sample... | 27,142 |
<p>I'm still trying to decide whether my (home) project should use <a href="http://en.wikipedia.org/wiki/UTF-8" rel="nofollow noreferrer">UTF-8</a> strings (implemented in terms of std::string with additional UTF-8-specific functions when necessary) or some 16-bit string (implemented as std::wstring). The project is a ... | <p>UTF-16 is still a variable length character encoding (there are more than 2^16 unicode codepoints), so you can't do O(1) string indexing operations. If you're doing lots of that sort of thing, you're not saving anything in speed over UTF-8. On the other hand, if your text includes a lot of codepoints in the 256-6553... | <p>Have you considered using wxStrings? If I remember correctly, they can do utf-8 <-> Unicode conversions and it will make it a bit easier when you have to pass strings to and from the UI.</p>
| 12,890 |
<p>After downloading files from a remote UNIX FTP server, you want to verify that you have downloaded all the files correctly. Minimal you will get information similar to "dir /s" command in Windows command prompt. The FTP client runs on Windows.</p>
| <p>Sadly this was written for Unix/Linux users :/</p>
<p>Personally, I would install CYGWIN just to get Linux binaries of LFTP/RSYNC to work on windows, as there appears not to be anything that competes with it. </p>
<p>As @zadok.myopenid.com
mentioned rsync, this appears to be a windows build for it using CYGWIN ( ... | <p>You can use <strong>ftp.listFiles("directory")</strong> from apache-commons-net and can write your own BFS or DFS to fetch all the files recursively.</p>
| 12,370 |
<p>Imagine I have the folling XML file:</p>
<p><a>before<b>middle</b>after</a></p>
<p>I want to convert it into something like this:</p>
<p><a>beforemiddleafter</a></p>
<p>In other words I want to get all the child nodes of a certain node, and move them to the parent node in orde... | <p>If your actual goal is to remove the links from a web page, then you should use a stylesheet like this, which matches all XHTML <code><a></code> elements (I'm assuming you're using XHTML?) and simply applies templates to their content:</p>
<pre><code><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3... | <p>Have you tried this?</p>
<p><code>file.xml</code></p>
<pre><code><r>
<a>start<b>middle</b>end</a>
</r>
</code></pre>
<p><code>template.xsl</code></p>
<pre><code><xsl:template match="/">
<a><xsl:value-of select="r/a" /></a>
</xsl:template>
... | 15,098 |
<p>fossil <a href="http://www.fossil-scm.org" rel="noreferrer">http://www.fossil-scm.org</a><br>
I found this recently and have started using it for my home projects. I want to hear what other people think of this VCS. </p>
<p>What is missing in my mind, is IDE support. Hopefully it will come, but I use the command... | <p>Mr. Millikin, if you will take a few moments to review some of the documentation on fossil, I think <a href="https://stackoverflow.com/a/165786/3195477">your objections</a> are addressed there. Storing a repository in an sQLite database is arguably safer than any other approach. See <a href="http://www.fossil-scm.... | <p>Perhaps an uneducated knee-jerk reaction, but the idea of storing a repository in a binary blob like an SQLite database terrifies me. I'm also dubious of the benefits of including wikis and bug trackers directly in the VCS -- either they're under-featured compared to full software like Trac, or the VCS is massively ... | 18,906 |
<p>I am setting up a test version of my website against a new schema. I am trying to connect using the proxy connection and am getting the following error: </p>
<blockquote>
<p>ORA-28150: proxy not authorized to connect as client</p>
</blockquote>
<p>my connect string has the following form:</p>
<blockquote>
<p>... | <p>According to <a href="http://download.oracle.com/docs/cd/B28359_01/server.111/b28278/e24280.htm#ORA-28150" rel="nofollow noreferrer">the docs</a>: Grant the proxy user permission to perform actions on behalf of the client by using the ALTER USER ... GRANT CONNECT command.</p>
| <p>Here is the <a href="http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_4003.htm" rel="nofollow noreferrer">ALTER USER documentation</a>. You will find the CONNECT THROUGH clause there as well as some proxy users examples. </p>
| 17,191 |
<p>I'm using the Belltown theme in a sharepoint portal and there are some styles that I want to change change in the Belltown stylesheet. I thought that I could just edit the theme.css file located at:</p>
<p>C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES\BELLTOWN</p>
<p>and ... | <p>I believe if you re-apply the Belltown theme to your site it will pick up your changes. When you apply a theme Sharepoint copies the contents of the TEMPLATE\THEMES\ <em>THEME FOLDER</em> to the site.</p>
<p>The other option would have been to point Sharepoint Designer at the site and modify the styles there which ... | <p>Deploying a new style sheet can be an iterative process. For this reason, it may be helpful to use the <a href="http://www.heathersolomon.com/blog/articles/brandsppart2.aspx" rel="nofollow noreferrer">CSS Import Trick</a> described on Heather Solomon's blog. </p>
<p>This could be helpful in that you won't have to ... | 43,860 |
<p>I have Perl on Mac, Windows and Ubuntu. How can I tell from within the script which one is which? Thanks in advance.</p>
<p><strong>Edit:</strong> I was asked what I am doing. It is a script, part of our cross-platform build system. The script recurses directories and figures out what files to build. Some files are... | <p>Examine the <a href="http://perldoc.perl.org/perlvar.html#%24OSNAME" rel="noreferrer"><code>$^O</code></a> variable which will contain the name of the operating system:</p>
<pre><code>print "$^O\n";
</code></pre>
<p>Which prints <code>linux</code> on Linux and <code>MSWin32</code> on Windows.</p>
<p>You ca... | <p>yes using Config module can be a good thing. One more possibility is getting the info from /etc/*release files</p>
<p>for eg..</p>
<p>cat /etc/os-release</p>
<pre><code>NAME="UBUNTU"
VERSION="12.0.2 LTS, Precise Pangolin"
ID="UBUNTU"
ID_LIKE=debian
PRETTY_NAME="Ubuntu precise (12.0.2 LTS)"
VERSION_ID="12.04"
</co... | 43,397 |
<p>Is there an issue with databinding in WPF when you bind to the current source (Path=".") and using a converter? The two way binding doesn't seem to work in this situation.</p>
<p>I know I could change the path, but I want to be able to pass the "Name" value to the converter.</p>
<p>I can't get the following exampl... | <p>Got the answer. We need to run this code, maybe in a console app. I still didn't get how to remove the event handler once it has been added though...</p>
<pre><code>string siteUrl = Console.ReadLine();
SPSite site = new SPSite(siteUrl);
SPWeb web = site.OpenWeb();
string listName = Console.ReadLine();
SPList list ... | <p>Take a look at the code that comes with the tool from u2u that I posted earlier. It is a convenient tool when you are working with event handlers.</p>
| 37,679 |
<p>I am about to embark on a rewrite of a VB6 application in .NET 3.5sp1. The VB6 app is pretty well written and the data layer is completely based on stored procedures. I'd like to go with something automated like Linq2SQL/Entity Framework/NHibernate/SubSonic. Admittedly, I haven't used any of these tools in anythi... | <p>I'm going to play devil's advocate and recommend you at least consider sticking with the stored procedures. These represent a chunk of code that you do not have to re-write and debug. <a href="http://www.joelonsoftware.com/printerFriendly/articles/fog0000000069.html" rel="nofollow noreferrer">This article</a> from... | <p>SubSonic, even according to Rob Connery, one of the authors, is written more to support rapid application development and less about large applications. I'd say go with NHibernate as you'll find the most support from the community as well as tried and true tested framework. You can get good information from www.di... | 36,157 |
<p>Let's look at an example - books. A book can have 1..n authors. An author can have 1..m books. What is a good way to represent all of the authors of a book?</p>
<p>I came up with an idea to create a Books table and an Authors table. The Authors table has a primary AuthorID key the author's name. The Books table has... | <p>Add another table called BookAuthors with columns for BookID, AuthorID, and NameUsed. A NULL value for NameUsed would mean to pull it from the Author's table instead. This is called an Intersection table.</p>
| <p>For 1..n relationship (author has many books, author has many aliases):</p>
<ol>
<li>Put a foreign key author_id in Books pointing at author.</li>
<li>Create a new table, author_aliases, to hold the aliases information.</li>
<li>Put a foreign key alias_id in Books pointing at alias (nullable if author details are d... | 22,216 |
<p>I've read Rick Strahl's article on <a href="http://www.west-wind.com/weblog/posts/246222.aspx" rel="nofollow noreferrer">Linq to SQL DataContext Lifetime Management</a> hoping to find some answers on how I would manage my .dbml files since they are so closely related to DataContext. Unfortunately, Rick's article se... | <p>Please note that LINQ2SQL is intended for simple and easy way to handle database relationship with objects.</p>
<p>Do not break table relationship and units of work concepts by creating multiple .dbml files. </p>
<p>If you ever need to create multiple .dbml files (which i don't recommend), then try to satisfy the ... | <p>The answer is tricky because it's what the situation requires. I try to logically separate each DBML into contexts (after all, the DBML provides the DataContext functionality). So if my app has a single context, then it doesn't make sense for me to have a separate DBML for each table. Context is king when creating... | 43,834 |
<p>In the Apple documentation for <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSRunLoop_Class/Reference/Reference.html#//apple_ref/occ/instm/NSRunLoop/run" rel="noreferrer">NSRunLoop</a> there is sample code demonstrating suspending execution while waiting for a flag to be set b... | <p>Runloops can be a bit of a magic box where stuff just happens.</p>
<p>Basically you're telling the runloop to go process some events and then return. OR return if it doesn't process any events before the timeout is hit.</p>
<p>With 0.1 second timeout, you're htting the timeout more often than not. The runloop fire... | <p>Your second example just work around as you poll to check input of the run loop within time interval 0.1.</p>
<p>Occasionally I find a solution for your first example:</p>
<pre><code>BOOL shouldKeepRunning = YES; // global
NSRunLoop *theRL = [NSRunLoop currentRunLoop];
while (shouldKeepRunning && [t... | 18,036 |
<p>I currently store my log file in the Program Files\My App folder but some users don't have permission to write here if they are not a power user or administrator. Is there a common location for this type of log file?</p>
<h3>Update:</h3>
<p>I'm currently using Application.StartupPath.</p>
<pre><code>logFileLocation ... | <p><a href="http://msdn.microsoft.com/en-us/library/system.environment.getfolderpath.aspx" rel="nofollow noreferrer">I'd use Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)</a> and then <a href="http://msdn.microsoft.com/en-us/library/system.io.path.combine.aspx" rel="nofollow noreferrer">Pat... | <p>I would use the temporary folder.</p>
<p>Use the function <a href="http://msdn.microsoft.com/en-us/library/aa364992(VS.85).aspx" rel="nofollow noreferrer">GetTempPath</a> on the Windows API,
or <a href="http://msdn.microsoft.com/en-us/library/system.io.path.gettemppath.aspx" rel="nofollow noreferrer">Path.GetTempPa... | 42,869 |
<p>I am writing my own slicer and wonder if there is a mathematical proof that proves that the intersection of the slicing plane with the STL file will only produce closed-loop polygons for every given slicing plane?</p>
<p>Thanks!</p>
| <p>You can't prove that because it isn't true. An STL file is just a collection of triangles. There is no guarantee that an intersection with the slicing plane will consist of closed-loop polygons. To be suitable for 3D printing an STL file should represent one or more closed, disjoint polyhedra (which would yield clos... | <p>I am also trying to write my own slicer and so I would just like to offer some additional information. </p>
<p>What you will find is that .stl files just store triangles and don't validate that the triangles assemble to create a printable model so a lot if not most .stl files are going to have data that isn't exact... | 767 |
<p>What is the best way of storing data out to a file on a network, which will be later read in again programmatically. Target platform for the program is Linux (Fedora), but it will need to write out a file to a Windows (XP) machine</p>
<p>This needs to be in C++, there will be a high number of write / read events so... | <p>Your question is too general. I would first define my needs, then a record structure for the file, and then use a textual representation to save it. Take a look at <a href="http://www.faqs.org/docs/artu/ch05s02.html" rel="nofollow noreferrer">Eric Stone Raymond's data metaformat</a>, at <a href="http://www.json.org/... | <p>Store it as binary if you're not doing text storage. Text is hideously inefficient; XML is even worse. The lack of efficiency of the storage format predicates larger file transfers which means more time. If you are having to store text, filter it through a zip library.</p>
<p>Your main issue is going to be file loc... | 29,690 |
<p>The site I'm working on is done in Classic ASP, and I'm trying to do it as best as possible. I've abstracted it out into a Rails-like directory structure:</p>
<pre>
app_name
- app
- includes
- helpers
- lib
- partials
- public
- stylesheets
- images
- javascripts
</pre>
<p>I've cr... | <p>You're probably going to run into issues mixing server-side and web directories.</p>
<p><code>Server.MapPath</code> will give you <strong><code>C:\InetPub\...\public\images\my_pic.jpg</code></strong> when you probably want <strong><code>/public/images/my_pic.jpg</code></strong>. The browser has no way of grabbing t... | <p>An excellent tool to use when troubleshooting these types of issues is Fiddler. It will show you the calls and responses directly bewtween your web browser and the server. It works out of the box with IE and FireFox support is just a config setting away.</p>
<p>I'ver personally used Fiddler to track down image lo... | 46,584 |
<p>For example, this regex</p>
<pre><code>(.*)<FooBar>
</code></pre>
<p>will match:</p>
<pre><code>abcde<FooBar>
</code></pre>
<p>But how do I get it to match across multiple lines?</p>
<pre><code>abcde
fghij<FooBar>
</code></pre>
| <p>It depends on the language, but there should be a modifier that you can add to the regex pattern. In PHP it is:</p>
<pre><code>/(.*)<FooBar>/s
</code></pre>
<p>The <strong>s</strong> at the end causes the dot to match <em>all</em> characters including newlines.</p>
| <h3>Option 1</h3>
<p>One way would be to use the <code>s</code> flag (just like the accepted answer):</p>
<pre><code>/(.*)<FooBar>/s
</code></pre>
<h3><a href="https://regex101.com/r/U9Ryj9/1/" rel="nofollow noreferrer">Demo 1</a></h3>
<h3>Option 2</h3>
<p>A second way would be to use the <code>m</code> (mul... | 19,250 |
<p>If I write <code>Session["asdf"] = 234;</code></p>
<p>In my asp.net web app, does this mean the client will have a cookie stored on their browser?</p>
| <p>Yes, but 234 won't be stored in the cookie. The cookie will only contain a unique ID (for example, <code>lit3py55t21z5v55vlm25s55</code>). Every time ASP.NET sees that unique ID, it will look up the corresponding session information.</p>
<p>If you don't want to use cookies, you can put the session ID in the URL. Re... | <p>Session variables are kept on the server, but the user will have a cookie that identifies his session.</p>
| 31,156 |
<p>Can anyone think of a good solution for getting IOC into a console application?</p>
<p>At the moment we are just using a static class with the following method:</p>
<pre><code>public static T Resolve<T>()
{
return dependencyResolver.Resolve<T>();
}
</code></pre>
<p>I would like the experience to b... | <p>You will have to make a service locater call (<code>Resolve<T>()</code>) somewhere. The trick is to get it as out-of-the-way as possible. For console applications this bootstrapping happens in the <code>Main()</code> method. Do it there and minimize those Resolve calls elsewhere and you'll be great. For mo... | <p>I've used Spring.NET from a console app with no problems. You just need to point it at your config file, and it will hook up all the dependencies. What you then <em>do</em> with those objects depends on what your console app is trying to do, of course.</p>
| 36,634 |
<p>I'm using Eclipse 3.4 with WTP 3.0.2 and running a fairly large Dynamic Web Project. I've set up the project so that I can access it at <a href="http://127.0.0.1:8080/share/" rel="noreferrer">http://127.0.0.1:8080/share/</a> but whenever I do, I get the following error:</p>
<pre>
java.lang.NoSuchMethodError: java... | <p>I ended up answering my own question: the problem was that among the necessary JARs that I had added to Tomcat was a conflicting servlet.jar. When I removed this, the error disappeared.</p>
| <p>Did you set a Tomcat path in "Preferences->Tomcat->Advanced->Tomcat base" ?</p>
<p>Try to clean that path (getting back to default configuration), and check if that does solve the problem.</p>
| 25,434 |
<p>In the Oracle world, it's been gospel to build your database block size to be even multiples of the File system's block size. I assume this is still true but I'm not adverse to being told why technology has made this irrelevant.</p>
<p>But I've been told some SQL Server DBA's are going to upgrade the OS of a SS2000... | <p>Make sure you read the Microsoft's <a href="http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/pdpliobp.mspx" rel="nofollow noreferrer">Predeployment I/O Best Practices</a></p>
<p>It recommends using 64K allocation units for NTFS volumes. </p>
<p>Also, read <a href="http://www.microsoft.com/technet/prod... | <p>The overall performance of the file-system can make a noticeable difference.</p>
<p>For example, I heard when Windows Server 2003 came out that SQL Server 2000 performance on that platform was improved significantly.</p>
<p>So it doesn't surprise me. I don't think the multiple factor is that big of a deal.</p>
| 38,043 |
<p>I need to use an x509 certificate to get secure message level authentication from a rich client via the internet to a secure WCF Web Service.</p>
<p>Specifically, I am looking for a working step-by-step guide to setup, configuration, coding, and deployment, including creating a 'dev' certificate, installing it, and... | <p>The following steps are a guide to get you started:</p>
<p>1) Firstly, you need a Root Authority to generate your client and server certificates. You can either use an external Authority Provider (e.g. Verisign) or you can generate your own using something like Microsoft Certificate Server.</p>
<p>To generate a de... | <p>I'd recommend reading the WCF Security guidance from Microsoft</p>
<p>This deals with this scenario as well as many others</p>
<p><a href="http://www.codeplex.com/WCFSecurityGuide/" rel="nofollow noreferrer">http://www.codeplex.com/WCFSecurityGuide/</a></p>
<p>edit: now at <a href="https://archive.codeplex.com/?p... | 43,549 |
<p>Which sorting algorithm works best on mostly sorted data?</p>
| <p>Based on the highly scientific method of watching <a href="http://www.sorting-algorithms.com/" rel="noreferrer">animated gifs</a> I would say Insertion and Bubble sorts are good candidates. </p>
| <p>Keep away from QuickSort - its very inefficient for pre-sorted data. Insertion sort handles almost sorted data well by moving as few values as possible.</p>
| 27,087 |
<p>How could you copy the contents of an HDC to a bitmap?</p>
| <p>Off the top of my head I think you need to:</p>
<ul>
<li>Create a new DC compatible with the source DC. Call this the memory DC.</li>
<li>Create a new bitmap of the correct size.</li>
<li>Select the bitmap into the memory DC.</li>
<li>BitBlt the source DC into the memory DC.</li>
<li>The bitmap should now contain a... | <p>There is a good piece of sample code <a href="http://www.codexxi.com/MyBlocks.html#atBmpTest" rel="nofollow noreferrer">here</a> that does just that (amongst other things).</p>
<p>I've used a similar technique before (many moons ago), but do not have the code to hand.</p>
| 45,720 |
<p>Is there any UI library that can be to build both a text user interface (ncurses) and graphical user interface (GTK? QT?) from the same source?
I know that debconf can be used with various frontends, I would like to build something similar but programmable.</p>
| <p>you could write your program to uses ncurses, and then use <a href="http://pdcurses.sourceforge.net/" rel="nofollow noreferrer">PDCurses</a> to convert it to an X11 application - as the readme advertise.</p>
<p>I know it because I've used it as portable curses, though I've never tested its X11 capabilities</p>
| <p>Maybe tcl/tk would provide what you want <a href="http://www.tcl.tk/" rel="nofollow noreferrer">http://www.tcl.tk/</a></p>
<p>Here's the page on interfacing with curses. There is a claim there of integration with ncurses.</p>
<p><a href="http://www2.tcl.tk/2372" rel="nofollow noreferrer">http://www2.tcl.tk/2372</a... | 6,147 |
<p>I am currently building a small website where the content of the main div is being filled through an Ajax call. I basically have a php script that returns the content like this:</p>
<p>(simplified php script...)</p>
<pre><code>
if(isset($_POST["id_tuto"])){
PrintHtml($_POST["id_tuto"]);
}
function PrintHtml($id... | <p>You could do it like so:</p>
<pre><code><?php
function PrintHtml($id) {
switch($id) {
case [...]:
?>
<h1>Tut page 1</h1>
<p>this is html content.</p>
<?php
break;
[...]
}
}
?>
</code></pre>
<p>Or perhaps:</p>
<pre><code><?php... | <p>You just do it the way you'd normally generate an HTML page, except it is not wrapped in HTML HEAD or BODY tags. It's just the HTML fragment that will be added to your page.</p>
<p>Everything you "echo" becomes part of the output. You can do it is pieces or all on one go, it doesn't matter because it call gets sent... | 28,642 |
<p>I have a ASP.NET application running on a remote web server and I just started getting this error. I can't seem to reproduce it in my development environment:</p>
<pre><code>Method not found: 'Void System.Collections.Generic.ICollection`1..ctor()'.
</code></pre>
<p>Could this be due to some misconfiguration of .N... | <p>Are the .NET versions on both systems the same inc. the same service pack?</p>
| <p>Is your IIS setup to use .NET 2.0? If not, change it to 2.0. If you can't see 2.0 in the list then you'll need to run aspnet_regiis from the 2.0 framework directory.</p>
| 14,911 |
<p>I have a microcontroller that must download a large file from a PC serial port (115200 baud) and write it to serial flash memory over SPI (~2 MHz). The flash writes must be in 256 byte blocks preceded by a write command and page address. The total RAM available on the system is 1 kB with an 80 byte stack size.</p>
... | <p>I'd do something like a scatter gather on a PC. Create a linked list of a struct like this:</p>
<pre><code>typedef struct data_buffer {
char flags;
char[128] data;
}
</code></pre>
<p>Have one of the bits in the flag mean "ReadyToFlash" and one for "Flashing". You should be able to tune the number of buff... | <p>Not sure what I'm missing here, but if the fact is that the average rate of data coming from the PC is higher than the average rate you can write it to the flash, then you're either going to need a lot of RAM, or you're going to need flow control.</p>
<p>But are you saying that it worked when you had block buffers,... | 46,933 |
<p>Anyone have any success or failure running Jira on a VM?</p>
<p>I am setting up a new source control and defect tracking server. My server room is near full and my services group suggested a VM. I saw that a bunch of people are running SVN on VM (including NCSA). The VM would also free me from hardware problems ... | <p>I don't see why you shouldn't run jira off a vm - but jira needs a good amount of resources, and if your vm resides on a heavily loaded machine, it may exhibit poor performance. Why not log a support request (support.atlassian.com) and ask?</p>
| <p>If, by VM, you mean a virtual instance of an OS, such as an instance of linux running on Xen, VMWare, or even Amazon EC2, then Jira will run just fine. The only time you need to worry about virtual systems is if you're doing something that depends on hardware, such as running graphical 3D apps, or say something tha... | 11,792 |
<p>I've developed a Visual C#.NET 2008 Express Edition solution containing three projects. I am cleaning it up to commit it into a CVS repository.</p>
<p>There are several files that are created during the build process that are not necessary to be placed in the repository since they will be regenerated automatically.... | <p>Typically these are the only things that you <em>have</em> to commit:</p>
<ul>
<li>.sln files</li>
<li>.cs files</li>
<li>.csproj files</li>
<li>.config files</li>
<li>External DLLs and corresponding XML/config files that you are referencing</li>
<li>other non-generated files that your application uses</li>
</ul>
... | <p>Thanks! This is what I have created:</p>
<pre><code>bin
obj
*.cache
*.suo
*.csproj.user
</code></pre>
| 17,753 |
<p>C#: What is a good Regex to parse hyperlinks and their description?</p>
<p>Please consider case insensitivity, white-space and use of single quotes (instead of double quotes) around the HREF tag.</p>
<p>Please also consider obtaining hyperlinks which have other tags within the <code><a></code> tags such as <... | <p>As long as there are no nested tags (and no line breaks), the following variant works well:</p>
<pre><code><a\s+href=(?:"([^"]+)"|'([^']+)').*?>(.*?)</a>
</code></pre>
<p>As soon as nested tags come into play, regular expressions are unfit for parsing. However, you can still use them by applying more a... | <p>Just going to throw this snippet out there now that I have it working..this is a less greedy version of one suggested earlier. The original wouldnt work if the input had multiple hyperlinks. This code below will allow you to loop through all the hyperlinks:</p>
<pre><code>static Regex rHref = new Regex(@"<a.*?hr... | 4,589 |
<p>I really don't understand the fascination with XHTML strict. Inline JavaScript typically requires a rats nest of escapes to make it compatible with XHTML and semi-backwards compatible with MSIE 5 & 6. Then there is the issue of not being OCD enough on user input to make sure you don't miss any illegal charact... | <p>XHTML1 vs HTML4 and Strict vs Transitional are completely orthogonal issues.</p>
<p>XML might not give any huge advantage to browsers today, but on the server end it's an order of magnitude easier to process documents using XML than trying to parse the mess that is old-school-SGML-except-not-really HTML4.</p>
<p>R... | <p>XHTML is by definition XML, unlike HTML.</p>
<p>This means you can do funky useful stuff with it, such as easily validate and parse it (since you know it's XML and thus can use the myriad of tools available).</p>
<p>Also, geeks like to make things "more correct" ;-)</p>
| 35,200 |
<p>After having read that QuickSilver was no longer supported by BlackTree and has since gone open source, I noticed more and more people switching to/suggesting other app launchers i.e. Buttler and LaunchBar. </p>
<p>Is QuickSilver still relevant? Has anyone experienced any instability since it's gone open source?</p... | <p>Quicksilver is still alive and well. There are at least a couple of endeavours to keep it going, up to date and restructure and clean up the code base. Check out the <a href="http://code.google.com/p/blacktree-alchemy/" rel="nofollow noreferrer">code</a> from Google Code.</p>
<p>As for launching apps, not even Spot... | <p>I use quicksilver all day (on latest version of OSX); and no spotlight doesn't negate it... quicksilver is still <em>much</em> faster for launching applications. </p>
| 13,280 |
<p>I'm trying to put in an exception in my web.config so that one page does not require authentication. However, it still redirects to the login page.</p>
<p><strong>The question isn't how to setup the web.config</strong>. Why? Our system (for better or worse) has a bunch of instrumentation besides the web.config. ... | <p>If you can debug the app, starting from <a href="http://msdn.microsoft.com/en-us/library/system.web.httpapplication.beginrequest.aspx" rel="nofollow noreferrer">HttpApplication.BeginRequest</a> in global.asax and <a href="http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framewor... | <p>Have you tried turning on Tracing? That may help.</p>
<p>How are you specifying the page doesn't require authentication, like:</p>
<pre><code><system.web>
...
</system.web>
<location path="NoAuthNeeded.aspx">
<system.web>
<authorization>
<allow roles="*" />... | 38,406 |
<p>I recently ripped a piece off of a nitro RC car I have. Seeing as I cannot find a direct replacement at the moment, I modeled it and it seems easy to 3d print.</p>
<p>My main concern is how heat resistant the replacement will be - this is a combined structural/exhaust heat deflector piece.</p>
<p>I've previously kno... | <blockquote>
<p>I have heard that it is best to use a raft</p>
</blockquote>
<p>Actually, it is not best to use a raft, a raft is an aid that can best be used in special cases, e.g. for filaments that shrink reasonably (PLA is not such a filament).</p>
<p>A raft always caused a rough bottom of your print and is frequen... | <p>Rafts fuse with models because the filament gets overheated. To avoid this, keep the temperature in the room between between 23 and 28 °C. Malfunctioning extruder fans, a heater & thermocouple, extruder printed circuit board (PCB), extruder cable, and motherboard can be also to blame.</p>
| 2,162 |
<p>How can I construct my ajaxSend call, this seems like the place to put it, to preview what is being passed back to the broker? also, can I stop the ajax call in ajaxSend?..so I can perfect my url string before dealing with errors from the broker?</p>
<p>This is the complete URL that, when passed to the broker, will... | <p>As far as I know, the only way to do that is to enter something (anything) on that line, then delete it. Or hit space and you'll never see it there until you return to that line.</p>
<p>Once VS determines that you've edited a line of text, it won't automatically modify it for you (at least, not in that way that yo... | <p>This is an annoyance to myself as well. Anytime the code is reformatted the blank lines are de-tabbed.
You might look at this: <a href="http://visualstudiogallery.msdn.microsoft.com/ac4d4d6b-b017-4a42-8f72-55f0ffe850d7" rel="nofollow">http://visualstudiogallery.msdn.microsoft.com/ac4d4d6b-b017-4a42-8f72-55f0ffe850d7... | 9,957 |
<p>I would like to 3D print a small thin tub/mold for an epoxy resin. I have tubings inserted into holes, and I need to fix these tubings securely with epoxy (see picture below). The space is very limited, and the whole assembly must have a smallest possible footprint, so I have to confine the epoxy from spreading to t... | <p>Cura is exceptionally bad at printing details comparable in size to the configured line width. Lower your wall line width to something like half the wall thickness (i.e. 0.225 mm) and see if that works. With a standard 0.4 mm nozzle I've had success printing tiny details with 0.2 mm line width or smaller. For exampl... | <p>I recently wanted to print something with small walls as well and <a href="https://www.gambody.com/blog/3d-printing-gaps-cura-settings/" rel="nofollow noreferrer">this site</a> helped me out.
Basically just set horizontal expansion to 0.04 and Cura does a better job.</p>
| 1,687 |
<p>In handling a WM_GETMINMAXINFO message, I attempt to alter the parameter MINMAXINFO structure by changing the ptMaxSize. It doesn't seem to have any effect. When I receive the WM_SIZE message, I always get the same value, no matter whether I increase or decrease the ptMaxSize in the WM_GETMINMAXINFO.</p>
| <p>Are you sure your window is maximized? As per <a href="http://msdn.microsoft.com/en-us/library/ms632605(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms632605(VS.85).aspx</a>, MINMAXINFO::ptMaxSize controls the maximum size of the window wen maximized.</p>
<p>If you want to control ... | <p>A window must have the <code>WS_THICKFRAME</code> or <code>WS_CAPTION</code> style to receive <code>WM_GETMINMAXINFO</code>.</p>
<p>This is basically all you need to know.</p>
| 17,220 |
<p>Is it possible to read a disk directly with .NET? By directly, I mean via the device bypassing the file system. I think I would go about this by opening the device some way "\Device\Ide\IdeDeviceP2T0L0-1" for example.</p>
<p>If I can't open the device with a .NET API, knowing which Win32 API to use would... | <p><a href="http://msdn.microsoft.com/en-us/library/aa363858.aspx" rel="noreferrer">CreateFile</a> has support for direct disk access. Read the notes under "Physical Disks and Volumes". You should be able to P/Invoke the call.</p>
<p>Note that Vista and Server 2008 have <a href="http://support.microsoft.com/kb/942448"... | <p>In .NET 5, you can use the FileStream method to read a file on the disk.</p>
<pre><code>new FileStream(@"\\.\PhysicalDrive1", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
</code></pre>
| 5,909 |
<p>I'm trying to parse objects to XML in Delphi, so I read about calling the object's ClassInfo method to get its RTTI info.</p>
<p>The thing is, this apparently only works for TPersistent objects. Otherwise, I have to specifically add a compiler directive {$M+} to the source code for the compiler to generate RTTI inf... | <p>Did you put those properties and methods into the <code>published</code> section?</p>
<p>Besides that, 'classical' RTTI ($TYPEINFO ON) will only get you information on properties, not on methods. You need 'extended' RTTI ($METHODINFO ON) for those.</p>
<p>Good starting point for extended RTTI: <a href="http://hall... | <p>As for the RttiType problem returning only nil, this probably occurs for one reason: in your test, you did not instantiate the class at any time. The compiler, because it never has a reference to this class (because it is not an instance at all), simply removes it from the information as a form of optimization. See ... | 20,337 |
<p>How is it possible to identify that the browser's close button was clicked?</p>
| <p>From the <a href="http://www.w3schools.com/jsref/jsref_events.asp" rel="nofollow noreferrer">JavaScript Event Reference</a>, the closest match appears to be the OnUnload event. However, this also catches navigation away from the page (and thus you don't want the functions to run if the user actually clicks on a lin... | <p>There is usually an event which fires when the user leaves the page (unload?) - this may be browser specific.</p>
<p>There is also a property, window.closed, which is set on the window object after its associated window is closed. This is typically used when you have a reference to a popup window.</p>
<p>I'm not s... | 32,641 |
<p>How can I determine if a remote drive has enough space for me to upload a given file using C# in .Net?</p>
| <p>There are two possible solutions. </p>
<ol>
<li><p>Call the Win32 function GetDiskFreeSpaceEx. Here is a sample program:</p>
<pre><code>internal static class Win32
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern bool GetDiskFreeSpaceEx(string drive, out lon... | <p>Are you talking about mapping a network share to a logical drive on you computer?</p>
<p>If so you can use DriveInfo.</p>
<pre>
DriveInfo info = new DriveInfo("X:");
info.AvailableFreeSpace;
</pre>
<p>DriveInfo only works with logical drives so if you are just using the full share (UNC) name I don't thin... | 16,602 |
<p>What are the possibilities to enforce restrictions on the package dependencies in a Java build system? For example, the <code>myapp.server.bl.Customer</code> class should not be allowed to refer to the <code>myapp.client.ui.customlayout</code> package.
I'm interested in either Ant-based or IDE-specific solutions. </... | <p>I believe Checkstyle has a check for that.
It's called <a href="http://checkstyle.sourceforge.net/config_imports.html#ImportControl" rel="noreferrer" title="Checkstyle Documentation">Import Control</a></p>
| <p>Eclipse has support for this via Build Path properties / jar properties. I think it may only work across jar / project boundaries.</p>
| 17,993 |
<p>I'd like to add some functionality to a site that would allow users to record video using their webcam and easily store it online. I don't even know if this is possible right now, but I think flash has access to local webcams running through the browser.</p>
<p>Do you have any suggestions or resources to get me sta... | <p>This is possible with <a href="http://www.adobe.com/products/flashmediaserver/" rel="nofollow noreferrer">Adobe's Flash Media Server</a>. <a href="http://osflash.org/red5" rel="nofollow noreferrer">Red5</a> is an open source alternative. The protocol they use for this is <a href="http://en.wikipedia.org/wiki/Real_Ti... | <p>On the server side, you have three alternatives:</p>
<ol>
<li><a href="http://www.adobe.com/products/flashmediaserver/" rel="nofollow noreferrer">Adobe's Flash Media Server</a></li>
<li><a href="http://osflash.org/red5" rel="nofollow noreferrer">Red5</a>, an open source version</li>
<li><a href="http://www.wowzamed... | 7,785 |
<p>I know of <code>python -c '<code>'</code>, but I'm wondering if there's a more elegant python equivalent to <code>perl -pi -e '<code>'</code>. I still use it quite a bit for things like find and replace in a whole directory (<code>perl -pi -e s/foo/bar/g *</code> or even <code>find . | xargs perl -pi -e... | <p>The command line usage from '<code>python -h</code>' certainly strongly suggests there is no such equivalent. Perl tends to make extensive use of '<code>$_</code>' (your examples make implicit use of it), and I don't think Python supports any similar concept, thereby making Python equivalents of the Perl one-liners... | <p>The above may work for stdin, but does not look like it would work for a file.</p>
<p>Maybe something like:</p>
<p>--</p>
<pre><code>import fileinput
import sys
for line in fileinput.input("./poop", inplace=True):
line = line.replace("foo", "bar")
sys.stdout.write(line)
</code></pre>
<p>--
where "./poop... | 47,918 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.