instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Im curious what the exact meaning of "committed" memory is when the value is queried from the MemoryUsage class. That class explains it as "committed represents the amount of memory (in bytes) that is guaranteed to be available for use by the Java virtual machine." Does this mean that the memory is in use by the j...
<p>The committed size is the actually allocated memory, the used size is the size used for storing actual data (when used ~= committed it's time for major GC and possibly growing the heap). The Max size is the hard limit to which the heap can grow - if it's not enough the JVM throws OutOfMemoryError.</p> <p>If a memor...
<p>"Does this mean that the memory is in use by the jvm process and NOT available to other processes" would be the correct one. So its less then (or equal to) the amount of memory the OS sees as taken by the JVM process. </p> <p><a href="http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html" rel="nofollow...
25,347
<p>I'm new to developing applications for the iPhone and iPod touch. Is it possible to communicate directly between 2 devices in the same room by using WiFi or perhaps even BlueTooth on the iPhone?</p> <p>I've seen a demo of a fire application where one iPhone "lights" other iPhone when they get close to each other. ...
<p>The iPhone supports Bonjour based service discovery and several applications take advantage of this to do things like syncing with a PC on the same network. Explore the samples and guides in the iPhone SDK. WiTap and BonjourWeb are good examples to start with. NSNetServices and CFNetServices are the APIs you'll be d...
<p>iPhone - iPhone communication can also be accomplished over bluetooth using <a href="http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/GameKit_Guide/GameKitConcepts/GameKitConcepts.html#//apple_ref/doc/uid/TP40008304-CH100-SW1" rel="noreferrer">GameKit</a>.</p>
29,449
<p>How do I generate a random <code>int</code> value in a specific range?</p> <p>The following methods have bugs related to integer overflow:</p> <pre class="lang-java prettyprint-override"><code>randomNum = minimum + (int)(Math.random() * maximum); // Bug: `randomNum` can be bigger than `maximum`. </code></pre> <pre c...
<p>In <strong>Java 1.7 or later</strong>, the standard way to do this is as follows:</p> <pre><code>import java.util.concurrent.ThreadLocalRandom; // nextInt is normally exclusive of the top value, // so add 1 to make it inclusive int randomNum = ThreadLocalRandom.current().nextInt(min, max + 1); </code></pre> <p>Se...
<p>You can do as below.</p> <pre><code>import java.util.Random; public class RandomTestClass { public static void main(String[] args) { Random r = new Random(); int max, min; Scanner scanner = new Scanner(System.in); System.out.println(&quot;Enter maximum value : &quot;); ma...
47,476
<p>I'm currently working on a pet project and need to do C++ development on Windows, Mac, Linux, and Solaris, and I've narrowed it down to Netbeans and Eclipse, so I was wonderig which is more solid as a C++ editor. I just need solid editing, good autocompletion for templated code ad external libraries, and project fil...
<p>I haven't used NetBeans, but Eclipse CDT (C Developer Tools, which includes C++), especially with the latest version, is really quite excellent:</p> <ul> <li>Syntax checking and spell checking</li> <li>Syntax highlighting that distinguishes between library calls and your function calls and between local and member ...
<p>having used eclipse for some time now i recently took a look at netbeans and must say i quite like it. at the end of the day they are both excellent ides and it is a very subjective choice. in my opinion netbeans seems to be a bit faster than eclipse, but that might just be a feeling.</p>
39,732
<p>Is there any way (in Java Servlet) to determine whether a HTTP POST or GET request is a result from a submission from a HTML form or otherwise?</p>
<p>You could possibly do it with a hidden form field + a cookie. </p> <p>What you could do is set up a <a href="http://en.wikipedia.org/wiki/Cryptographic_nonce" rel="nofollow noreferrer">nonce</a>, and have that as the hidden field of the form. You would then apply that to a cookie that is sent along with the form. ...
<p>I think it is impossible unless the client itself is co-operating (means the client set some header)</p>
15,974
<p>I am looking to convert a <code>MySQL timestamp</code> to a epoch time in seconds using <code>PHP</code>, and vice versa. </p> <p>What's the cleanest way to do this?</p>
<p>There are two functions in MySQL which are useful for converting back and forth from the unix epoch time that PHP likes:</p> <p><a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_from-unixtime" rel="nofollow noreferrer">from_unixtime()</a></p> <p><a href="http://dev.mysql.com/doc...
<p>From MySQL timestamp to epoch seconds:</p> <pre><code>strtotime($mysql_timestamp); </code></pre> <p>From epoch seconds to MySQL timestamp:</p> <pre><code>$mysql_timestamp = date('Y-m-d H:i:s', time()); </code></pre>
14,073
<p>I have this SQL Server CE database which I would like to convert to SQL Server 2008 database because I want it to be accessible through the network. I am using SQL Server 2008 Express and VB9.</p> <p>Any idea?</p>
<p>A simple way would be to go into SQL Management Studio (I think it can connecto to SDF files?) and right click on it and in actions there will be a script database to text file. That will give you SQL scripts to create the schema, then you can create them in SQL 2008.</p>
<p>It all depends on which version of SQL Server Management Studio you using. If you using the SQL Server 2005 Management Studio Express, make sure you download the one with Service Pack2 from this <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=6053c6f8-82c8-479c-b25b-9aca13141c9e&amp;DisplayLang=en"...
33,593
<p>I mean, how does Java decide which protocols are available? I run some code from inside Eclipse, and it works just fine. Then I run the same code from outside Eclipse, and I get "unknown protocol" MalformedURLException. Probably it has to do with the code base, or something? Any hints would be helpful.</p> <p>Thank...
<p>The work of resolving the protocol is done by the <a href="http://java.sun.com/javase/6/docs/api/java/net/URLStreamHandler.html" rel="nofollow noreferrer"><code>URLStreamHandler</code></a>, which are stored in <code>URL.handlers</code> by protocol in lowercase. The handler, in turn, is created by the <a href="http:/...
<p>Probably a classpath issue. If you are using a protocol that depends on some library (jar) you included, and then exported a JAR from eclipse, the JAR files you included in your project are probably not being found by the running code outside of eclipse. You need a manifest file in your jar that will point to the ...
16,860
<p>How can I add a column with a default value to an existing table in <a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server#Genesis" rel="noreferrer">SQL Server 2000</a> / <a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server#SQL_Server_2005" rel="noreferrer">SQL Server 2005</a>?</p>
<h2>Syntax:</h2> <pre><code>ALTER TABLE {TABLENAME} ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL} CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VALUE} WITH VALUES </code></pre> <h2>Example:</h2> <pre><code>ALTER TABLE SomeTable ADD SomeCol Bit NULL --Or NOT NULL. CONSTRAINT D_SomeTable_SomeCol --When Omitted a ...
<p><strong>SYNTAX:</strong></p> <pre><code>ALTER TABLE {TABLENAME} ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL} CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VALUE} WITH VALUES </code></pre> <p><strong>EXAMPLE:</strong></p> <pre><code>ALTER TABLE Admin_Master ADD Can_View_Password BIT NULL CONSTRAINT DF_Admin_Master_Ca...
11,761
<p>For C#, I have often used <a href="http://www.codesmithtools.com/" rel="nofollow noreferrer">CodeSmith</a> and lately the <a href="http://www.hanselman.com/blog/" rel="nofollow noreferrer">T4 generator</a> which is part of Visual Studio.</p> <p>I'm looking for something similar for Java, in particular an Eclipse ad...
<p>I've found that <a href="http://freemarker.sourceforge.net/" rel="noreferrer">freemarker</a> does a pretty good job for generating any type of code. From the website:</p> <blockquote> <p>FreeMarker is a "template engine"; a generic tool to generate text output (anything from HTML to autogenerated source code) bas...
<p>I'm not a C# man so I don't know what the equivalents would be, however I've found <a href="http://xdoclet.sourceforge.net/xdoclet/index.html" rel="nofollow noreferrer">xdoclet</a> to be very good in the past. I don't think it integrates with eclipse as such but you can run it from an ant script. Does things like ge...
25,777
<p>I'm building a web application that guides my users through the configuration and installation of an application. It builds a set of configuration files dynamically, then sends them in an archive (.ZIP file) along with an installer for the application. The web page is generated from a linux shell script (sorry), a...
<p>You Can't really do that I think.<br> You can force the file download through the following headers but as far is I know you can't mix HTML and file download.</p> <p>Headers:</p> <pre> Content-type: MIME/type Content-Disposition: attachment; filename="archive.zip" Content-Length: filesize_in_bytes </pre> <p>The c...
<p>I think you can make the browser prompt the user to download a file by using the <a href="http://en.wikipedia.org/wiki/Meta_refresh" rel="nofollow noreferrer">meta tag</a> to do a refresh, but as Pim Jager said I don't think you can do it with one transfer. You could maybe try doing something like:</p> <pre><code>&...
45,259
<p>Here is my function (<strong>updated</strong>):</p> <pre><code>Public Shared Function shortenUrl(ByVal URL As String) As String Return shortenUrl(URL, 32) End Function Public Shared Function shortenUrl(ByVal URL As String, ByVal maxLength As Integer) As String If URL.Length &gt; maxLength Then Strin...
<p>Why not do this?</p> <pre><code>Public Shared Function shortenUrl(ByVal URL As String) As String Return shortenUrl(URL, 29) End Function Public Shared Function shortenUrl(ByVal URL As String, ByVal maxLength As Integer) As String If URL.Length &gt; maxLength Then Return String.Format("{0}...{1}", UR...
<pre><code>Public Shared Function shortenUrl(ByVal URL As String, Optional ByVal maxLength As Integer = 29) As String If URL.Length &gt; maxLength Then Return String.Format("{0}...{1}", URL.Substring(0, maxLength / 2), URL.Substring(URL.Length - (maxLength / 2))) Else Return URL End I...
28,139
<p>I'm working on an ASP.NET website where I am using an asp:repeater with paging done through a VB.NET code-behind file. I'm having trouble with the database connection though. As far as I can tell, the paging is working, but I can't get the data to be certain.</p> <p>The database is a Microsoft Access database. The ...
<p>If you need help with Connection Strings, this site is the ultimate resource!</p> <p><a href="http://www.connectionstrings.com/" rel="nofollow noreferrer">http://www.connectionstrings.com/</a></p>
<p>Are you creating the connection string by hand? If so...don't do that! Use the Server Explorer to create your connection. Then highlight it and go to the Properties window, and you'll see the connection string it uses.</p> <p>Also, using the Server Explorer will let you browse through your tables and even open t...
23,721
<p>I'd like to take an existing application (written in OCaml) and create an Emacs "interface" for it (like, for example, the Emacs GDB mode). I would prefer to do this without writing a ton of Lisp code. In MVC terms, I'd like for the View to be Emacs, but for the Model and Controller to remain (primarily) OCaml.</p> ...
<p><a href="http://www.emacswiki.org/cgi-bin/emacs-en?CategoryExtensionLanguage" rel="nofollow noreferrer">http://www.emacswiki.org/cgi-bin/emacs-en?CategoryExtensionLanguage</a> is a list of all non-Elisp extension languages you can use.</p> <p>It does appear to be dynamic language centric.</p> <p><a href="http://co...
<p>There is no "Extension API". Emacs Lisp is way in there, and it ain't moving.</p> <p>You can run Emacs commands from your other process. Have a look at Gnuserv.</p> <p>There are plenty of applications where Emacs is the View for a Model/Controller in a separate process. The Emacs GDB interface is a good example...
3,597
<p>I have a C# method that projects the value of a number from an interval to a target interval.<br> <strong>For example:</strong> we have an interval of -1000 and 9000 and a value of 5000; if we want to project this value to an interval of 0..100 we get 60.</p> <p>Here is the method: </p> <pre><code>/// &lt;summary&...
<p>Only thousands of values? Do you really need to optimise this further? I can't imagine it's actually a bottleneck at the moment. Have you profiled the app to check that this is really an issue?</p> <p>Given that the method is O(1), you're not going to make the most drastic kind of optimisation you normally aim at -...
<p>You code appears more complex than it really needs to be. The formula is:</p> <pre><code>intervalTop + (intervalBottom - intervalTop) * (val - min) / (max - min); </code></pre> <p>which is much simpler than your version (and works for integral types). There's no conditional branches in there (the Math.Min call) or...
44,171
<p>Okay, this bugged me for several years, now. If you sucked in statistics and higher math at school, turn away, <em>now</em>. Too late.</p> <p>Okay. Take a deep breath. Here are the rules. Take <em>two</em> thirty sided dice (yes, <a href="http://paizo.com/store/byCompany/k/koplow/dice/d30" rel="nofollow noreferrer"...
<p>I had to first rewrite your code before I could understand it:</p> <pre><code>def OW60(sign=1): r1 = random.randint (1, 30) r2 = random.randint (1, 30) val = sign * (r1 + r2) islow = (r1&lt;=5) + (r2&lt;=5) ishigh = (r1&gt;=26) + (r2&gt;=26) if islow == 2 or ishigh == 2: return v...
<p>Well, let's see. The <em>second</em> throw (which will sometimes be added or subtracted to the first roll) has a nice easily predictable bell curve around 31. The first roll, of course, is the problem.</p> <p>For the first roll, we have 900 possible combinations. </p> <ul> <li>50 combinations result in adding th...
38,823
<p>I'm looking to convert the following <code>mod_rewrite</code> rule to the <a href="http://wiki.codemongers.com/NginxHttpRewriteModule" rel="noreferrer">Nginx equivalent</a>:</p> <pre><code>RewriteRule ^foo/(.*)$ /bar/index.php?title=$1 [PT,L,QSA] RewriteRule ^foo/*$ /bar/index.php [L,QSA] </code></pre> <p>So far I...
<p>These rewrite rules made the scripts work:</p> <pre><code>rewrite ^/foo/([^?]*)(?:\?(.*))? /bar/index.php?title=$1&amp;$2; rewrite ^/foo /bar/index.php; </code></pre>
<p>These rewrite rules made the scripts work:</p> <pre><code>rewrite ^/foo/([^?]*)(?:\?(.*))? /bar/index.php?title=$1&amp;$2; rewrite ^/foo /bar/index.php; </code></pre>
35,470
<p>How do you globally set the date format in ASP.NET?</p> <p>My local machine and servers have Regional Settings set to "English (New Zealand)".</p> <p>When I format a date with <code>dd/MM/yyyy</code> I expect to see <code>19/11/2008</code> for today for example.</p> <p>Until recently, that is what I did in fact g...
<p>You can change the current thread culture in your Global.asax file, and override the date format for example:</p> <pre><code>using System.Globalization; using System.Threading; //... protected void Application_BeginRequest(Object sender, EventArgs e) { CultureInfo newCulture = (CultureInfo) System.Threading....
<p>For format strings, the format character / does not actually resolve to the literal "/" as you would expect. Instead, it resolves to the current date time separator as configured in your regional settings. Try changing the DateTimeFormatInfo.DateSeparator property.</p> <p>For more information, see: <a href="http://...
38,578
<p>I'm new to ruby and started to create my *nd toy app. I:</p> <ol> <li>Created controller 'questions'</li> <li>Created model 'question'</li> <li>Created controller action 'new'</li> <li>Added 'New.html.erb' file</li> </ol> <p>in erb file I use <code>form_for</code> helper and and <code>new</code> controller action ...
<p>In <code>config/routes.rb</code> you will need to add:</p> <pre><code>map.resources :questions </code></pre> <p>to fix the undefined method questions_path problem.</p> <p>One way to get <code>/questions/ask</code> is to modify <code>routes.rb</code> like so:</p> <pre><code>map.ask_question '/questions/ask', :con...
<p>It looks like you did all of these steps individually. You should try out the scaffold generator, which will build all of this for you.</p> <p>Example:</p> <pre><code>&gt;ruby script/generate scaffold question question:string answer:string votes:integer exists app/models/ exists app/controllers/ exists a...
42,872
<p>I want to embed the native camera application into custom form. The RECT r properties where I want to embed the camera are the following:</p> <p>r.top = 26; r.bottom = 220; r.left = 0; r.right = 320;</p> <p>and this is the method which runs the native camera application:</p> <blockquote> <p>HRESULT CPhotoCaptur...
<p>You're not too clear on what hwndOwner points to. My **guess* on how this probably works is that you need to create a Window that is a child of your main display Window whose location matches your rect (and is visible), then pass it's handle in and that the capture API then uses DShow to pipe the output of the fram...
<p>You're not too clear on what hwndOwner points to. My **guess* on how this probably works is that you need to create a Window that is a child of your main display Window whose location matches your rect (and is visible), then pass it's handle in and that the capture API then uses DShow to pipe the output of the fram...
47,386
<p>Is there a way to compile a .vbproj or .csproj project file directly, just like Visual Studio does?</p> <p>When you compile in Visual Studio, the "output" window shows the actual call to the compiler, which normally looks like:</p> <p>vbc.exe [bunch of options] [looooong list of .vb files]</p> <p>I would like to ...
<p>MSBuild is the easiest way to go. For instance:</p> <pre><code>msbuild /property:Configuration=Release MyFile.vbproj </code></pre>
<p>At the top of a .vbproj file is a . Add this line to the property group to suppress the VB runtime:</p> <pre><code>&lt;NoVBRuntimeReference&gt;On&lt;/NoVBRuntimeReference&gt; </code></pre> <p>MSBuild does the rest. No need to use the command line if you have the IDE.</p>
33,388
<p>How can I ignore directories or folders in Git using msysgit on Windows?</p>
<p>Create a file named <code>.gitignore</code> in your project's directory. Ignore directories by entering the directory name into the file (with a slash appended):</p> <pre><code>dir_to_ignore/ </code></pre> <p>More information is <a href="http://git-scm.com/docs/gitignore" rel="noreferrer">here</a>.</p>
<p>Just create <code>.gitignore</code> file in your project folder Then add the name of the folder in it for ex: </p> <pre><code>frontend/node_modules </code></pre>
44,692
<p>I want to deserialize an object but don't know the class up front. So, consider the following code...</p> <pre><code>IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream("MyFile.bin", FileMode.Open, FileAccess.Read, FileShare.Read); MyObject obj = (MyObject)formatter.Deserialize(stream); </...
<p>Just do:</p> <pre><code>object result = formatter.Deserialize(stream); Type t = result.GetType(); </code></pre>
<p>A few suggestions,</p> <ol> <li><p>If you deserialize the object without casting object myObject = formatter.Deserialize(stream); and then use the "as" operator to check for type compatibility to known types then that might work.</p></li> <li><p>Take a look at BinaryFormatter.Binder property which is of type Serial...
26,835
<p>A quick search gave me this <a href="http://www.mail-archive.com/dbdi-dev@perl.org/msg00002.html" rel="nofollow noreferrer">announcement of Parrot DBDI</a> from January 2004 and a <a href="http://www.mail-archive.com/dbdi-dev@perl.org/" rel="nofollow noreferrer">dbdi-dev mailing list</a> which appears to be long dea...
<p>The lookup is done at a time when the constness of <code>this</code> is not known. You just have to give it a hint via casting. Try this:</p> <pre><code>typedef void (abc::*fptr)(int) const; // or remove const std::tr1::bind((fptr)&amp;abc::hello, x , _1)(a); </code></pre> <p>You may also notice here that removi...
<p>As John suggested, the problems arisen in those snippets are the following:</p> <ol> <li>When passing a <em>member-function-pointer</em> it's necessary to specify its signature (if overloaded)</li> <li><code>bind()</code> are passed arguments by value.</li> </ol> <p>The first problem is solved by casting the membe...
39,984
<p>I am working on a database that usually uses GUIDs as primary keys.</p> <p>By default SQL Server places a clustered index on primary key columns. I understand that this is a silly idea for GUID columns, and that non-clustered indexes are better.</p> <p>What do you think - should I get rid of all the clustered inde...
<p>A big reason for a clustered index is when you often want to retrieve rows for a range of values for a given column. Because the data is physically arranged in that order, the rows can be extracted very efficiently.</p> <p>Something like a GUID, while excellent for a primary key, could be positively detrimental to ...
<p>Yes you should remove the clustered index on GUID primary keys for the reasons Galwegian states above. We have done this on our applications. </p>
35,039
<p>I'm using Gnome terminal and I want to change the background color or the profile through a command so I can group some commands in an alias to visually differentiate my windows when I run certain processes. I'm running Ubuntu, and bash is my shell. Are there commands in to do this?</p>
<p>you can use setterm like this</p> <pre><code>setterm -term linux -back blue -fore white -clear </code></pre>
<p>well, xterm has direct methods to change colours, fonts and size:</p> <p>xterm -bg Blue1 -fg white -fa 'Monospace' -fs 9 </p> <p>why use gnome-terminal?</p>
33,045
<p>I am currently using TcpListener to address incoming connections, each of which are given a thread for handling the communication and then shutdown that single connection. Code looks as follows:</p> <pre><code>TcpListener listener = new TcpListener(IPAddress.Any, Port); System.Console.WriteLine("Server Initialized,...
<p>These are two quick fixes you can use, given the code and what I presume is your design:</p> <h2>1. Thread.Abort()</h2> <p>If you have started this <code>TcpListener</code> thread from another, you can simply call <code>Abort()</code> on the thread, which will cause a <code>ThreadAbortException</code> within the blo...
<p>Probably best to use the asynchronous <a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.beginaccepttcpclient.aspx" rel="nofollow noreferrer">BeginAcceptTcpClient</a> function. Then you can just call Stop() on the listener as it won't be blocking.</p>
47,701
<p>At a previous place where I worked a colleague figured out how to configure MediaWiki so that, for example, a string like <code>#12345</code> in the wiki markup could be expanded into a hypertext link to ticket 12345 in the ticket system.</p> <p>I would like to do something similar in TWiki. I have not yet figured...
<p>gcc does not reorder the elements of a struct, because that would violate the C standard. Section 6.7.2.1 of the C99 standard states:</p> <blockquote> <p>Within a structure object, the non-bit-field members and the units in which bit-fields reside have addresses that increase in the order in which they are declar...
<p>You might want to try the latest gcc trunk or, struct-reorg-branch which is under active development.</p> <p><a href="https://gcc.gnu.org/wiki/cauldron2015?action=AttachFile&amp;do=view&amp;target=Olga+Golovanevsky_+Memory+Layout+Optimizations+of+Structures+and+Objects.pdf" rel="nofollow">https://gcc.gnu.org/wiki/c...
14,372
<p>Is there a way for a Windows application to access another applications data, more specifically a text input field in the GUI, and grab the text there for processing in our own application?</p> <p>If it is possible, is there a way to &quot;shield&quot; your application to prevent it?</p> <hr /> <p><strong>EDIT:</str...
<p>For reading text content from another application's text box you will need to get that text box control's window handle somehow. Depending on how your application UI is designed (if it has a UI that is) there are a couple of different ways that you can use to get this handle. You might use "FindWindow"/"FindWindow...
<p>About how to shield the application to prevent it, you could do many things. One way would be to have a own control to handle text input that build up the text from lets say a couple of labels placed where the text would be, or that draws the text graphically. </p>
45,864
<p>In ActionScript 3.0, is there an automatic way to calculate the number of days, hours, minutes and seconds between two specified dates?</p> <p>Basicly, what I need is the ActionScript equivalent of the .NET Timespan class.</p> <p>Any idea?</p>
<p>I created an ActionScript TimeSpan class with a similar API to System.TimeSpan to fill that void, but there are differences due to the lack of operator overloading. You can use it like so:</p> <pre><code>TimeSpan.fromDates(later, earlier).totalDays; </code></pre> <p>Below is the code for the class (sorry for the b...
<p>ArgumentValidation is another class of Mr Szalays that does some checks to make sure each method has the right values to perform it's tasks without throwing unrecognisable errors. They are non-essential to get the TimeSpan class working so you could just comment them out and the class will work correctly.</p> <p>R...
20,422
<p>I'm working on a messaging/notification system for our products. Basic requirements are:</p> <ul> <li>Fire and forget</li> <li>Persistent set of messages, possibly updating, to stay there until the sender says to remove them</li> </ul> <p>The libraries will be written in C#. Spring.NET just released a milestone ...
<p>I'm kinda biased as I work on <a href="http://activemq.apache.org" rel="noreferrer">ActiveMQ</a> but pretty much all of benefits listed for MSMQ above also apply to ActiveMQ really. </p> <p>Some more benefits of ActiveMQ include</p> <ul> <li>great support for <a href="http://activemq.apache.org/cross-language-clie...
<p>I suggest you have a look at TIBCO Enterprise Messaging Service - EMS, which is a high performance messaging product that supports multicasting, routing, supports JMS specification and provides enterprise wide features including your requirements suchas fire-forget and message persistence using file/database using s...
5,285
<p>When I try using a <code>Name="id"</code> and\or <code>x:name="id"</code> I get a compiler error:</p> <pre><code>The Type 'MyName' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. </code></pre> <p>When I don't have this specified my control ru...
<p>Well, first of all the right syntax is <code>x:Name</code>, although <code>Name</code> by itself usually (but not always) works too.</p> <p>Does the <code>x:Class</code> on your root-level element match the name (and namespace!) of your code-behind file? I know that some versions of Blend and VS didn't insert the ...
<p>I've run into this before and believe it's a compiler bug. I ended up just sticking a named <code>ContentControl</code> in my XAML and sticking the user control in it from the code behind. Hopefully someone can share an actual fix for this.</p>
37,884
<p>Ender3 v2, SIENOC PETG which advises temperature of 230-250 °C on the box. I'm printing on top of cleaned blue tape, using a temperature of 230 °C for the nozzle and 80 °C for the bed.</p> <p>I've had all sorts of trouble getting first layer to stick but finally managed it. However the thin end of this hook has now ...
<p>There are many types of <a href="https://3dprinting.stackexchange.com/questions/10998/e3d-v6-original-vs-clone/11012#11012">heatbreak clones</a>. In cour case, your clone effectively turns your hotend into an e3d Lite6, not an all-metal e3d v6. To function properly, the PTFE liner needs to butt against the nozzle or...
<p>Long story short, you can print Nylon with a Teflon tube. I've done it. P.S. The nylon absorbs water like nothing you've ever seen. Even after the part is printed, it absorbs water, and expands!</p>
1,713
<p>Is there a TortoiseSVN equivalent for OS X? I'm looking for an SVN client that will integrate with OS X's Finder and be added as Context menu items.</p> <p>Update: Just found <a href="https://www.smartsvn.com/" rel="nofollow noreferrer">SmartSVN</a>. Anyone with feedback on it?</p>
<p>There is <a href="http://scplugin.tigris.org/" rel="noreferrer" title="SCPlugin">SCPlugin</a> which is the closest match to TortoiseSVN on OS X. It adds overlay icons as well as context menu entries to the Finder.</p>
<p>I don't believe so, but I've recently started using Cornerstone as a SVN client on the Mac and I'm super-happy with it.</p> <p>It's about $60 and has a 30 day trial. Also try "Versions". I trailed it for a few weeks and it was the "best other" SVN client, but not as good as Cornerstone (IMO).</p>
14,171
<p>Does anyone know where online copies of the old <em>The Perl Journal</em> articles can be found?</p> <p>I know they are now owned by Dr. Dobb's, just the main page for it says they are part of whatever section the subject matter is relevant too, rather than being indexed together. That said, I have never been able ...
<p>Volumes 1-5 (1996 -> 2000) can be found at <a href="http://www.foo.be/docs/tpj/" rel="noreferrer">http://www.foo.be/docs/tpj/</a></p> <p>Hmm, looks like that was the entire run? I though it was longer than that for some reason.</p>
<p>Randal Schwartz's Perl Journal articles are linked from <a href="http://www.stonehenge.com/merlyn/PerlJournal/" rel="nofollow noreferrer"><a href="http://www.stonehenge.com/merlyn/PerlJournal/" rel="nofollow noreferrer">http://www.stonehenge.com/merlyn/PerlJournal/</a></a></p>
2,700
<p>What is the best (regarding performance) way to compute the critical path of a directional acyclic graph when the nodes of the graph have weight?</p> <p>For example, if I have the following structure:</p> <pre><code> Node A (weight 3) / \ Node B (weight 4) Node D (wei...
<p>I have no clue about "critical paths", but I assume you mean <a href="http://en.wikipedia.org/wiki/Critical_path_method" rel="nofollow noreferrer">this</a>.</p> <p>Finding the longest path in an acyclic graph with weights is only possible by traversing the whole tree and then comparing the lengths, as you never rea...
<p>Try the A* method.</p> <p><a href="http://en.wikipedia.org/wiki/A*_search_algorithm" rel="nofollow noreferrer">A* Search Algorithm</a></p> <p>At the end, to deal with the leaves, just make all of them lead on to a final point, to set as the goal.</p>
13,307
<p>Just that... I get a string which contains a path to a file plus some arguments. How can I recognize the path? I thought about the index of the '.' in the file... but I don't like it.<br> What about using regular expressions? Can anyone point me in the right direction?</p> <p>Regards</p> <p>Edit: Theses are valid ...
<p>You can use System.IO.Path, and it's static methods.</p> <pre><code>bool isPath = System.IO.Path.GetDirectoryName(@"C:\MyFolder\SomeFile.exe -i -d") != String.Empty; if (isPath) { Console.WriteLine("The string contains a path"); } </code></pre> <p>The static Path class has several other methods which are usefu...
<p>If you have any control over the string I'd recommend you change the way it is represented. One way would be to use URL-style parameters - e.g. fileName=myFile;arg1=value, etc. Then it's trivial to parse on keys. </p> <p>The problem with any sort of raw parsing scheme is that the trailing data is not necessarily...
37,325
<p>I´ve been looking for it yet in stackoverflow without success...</p> <p>Is it posible a connection pooling in asp.net? Is it worthwhile? How?</p>
<p>It is actually really simple, simply add the following parameters to your connection string and (either in code or in the web.config) and ASP.NET will pick up the rest:</p> <pre><code>Min Pool Size=5; Max Pool Size=60; Connect Timeout=300; </code></pre> <p><em>Note: The Connection Timeout is in seconds and is not ...
<p>by default max pool is 100</p>
33,777
<p>I'd like to display a stack trace in an error dialog in Delphi 2007 (Win32).</p> <p>Ideally, I'd like something like this:</p> <pre><code>try //do something except on e : exception do begin //rollback a transaction or whatever i need to do here MessageDlg('An error has occurred!' + #13#10 + ...
<p><a href="http://www.madshi.net/madExceptDescription.htm" rel="noreferrer">madExcept</a> has a method StackTrace (in unit madStackTrace) that does that.</p> <p><a href="http://sourceforge.net/projects/jcl/" rel="noreferrer">JEDI Code Library</a> offers similar functionality in unit JclDebug.</p>
<p>We use <a href="http://www.dimusware.com/products/excmagic/index.html" rel="noreferrer">Exceptional Magic</a> and it works really well for us. With it you can do something like this:</p> <pre><code>try raise Exception.Create('Something bad happened...'); except on e: Exception do begin CallStack :=...
32,299
<p>What do you keep on mind to avoid memory leaks when you write thousands lines of .NET code? I'm a big fan of prevention over inspection , there is a famous example regarding this point which is using a "StringBuilder" to combine strings instead of "String1+String2", so what is else out there from your coding experi...
<p>Events. Always unsubscribe from events, this is single most leak-providing feature of .NET.</p> <p>Subscribing to event means "notify and hold me while you are alive", not "notify me while I'm alive". Failing to unsubscribe from event usually leads to large clusters of hanging objects, especially in UI.</p>
<pre><code>something.someEvent += new EventHandler(memoryhog.someMethod); [...] something.someEvent += new EventHandler(memoryhog.someMethod); [...] something.someEvent -= new EventHandler(memoryhog.someMethod); </code></pre> <p>If you miss unhooking all the event handlers from an object then the object that implement...
31,389
<p>What possible reasons could exist for MySQL giving the error <code>“Access denied for user 'xxx'@'yyy'”</code> when trying to access a database using PHP-mysqli and working fine when using the command-line mysql tool with exactly the same username, password, socket, database and host?<br> <strong>Update:</strong><br...
<p>Sometimes in php/mysql there is a difference between localhost and 127.0.0.1</p> <p>In mysql you grant access based on the host name, for localusers this would be localhost. I have seen php trying to connect with 'myservername' instead of localhost allthough in the config 'localhost' was defined.</p> <p>Try to gra...
<p>After I read your update I would suspect an error in/with the password. Are you using "strange" characters in your PW (something likely to cause utf-8/iso encoding problems)?</p> <p>Using % in the Host field would allow the user to connect from any host. So the only thing that could be wrong would be the password.<...
30,568
<p>I have a SSIS package that eventually I would like to pass parameters too, these parameters will come from a .NET application (VB or C#) so I was curious if anyone knows of how to do this, or better yet a website with helpful hints on how to do it. </p> <p>So basically I want to execute a SSIS package from .NET pas...
<p>Here is how to set variables in the package from code - </p> <pre><code>using Microsoft.SqlServer.Dts.Runtime; private void Execute_Package() { string pkgLocation = @"c:\test.dtsx"; Package pkg; Application app; DTSExecResult pkgResults; Variables vars; ...
<p>You can use this Function if you have some variable in the SSIS.</p> <pre><code> Package pkg; Microsoft.SqlServer.Dts.Runtime.Application app; DTSExecResult pkgResults; Variables vars; app = new Microsoft.SqlServer.Dts.Runtime.Application(); pkg = app.LoadPackage(" Location of your SSIS pac...
34,493
<p>I am wondering if making an hermetic box is feasible using 3D printer. The box would be a cube with a front face removable, with screw and sealing joint to close it.<br> I searched for different materials, however, none talks about hermiticity. (However, I found a product that seems to improve water resistance of 3D...
<p>A few thoughts that might help...</p> <p><strong>Material:</strong></p> <ul> <li>ABS can be vapor smoothed with Acetone which results in the layers sort of "melting" together to form a smoother, and less porous surface.</li> <li>Other plastics can be smoothed with compatible solvents, but I've not tried solvent sm...
<p>I believe this can be achieved using o-rings. That's what they use for scuba diving lights. The component doesn't need to be circular, but the o-ring needs to be slightly smaller than the component so that it is held in place via tension. Additionally, you'll want to create a groove for the o-ring to set it in an...
392
<p>How can I fetch data in a Winforms application or ASP.NET form from a SAP database? The .NET framework used is 2.0. , language is C# and SAP version is 7.10. </p>
<p>See <a href="http://en.wikipedia.org/wiki/Longest_common_substring_problem" rel="noreferrer">the longest common substring problem</a>. I guess difflib uses the DP solution, which is certainly too slow to compare executables. You can do much better with suffix trees/arrays.</p> <p>Using perl <a href="http://search.c...
<p>I suspect that looking for binary strings isn't going to help you. An install program is likely to be doing some 'suspicious' things. </p> <p>You probably need to talk to CA and spybot about white-listing your installer, or about what is triggering the alert.</p>
14,549
<p>I have a new German RepRap NEO 3D printer, and when I try heating the Extruder to 215°C with Repetier-Host Mac 1.0.1, it always stops at 130°C - does anybody have an idea what could be the reason?</p>
<p>A few possiblitites.</p> <p>You wire is too small. If your wire is HOT that is a fire hazard.</p> <p>Your thermistor is bad. Check with a high temp heat probe or try replacing thermistor.</p> <p>Your heating element is bad (rare).</p> <p>Last it could be a limit in your firmware. But that would surprise me.</p> ...
<p>The most likely problem is that your thermistor is either broken or not screwed in correctly. If this is not the case you should either check look through your firmware for issues, or buy a new heater cartridge and thermistor.</p>
362
<p>I have already visited <a href="https://stackoverflow.com/questions/191673/preferred-python-unit-testing-framework">Preferred Python unit-testing framework</a>. I am not just looking at Python Unit Testing Framework, but also code coverage with respect to unit tests. So far I have only come across <a href="http://ne...
<p>We use this <a href="http://www.djangosnippets.org/snippets/705/" rel="nofollow noreferrer">Django coverage integration</a>, but instead of using the default coverage.py reporting, we generate some simple HTML: <a href="http://code.activestate.com/recipes/52298/" rel="nofollow noreferrer">Colorize Python source usi...
<p><a href="http://code.google.com/p/testoob/" rel="nofollow noreferrer">Testoob</a> has a neat "<code>--coverage</code>" command-line option to generate a coverage report.</p>
34,256
<p>How do you create your own custom moniker (or URL Protocol) on Windows systems?</p> <p>Examples:</p> <ul> <li>http:</li> <li>mailto:</li> <li>service:</li> </ul>
<p>Take a look at <a href="http://msdn.microsoft.com/en-us/library/aa741006(VS.85).aspx" rel="nofollow noreferrer">Creating and Using URL Monikers</a> , <a href="http://msdn.microsoft.com/en-us/library/aa767916(VS.85).aspx" rel="nofollow noreferrer">About Asynchronous Pluggable Protocols</a> and <a href="http://msdn.mi...
<p><em>Inside OLE</em> from Craig Brockschmidt probably has the best coverage on monikers. If you want to dig a little deeper into this topic, I'd recommend getting this book. It is also contained on the MSDN disk that came along with VS 6.0, in case you still have that.</p>
2,665
<p>I am getting an 'Access to the path is denied" error message when running in debug mode. I have tried granting permissions to {MACHINENAME}\ASPNET and to NETWORK SERVICE but this hasn't made any difference. I have also tried &lt; impersonate = true /> using an admin account, this also made no difference. So how do I...
<p>To find out which NT account your app is running under at any given time, do something like (in VB.NET):</p> <pre><code> Dim User = System.Security.Principal.WindowsIdentity.GetCurrent.User Dim UserName = User.Translate(GetType(System.Security.Principal.NTAccount)).Value </code></pre> <p>When using ASP.NET,...
<pre><code>strint t=System.Web.Security.Membership.GetUser().UserName.ToString(); </code></pre>
34,766
<p>We are developing a small in-house application that will run on monitor having multi resolutions. Now we want that the application should adjust itself and remain consistent over all monitors.</p> <p>I came from a Java background too where we used different layouts to accomplish the task. I experimented in .NET wit...
<p>It would completely depend on the content / context of your application, but the .NET Form designer provides you with some useful tools while designing your UI.</p> <p>Most controls have an <strong><code>Anchor</code></strong> property that allows you specify that a control should stay anchored the specified distan...
<p>It would completely depend on the content / context of your application, but the .NET Form designer provides you with some useful tools while designing your UI.</p> <p>Most controls have an <strong><code>Anchor</code></strong> property that allows you specify that a control should stay anchored the specified distan...
31,401
<p>When supporting a new web app in an enterprise environment, it is often necessary to log in as a specific user in order to diagnose a real or perceived problem they are having. Two opposing issues apply here:</p> <ol> <li><p>Best practice is to use <strong>hashed or encrypted passwords</strong>, not clear text. Som...
<p>A number of these ideas inconvenience the user, either by forcing them to change their password, or by occupying their desktop for your debugging session.</p> <p>Markc's idea is the best: augment your authentication logic to allow superusers to log in as a particular user by supplying not the user's credentials, bu...
<ol> <li><p>Could you have a testing environment where there is a regular cut of live data copied to (obviously sanitised to meet any security or data protection issues). A user similar in setup to the one having trouble could be used to troubleshoot or indeed the very user if this is allowed.</p></li> <li><p>Use a re...
32,971
<p>Is there any reason that MVC isn't equally useful for desktop apps as for web apps? </p> <p>What would be required to make an ASP.NET MVC directory tree implementable as a desktop app?</p>
<p><a href="http://compositewpf.codeplex.com/" rel="nofollow">Prism</a></p>
<p>Hmmm... well, your view can be rendered as anything... HTML, XML, etc. So, why not XAML? I wonder if you can get your WPF or Silverlight app to work in the MVC framework this way... that is, not requiring a web server to run.</p>
42,344
<p>So What I'm essentially trying to do is have something happen 70% of the time, another few things happen 10% of the time each if that makes sense but my app doesn't seem to do any of the actions I'm guessing I'm misunderstanding the loop syntax or something, anyway if anyone could take a look and maybe give me some ...
<p><code>net {start|stop} mssqlserver</code></p>
<p>Here's an answer that actually contains a little bonus information...and more thoroughly answers the question. What if you have more than one instance of SQL server? Then you need to know the extended syntax of NET START. You can start services by Name, not just by service moniker (or whatever mssqlserver is an exam...
48,146
<p>In the (otherwise) excellent book <a href="http://www.gotw.ca/publications/c++cs.htm" rel="nofollow noreferrer">C++ Coding Standards</a>, Item 44, titled <strong>"Prefer writing nonmember nonfriend functions"</strong>, Sutter and Alexandrescu recommend that only functions that really need access to the members of a ...
<p>I'm going to have to disagree with Sutter and Alexandrescu on this one. I think if the behavior of function <code>foo()</code> falls within the realm of class <code>Bar</code>'s responsibilities, then <code>foo()</code> should be part of <code>bar()</code>.</p> <p>The fact that <code>foo()</code> doesn't need dire...
<p>I would have thought the IDE was actually helping you out.</p> <p>The <strong>IDE</strong> is hiding the <strong>protected functions</strong> from the list because they are not available to the <strong>public</strong> just as the designer of the class intended.</p> <p>If you had been within the scope of the class ...
16,423
<p>I'm working on an installer (using Wise Installer, older version from like 1999).</p> <p>I'm creating a shortcut in the Programs group to an EXE. I'm also creating a shortcut on the Desktop.</p> <p>If the install is run from an Admin account, then I create the shortcut on the Common Desktop and Common Program Grou...
<p>Vista does some nifty transparent redirection to provide backwards compatibility with non-vista applications. Try installing to the All Users location as a non-admin, and Vista should transparently put your shortcuts somewhere unique to that user.</p>
<p>I had a permissions issue with an installer I created when users started installing on Vista. What solved my problem was renaming the installer to install.exe (or setup.exe). </p> <p>-Dave</p>
8,214
<p>I know how to load themes dynamically when they are stored locally. Is it possible to store theses themes in the database yet still apply them programmatically as described in referenced MSDN article?</p> <p>Also - If you do store them in the filesystem, is it possible to change the path of the App_Themes directory...
<p>The index can be used, though the optimiser may have chosen not to use it for your particular example:</p> <pre><code>SQL&gt; create table my_objects 2 as select object_id, object_name 3 from all_objects; Table created. SQL&gt; select count(*) from my_objects; 2 / COUNT(*) ---------- 83783 SQL&...
<p>Are you sure you want the index to be used? Full table scans are not bad. Depending on the size of the table, it might be more efficient to do a table scan than use an index. It also depends on the density and distribution of the data, which is why statistics are gathered. The cost based optimizer can usually be...
21,349
<p>I had a couple of recent nozzle/bed crashes, so I now frequently do a manual bed levelling. I do these while the bed is heated to allow for expansion.</p> <p>Today I found, after levelling, a subsequent print could vary from having too much clearance (paper moves very freely) to less than no clearance (which left de...
<p>This was killing me on mine. My problem wasn't the z-axis, it was the x-axis arm. On the right side, opposite the extruder gear, it had a lot of give (wobble). I could level my bed four times before starting a print and would still have problems, especially with the nozzle making deep grooves in the magnetic bed. Th...
<p>I'm having the same issue with Ender 3 V2. Everything tightened, Z-axis coupler not &quot;slipping&quot;... I noticed, that the error is made by the Z-axis end switch itself. I am not sure how that is possible but try homing several times and you'll see that the loud click when the switch is triggered occurs in a sp...
1,087
<p>I'm interested in hearing people's thoughts about the pros and cons of database mirroring vs. log shipping in this scenario: we need to setup a database backup situation wherein there is exactly one secondary server that need not automatically pick up when the primary fails. Recovering and starting with the seconda...
<p><strong>Mirroring</strong></p> <ul> <li>Database mirroring is limited to only two servers.</li> <li>Mirroring with a Witness Server allows for High Availability and automatic fail over.</li> <li>You can configure your DSN string to have both mirrored servers in it so that when they switch you notice nothing.</li> <...
<p>Switching to the secondary database does take longer with log shipping, but it's not too bad. You'll have to manually copy any uncopied backup files, apply the transaction log backups to the secondary database, recover the secondary database, and change its role to primary. If the old primary databases accessible,...
41,005
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/1586658/combine-gyroscope-and-accelerometer-data">Combine Gyroscope and Accelerometer Data</a> </p> </blockquote> <p>I have read a number of papers on <code>Kalman filters</code>, but there seem to be few good ...
<p>You seem to have two (or three) separate problems here.<p> 1. You don't really understand Kalman filters and/or the mathematics behind them. That is going to make it very difficult to correctly implement and use one.<p> 2. You don't seem to understand the basic physics involved in the problem. (Basic physics means...
<p>If you happen to be developing for the Propeller uController, than <a href="http://obex.parallax.com/objects/search/?q=kalman" rel="nofollow noreferrer">the Parallax Object Exchange</a> has some code. Great question ;-)</p>
13,599
<p>I'm looking to implement an ESB and wanted to get thoughts related to "how" my web services might change (WCF) or -- how my client apps that consume these services might "need to be revised" (-- other than a new service ref to the ESB path --)</p> <p>The device I'm working with specifically is the "WebSphere DataPo...
<p>Okay found the answer at <a href="http://archive.midrange.com/midrange-l/200809/msg01062.html" rel="nofollow noreferrer">http://archive.midrange.com/midrange-l/200809/msg01062.html</a>.</p> <p>It is not possible at V5R3. Supposedly at V6R1 this is possible.</p>
<p>Could you accomplish the same thing using a logical file or with an <code>OPNQRYF</code> statement? Both of those allow you to set key fields and may be able to strip out the spaces in a file.</p>
14,816
<p>I have the following code to zip all the files and then save it to the harddisk. I want zip all the files (this is done) and then attach the zip file to the Response stream so that the user have the option to save it! </p> <pre><code>protected void DownloadSelectedFiles_Click(object sender, EventArgs e) { ...
<p>I blogged about sending files like this a while ago. You might find something usefull in there.</p> <p><a href="http://absolutecobblers.blogspot.com/2008/02/downloading-and-deleting-temporary.html" rel="nofollow noreferrer">http://absolutecobblers.blogspot.com/2008/02/downloading-and-deleting-temporary.html</a></p>...
<p>And a long shot, try set the mime type to application/unknown, in this post there seems to be part of the solution to the posters problem:</p> <p><a href="http://jamesewelch.com/2008/12/03/sharpziplib-and-windows-extraction-wizard-errors/" rel="nofollow noreferrer">http://jamesewelch.com/2008/12/03/sharpziplib-and-...
48,754
<p>What does ::Base part mean in Person &lt; ActiveRecord::Base class declaration? I'm new to ruby and from what I've gathered so far, Person &lt; ActiveRecord should be used. Thank you.</p>
<p>::Base is a class in module ActiveRecord. One of the things modules do is provide namespacing in Ruby. In Ruby you don't inherit from a module but you can mix it in using the include statement.</p> <p>May I suggest picking up the <a href="http://www.pragprog.com/titles/ruby3/programming-ruby-1-9" rel="nofollow nore...
<p>in Ruby, <code>::</code> accesses static class or module constants. <code>ActiveRecord::Base</code> indicates that the <code>ActiveRecord</code> class or module has a static inner class called <code>Base</code> that you're extending.</p> <p><strong>Edit:</strong> as Mike points out, in this case <code>ActiveRecord<...
42,837
<p>Does anyone know why there is no <code>respond_to</code> block for generated <code>edit</code> actions? Every other action in typical scaffold controllers has a <code>respond_to</code> block in order to output <code>html</code> and <code>xml</code> formats. Why is the <code>edit</code> action an exception?</p> <p>I...
<p>Rails handles the 99% case: It's fairly unlikely you'd ever need to do any XML or JSON translations in your Edit action, because non-visually, the Edit action is pretty much just like the Show action. Nonvisual clients that want to update a model in your application can call the controller this way</p> <pre><code>G...
<p>Because the edit action will only be called from HTML There is no need for the edit form to be returned in an XML context. Using REST, you simply make a put call directly to update with the relevant information.</p>
14,042
<p>Greetings,</p> <p>I have problems (when trying to print from c# to certain printers that do not have large print areas. Is there a way to shrink to printable area (like Adobe Acrobat do)? Thanks!</p>
<p>You can determine the size of your image, then the size of the printing area (from the printer settings and margins - as mentioned in the other post) and then calculate a ratio for shrinking horizontally or vertically (whichever is higher, so the image is not cropped). Use this ratio in a scale transform on the prin...
<p>What do you use for printing? Most likely you will have to query the printer for it's margins and then adjust the drawing code to print inside the printable area.</p> <p>In other words - you would have to do it "by hand".</p>
42,667
<p>What's wrong with Linq to SQL?</p> <p>Or - what about Linq to SQL would make it unsuitable for a project, either new or existing? I want to hear about why you would <strong>not</strong> choose Linq to SQL for a particular project - including what project parameters make it unsuitable.</p>
<p>It is not very adaptable to changes in the database schema. You have to rebuild the dbml layer and regenerate your data contexts.</p> <p>Like any ORM (I am not getting into the debate as to whether it is an ORM or not), you do have to be aware what SQL is being generated, and how that will influence your calls.</p>...
<p>This question was asked once before <a href="https://stackoverflow.com/questions/72168/does-linq-to-sql-provide-faster-response-times-than-using-adonet-and-oledb#73805">over here</a>. But, in essence, LINQ to SQL generates sub-optimal execution plans in your database. For every different length of parameter you se...
19,956
<p>I've looked at the java documentation and scoured the net for information on java's support for international characters with specific fonts (such as Monospace), but haven't been able to get a clear concrete answer.</p> <p>There has been a change between java 1.4 and java 1.5/1.6. For example, in java 1.4 if you se...
<p>From <a href="http://java.sun.com/j2se/1.5.0/docs/guide/intl/enhancements.html" rel="nofollow noreferrer">Internationalization Enhancements</a>:</p> <blockquote> <p><strong>Multilingual Text Rendering</strong><br><br> To render multilingual text, using logical fonts, 2D now takes advantage of installed host OS fonts...
<p>How "foreign" are these characters? Most Latin-based fonts can handle at least the accented letters and other characters in the upper half of ISO-8859-1, but I don't think you can reasonably count on support for anything beyond that. </p> <p>Your best bet is usually to let the user choose from a list of supported...
17,146
<p>I've convinced myself that they can't.</p> <p>Take for example:</p> <p>4 4 + 4 /</p> <p>stack: 4 stack: 4 4 4 + 4 = 8 stack: 8 stack: 8 4 8 / 4 = 2 stack: 2</p> <p>There are two ways that you could write the above expression with the same operators and operands such that the operands all come first: "4 4 4 + /...
<p>Consider the algebraic expression:</p> <pre><code>(a + b) * (c + d) </code></pre> <p>The obvious translation to RPN would be:</p> <pre><code>a b + c d + * </code></pre> <p>Even with a swap operation available, I don't think there is a way to collect all the operators on the right:</p> <pre><code>a b c d + a b S...
<p>It is enough to show one that can't in order to tell you the answer to this.</p> <p>If you can't reorder the stack contents, then the expression (2+4)*(7+8) can't be rearranged.</p> <p>2 4 + 7 8 + *</p> <p>No matter how you reorder this, you'll end up with something that needs to be summed before you go on.</p> ...
6,008
<p>I'm trying to create a QTVR movie via QTKit, and I've got all the frames in the movie. However, setting the attributes necessary doesn't seem to be having any effect. For example:</p> <pre><code>NSNumber *val = [NSNumber numberWithBool:YES]; [fMovie setAttribute:val forKey:QTMovieIsInteractiveAttribute]; val = [...
<p>What I do when I want to export a Quicktime movie is something like the following:</p> <pre><code>NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], QTMovieExport, [exportSettings objectForKey: @"subtype"], QTMovieExportType, [exportSettin...
<p>Those attributes are documented as things you can read but not write. However, you might be able to set them when you create the movie, with initWithAttributes:error:.</p>
24,678
<p>Which would be a neat implemenation of a N-ary tree in C language?</p> <p>Particulary, I want to implement an n-ary tree, not self-ballancing, with an unbound number of children in each node, in which each node holds an already defined struct, like this for example:</p> <pre><code>struct task { char command[MAX_...
<p>Any n-ary tree can be represented as a binary tree where in each node the left pointer points to the first child and the right pointer points to the next brother.</p> <pre> R R / | \ | B C D B -- C -- D / \ ...
<p>As a first pass, you could simply create a <em>struct</em> (let's call it <em>TreeNode</em>) which holds a <em>task</em>, as well as a set of pointers to <em>TreeNode</em>s. This set could either be an array (if <strong>N</strong> is fixed) or a linked list (if <strong>N</strong> is variable). The linked list woul...
23,033
<p>Just getting started with Linq to SQL so forgive the newbie question. I'm trying to reproduce the following (working) query in Linq to SQL (VB.NET):</p> <pre><code>Select f.Title, TotalArea = Sum(c.Area) From Firms f Left Join Concessions c on c.FirmID = f.FirmID Group By f.Title Order by Sum(c.Area) DESC <...
<h2>Answer</h2> <p>Here's the correct Linq to SQL equivalent</p> <pre><code>From c In Concessions _ Join f In Firms on f.FirmID equals c.FirmID _ Group by f.Title _ Into TotalArea = sum(c.OfficialArea) _ Order by TotalArea Descending _ Select Title, TotalArea </code></pre> <p>Thanks to @CMS for pointing me to <a href=...
<p><a href="http://msdn.microsoft.com/en-us/vbasic/bb737922.aspx" rel="noreferrer">Here</a> you can find many examples about using aggregate functions and grouping, additionally I recommend you very much <a href="http://www.linqpad.net/" rel="noreferrer">LinqPad</a>, it's a great tool to test your queries on the fly an...
26,618
<p>When is it right for a constructor to throw an exception? (Or in the case of Objective C: when is it right for an init'er to return nil?)</p> <p>It seems to me that a constructor should fail -- and thus refuse to create an object -- if the object isn't complete. I.e., the constructor should have a contract with its...
<p>The constructor's job is to bring the object into a usable state. There are basically two schools of thought on this.</p> <p>One group favors two-stage construction. The constructor merely brings the object into a sleeper state in which it refuses to do any work. There's an additional function that does the actual ...
<p>Speaking strictly from a Java standpoint, any time you initialize a constructor with illegal values, it should throw an exception. That way it does not get constructed in a bad state.</p>
10,311
<p>I'm developing an embedded system which currently boots linux with console output on serial port 1 (using the console boot param from the boot loader). However, eventually we will be using this serial port. What is the best solution for the kernel console output? /dev/null? Can it be put on a pty somehow so that...
<p>I've been able to refine the original sample down and have some advice for anyone else running into similar situations.</p> <p>First, consider if BackgroundWorker will meet the needs. I still use AsyncCommand often to get the automatic disable function, but if many things could be done with BackgroundWorker.</p> ...
<p>As I answered in your other question, you probably still want to bind to this synchronously and then launch the commands asynchronously. That way you avoid the problems you're having now.</p>
18,278
<p>I am looking for a text editor to be used in a web page. Where users can format the text and get a WYSIWYG experience. Doesn't need to be too fancy. But has to be easy to use and integrate into the page. Has to generate HTML as output. Support AJAX (one I checked works only with standard form submit) and has to be s...
<p>Well it depends what platform you are on if you are looking for server-side functionality as well, but the defacto badass WYSIWYg in my opinion is <a href="http://www.fckeditor.net/" rel="noreferrer">FCKeditor</a>. I have worked with this personally in numerous environments (both professional and hobby level) and ha...
<p>Using fck for some tine now, after "free text box", or something like that. Had problems only once, when I put fck inside asp.net ajax updatepanel, but found fix on forums. Problem was solved in next release.<br> I would like to see some nice photo browser in it, because fck comes only with simple browser that displ...
4,150
<p>I am currently stuck on an ASP.NET error when trying to access a .aspx page through localhost. This is the error:</p> <p><strong>OCIEnvCreate failed with return code -1 but error message text was not available.</strong></p> <p><strong>Description</strong>: An unhandled exception occurred during the execution of th...
<p>I've come across the same problem with oracle 10g, from what I've read this error seems to mean that the .Net oracle driver can't find the oracle client. </p> <p>There are various suggestions to fix this, including checking the PATH and ORACLE_HOME environment variables; re-installing the oracle client in the defau...
<p>I've experienced this on a windows 7 machine. Adding the ORACLE_HOME environment variable and running the executable that uses the oracle client in the "windows xp sp3" compatibility mode (file/properties/compatibility) solved the issue for me.</p>
36,263
<p>When creating a web application that some how displays the display of a unique identifier for a recurring entity (videos on YouTube, or book section on a site like mine), would it be better to use a uniform length identifier like a hash or the unique key of the item in the database (1, 2, 3, etc).</p> <p>Besides re...
<p>Unless you're trying to hide the state of your internal object ID counter, hashes are needlessly slow (to generate and to compare), needlessly long, needlessly ugly, and needlessly capable of colliding. GUIDs are also long and ugly, making them just as unsuitable for human consumption as hashes are.</p> <p>For inve...
<p>Hashes aren't guaranteed to be unique, nor, I believe, consistent.</p>
23,900
<pre><code>public static IList&lt;T&gt; LoadObjectListAll&lt;T&gt;() { ISession session = CheckForExistingSession(); var cfg = new NHibernate.Cfg.Configuration().Configure(); var returnList = session.CreateCriteria(typeof(T)); var list = returnList.List(); var castList = list.Cast&lt;typeof(T)&gt;()...
<p><code>T</code> is not a type nor a <code>System.Type</code>. <code>T</code> is a type parameter. <code>typeof(T)</code> returns the type of <code>T</code>. The <code>typeof</code> operator does not act on an object, it returns the <code>Type</code> object of a type. <a href="http://msdn.microsoft.com/en-us/librar...
<p>The most glaring error I can see is that an <code>IList</code> is definitely different from an <code>IList&lt;T&gt;</code>. An <code>IList</code> is non-generic (e.g., <code>ArrayList</code>).</p> <p>So your method signature should be:</p> <pre><code>public static IList&lt;T&gt; LoadObjectListAll() </code></pre>
6,472
<p>Is there a realistic way of implementing a multi-threaded model in PHP whether truly, or just simulating it. Some time back it was suggested that you could force the operating system to load another instance of the PHP executable and handle other simultaneous processes.</p> <p>The problem with this is that when the...
<h1>Multi-threading is possible in php</h1> <p>Yes you can do multi-threading in PHP with <a href="https://github.com/krakjoe/pthreads" rel="noreferrer">pthreads</a> </p> <p>From <a href="http://www.php.net/manual/en/intro.pthreads.php" rel="noreferrer">the PHP documentation</a>:</p> <blockquote> <p>pthreads is an...
<p>Multithreading means performing multiple tasks or processes simultaneously, we can achieve this in php by using following code,although there is no direct way to achieve multithreading in php but we can achieve almost same results by following way.</p> <pre><code>chdir(dirname(__FILE__)); //if you want to run this...
9,634
<p>How do you protect your commercial application from being installed on multiple computers from people who only own one license?</p> <p>Do you think it's a good idea to have more than just a serial based scheme?</p>
<p>The following method works well, as long as you have a public server at your disposal:</p> <ul> <li>Serial based protection, user must enter a serial before using the program</li> <li>On first serial entry, bind the serial to the MAC address and create an auth code generated from both of these values. </li> <li>Che...
<p>You can always use a USB dongle if the software is worth it. Of course, all dongle manufacturers claim that their copy protection cannot be broken.</p> <p>The advantage of this method is that it allows the user to use the software on multiple computers, but only run on one at a time, and it is actually not such has...
21,185
<p>we have a old and dying dedicated server. we want a new one at a new datacenter. we have a bunch of sites using the current server and don't have control of all their DNS. is there an easy way to redirect all the traffic from xx.xx.xx.xx to zz.zz.zz.zz without updating DNS records?</p> <p>Thanks.</p>
<p>Judging from the <code>IIS</code> tag, I'm assuming you're replacing a web server. If that's the case, look into HTTP redirection. One example is here: <a href="http://www.somacon.com/p145.php" rel="nofollow noreferrer">http://www.somacon.com/p145.php</a></p> <p>This has the advantage of "telling" your clients t...
<p>The short answer is no. Do you think that if it was possible to redirect all traffic from <code>208.69.34.231</code> to <code>87.248.113.14</code>, it wouldn't have been done by now?</p> <p>There are software tools that you can use to relay traffic on certain ports via <code>xx.xx.xx.xx</code> to <code>zz.zz.zz.zz...
32,748
<p>I am looking for a more sophisticated way of using Linq to SQL. I am leaning L2Q but I am only seeing simple examples of business objects and simple CRUD operations in them.</p> <p>Any sample application that includes these:</p> <p>1- Business objects which get their data from more than 1 table and from many to ma...
<p>Scott Gutherie did a 9 part series on his blog that might be of interest to you</p> <p><a href="http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx</a></p>
<p>Here's two other sources with broad content:</p> <p><a href="http://www.hookedonlinq.com/LINQtoSQL.ashx" rel="nofollow noreferrer">This</a> website is a wiki with a ton of information.</p> <p><a href="http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx" rel="nofollow noreferrer">This</a> is a well-organized MSDN...
29,286
<p>When generating graphs and showing different sets of data it usually a good idea to difference the sets by color. So one line is red and the next is green and so on. The problem is then that when the number of datasets is unknown one needs to randomly generate these colors and often they end up very close to each ot...
<p>You have three colour channels 0 to 255 R, G and B.</p> <p>First go through</p> <pre><code>0, 0, 255 0, 255, 0 255, 0, 0 </code></pre> <p>Then go through</p> <pre><code>0, 255, 255 255, 0, 255 255, 255, 0 </code></pre> <p>Then divide by 2 => 128 and start again:</p> <pre><code>0, 0, 128 0, 128, 0 128, 0, 0 0, ...
<p>You could get a random set of your 3 255 values and check it against the last set of 3 values, making sure they are each at least X away from the old values before using them. </p> <p>OLD: 190, 120, 100</p> <p>NEW: 180, 200, 30</p> <p>If X = 20, then the new set would be regenerated again.</p>
39,831
<p>I need to add full web search to my site. I need something like Google Custom Search but with no ads and it has to be free. Any recommendation of a web service or open source project that can index my site and allow me to search it will be helpful.</p> <p>My site is made in ruby on rails, if that helps.</p> <p>I'l...
<p>Depends what you mean by full web search really. If you want to search the whole web then the answers above wont help you much as they are really for indexing and searching the content of your site. I would suggest using the Google ajax search (just a 'powered by google' needed, no ads) or Boss from yahoo (might req...
<p>I recommend <a href="http://github.com/frabcus/acts_as_xapian/wikis" rel="nofollow noreferrer">acts_as_xapian</a>. It's very easy to implement, it's fast enough, and it's the got the features you'll normally need.</p>
21,847
<p>Do you know of any good remoting solutions using powershell V1 (I know the V2 stuff is awesome, but my organization doesn't like using pre-release software). I don't need anything spectactular, just a way to kick off powershell script on another box and get the results back when they're done. I'm considering using...
<p>There is a <a href="http://blogs.msdn.com/powershell/archive/2008/02/29/remoting-using-powershell-v1.aspx" rel="nofollow noreferrer">great article</a> up on the PowerShell team blog that describes how to get some basic remoting working in V1. </p> <p>Basically, PS V2 uses Windows Remote Management (WinRM) under the...
<p>I have used PSExec successfully. You can also use WMI to kick off remote processes. <a href="http://blog.svenlandgraf.nl/?p=24" rel="nofollow noreferrer">Here</a> is an example.</p>
41,670
<p>I'm about to inherit a rather large Java enterprise project that has a large amount of third party dependencies. There is at least seventy JARs included and some of them would seem to be unused e.g. spring.jar which I know isn't used.</p> <p>It seems that over the years as various developers have touched upon the c...
<p>Personally, I think you have to start by assessing the scale of the problem. It's going to be fairly painful, but I'd make a list of the dependencies and work out exactly which parts of the project use which ones.</p> <p>Then I'd work out exactly what features of each you're actually making use of (in many cases, ...
<p>if you have a full regression test suite for this project, all you have to do is run the regression suite while running with 1 less JAR each time in a loop. it is NOT fast BUT it is easy to do.</p>
23,243
<p>Preferably free tools if possible.</p> <p>Also, the option of searching for multiple regular expressions and each replacing with different strings would be a bonus.</p>
<p>Perl. </p> <p>Seriously, it makes sysadmin stuff so much easier. Here's an example:</p> <pre><code>perl -pi -e 's/something/somethingelse/g' *.log </code></pre>
<p>I've found the tool <a href="http://rxfind.codeplex.com/" rel="nofollow noreferrer">RxFind</a> useful (free OSS).</p>
12,766
<p>In Java, static and transient fields are not serialized. However, I found out that initialization of static fields causes the generated serialVersionUID to be changed. For example, <code>static int MYINT = 3;</code> causes the serialVersionUID to change. In this example, it makes sense because different versions of ...
<p>You can find some information about that in the <a href="http://bugs.sun.com/view_bug.do?bug_id=4365406" rel="nofollow noreferrer">bug 4365406</a> and in the <a href="http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/class.html#4100" rel="nofollow noreferrer">algorithm for computing <strong>serialVersionU...
<p>If I read the spec correctly the automatic <code>serialVersionUID</code> shouldn't change if you change the value of a static of transient field. Take a look at <a href="http://java.sun.com/javase/6/docs/platform/serialization/spec/version.html#6678" rel="nofollow noreferrer">Chapter 5.6</a> of the Spec.</p> <p><st...
6,281
<p>I need to be able to see if a form input in PHP is numeric. If it is not numeric, the website should redirect. I have tried is_numeric() but it does not seem to work.</p> <p>Code examples will be nice.</p> <p>I am developing a shopping cart that accepts an integer value for the quantity. I am trying this: </p> ...
<pre><code>if(!is_numeric($quantity == 0)){ //redirect($data['referurl']."/badinput"); echo "is not numeric"; </code></pre> <p>What you have here are two nested conditions. Let's say $quantity is 1.</p> <p>The first condition evaluates 1 == 0 and returns FALSE. The second condition che...
<p>What Rob said, although instead of regular expressions to check for digits, I would use <a href="http://php.net/ctype_digit" rel="nofollow noreferrer">ctype_digit</a></p>
41,074
<p>I'm reading all the files in a single directory and I want to filter on JPG,JPEG,GIF and PNG.</p> <p>Both capital and small letters. Those are the only files to be accepted.</p> <p>I am currently using this:</p> <pre><code>$testPics = takeFiles($picsDir, "([^\s]+(?=\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF))\.\2)"); <...
<p>I think something is wrong with your regex. Try testing regexes here first: <a href="https://www.regexpal.com/" rel="noreferrer">https://www.regexpal.com/</a></p> <p>I think this one might work for you:</p> <p><code>/^.*\.(jpg|jpeg|png|gif)$/i</code></p> <p>Note the /i at the end - this is the "case insensitive" ...
<p>There are a few ways of doing this.</p> <p>Have you tried <a href="http://us3.php.net/glob" rel="nofollow noreferrer">glob()</a>?:</p> <pre><code>$files = glob("{$picsDir}/*.{gif,jpeg,jpg,png}", GLOB_BRACE); </code></pre> <p>Have you considered <a href="http://us.php.net/pathinfo" rel="nofollow noreferrer">pathin...
41,560
<p>I'm looking for a good server/client protocol supported in Python for making data requests/file transfers between one server and many clients. Security is also an issue - so secure login would be a plus. I've been looking into XML-RPC, but it looks to be a pretty old (and possibly unused these days?) protocol.</p>...
<p><a href="http://pyro.sf.net" rel="noreferrer">Pyro</a> (Python Remote Objects) is fairly clever if all your server/clients are going to be in Python. I use <a href="http://www.xmpp.org" rel="noreferrer">XMPP</a> alot though since I'm communicating with hosts that are not always Python. XMPP lends itself to being ext...
<p>In the RPC field, Json-RPC will bring a big performance improvement over xml-rpc: <a href="http://json-rpc.org/wiki/python-json-rpc" rel="nofollow noreferrer">http://json-rpc.org/wiki/python-json-rpc</a></p>
8,996
<p>I'm trying to boil down the concepts of coupling and cohesion to a concise definition. Can someone give me a short and understandable explanation (shorter than the definitions on Wikipedia <a href="http://en.wikipedia.org/wiki/Coupling_%28computer_science%29" rel="noreferrer">here</a> and <a href="http://en.wikipedi...
<p><strong>Coupling</strong></p> <ul> <li><p>Loose: You and the guy at the convenience store. You communicate through a well-defined protocol to achieve your respective goals - you pay money, he lets you walk out with the bag of Cheetos. Either one of you can be replaced without disrupting the system.</p></li> <li><p>...
<p>"Coupling is a measure of interdependencies between modules, which should be minimized" "cohesion, a quality to be maximized, focuses on the relationships between the activities performed by each module."</p> <p>quoted from this paper: <a href="http://steve.vinoski.net/pdf/IEEE-Old_Measures_for_New_Services.pdf" re...
6,114
<p>I am trying to solve a persistent IO problem when we try to read or write to a Windows 2003 Clustered Fileshare. It is happening regularly and seem to be triggered by traffic. We are writing via .NET's FileStream object.</p> <p>Basically we are writing from a Windows 2003 Server running IIS to a Windows 2003 file...
<p>I've heard of <a href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;q138365" rel="nofollow noreferrer">AutoDisconnect</a> causing similar issues (even if the device isn't idle). You may want to try disabling that on the server.</p>
<p>I've seen other people reporting the "delayed write failed" error. One recommendation was to adjust the size of the cache, there's a utility from sysinternals (<a href="http://technet.microsoft.com/en-us/sysinternals/bb897561.aspx" rel="nofollow noreferrer">http://technet.microsoft.com/en-us/sysinternals/bb897561.a...
5,045
<p>I was wondering the other day why don't all three motors move at the same time? Don't normal paper printers move 2 motors at a time? they're 2D printers. It makes sense if a 3D printer really does print with <em>all</em> three motors moving. Won't it also be more efficient if they do 3D print in all axes?</p>
<blockquote> <p>I was wondering the other day why don't all three motors move at the same time?</p> </blockquote> <p>That is perfectly possible for most printers (with limitations, &quot;3D Printing&quot; with all steppers being used is called &quot;non-planar&quot; printing), but there are some major cons you need to ...
<p>The Z axis moves between each layer so you are indeed printing in the 3rd dimension. There are some techniques that move all three axis at the same time.</p>
1,924
<p>I'm not really sure if I'm asking the right question here, but I just made a noob mistake of buying 3 mm filaments instead of 1.75 mm. I have a Makerbot Replicator 2 which I've been using and so far it is pulling in 1.75 mm quite well.</p> <p>Is there any way I can still make use the 3 mm filaments, or do I need to ...
<p>This is not a definitive answer (and has turned into a ramble), as I have not yet had to change my filament size. </p> <p>However, initially, I would have thought that only the hotend and the hotend's nozzle would need to be changed, from one that can handle the 1.75 mm filament to 3 mm. If the extruder is spring l...
<p>Late to the party here but I am doing this exact thing. I stupidly bought like a dozen rolls of 3mm filament for about $6 a Kg. I think trying the switch should be fun...but I have 7 printers so its no big deal to tinker on one of them.</p> <p>What you need to do is modify the extruder. I have done this successfully...
507
<p>I have an owner-drawn UserControl where I've implemented double-buffering. In order to get double-buffering to work without flicker, I have to override the OnPaintBackground event like so:</p> <pre><code>protected override void OnPaintBackground(PaintEventArgs e) { // don't even have to do anything else } </co...
<p>Steven Lowe's solution unfortunately cover all scenarios, espcially when user controls come into the picture.</p> <p>The this.DesignMode flag is very deceptive. Its only scope is to check if the direct parent is within the designer. </p> <p>For instance, if you have a Form A, and a UserControl B, in the designer:...
<pre><code>if (this.DesignMode) { return; //or call base.OnPaintBackground() } </code></pre>
37,439
<p>OS: Windows Vista Business SP1</p> <p>IDE: Visual Studio 2008 SP1</p> <p>Question: when I create a new web application in VS 2008 and start it, the embedded web server from VS 2008 launches on one port (say 50140). Then the browser (IE7) automatically launches with address <a href="http://localhost:50137/" rel="no...
<p>You could check the web launch options in the project properties. It may be hard coded to load a specific URL - maybe from a previous run.</p>
<p>I guess you have multiple projects in the solution, one of them must be a web service, and the other (In IE) is a Web application.</p>
45,228
<p>I've got a WAR file that I need to add two files to. Currently, I'm doing this:</p> <pre><code>File war = new File(DIRECTORY, "server.war"); JarOutputStream zos = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(war))); //Add file 1 File file = new File(DIRECTORY, "file1.jar"); InputStream is = ne...
<p>Yeah, there's an extra boolean argument to the <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileOutputStream.html#FileOutputStream(java.io.File,%20boolean)" rel="noreferrer">FileOutputStream constructor</a> which lets you force it to append to the file rather than overwrite it. Change your code to </p> ...
<p>I have the same problem; I'm looking for an easy way to update a file in an existing jar file. If it's so easy to do a "jar uf foo.jar ..." command, how come there isn't a way to use Java API's to do the same?</p> <p>Anyway, here is the RFE to add this functionality to Java; it also suggests some work-arounds:</p> ...
33,403
<p>I'm using <a href="http://www.helicontech.com/isapi_rewrite/" rel="nofollow noreferrer">Helicon's ISAPI Rewrite 3</a>, which basically enables .htaccess in IIS. I need to redirect a non-www URL to the www version, i.e. example.com should redirect to www.example.com. I used the following rule from the examples but ...
<p>Append the following RewriteCond:</p> <pre><code>RewriteCond %{HTTP:Host} ^[^.]+\.[a-z]{2,5}$ [NC] </code></pre> <p>That way it'll only apply the rule to nondottedsomething.uptofiveletters as you can see, subdomain.domain.com will not match the condition and thus will not be rewritten.</p> <p>You can change [a-z]...
<p>Can't you adjust the RewriteCond to only operate on example.com?</p> <pre><code>RewriteCond %{HTTP:Host} ^example\.com(.*) [NC] </code></pre>
7,374
<p>I've been playing around with the ASP.NET MVC Framework and the one thing that's really confusing me is how I'm meant to do server side validation of posted form data. I presume I don't post back to the same URL, but if I don't, how do I redisplay the form with the entered data and error messages? Also, where shou...
<p>Here's an overview of the flow in MVC:</p> <ol> <li>/new - render your "New" view containing a form for the user to fill out <ul> <li>User fills out form and it is posted to /create</li> <li>The post is routed to the Create action on your controller</li> <li>In your action method, update the model with the data th...
<p>I'm just learning the MVC framework too so I'm not sure how off this is, but from what I understand you would have a form on a View such as Edit.aspx. This form would then post to the controller to another action method such as Update() passing in the contents of the form that you set in Edit.aspx as parameters.</p...
3,150
<p>I'm working on framework for testing some command line utilities. I want to create some classes to hold the different types of information more easily. </p> <p>Python is fairly new to me so I'm not sure how you would handle this. Do you keep all your classes in one file with your main script or can you separate t...
<p>"What is the paradigm for how you create multiple classes and use them in a single script?"</p> <p>Are you asking about the <a href="http://docs.python.org/reference/simple_stmts.html#the-import-statement" rel="nofollow noreferrer">import</a> statement? </p>
<p>I spread functionality out into separate files as it makes sense, using a modular approach.</p>
38,886
<p>I have a counter in hardware that I can observe for timing considerations. It counts miliseconds and is stored in a 16 bit unsigned value. How do I safely check if a timer value has passed a certain time and safely handle the inevitable rollover:</p> <pre><code>//this is a bit contrived, but it illustrates what I'm...
<p>You don't actually need to do anything here. The original code listed in your question will work fine, assuming <code>ms_timer()</code> returns a value of type uint16_t.</p> <p>(Also assuming that the timer doesn't overflow twice between checks...) </p> <p>To convince yourself this is the case, try the following t...
<p>Sometimes I do it like this:</p> <pre><code>#define LIMIT 10 // Any value less then ULONG_MAX ulong t1 = tick of last event; ulong t2 = current tick; // This code needs to execute every tick if ( t1 &gt; t2 ){ if ((ULONG_MAX-t1+t2+1)&gt;=LIMIT){ do something } } else { if ( t2 - t1 &gt;= LIMT ){ ...
8,667
<p>I'll have an ASP.net page that creates some Excel Sheets and sends them to the user. The problem is, sometimes I get Http timeouts, presumably because the Request runs longer than executionTimeout (110 seconds per default).</p> <p>I just wonder what my options are to prevent this, without wanting to generally incre...
<p>If you want to increase the execution timeout for this one request you can set</p> <pre><code>HttpContext.Current.Server.ScriptTimeout</code></pre> <p>But you still may have the problem of the client timing out which you can't reliably solve directly from the server. To get around that you could implement a "proc...
<p>I've not really had to face this issue too much yet myself, so please keep that in mind.</p> <p>Is there not anyway you can run the process async and specify a callback method to occur once complete, and then keep the page in a "we are processing your request.." loop cycle. You could then open this up to add some n...
4,940