instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Is there an easy way write to a file asynchronously in Python?</p> <p>I know the <a href="https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files" rel="noreferrer">file io that comes with Python</a> is blocking; which is fine in most cases. For this particular case, I need writes not to block...
<p>Twisted has <a href="http://twistedmatrix.com/documents/8.1.0/api/twisted.internet.fdesc.html" rel="noreferrer">non-blocking writes on file descriptors</a>. If you're writing async code, I'd expect you to be using twisted, anyway. :)</p>
<p>Python 3 seems to have such functionality. See <a href="http://www.python.org/dev/peps/pep-3116/" rel="nofollow">PEP 3116</a>.</p>
41,256
<p>I hear logarithms mentioned quite a lot in the programming context. They seem to be the solution to many problems and yet I can't seem to find a real-world way of making use of them. I've read the <a href="http://en.wikipedia.org/wiki/Logarithms" rel="noreferrer">Wikipedia entry</a> and that, quite frankly, leaves m...
<p>Say you've got $1000, and it's in a savings account with 2.4% interest.</p> <p>How many years do you have to wait until you have $2000 to buy a new laptop?</p> <p>1000 &times; 1.024<sup>x</sup> = 2000</p> <p>1.024<sup>x</sup> = 2</p> <p>x = log <sub>1.024</sub> 2 = 29.23 years</p>
<p><strong>Demystifying the Natural Logarithm (ln)</strong> at BetterExplained is the best i have found. It clears the concepts from the base and help you understand the underlying concepts. After that everything seems a cakewalk.</p>
14,820
<p>I'm wondering if there's a way to do what I can do below with Python, in Ruby:</p> <pre><code>sum = reduce(lambda x, y: x + y, map(lambda x, y: x * y, weights, data)) </code></pre> <p>I have two arrays of equal sizes with the weights and data but I can't seem to find a function similar to map in Ruby, reduce I hav...
<p>@Michiel de Mare</p> <p>Your Ruby 1.9 example can be shortened a bit further:</p> <pre><code>weights.zip(data).map(:*).reduce(:+) </code></pre> <p>Also note that in Ruby 1.8, if you require ActiveSupport (from Rails) you can use:</p> <pre><code>weights.zip(data).map(&amp;:*).reduce(&amp;:+) </code></pre>
<p>An alternative for the map that works for more than 2 arrays as well:</p> <pre><code>def dot(*arrays) arrays.transpose.map {|vals| yield vals} end dot(weights,data) {|a,b| a*b} # OR, if you have a third array dot(weights,data,offsets) {|a,b,c| (a*b)+c} </code></pre> <p>This could also be added to Array:</p> ...
2,546
<p>I've encountered the following problem pattern frequently over the years:</p> <ul> <li><p>I'm writing complex code for a package comprised of a standalone application and also a library version of the core that people can use from inside other apps.</p></li> <li><p>Both our own app and presumably ones that users cr...
<p>"isn't that [text manipulation] more of something that should be programmed into the application?"</p> <p>Usually, yes. The generally accepted "<a href="http://en.wikipedia.org/wiki/Multitier_architecture" rel="nofollow noreferrer">three-tier</a>" application design for databases says that your logic should be in t...
<p>I think most additional languages are offered so that if you develop in that language on a regular basis, you can feel comfortable writing db functions, triggers, etc. The usefulness of these features is to provide a control over data as close to the data as possible.</p>
6,060
<p>What are best practices with regards to C and C++ coding standards? Should developers be allowed to willy-nilly mix them together. Are there any complications when linking C and C++ object files.</p> <p>Should things like socket libraries that traditionally is written in C remain in C and kept in seperate source ...
<p>The biggest issue is calling a C function from C++ code or vice versa. In that case, you want to make sure you mark the function as having "C" linkage using <code>extern "C"</code>. You can do this in the header file directly using:</p> <pre><code>#if defined( __cplusplus ) extern "C" { #endif extern int myfunc( c...
<p>If you compile all your source with g++ then it is all compiled in C++ object files (i.e. with the appropriate name mangling and the C++ ABI).</p> <p>You will only need to use the extern "C" trick if you are building libraries that need to be used by explicitly C applications that need to use the C ABI.</p> <p>If ...
35,976
<p>Years ago I created a programming collaboratory in Diversity University MOO -- a room written in MOOcode that used TCP/IP to communicate with a perl server back at my campus to compile and execute C, Perl, Bash and other programs and return results to the MOO collaboratory -- all for demonstrating programming langua...
<p><a href="http://en.wikipedia.org/wiki/Representational_State_Transfer" rel="noreferrer">REST</a> is now in fashion for web services. There is no real reason to get down to TCP/IP layer for something which from your description does not require super performance or response times. LSL HTTP support is quite good so yo...
<p>As Ilya said, REST and LSL-HTTP would be the way to go.</p> <p>The <strong>new implementation of JSON</strong> within the Linden Scripting Language should help with that. You might want to start with reading the <a href="http://wiki.secondlife.com/wiki/Json_usage_in_LSL" rel="nofollow">Json usage in LSL</a> page on...
12,901
<p>Is it possible in plain JPA or JPA+Hibernate extensions to declare a composite key, where an element of the composite key is a sequence?</p> <p>This is my composite class:</p> <pre><code>@Embeddable public class IntegrationEJBPk implements Serializable { //... @ManyToOne(cascade = {}, fetch = FetchType....
<p>I believe that this is not possible with plain JPA.</p>
<p>Try like this:</p> <pre><code>@TableGenerator(name = "canonicalKeys", allocationSize = 1, initialValue = 1) @GeneratedValue(strategy = GenerationType.TABLE, generator = "canonicalKeys") @Column(name = "CANONICAL_ID", unique = false, nullable = false, insertable = true, updatable = true) public String getCanonicalId...
30,084
<p>We're working on an application that displays information through a Direct3D visualisation. A late client request is the ability to view this application via some Remote Desktop solution.</p> <p>Has anyone done anything similar? What options are available / unavailable? I'm thinking RDC, VNC, Citrix...</p> <p>Any ...
<p>I think you can still use all of the normal D3D tools, but you won't be able to render to a surface associated with the screen. You'll have to render to a DIB (or some such) and Blt it with GDI to a normal window HDC. RDC/VNC/Citrix should all work with this technique.</p> <p>Performance will definitely suffer - bu...
<p>The build-in remote desktop works. (You don't have to do anything special)</p> <p>But it is extremely slow, because when in doubt, it just sends the contents of a window as a bitmap.</p>
5,720
<p>I have noticed that some apps like Safari and Mail show a loading indicator in the status bar (the bar at the very top of the phone) when they are accessing the network. Is there a way to do the same thing in SDK apps, or is this an Apple only thing?</p>
<p>It's in UIApplication:</p> <p><strong>For Objective C:</strong></p> <p>Start:</p> <pre><code>[UIApplication sharedApplication].networkActivityIndicatorVisible = YES; </code></pre> <p>End:</p> <pre><code>[UIApplication sharedApplication].networkActivityIndicatorVisible = NO; </code></pre> <p><strong>For swift :...
<p>It might also be helpful to make sure you are running it on the main thread as it is UI related. </p> <pre><code>dispatch_async(dispatch_get_main_queue(), ^{ [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; }); </code></pre>
20,135
<p>I have a Monoprice Maker Select Plus (Wanhao Duplicator i3 clone) and I'm having issued with the top layer of my prints. The bottom surface and the sides always come out perfect but my top layer is left with gaps in it. I have tried adjusting the print temperature, flow rate, print speed and layer height all with no...
<p>This is probably caused by too few top layers in combination with a too low infill percentage. Increase skin layers and increase infill percentage.</p> <p>If you have multiple layers already (at least about 4 for 0.2 mm layer height, for smaller layer heights even more), you might be printing at a too high temperatu...
<p>To combat the bad top layers, I usually use usually 5 top layers for any model of layer height 0.1 to 0.3 mm. I generally don't print with less than 9 % infill for PLA, which I have found sufficient to support even complex geometry on top.</p> <p>Also, I generally use a mixed setup of layers: the outermost layers I ...
1,813
<p>How can I delete all the tables in a web page? The tables don't have any ids associated with them.</p>
<p>Very simple version:</p> <pre><code>var tables = document.getElementsByTagName("TABLE"); for (var i=tables.length-1; i&gt;=0;i-=1) if (tables[i]) tables[i].parentNode.removeChild(tables[i]); </code></pre>
<p>Or:</p> <pre><code>function myF() { this.checkChild = function(tagN, node) { if (node.tagName.toLower() == tagN.toLower()) { node.parentNode.removeChild(node); } else { var i; for(i = 0; i &lt; node.childNodes.length; i++) this.checkChi...
37,266
<p>I have a huge database with 100's of tables and stored procedures. Using SQL Server 2005, how can I get a list of stored procedures that are doing an insert or update operation on a given table.</p>
<pre><code>select so.name, sc.text from sysobjects so inner join syscomments sc on so.id = sc.id where sc.text like '%INSERT INTO xyz%' or sc.text like '%UPDATE xyz%' </code></pre> <p>This will give you a list of all stored procedure contents with INSERT or UPDATE in them for a particular table (you can obvi...
<pre><code>SELECT Distinct SO.Name FROM sysobjects SO (NOLOCK) INNER JOIN syscomments SC (NOLOCK) on SO.Id = SC.ID AND SO.Type = 'P' AND (SC.Text LIKE '%UPDATE%' OR SC.Text LIKE '%INSERT%') ORDER BY SO.Name </code></pre> <p><a href="http://www.knowdotnet.com/articles/storedprocfinds.html" rel="nofollow noreferrer">Thi...
14,550
<p>I'm using GNU autotools for the build system on a particular project. I want to start writing automated tests for verifcation. I would like to just type "make check" to have it automatically run these. My project is in C++, although I am still curious about writing automated tests for other languages as well.</p> <...
<p>To make test run when you issue <code>make check</code>, you need to add them to the <code>TESTS</code> variable</p> <p>Assuming you've already built the executable that runs the unit tests, you just add the name of the executable to the TESTS variable like this:</p> <pre><code>TESTS=my-test-executable </code></pr...
<p>You can use Automake's <code>TESTS</code> to run programs generated with <code>check_PROGRAMS</code> but this will assume that you are using a log driver and a compiler for the output. It is probably easier to still use <code>check_PROGRAMS</code> but to invoke the test suite using a local rule in the Makefile:</p> ...
15,888
<p>I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially "inline", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in pro...
<p>AFAIK an SQLITE database is just a file. To check if the database exists, check for file existence.</p> <p>When you open a SQLITE database it will automatically create one if the file that backs it up is not in place.</p> <p>If you try and open a file as a sqlite3 database that is NOT a database, you will get this...
<p>Yes, I was nuking out the problem. All I needed to do was check for the file and catch the IOError if it didn't exist.</p> <p>Thanks for all the other answers. They may come in handy in the future.</p>
25,995
<p>We have an advanced webpage (ASP.NET, C#), and a application which needs to be installed on the client computer in order to utilize the webpage to its fullest. The application is a tray app, and has primarily two tasks. Detect when certain events happen on the webserver (for instance invited to a meeting, or notify ...
<p>If you want to detect with javascript inside the browser, you can probably use the collection "navigator.plugins". It works with Firefox, Opera and Chrome but unfortunately not with IE. </p> <p>Update: In FF, Opera and Chrome you can test it easily like this:</p> <pre><code>if (navigator.plugins["Adobe Acrobat"]) ...
<p>Expose the trayapp (assuming this as a Managed app) as COM object. You could then use the tag with the GUID and trap errors when not found or use the ActiveXobject with the progid to detect if it's installed.</p>
37,207
<p>I am on Windows XP.</p> <p>I am using ImageMagick (MagickNet) to convert PDF's to TIF's. </p> <p>My problem is that when I load a PDF in the MagicNet.Image object, it doesn't throw an error, but when I look at the properties, it is obvious it didn't load the PDF (it doesn't contain any data).</p> <p>My guess is ...
<p>One thing you could try (although I haven't tried it, so I can't say how effective this method would be) to <em>immediately</em> try to search the memory space of the browser for the text - maybe it was not deallocated, or even if it was deallocated, maybe it wasn't overwritten by other data.</p> <p>You can do this...
<p>Whenever I type something really long, I always copy it to my clipboard before submitting the form in case something happens. Or, sometimes I type it in Notepad and copy it over when I'm done. That may not be the answer you're looking for, but it might help.</p>
15,635
<p>I have a control, VideoControl, which displays video using DirectShow - it's set as the owner of an IVideoWindow. I have another control, AreaControl, which is supposed to show a dashed rectangle over the video control. AreaControl is set to be transparent using SetStyle(ControlStyles.SupportsTransparentBackColor,...
<p>As far as I know, there is no way of doing, what you want to do directly. The problem is, the implementation of the transparent style of a control. A control with this style attribute basically just draws, what is behind it making it appear transparent. (In reality it isn't really transparent at all). </p> <p>The o...
<p>As far as I know, there is no way of doing, what you want to do directly. The problem is, the implementation of the transparent style of a control. A control with this style attribute basically just draws, what is behind it making it appear transparent. (In reality it isn't really transparent at all). </p> <p>The o...
39,360
<p><strong>Update</strong></p> <p><em>Got it! See my solution (fifth comment)</em></p> <p>Here is my problem:</p> <p>I have created a small binary called "jail" and in /etc/password I have made it the default shell for a test user.</p> <p>Here is the -- simplified -- source code:</p> <pre><code>#define HOME "/home...
<p>The shell isn't interactive. Try adding -i to the list of arguments.</p>
<p>By the time your user is logging in and their shell tries to source this file, it's running under their UID. The <code>chroot()</code> system call is only usable by root -- you'll need to be cleverer than this.</p> <p>Also, chrooting to a user's home directory will make their shell useless, as (unless they have a l...
31,745
<p>I'm new to mock objects, but I understand that I need to have my classes implement interfaces in order to mock them.</p> <p>The problem I'm having is that in my data access layer, I want to have static methods, but I can't put a static method in an interface. </p> <p>What's the best way around this? Should I jus...
<p>I would use a method object pattern. Have a static instance of this, and call it in the static method. It should be possible to subclass for testing, depending on your mocking framework.</p> <p>i.e. in your class with the static method have:</p> <pre class="lang-cs prettyprint-override"><code>private static fina...
<p>A simple solution is to allow to change the static class's implementation via a setter:</p> <pre><code>class ClassWithStatics { private IClassWithStaticsImpl implementation = new DefaultClassWithStaticsImpl(); // Should only be invoked for testing purposes public static void overrideImplementation(IClassWit...
18,466
<p>Vista's Resource Monitor includes a reading for "Hard Faults/sec". Is there an equivalent performance counter I can use in C# to get this reading? I've tried the "Page Faults/sec" under the memory category, but that appears to be something different.</p>
<p>A hard fault is the same as a page fault.</p> <p>Source: "<a href="http://technet.microsoft.com/en-us/library/cc722173(WS.10,printer).aspx" rel="nofollow noreferrer">Windows Vista Performance and Reliability Monitoring Step-by-Step Guide</a>".</p> <p>See section <em>Resource View details</em>, Label Memory (the 4t...
<p>Page faults/sec measures both Hard Faults and Soft Faults. The counter named Transition Faults/sec measures Soft Faults. Thus, to get the Hard Faults you should subtract Transition Faults/sec from Page Faults/sec</p>
32,886
<p>Are all these types of sites just illegally scraping Google or another search engine?<br> As far as I can tell ther is no 'legal' way to get this data for a commercial site.. The Yahoo! api ( <a href="http://developer.yahoo.com/search/siteexplorer/V1/inlinkData.html" rel="nofollow noreferrer">http://developer.yahoo....
<p>For example, if you wanted to find all the links to Google's homepage, search for</p> <pre><code>link:http://www.google.com </code></pre> <p>So if you want to find all the inbound links, you can simply traverse your website's tree, and for each item it finds, build a URL. Then query Google for:</p> <pre><code>lin...
<p>For example, if you wanted to find all the links to Google's homepage, search for</p> <pre><code>link:http://www.google.com </code></pre> <p>So if you want to find all the inbound links, you can simply traverse your website's tree, and for each item it finds, build a URL. Then query Google for:</p> <pre><code>lin...
47,240
<p>I'm talking about this:</p> <p>If we have the letter 'A' which is 77 in decimal and 4D in Hex. I am looking for the fastest way to get D.</p> <p>I thought about two ways:</p> <p>Given x is a byte.</p> <ol> <li><p><code>x &lt;&lt; 4; x &gt;&gt; 4</code></p></li> <li><p><code>x %= 16</code></p></li> </ol> <p>Any ...
<p>I always use <code>x &amp;= 0x0f</code></p>
<p>x = x &amp; 15</p>
37,728
<p>When you're doing a usual gdb session on an executable file on the same computer, you can give the run command and it will start the program over again.</p> <p>When you're running gdb on an embedded system, as with the command <code>target localhost:3210</code>, how do you start the program over again without quitti...
<p>You are looking for <a href="http://sourceware.org/gdb/onlinedocs/gdb/Server.html" rel="noreferrer">Multi-Process Mode for gdbserver</a> and <a href="http://sourceware.org/gdb/onlinedocs/gdb/Remote-Configuration.html" rel="noreferrer"><code>set remote exec-file filename</code></a></p>
<p>On EFM32 Happy Gecko none of the suggestions would work for me, so here is what I have learned from the documentation on integrating GDB into the Eclipse environment.</p> <pre><code>(gdb) mon reset 0 (gdb) continue (gdb) continue </code></pre> <p>This puts me in the state that I would have expected when hitting re...
10,088
<p>I have an old Borland project which I would like to port to <a href="http://en.wikipedia.org/wiki/Microsoft_Visual_Studio#Visual_Studio_2008" rel="nofollow noreferrer">Visual&nbsp;Studio&nbsp;2008</a>. Is there a way to dump, in a human-readable format, the source file, compile options and dependency information fro...
<p>If this is a <a href="https://en.wikipedia.org/wiki/Visual_Component_Library" rel="nofollow noreferrer">VCL</a> application, options and settings are the least of your concerns, since the VCL API is completely different from <a href="http://en.wikipedia.org/wiki/Microsoft_Foundation_Class_Library" rel="nofollow nore...
<p>I don't know about Borland 5, 6 or latest compilers (latest version I've used is Borland C++ 3.1 back in 1994/95 ...), but if you have the chance to generate a Makefile maybe the best solution is to use that Borland makefile to write a NMAKE compatible makefile by hand, if it's not too large. </p> <p>Another option...
49,887
<p>How to enforce that developers writing XAML in Visual Studio should follow certain standards and validations need to be run and if invalid compile time errors are thrown.</p> <p>For example, making sure that all the databinding expressions (some are real long) are written correctly as per 'a custom validation' I wo...
<p>There is no built-in way to do this. The best way you will be able to get this result is to run a custom tool on the input. This will require a lot of leg work on your part because it will involve parsing the file yourself but you should be able to get this scenario working.</p> <p>Example site for creating a cus...
<p>Sorry, the XAML language service can’t be extended this way either. The best way to do this today is to author a build task. I think you can hook it into the MarkupCompilePass1DependsOn target and it will be invoked automatically when the user saves or changes a XAML file. You still have to scan the file redundan...
43,541
<p>I'm having a problem where the relative dimensional error of cylinders is rapidly increasing as the absolute size decreases. Printing a calibration stack of cylinders of diameters 8, 7, 6, 5, 4, and 3 mm, they come out undersized by 5%, 5.3%, 7%, 8%, 10%, and 13%, respectively, as measured by a digital caliper. Cube...
<p>You should not look at the relative dimensional differences, you should be looking at the absolute differences. Multiplying the undersized dimensions in percentage with the cylinder diameter gives you a value of 0.4 &nbsp;mm for each cylinder give or take a few hundreds. So, basically your printer works very consist...
<p>This problem seems to have mostly gone away - at least any remaining error is within a margin explainable by my cheap/low-quality digital caliper. Since asking the question, I've made a lot of changes that could contribute, but the biggest factor was probably the loose X-axis timing belt and <a href="https://3dprint...
1,266
<p>I'm encountering a strange memory read/write error while calling a compiled DLL from C#. I use DllImport to get a handle to the function we need, which writes a return value to a parametric pointer to an int (i.e., int* out). This function is called multiple times within a thread, and runs successfully over the exec...
<p>Given that the problem only occurs when multiple threads are involved, it may be that the command interpreter DLL is using some sort of thread-local storage and doing it incorrectly. It could also have to do with the COM initialization state of the second thread (the one that generates the error).</p> <p>It would b...
<p>It may be the [DllImport]. If you post the [DllImport] signature, and the DLL's ptototype, maybe we can spot a problem.</p> <p>I read that the Managed, Native, and COM Interop Team released the PInvoke Interop Assistant on CodePlex. <a href="http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=...
26,075
<p>I am currently trying to make a <code>navigation-menu</code> where an <code>active-class</code> is applied to the anchors whose <code>href</code> attributes that match the current URL, so I can style that anchor in a way that makes it stand out from the rest of the menu.</p> <p>This is my mark-up:</p> <pre><code>&...
<p>This should do want you want: <strong>mark the matching link, and failing that, mark your default one.</strong></p> <pre><code>function markActiveLink() { //Look through all the links in the sidebar $("div#sidebar a").filter(function() { //Take the current URL and split it into chunks at each slash ...
<p>I think you can simplify this a bit:</p> <pre><code>function highlightSelected() { $("h2.subnav a").each( function() { if (location.pathname.indexOf(this.href) &gt; -1) { $(this).addClass("selected"); } } ); } </code></pre>
38,914
<p>I am using Flex to connect to a Rest service. To access order #32, for instance, I can call the URL <a href="http://[service]/orders/32" rel="nofollow noreferrer">http://[service]/orders/32</a>. The URL <em>must</em> be configured as a destination - since the client will connect to different instances of the service...
<p>Just so everyone knows, this is how I resolved this issue:</p> <p>I created a custom HTTPProxyAdapter on the server</p> <pre><code>public MyHTTPProxyAdapter extends flex.messaging.services.http.HTTPProxyAdapter { public Object invoke(Message message) { // modify the message - if required process(message);...
<p>Here's a simple way to resolve the url to the HTTPService within Flex via the click event's handler.</p> <p>here's a service:</p> <pre><code>&lt;mx:HTTPService id="UCService" result="UCServiceHandler(event)" showBusyCursor="true" resultFormat="e4x" /&gt; </code></pre> <p>Then here's the handl...
16,107
<p>I opened up my compiled Hello World Obj-C application in a text editor and, to my surprise, I found about 8 kilobytes of 00 00 00 00 00 00 00 00 ....</p> <p>Why are these here? Is there a way to clear out these zeroes (which I doubt have <em>too</em> much function)?</p> <p>Obviously it's not so important in <em>t...
<p>It's most likely padding between code, data, relocation or other sections of the executable format you use.</p> <p>Linkers like to pad such sections on a 4k or 8k boundary. This improves loading time for the price of a bit of memory-waste.</p> <p>For a simple hello world it's significant, but for a large applicati...
<p>Maybe it's a static variable? I know in many C-like languages, the initial value of a variable that is declared static is embedded in the code emitted by the compiler. At runtime this initial value is mapped to the memory of the process. Maybe you (or some code you're including or linking against) defines an 8 KB ze...
17,595
<p>Is there any easy way to create a class that uses <strong>IFormatProvider</strong> that writes out a user-friendly file-size?</p> <pre><code>public static string GetFileSizeString(string filePath) { FileInfo info = new FileInfo(@"c:\windows\notepad.exe"); long size = info.Length; string sizeString = siz...
<p>I use this one, I get it from the web</p> <pre><code>public class FileSizeFormatProvider : IFormatProvider, ICustomFormatter { public object GetFormat(Type formatType) { if (formatType == typeof(ICustomFormatter)) return this; return null; } private const string fileSizeFormat = "fs...
<p>using C# 9.0 syntax can be written like this:</p> <pre class="lang-cs prettyprint-override"><code>public static string ToFormatSize(ulong size) { return size switch { ulong s when s &lt; 1024 =&gt; $&quot;{size} bytes&quot;, ulong s when s &lt; (1024 &lt;&lt; 10) =&gt; $&quot;{Math.Round(size / 1024D, 2)...
15,651
<p>Imagine you got an entity in the Google App Engine datastore, storing links for anonymous users. You would like to perform the following SQL query, which is not supported:</p> <pre><code>SELECT DISTINCT user_hash FROM links </code></pre> <p>Instead you could use:</p> <pre><code>user = db.GqlQuery("SELECT user_ha...
<p>A set is good way to deal with that:</p> <pre><code>&gt;&gt;&gt; a = ['google.com', 'livejournal.com', 'livejournal.com', 'google.com', 'stackoverflow.com'] &gt;&gt;&gt; b = set(a) &gt;&gt;&gt; b set(['livejournal.com', 'google.com', 'stackoverflow.com']) &gt;&gt;&gt; </code></pre> <p>One suggestion w/r/t the fir...
<p>Sorry to dig this question up but in GAE I cannot compare objects like that, I must use .key() for comparison like that:</p> <p>Beware, this is very inefficient :</p> <pre><code>def unique_result(array): urk={} #unique results with key for c in array: if c.key() not in urwk: urk[str(c.k...
29,598
<p>I have built a windows service application in VB.net 2008, and used the Setup Wizard to add an installation process.</p> <p>The installer works, in that it adds the app to add/remove programs and copies all of the files etc, but it's missing the final (required) step of actually installing the service.</p> <p>I ha...
<p>You need to create a custom install task; MSDN has <a href="http://msdn.microsoft.com/en-us/library/zt39148a(VS.80).aspx" rel="nofollow noreferrer">everything you need to know</a></p>
<p>You can do two things: </p> <p>1) Use custom actions in your setup project to register the service using the "installutil" .Net Framework command line utility, or simply register it yourself using installutil.</p> <p>2) Add an Installer class to your Windows service. This <a href="http://www.codeproject.com/KB/do...
25,591
<p>I have a fresh install of django 1.0 and a simple page served from it takes 5 secs to load. On my colleague's computer it takes almost no time.</p> <p>I start the server using </p> <pre> python manage.py testserver </pre> <p>I can see each GET request (PNGs and style sheets) take about half a second.</p> <p>Anot...
<p>Firefox has a problem browsing to localhost on some Windows machines. You can solve it by switching off ipv6, which isn't really recommended. Using 127.0.0.1 directly is another way round the problem.</p>
<p>Disable AV Scanning &amp; see if that makes a difference. It could also be caused by Vista. Upgrade to the latest service pack and try again. </p>
47,358
<p>I think this is specific to IE 6.0 but...</p> <p>In JavaScript I add a <code>div</code> to the DOM. I assign an <code>id</code> attribute. When I later try to pick up the <code>div</code> by the <code>id</code> all I get is <code>null</code>.</p> <p>Any suggestions?</p> <p>Example:</p> <pre><code>var newDiv = do...
<p>In addition to what the other answers suggest (that you need to actually insert the element into the DOM for it to be found via <code>getElementById()</code>), you also need to use a lower-case attribute name in order for IE6 to recognize it as the <code>id</code>:</p> <pre><code>var newDiv = document.createElement...
<p>newDiv.setAttribute( "ID", "obj_1000" );</p> <p>should be</p> <p>newDiv.id = "obj_1000";</p>
7,609
<p>I am trying to create a couple of holders for my ultrasonic cleaners. They are supposed to be used for parts that don't fit in the holder that came with the cleaners. I was wondering what material is best to use for this.</p> <p>My initial thoughts are:</p> <ul> <li>Material should hold up to the cleaning solution, ...
<p>This is going to be hard. Even holding a vacuum is hard (I've tried it and not succeeded). I'm not sure what the mechanism of air molecules getting thru the print is - whether it's defects in inter-layer bonding, defects at seams, imperfect mating with the fitting, or even permeability of the plastic itself. It migh...
<h2>Not without postprocessing</h2> <p>FDM is pretty much welding plastic to plastic. Many many layers. Each of them is a potential breaking point, a corner for stress to arise and break the print.</p> <h2>Easy with a hollow body</h2> <p>Printing a hollow item that can be filled with resin is comparatively easy. Once f...
2,199
<p>I'm doing some Objective-C programming that involves parsing an NSXmlDocument and populating an objects properties from the result.</p> <p>First version looked like this:</p> <pre><code>if([elementName compare:@"companyName"] == 0) [character setCorporationName:currentElementText]; else if([elementName compare...
<p>I hope you'll all forgive me for going out on a limb here, but I would like to address the more general question of parsing XML documents in Cocoa without the need of if-else statements. The question as originally stated assigns the current element text to an instance variable of the character object. As jmah pointe...
<p>Similar to Lvsti I am using blocks to perform a switching pattern on objects.</p> <p>I wrote a very simple filter block based chain, that takes n filter blocks and performs each filter on the object.<br> Each filter can alter the object, but must return it. No matter what.</p> <p>NSObject+Functional.h</p> <pre><c...
12,993
<p>How can I create an instance of the following annotation (with all fields set to their default value).</p> <pre><code> @Retention( RetentionPolicy.RUNTIME ) public @interface Settings { String a() default "AAA"; String b() default "BBB"; String c() default "CCC"; } </c...
<p>You cannot create an instance, but at least get the default values</p> <pre><code>Settings.class.getMethod("a").getDefaultValue() Settings.class.getMethod("b").getDefaultValue() Settings.class.getMethod("c").getDefaultValue() </code></pre> <p>And then, a dynamic proxy could be used to return the default values. Wh...
<p>This works with Sun/Oracle Java 5,6,7,8: (but could potentially break with Java 9 due to the sun classes involved). //edit Just verified that this still works with OpenJDK 9b59.</p> <pre><code>package demo; import sun.reflect.annotation.AnnotationParser; import java.lang.annotation.*; import java.lang.reflect.Me...
33,466
<p>What is the difference between the <code>EXISTS</code> and <code>IN</code> clause in SQL?</p> <p>When should we use <code>EXISTS</code>, and when should we use <code>IN</code>?</p>
<p>The <code>exists</code> keyword can be used in that way, but really it's intended as a way to avoid counting:</p> <pre class="lang-sql prettyprint-override"><code>--this statement needs to check the entire table select count(*) from [table] where ... --this statement is true as soon as one match is found exists ...
<p>If you are using the IN operator, the SQL engine will scan all records fetched from the inner query. On the other hand if we are using EXISTS, the SQL engine will stop the scanning process as soon as it found a match. </p>
4,456
<p>I know about the <a href="http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/Intro/Intro.html" rel="noreferrer">HIG</a> (which is quite handy!), but what programming practices do you use when writing Objective-C, and more specifically when using Cocoa (or CocoaTouch).</...
<p>There are a few things I have started to do that I do not think are standard:</p> <p>1) With the advent of properties, I no longer use "_" to prefix "private" class variables. After all, if a variable can be accessed by other classes shouldn't there be a property for it? I always disliked the "_" prefix for makin...
<pre><code>#import "MyClass.h" @interface MyClass () - (void) someMethod; - (void) someOtherMethod; @end @implementation MyClass </code></pre>
18,870
<p>We have a large OpenWiki powered wiki. OpenWiki appears to be a dead project, and ScrewTurn the next best option.</p> <p>Is anyone aware of a data migration route to move our content from the OpenWiki SQL Server format to the ScrewTurn wiki SQL Server format?</p> <p>We may end up creating our own (and sharing it) ...
<p>Are you sure about the "dead" status?</p> <p><a href="http://www.facebook.com/pages/OpenWiki-The-Post-It-Note-of-the-Web/145492998806288" rel="nofollow noreferrer">http://www.facebook.com/pages/OpenWiki-The-Post-It-Note-of-the-Web/145492998806288</a></p>
<p>Are you sure about the "dead" status?</p> <p><a href="http://www.facebook.com/pages/OpenWiki-The-Post-It-Note-of-the-Web/145492998806288" rel="nofollow noreferrer">http://www.facebook.com/pages/OpenWiki-The-Post-It-Note-of-the-Web/145492998806288</a></p>
34,342
<p>My code needs to run all networking routines in a separate NSThread. I have got a library, which I pass a callback routine for communication:</p> <pre><code>my thread code library my callback (networking) library my thread code </code></pre> <p>My callback routine must POST some data to an HTTP ser...
<p>If you need to block until you've done the work and you're already on a separate thread, you could use <code>+[NSURLConnection sendSynchronousRequest:returningResponse:error:]</code>. It's a bit blunt though, so if you need more control you'll have to switch to an asynchronous <code>NSURLRequest</code> with delegate...
<p>To answer your mini-question "start an NSRunLoop?":</p> <p>I'm not sure I understand, but it sounds like you are saying your pseudocode above is all being executed on a secondary thread (i.e., not the main event processing thread). If that's the case, there probably isn't any point in creating an NSRunLoop, becaus...
19,083
<p>My friends and I are starting a game like Pokemon and we wanted to know how will we add monsters to the game? We're using VisualBasic because my friend's brother said it would be easier.</p> <p>So far we can put pictures of the monsters on the screen and you can click to attack and stuff.</p> <p>Right now when we...
<p>I think the best solution would be to make a generic window which can take a few parameters which describe the monster. </p> <p>Im not entirely up-to-date with VB, but in an OO language we would have a Monster base class, and inheritance to create a Pikachu. The base class would define basic things a monster has (l...
<p>Once you have created your artwork, I would load it dynamically from the hard disk rather than compile it into one big EXE. You can use the PictureBox control's LoadPicture method.</p>
10,548
<p>I've been hearing about triggers, and I have a few questions.<br /> What are triggers?<br /> How do I set them up?<br /> Are there any precautions, aside from typical SQL stuff, that should be taken?</p>
<p>Triggers allow you to perform a function in the database as certain events happen (eg, an insert into a table). </p> <p>I can't comment on mysql specifically.</p> <p>Precaution: Triggers can be very alluring, when you first start using them they seem like a magic bullet to all kinds of problems. But, they make "ma...
<p>A trigger is a named database object that is associated with a table and that is activated when a particular event occurs for the table.<br /> <br />To create a trigger:<br /></p> <pre><code>CREATE TRIGGER triggerName [BEFORE|AFTER] [INSERT|UPDATE|DELETE|REPLACE] ON tableName FOR EACH ROW SET stuffToDoHERE; </code>...
6,961
<p>I am trying to do some prime factorisation with my VBA excel and I am hitting the limit of the <code>long</code> data type - </p> <blockquote> <p>Runtime Error 6 Overflow </p> </blockquote> <p>Is there any way to get around this and still stay within VBA? I am aware that the obvious one would be to use another m...
<p>You can use Decimal data type. Quick hint from google: <a href="http://www.ozgrid.com/VBA/convert-to-decimal.htm" rel="nofollow noreferrer">http://www.ozgrid.com/VBA/convert-to-decimal.htm</a></p>
<p>You can use Decimal data type. Quick hint from google: <a href="http://www.ozgrid.com/VBA/convert-to-decimal.htm" rel="nofollow noreferrer">http://www.ozgrid.com/VBA/convert-to-decimal.htm</a></p>
38,030
<p>What are the biggest pros and cons of <a href="http://incubator.apache.org/thrift/" rel="noreferrer">Apache Thrift</a> vs <a href="http://code.google.com/apis/protocolbuffers/" rel="noreferrer">Google's Protocol Buffers</a>?</p>
<p>They both offer many of the same features; however, there are some differences:</p> <ul> <li>Thrift supports 'exceptions'</li> <li>Protocol Buffers have much better documentation/examples</li> <li>Thrift has a builtin <code>Set</code> type</li> <li>Protocol Buffers allow "extensions" - you can extend an external pr...
<p>It's also important to note that not all supported languages compair consistently with thrift or protobuf. At this point it's a matter of the modules implementation in addition to the underlying serialization. Take care to check benchmarks for whatever language you plan to use.</p>
9,472
<p>When I call the connect function of the Paramiko <code>SSHClient</code> class, it outputs some log data about establishing the connection, which I would like to suppress.</p> <p>Is there a way to do this either through Paramiko itself, or Python in general?</p>
<p>Paramiko doesn't output anything by default. You probably have a call to the logging module, setting a loglevel that's inherited when paramiko sets up it's own logging.</p> <p>If you want to get at the paramiko logger to override the settings:</p> <pre><code>logger = paramiko.util.logging.getLogger() </code></pre>...
<p>I don't know what Paramiko is, and there must be a log level setting for sure, but if you are desperate and looking for a temporary solution and if your app is single threaded</p> <pre><code>import sys dev_null = sys.stdout = sys.stderr = open('/dev/null', 'w') try: . . connect() . finally: dev_null.close() </cod...
44,215
<p>I'm currently looking to perform some headless HTML rendering to essentially create resources off screen and persist the result as an image. The purpose is to take a subset of the HTML language and apply it to small screen devices (like PocketPCs) because our users know HTML and the transition from Photoshop to HTM...
<p><a href="http://www.phantomjs.org/">http://www.phantomjs.org/</a></p> <p><strong>Full web stack</strong></p> <p>PhantomJS is a headless WebKit with JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.</p>
<p><a href="http://code.google.com/p/flying-saucer//" rel="nofollow noreferrer">Flying Saucer</a> is a Java-based XHTML &amp; CSS2.1 renderer that passess ACID2 with some error caveats. Its downside is that it has no error handling. It is not really designed to be a browser, but rather to be a component used to displ...
11,296
<p>I've noticed that SQL Server 2005 x64 does not seem to lock pages into memory the same way SQL Server 2000 did. In 2000 I could easily see from task manager that SQL had locked 8GB of ram with AWE. I'm fairly certain I've got 2005 setup in an equivalent way.</p> <p>Is this a normal x64 difference or am I forgetti...
<p>SQL Server 2005 x64 certainly doesn't need, or use, AWE; AWE is only to allow it to use > 4GB on 32 bit systems.</p> <p>You <em>can</em> use the old lock-pages-in-memory trick, but as this KB shows (<a href="http://support.microsoft.com/kb/918483" rel="nofollow noreferrer">http://support.microsoft.com/kb/918483</a>...
<p>I've seen permissions problems crop up a lot too - if the account you're using for the SQL Server service doesn't have the right permissions, it can't lock pages in memory even if you're running Enterprise Edition. This blog entry by the PSS SQL Server Engineers is really helpful:</p> <p><a href="http://blogs.msdn...
7,542
<p>Backstory: I'm using <a href="http://logging.apache.org/log4net/index.html" rel="noreferrer">log4net</a> to handle all logging for a project I'm working on. One particular method can be called under several different circumstances -- some that warrant the log messages to be errors and others that warrant the log me...
<p>Declare your delegate signature:</p> <pre><code>Public Delegate Sub Format(ByVal value As String) </code></pre> <p>Define your Test function:</p> <pre><code>Public Sub CheckDifference(ByVal A As Integer, _ ByVal B As Integer, _ ByVal format As Format) If (...
<pre><code>Public Delegate errorCall(ByVal error As String, Params objs As Objects()) CheckDifference(10, 0, AddressOf log.ErrorFormat) </code></pre> <p>Please forgive the formatting :P</p> <p>Basically though, create the delegate that you want, with the correct signature, and pass the address of it to the method.</p...
14,325
<p>I have a .NET <strong>2.0</strong> WebBrowser control used to navigate some pages with no user interaction (don't ask...long story). Because of the user-less nature of this application, I have set the WebBrowser control's ScriptErrorsSuppressed property to true, which the documentation included with VS 2005 states ...
<p>This is most definitely hacky, but if you do any work with the WebBrowser control, you'll find yourself doing a lot of hacky stuff.</p> <p>This is the easiest way that I know of to do this. You need to inject JavaScript to override the alert function... something along the lines of injecting this JavaScript functio...
<p>Are you trying to implement a web robot? I have little experience in using the hosted IE control but I did completed a few Win32 projects tried to use the IE control. Disabling the popups should be done via the event handlers of the control as you already did, but I found that you also need to change the 'Disable sc...
10,312
<p>I'm trying to get the contents of a XML document element, but the element has a colon in it's name.</p> <p>This line works for every element but the ones with a colon in the name:</p> <pre><code>$(this).find("geo:lat").text(); </code></pre> <p>I assume that the colon needs escaping. How do I fix this?</p>
<p>Use a backslash, which itself should be escaped so JavaScript doesn't eat it:</p> <pre><code>$(this).find("geo\\:lat").text(); </code></pre>
<p>if you have a <strong>jquery selector problem with chrome or webkit</strong> not selecting it try </p> <pre><code>$(this).find('[nodeName=geo:lat]').text(); </code></pre> <p>this way it works in all browsers</p>
15,647
<p>Is there a way to set a maximum size for files that can be check in into source control under Team Foundation Server 2005 or 2008?</p> <p>In the past, when we worked with SourceSafe there were several cases were developers decided to checkin a 500mb data file to source control. </p> <p>I don't know what such a thi...
<p>I'm a little confused by the question, but here are some thoughts:</p> <ol> <li><code>DataGridView</code> has an <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.autogeneratecolumns.aspx" rel="nofollow noreferrer"><code>AutoGenerateColumn</code>s</a> property; if you don't want it ...
<p>I can only give a partial answer but I think the reason that </p> <pre><code>public void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { libDataGrid.DataSource = this.manager.Lib.LibList; libDataGrid.Refresh(); } </code></pre> <p>isn't working, is beca...
41,230
<p>How can I get a user-defined function to re-evaluate itself based on changed data in the spreadsheet?</p> <p>I tried <strong><kbd>F9</kbd></strong> and <strong><kbd>Shift</kbd>+<kbd>F9</kbd></strong>.</p> <p>The only thing that seems to work is editing the cell with the function call and then pressing Enter.</p>
<p>You should use <code>Application.Volatile</code> in the top of your function:</p> <pre><code>Function doubleMe(d) Application.Volatile doubleMe = d * 2 End Function </code></pre> <p>It will then reevaluate whenever the workbook changes (if your calculation is set to automatic).</p>
<pre><code>Public Sub UpdateMyFunctions() Dim myRange As Range Dim rng As Range 'Considering The Functions are in Range A1:B10 Set myRange = ActiveSheet.Range("A1:B10") For Each rng In myRange rng.Formula = rng.Formula Next End Sub </code></pre>
3,223
<p>I am using xsl to control the output of my xml file, but the BOM character is being added.</p>
<pre><code># vim file.xml :set nobomb :wq </code></pre>
<p>I was under the impression that XML is encouraged to be written in Unicode, in some Unicode encoding, and that certain Unicode encodings are specified to contain an initial byte-order mark. Without that byte-order mark, your file is no longer correctly encoded in a Unicode encoding and therefore no longer correct XM...
37,763
<p>What are your opinions on developing for the command line first, then adding a GUI on after the fact by simply calling the command line methods?</p> <p>eg.</p> <blockquote> <p>W:\ todo AddTask "meeting with John, re: login peer review" "John's office" "2008-08-22" "14:00" </p> </blockquote> <p>loads <code>tod...
<p>I would go with building a library with a command line application that links to it. Afterwards, you can create a GUI that links to the same library. Calling a command line from a GUI spawns external processes for each command and is more disruptive to the OS.</p> <p>Also, with a library you can easily do unit test...
<p><strike>Command line tools generate less events then GUI apps and usually check all the params before starting. This will limit your gui because for a gui, it could make more sense to ask for the params as your program works or afterwards. </p> <p>If you don't care about the GUI then don't worry about it. If the en...
3,949
<p>I would like to change the name of my SQL Server instance. Is there a simple way of doing this or is a significant effort required? Note, this is a named instance - not the default instance.</p>
<p>The only way is a reinstall. See this similar thread for more info: <a href="https://stackoverflow.com/questions/35026/sql-server-convert-a-named-instance-to-default-instance#35641">SQL Server, convert a named instance to default instance?</a></p>
<p>Renaming does't work well on the registry. Install a new isntance.</p>
18,875
<p>I have an application that we're trying to migrate to 64bit from 32bit. It's .NET, compiled using the x64 flags. However, we have a large number of DLLs written in FORTRAN 90 compiled for 32bit. The functions in the FORTRAN DLLs are fairly simple: you put data in, you pull data out; no state of any sort. We als...
<p>You'll need to have the 32-bit dll loaded into a separate 32-bit process, and have your 64 bit process communicate with it via interprocess communication. I don't think there is any way a 32-bit dll can be loaded into a 64 bit process otherwise.</p> <p>There is a pretty good article here:</p> <p><a href="http://bl...
<p>John's answer is correct if you don't want to recompile your existing dlls; however that might be an option for you as well. </p> <p>Our team is currently migrating our x86 FORTRAN code to x64 to increase the memory ceiling.</p>
15,628
<p>I'm trying to click on a link using jquery. There only appears to be a click event that replicates "onclick" (i.e user input). Is it possible to use jquery to actually click a link?</p>
<p>From your answer: </p> <pre><code>$("a[0]") </code></pre> <p>is not a valid selector. to get the first a on the page use: </p> <pre><code>$("a:first") </code></pre> <p>or </p> <pre><code>$("a").eq(0). </code></pre> <p>So for the selector in your answer:</p> <pre><code>$("table[1]/tr[1]/td[1]/a").trigger(...
<p>Try it this way:</p> <pre><code>$("table:first").find("tr:first").find("td:first").find("a:first").click(); </code></pre> <p>That will trigger the onclick event of the the first a in the first cell of the first row in the first table...and its very readable in itself.</p>
44,715
<p>how do I get information about a photo like the author, the license using PHP?</p>
<p>This information is all available through the <a href="http://www.flickr.com/services/api/" rel="nofollow noreferrer">Flickr API</a>, if you poke around their docs you may find what you're looking for.</p>
<p>This information is all available through the <a href="http://www.flickr.com/services/api/" rel="nofollow noreferrer">Flickr API</a>, if you poke around their docs you may find what you're looking for.</p>
38,626
<p>I have created a pretty basic Flash website for a client and am having an issue programming a Client Login feature that he would like. Currently, if I navigate to the site and click Client Login, it takes me to a login page. The way I need this to work is -- within the Flash, using ActionScript 2.0 -- have the user ...
<p>Try this:</p> <pre><code>myVars = new LoadVars(); myVars.username = username.text; myVars.password = pwd.text; myVars.onLoad = function(success) { trace("yay!"); else { trace("try again"); } } myVars.sendAndLoad("login.php", myVars, "POST"); </code></pre>
<p>So, I get "yay!" with the code provided below (yours had an error in it). However, I need to be redirected to the resulting "logged-in" page. How do I do that?</p> <pre> myVars = new LoadVars(); myVars.txtUserID = "some_user"; myVars.txtPassword = "some_password"; myVars.__VIEWSTATE = "dDw3MTcxMTg3ODM7dDw7bDxpPDM+O...
28,680
<p>I've got a bunch of properties which I am going to use read/write locks on. I can implement them either with a <code>try finally</code> or a <code>using</code> clause.</p> <p>In the <code>try finally</code> I would acquire the lock before the <code>try</code>, and release in the <code>finally</code>. In the <code>u...
<p>From MSDN, <a href="http://msdn.microsoft.com/en-us/library/yh598w02.aspx" rel="noreferrer">using Statement (C# Reference)</a></p> <blockquote> <p>The using statement ensures that Dispose is called even if an exception occurs while you are calling methods on the object. You can achieve the same result by putting ...
<p>Silly me. There's a way to make that even simpler by making the locked methods part of each instance (instead of static like in my previous post). Now I really prefer this because there's no need to pass `rwlMyLock_m' off to some other class or method.</p> <pre><code>class StackOTest { private delegate DateTi...
35,220
<p>Are any of you aware of a library that helps you build/manipulate SQL queries, that supports JOIN's?</p> <p>It would give a lot of flexibility i'd think if you have something where you could return an object, that has some query set, and still be able to apply JOIN's to it, subqueries and such.</p> <p>I've search ...
<p>Maybe you can try an <a href="http://en.wikipedia.org/wiki/Object-relational_mapping" rel="noreferrer">ORM</a>, like <a href="http://propel.phpdb.org/trac/" rel="noreferrer">Propel</a> or <a href="http://www.doctrine-project.org/" rel="noreferrer">Doctrine</a>, they have a nice programmatic query language, and they ...
<p>You can use lenkorm it's very easy:</p> <p>select('contents)->left('categories ON categories.category.id = contents.category_id)->where('content_id = 1')->result();</p> <p>or you can use as: </p> <p>select('contents)->left('categories->using(categoru_id)->where('content_id = 1')->result();</p> <p><a href="https:...
26,573
<p>I have a basic model in which i have specified some of the fields to validate the presence of. in the create action in the controller i do the standard:</p> <pre><code>@obj = SomeObject.new(params[:some_obj]) if @obj.save flash[:notice] = "ok" redirect... else flash[:error] = @obj.errors.full_messages.collec...
<p>You <code>render :action =&gt; :new</code> rather than redirecting.</p>
<p>Capture <code>@obj</code> in the flash hash as well, and then check for it in the <code>new</code> action.</p> <pre><code>@obj = SomeObject.new(params[:some_obj]) if @obj.save flash[:notice] = "ok" # success else flash[:error] = @obj.errors.full_messages.collect { |msg| msg + "&lt;br/&gt;" } flash[:obj] = ...
19,141
<p><strike>All of the errors are on auto-generated files, not within the files that were created by me. Here are a few of them:</p> <pre><code>'Context' is not a member of 'auth_cookies' 'ProcessRequest' cannot be declared 'Overrides' because it does not override a sub in a base class 'Server' is not a member of 'ASP...
<p>Did you put a <code>&lt;%@Page%&gt;</code> directive in your Master page? It should only have a <code>&lt;%@Master%&gt;</code> directive.</p>
<p>No, the header of my MasterPage is:</p> <pre><code>&lt;%@ Master Language="VB" CodeFile="theMaster.master.vb" Inherits="theMaster" %&gt; </code></pre> <p>There is no <code>&lt;%@Page%&gt;</code> directive on the MasterPage.</p>
35,137
<p>We would like to give access to some of our EJBs from Excel. The goal is to give an API usable from VBA.</p> <p>Our EJBs are mostly Stateless Session Beans that do simple CRUD operations with POJOs.</p> <p>Some possible solutions: </p> <ul> <li>Exposing the EJBs as WebServices and create a VB/C# dll wrapping them...
<p>You could take a look at <a href="http://www.codeproject.com/KB/cs/iiop_net_and_ejb.aspx" rel="nofollow noreferrer">IIOP.NET</a>, which addresses this issue.</p>
<p>I highly recommend <a href="http://www.ikvm.net/" rel="nofollow noreferrer">IKVM</a>. It is a java byte code to .NET assembly compiler (i.e. JAR --> DLL) and I have used it to create live JMX links and listeners in an Excel automation server. It should not be difficult for you to create a .NET assembly of your EJB c...
11,668
<p>I am working on a legacy project in <code>VC++/Win32/MFC</code>. Recently it became a requirement that the application work on a <strong>tablet pc</strong>, and this ushered in a host of new issues. I have been able to work with, and around these issues, <strong>but am left with one wherein I could use some expert s...
<p>As a tablet user I can answer a few of your questions.</p> <p>First:</p> <blockquote> <p>You cannot very easily keep a "keyboard focus" on a window when the stylus has to trail out of the focused window to push a key on the virtual keyboard.</p> </blockquote> <p>Most of the virtual keyboards I've used (The wind...
<p>As I understand it, there is no "lift" event -- the only event happens when the stylus is brought back to the screen later. Of course, this depends on your specific driver and so on.</p> <p>Worse, the bug you describe might be reproducible with just a typical mouse. Try moving the mouse as fast as you can -- it wil...
10,598
<p>Is there an intuitive way, or a good mnemonic, for understanding the correspondence between colors and their hexadecimal values?</p>
<p>You just have to remember that the scale is 00 (no color effect) through FF (full color effect) and the three parts of the triplet are red, green and blue.</p> <p>000000 is black (i.e., no color) and FFFFFF is white (mixing all three primary colors).</p> <p>The hard bit is remembering the mixtures, which I use the ...
<p>Well, monitors use an 'RGB' colorscheme. The order of the colors in the hexadecimal number is RRGGBB. So just remembering the name of the colorscheme tells you what goes where. Then you can parse the #RRGGBB as three numbers RR, GG and BB.</p> <p>The higher the number the brighter that particular component.</p> <p...
34,592
<p>When a web site is licensed under Creative Commons, I use the <a href="http://microformats.org/wiki/rel-license" rel="noreferrer">rel-license microformat</a>. When a web site is licensed under regular copyright, I have a boring paragraph element.</p> <pre><code>&lt;p id="copyright"&gt;&amp;copy; 2008 Example Corpor...
<p>Thanks to Owen for pointing me in the direction of RDFa, I think I've got the solution now:</p> <pre><code>&lt;div id="footer" xmlns:dc="http://purl.org/dc/elements/1.1/"&gt; &lt;p id="copyright" property="dc:rights"&gt;&amp;copy; &lt;span property="dc:dateCopyrighted"&gt;2008&lt;/span&gt; &lt;span property="dc...
<p>Why not use the CC format, but indicate that no rights are granted?</p> <p>In any case, the main problem with the use of the CC formats is that people do not clearly identify which elements of the webpage that they appear on they apply to.</p>
31,762
<p>I'm interested in developing applications on the iPhone and being a .NET &amp; ActionScript developer I'm a bit scared from the learning curve of Objective-C Cocoa Touch programming. I know that Adobe has Flash player ready for iPhone and I think that Apple doesn't want it just for political reason. Is there any e...
<p>Currently there is no other way. As a long time Apple Fanboy I've learnt one thing time and time again "It's Steve's way or the highway". If Steve says no Flash then you can bet your sweet little bippy that there will be no Flash. So either develop a web app, or learn Objective-C. I'm a JAVA head and I learnt all I ...
<p>Flash is a proprietary runtime. Why would apple want this on their device?</p> <p>Not to mention the fact that Flash developers routinely hog CPU cycles on the web. Ever have your fan spin up while on a web page with heavy flash objects hogging your cpu?</p> <p>I don't see Apple ever supporting Flash and I am glad...
47,690
<p>I would like to inject binary data into an object in JavaScript. Is there a way to do this? </p> <p>i.e.</p> <pre><code>var binObj = new BinaryObject('101010100101011'); </code></pre> <p>Something to that effect. Any help would be great.</p>
<p>You can use parseInt:</p> <p><code>var bin = parseInt('10101010', 2);</code></p> <p>The second argument (the radix) is the base of the input.</p>
<p>Javascript doesn't provide a mechanism to load an object in any form other than simple strings.</p> <p>Closest you can do is serializing the object to a string, optionally encrypting/compressing it, sending it to the browser, and decrypting/decompressing if necessary, checking for sanity, eval() and pray().</p> <p...
42,475
<p>Please tell me if it is possible to do the following:</p> <ul> <li>create an instance of a specific class in Java</li> <li>pass it to JRuby to do something with it</li> <li>continue using the "modified" version in Java</li> </ul> <p>May you provide a small working example?</p> <p>EDIT: It turns out that embedding...
<p>Yes it's possible. <a href="https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby" rel="nofollow noreferrer">This page</a> on the JRuby wiki should get you started.</p>
<p>It depends on what you mean by "do something". If you mean "redefine a method", then the answer is no, not really. The new method will be used by jruby, but any calls to the method in java will continue to invoke the old method.</p>
39,393
<p>I'm getting a pet bird soon, and I know that off-gassing from heating PTFE above 300&nbsp;°C creates noxious fumes, which are bird-killer<sup>1</sup>. To try to prevent even the chance of that I'm replacing my hotend with an all-metal one. I have an E3D v6 1.75&nbsp;mm, which I noticed still uses a PTFE tube at the ...
<p>First of all, we need to discuss the failure mode and what can be done. LEt's do a</p> <h2>Failure mode 1: coolend-fan stops working.</h2> <p>Let's assume the coolend-fan for whatever reason (cut cable, defect fan, burnt board...) stops working. As a result, the coolend starts to rise in temperature, as it doesn't d...
<p>It is doubtful that small PTFE inside hotend could produce that kind of dangerous gas leak. But another thing should be considered: the PTFE tube inside hotend WILL degrade over time and will need replacement.</p> <p>For last several years I had numerous experiments with all kind of solutions including my own desig...
1,607
<p>I have a simple app loading a site optimized for the iPhone in a <code>UIWebView</code>.</p> <p>Problem is, caching does not seem to work:</p> <pre><code>[webView loadRequest: [NSURLRequest requestWithURL: [NSURL URLWithString: url] cachePolicy: NSURLRequestUseProtocolCachePo...
<p>One workaround of this problem as I see is to </p> <p>1) download HTML code</p> <p>2) store it in the string</p> <p>3) find all external links in it like</p> <pre><code>&lt;img src="img.gif" width="..." height="..." /&gt; </code></pre> <p>4) download them all</p> <p>5) replace them with embedded Base64-encoded...
<p>You should be able to subclass <code>NSURLCache</code> and substitute it for the shared cache used by the <code>UIWebView</code> as described in this Cocoa with Love article: <a href="http://www.cocoawithlove.com/2010/09/substituting-local-data-for-remote.html" rel="nofollow">Substituting local data for remote UIWeb...
44,947
<p>Windows has its 3D Builder software which upon importing an image, converts it to a heightmap of the image, aka turning it to a 3D model that can be saved as an stl.</p> <p>Does Linux have software with similar properties that takes a black and white image and turning it into a 3D heightmap model?</p>
<p>The OpenSCAD <code>surface</code> function will do this. You can feed it a greyscale image or a textfile containing a matrix. Documentation and examples can be found at <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surface" rel="nofollow noreferrer">https://en.wikibooks.org/wi...
<p>FreeCAD can import JPG (and IIRC TIFF and PNG as well) image files and produce a lithophane type height-map based on the brightness of each pixel. I'd be rather surprised if other 3D CAD software aimed at the 3D printing user base couldn't do the same. Most of the common free-to-use 3D CAD packages have Linux vers...
1,954
<p>I am reading an XML file into a DataSet and need to get the data out of the DataSet. Since it is a user-editable config file the fields may or may not be there. To handle missing fields well I'd like to make sure each column in the DataRow exists and is not DBNull. </p> <p>I already check for DBNull but I don't kno...
<p>DataRow's are nice in the way that they have their underlying table linked to them. With the underlying table you can verify that a specific row has a specific column in it.</p> <pre><code> If DataRow.Table.Columns.Contains("column") Then MsgBox("YAY") End If </code></pre>
<p>You can encapsulate your block of code with a try ... catch statement, and when you run your code, if the column doesn't exist it will throw an exception. You can then figure out what specific exception it throws and have it handle that specific exception in a different way if you so desire, such as returning "Colu...
21,543
<p>When writing the string "¿" out using</p> <pre><code>System.out.println(new String("¿".getBytes("UTF-8"))); </code></pre> <p>¿ is written instead of just ¿.</p> <p>WHY? And how do we fix it?</p>
<p>You don't have to use UTF-16 to solve this:</p> <pre><code>new String("¿".getBytes("UTF-8"), "UTF-8"); </code></pre> <p>works just fine. As long as the encoding given to the <code>getBytes()</code> method is the same as the encoding you pass to the String constructor, you should be fine!</p>
<p>Sounds like the system console isn't in UTF-8</p>
21,212
<p>Does anyone know the query the last synchronization date from sql server (2008).</p> <p>It is the same information displayed in replication monitor, but I want to be able to get that date from a query.</p>
<p>You can see a lot of info about merge sessions by using the system table msMerge_sessions:</p> <pre><code>select * from msMerge_sessions </code></pre> <p>Depending on the info you need, use the other system tables available in your database.</p>
<p>For Answered Number 3 </p> <p>Great Effort but there're some modification On view for ability running Query </p> <p>---- Create View LastSync as below </p> <pre><code>Create View LastSync As select subscriber_name, max(start_time) as last_sync, ID, creation_date from msMerge_sessions inner join msMerge_agents ...
49,358
<p>I have a form in C# that has a button that, when clicked, I want the background image to cycle through a set of images (which I have as resources to the project). The images are named '_1', '_2', etc. and each time I click the button I want its background image to increment to the next one and go back to "_1" when ...
<p>Why don't you just put the images in an array?</p>
<p>You could subclass Button and override the BackgroundImage property so you can better keep track of the current resource that represents the image. You might also override the onclick method to internally handle cycling to the next image, though that might be a little weird if the resources are handled outside of y...
3,587
<p>I have a simple question and wish to hear others' experiences regarding which is the best way to replicate images across multiple hosts.</p> <p>I have determined that storing images in the database and then using database replication over multiple hosts would result in maximum availability.</p> <p>The worry I have...
<p>If you store images in the database, you take an extra database hit <em>plus</em> you lose the innate caching/file serving optimizations in your web server. Apache will serve a static image much faster than PHP can manage it.</p> <p>In our large app environments, we use up to 4 clusters:</p> <ul> <li>App server cl...
<p>Having your images in a database doesn't necessarily mean a database call for each one; you could cache these separately on each host (e.g. in temporary files) when they are retrieved. The source images would still be in the database and easy to synchronise across servers.</p> <p>You also don't really need to add A...
48,586
<p>I'm building a Thunderbird extension and would like to add my own header to all outgoing email (e.g. &lt;myext-version: 1.0&gt; ). Any idea how to do this? I know it's possible since this is done in the OpenPGP Enigmail extension. Thanks!</p>
<p>Here is the code from one extension I'm working on:</p> <pre><code>function SendObserver() { this.register(); } SendObserver.prototype = { observe: function(subject, topic, data) { /* thunderbird sends a notification even when it's only saving the message as a draft. * We examine the caller chain t...
<p>I don't know the answer but just some thoughts...</p> <p>I think thunderbird extensions are usually just xul and js. From the enigmail site:</p> <blockquote> <p>Unlike most Mozilla AddOns, Enigmail contains platform dependent parts: it depends on the CPU, the compiler, libraries of the operating system an...
19,600
<p>What interrupt would you hook from DOS to get the real-time clock?</p>
<p>The realtime clock cannot generate interrupts. It was (maybe still is) coupled with the cmos-ram because it was buffered by the battery. It can only be accessed via the ports 0x70 and 0x71.</p> <p>You can however hook the interrupt of the PIT (programmable interrupt timer). That's interrupt 0x08 (e.g. hardware IRQ0...
<p>Read up on the <a href="http://en.wikipedia.org/wiki/Intel_8259" rel="nofollow noreferrer">Intel 8259</a> family of Programmable Interrupt Controllers. According to this, it's interrupts 8 (master) and 112 (slave). Here's a very technical document on the 8259A: <a href="http://pdos.csail.mit.edu/6.828/2008/reading...
10,929
<p>ModRewrite can easily handle stripping the www off the front of my domain.<br> In .htaccess:</p> <pre><code>RewriteEngine On RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(....
<p>You can get certificates with multiple domain names in them. Get one with <code>mydomain.com</code> and <code>www.mydomain.com</code>. I think it's also possible to buy "wildcard" certificates that will match any subdomain, but they cost much more.</p>
<p>What you are trying to do is impossible. If a user accesses www.domain.cc over SSL, then you will get a certificate error if you do not have a valid SSL certificate - even if all you want to do is redirect them to the correct site. </p> <p>You will either need a new certificate for www.domain.cc, or convince your r...
22,017
<p>Say I have an array that represents a set of points:</p> <pre><code>x = [2, 5, 8, 33, 58] </code></pre> <p>How do I generate an array of all the pairwise distances? </p>
<pre><code>x = [2, 5, 8, 33, 58] print x.collect {|n| x.collect {|i| (n-i).abs}}.flatten </code></pre> <p>I think that would do it.</p>
<p>If you really do want an array instead of a matrix, this is O(n^2/2) instead of O(n^2).</p> <pre><code>result=[] x.each_index{|i| (i+1).upto(x.size-1){|j| result&lt;&lt;(x[i]-x[j]).abs}} </code></pre>
15,161
<p>Before I do this I figured I would ask if it was the best way. Each "Vendor" object has a "Bucket" object. In my repeater I need to display some properties from Vendor and some from Bucket, also some images populated by FileSystem that are linked to the vendor. I figured the best way to do this is bind the repeater ...
<p>Haven't heard of it before, but I can't wait to see if you can make it useful!</p> <p>You can assign Visual Studio functions to "chords" of key combinations, right? So maybe you could play shave-and-a-haircut to start a build.</p>
<p>Yeah, I was thinking about doing something similiar to that myself. I'm pretty sure you'd have to write your own driver for it though.</p>
13,285
<p>I would like to make my web control more readable in design mode, basically I want the tag declaration to look like:</p> <pre><code>&lt;cc1:Ctrl ID="Value1" runat="server"&gt; &lt;Values&gt;string value 1&lt;/Value&gt; &lt;Values&gt;string value 2&lt;/Value&gt; &lt;/cc1:Ctrl&gt; </code></pre> <p>...
<p>I think what you are searching for is the attribute:</p> <pre><code>[PersistenceMode(PersistenceMode.InnerProperty)] </code></pre> <p><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.persistencemode.aspx" rel="nofollow noreferrer">Persistence Mode</a></p> <p>Remember that you have to register your n...
<p>I see two options, but both depend on your web control implementing some sort of collection for your values. The first option is to just use the control's collection instead of your private variable. The other option is to copy the control's collection to your private variable at run-time (maybe in the Page_Load e...
8,717
<p>I have a list string tag.</p> <p>I am trying to initialize a dictionary with the key as the tag string and values as the array index.</p> <pre><code>for i, ithTag in enumerate(tag): tagDict.update(ithTag=i) </code></pre> <p>The above returns me {'ithTag': 608} <em>608 is the 608th index</em></p> <p>My probl...
<p>You actually want to do this:</p> <pre><code>for i, tag in enumerate(tag): tagDict[tag] = i </code></pre> <p>The .update() method is used for updating a dictionary using another dictionary, not for changing a single key/value pair.</p>
<p>I think this is what you want to do:</p> <pre><code>d = {} for i, tag in enumerate(ithTag): d[tag] = i </code></pre>
20,878
<p>I am putting together a build system and wanted to know if there is a reliable way to find out if a checked out SVN folder needs updating (i.e. is it out of sync with the repository). I want to avoid a nightly build unless something has changed. I could write a script that parses the results of the <code>svn updat...
<p>Use the <a href="http://www.visualsvn.com/support/svnbook/ref/svn/#svn.ref.svn.sw.show_updates" rel="noreferrer">show updates option</a> of the status command: </p> <pre><code>svn status -u </code></pre> <p>or</p> <pre><code>svn status --show-updates </code></pre>
<p>The <a href="https://stackoverflow.com/a/305294/1184842">answer of flolo</a> does not work good for subversion externals (which is also discussed in <a href="https://stackoverflow.com/questions/2789344/dont-show-svnexternals-in-svn-status">Don&#39;t show svn:externals in svn status</a>). A better solution if you onl...
39,254
<p>How can I write a scheduler application in C# .NET?</p>
<p>You could also try <a href="http://quartznet.sourceforge.net/index.html" rel="nofollow noreferrer">Quartz.Net</a>.</p>
<p>You can also use the timer control to have the program fire of whatever event you want every X ticks, or even just one. The best solution really depends on what you're tring to accomplish though.</p>
18,549
<p>I have a C# .NET web project that I'm currently working on. What I'm trying to do is read some files that I dropped into a dir which is at the same level as fileReader.cs which is attempting to read them. On a normal desktop app the following would work:</p> <pre><code>DirectoryInfo di = new DirectoryInfo(./myDir...
<p>Use <a href="http://msdn.microsoft.com/library/ms178116.aspx" rel="nofollow noreferrer"><code>Server.MapPath</code></a> to get the local path for the currently executing page.</p>
<p>Use <a href="http://msdn.microsoft.com/library/ms178116.aspx" rel="nofollow noreferrer"><code>Server.MapPath</code></a> to get the local path for the currently executing page.</p>
32,984
<p>I am using a new Prusa i3 MK3S 3D printer kit. I print lots of things using PLA and PETG. </p> <p>After a week of great performance I noticed that when printing some objects with PETG filament I often encountered a problem when there's <strong>intense stringing, infill gaps, artifacts, the object sometimes detach...
<p>230&nbsp;°C is way too cool for PETG and will result in underextrusion unless you print really slow, and poor bonding. Underextrusion in turn leads to stringing because of pressure build-up. I print PETG at 250&nbsp;°C.</p>
<p>You might try printing with Prusa's recommended settings. They tend to be hotter and slower than I expected.</p> <p>I have made several pet-G prints with the same machine you have. </p>
1,373
<p>Is there a way to create an html link using h:outputLink, other JSF tag or code to create a non faces request (HTTP GET) with request parameters?</p> <p>For example I have the following navigation-rule</p> <pre><code>&lt;navigation-rule&gt; &lt;navigation-case&gt; &lt;from-outcome&gt;showMessage&lt;/fr...
<p>This is an interesting idea. I'd be curious to know how it pans out in practice.</p> <p><strong>Getting the navigation rules</strong></p> <p>Navigation is handled by the <a href="http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/api/javax/faces/application/NavigationHandler.html" rel="noreferrer">NavigationHa...
<p>Have you considered a form?</p> <pre><code>&lt;h:form&gt; &lt;h:commandLink value="Click to see the message" action="#{handler.outcome}" /&gt; &lt;h:inputHidden id="msgId" value="#{bean.msgId}"/&gt; &lt;/h:form&gt; </code></pre>
16,791
<p>How do you repopulate a form in ASP.NET MVC that contains a DropDownList?</p>
<p>I believe you are asking how to maintain the value for a dropdown list after a form is submitted and re-displayed. If so, please see below for a <strong>VERY SIMPLE</strong> example:</p> <p>Create a new MVC app (using MVC beta) and place the following in HomeController:</p> <pre><code>private Dictionary&lt;string...
<p>I just wanted to add the BigJoe714 has it right except the ...new SelectList(listItems, "Value", "Key", selectedItem) has the key / value switched</p> <p>The constructor takes these params for this overload</p> <pre><code>public SelectList( IEnumerable items, string dataValueField, string dataTextField, object se...
38,024
<p>I'm looking for patterns that concern coding parts of a GUI. <strong>Not</strong> as global as <strong>MVC</strong>, that I'm quite familiar with, but patterns and good ideas and best practices concerning single controls and inputs.</p> <p>Let say I want to make a control that display some objects that may overlap....
<p>I think to be honest you a better just boning up on your standard design patterns and applying them to the individual problems that you face in developing your UI.</p> <p>While there are common UI &quot;themes&quot; (such as dealing with modifier keys) the actual implementation may vary widely.</p> <p>I have O'Reill...
<p>I don't think the that benefit of design patterns come from trying to find a design pattern to fit a problem. You can however use some heuristics to help clean up your design in this quite a bit, like keeping the UI as decoupled as possible from the rest of the objects in your system.</p> <p>There is a pattern that...
3,239
<p>Specifically using stainless steel nozzles, but I guess it's worth knowing about brass too. Is there any reason to be concerned about dimensional accuracy of the nozzle or anything like that as a result of repeated heating with a butane torch? </p>
<p>If you carbonize the filament or other particles that are clogging the nozzle, then you will never get them clean. In my experience, it's not worth cleaning the nozzle with anything other than cleaning filament. If that doesn't work then change the nozzle. Heating the metal nozzle with a torch will change the temper...
<p>If you can get the torch hot enough and you carbonise/burn the filament properly, it may work. You still need to do a cold pull to remove as many residues as you can, but if you heated it enough, the residuals maybe won't stick too much to the nozzle.</p> <p>You already have the butane, try and tell us.</p>
1,628
<p>I want to embed a wikipedia article into a page but I don't want all the wrapper (navigation, etc.) that sits around the articles. I saw it done here: <a href="http://www.dayah.com/periodic/" rel="nofollow noreferrer">http://www.dayah.com/periodic/</a>. Click on an element and the iframe is displayed and links to ...
<p>The periodic table example loads the printer-friendly version of the wiki artice into an iframe. <a href="http://en.wikipedia.org/wiki/Potasium" rel="noreferrer">http://en.wikipedia.org/wiki/Potasium</a>?<b>printable=yes</b></p> <p>it's done in <i>function click_wiki(e)</i> (line 534, interactivity.js)</p> <blockq...
<p>You could always download the site and scrap it. I think everything inside <code>&lt;div id="bodyContent"&gt;</code> is the content of the article - sans navigation, header, footer, etc..</p> <p>Don't forget to credit. ;)</p>
8,723
<p>Can I rename a folder in Perforce from <em>//depot/FooBar/</em> to <em>//depot/Foobar/</em>?</p> <p>I've tried this by renaming from <em>//depot/FooBar/</em> to <em>//depot/Temp/</em> to <em>//Depot/Foobar/</em> but the end result ends up the same as <em>//depot/FooBar/</em>.</p>
<p>Once it is in Perforce, the case remains set. As mentioned by Johan you can obliterate, set the name up correctly, and add it in again. However, there is a slight gotcha....</p> <p>If anyone else (running Windows) has already synced the wrong-cased version, then when they sync again the right one, it will not chang...
<p>The question is over 3 years old, but I ran into an issue like this while doing a Subversion import into Perforce and figured the info I got could be useful to some. It's similar to the obliterate method, but helps you retain history. You use the duplicate command that may not have been available back then to retain...
16,139
<p>I Use Jacob (JAVA COM Bridge) on a 64 Bit Machine and want to load COM Objects from a 32 bit DLL. How can I do that?</p>
<p>You will need to host the 32 bit COM object in a 32bit process. So either your entire app will have to run 32bit or youll need to place the COM object in something like COM+ and use cross process calls.</p>
<p>You will need to host the 32 bit COM object in a 32bit process. So either your entire app will have to run 32bit or youll need to place the COM object in something like COM+ and use cross process calls.</p>
46,943
<p>I think everyone would agree that the MATLAB language is not pretty, or particularly consistent. But nevermind! We still have to use it to get things done.</p> <p>What are your favourite tricks for making things easier? Let's have one per answer so people can vote them up if they agree. Also, try to illustrate your...
<p>Turn a matrix into a vector using a single colon.</p> <pre><code>x = rand(4,4); x(:) </code></pre>
<p>Using ismember() to merge data organized by text identfiers. Useful when you are analyzing differing periods when entries, in my case company symbols, come and go.</p> <pre><code>%Merge B into A based on Text identifiers UniverseA = {'A','B','C','D'}; UniverseB = {'A','C','D'}; DataA = [20 40 60 80]; DataB = [30 5...
16,015
<p>I have a directory with several subdirectories with files.<br> How can I copy all files in the subdirectories to a new location?<br></p> <p><strong>Edit:</strong> I do not want to copy the directories, just the files...</p> <p>As this is still on XP, I chose the below solution:</p> <pre><code> for /D %S IN ("src\...
<p>Ok. With your edit that says you don't want the directory structure, i think you're going to want to use something like this:</p> <pre><code>for /F "usebackq" %s IN (`DIR /B /S /A-D SrcDir`) DO @( XCOPY %s DestDir\%~nxs ) </code></pre>
<p>If you want to keep the same folder structure on the other end, sounds as simple as XCOPY</p> <blockquote> <p>xcopy c:\old\*.* d:\new\ /s</p> </blockquote> <p>Use /e instead of /s if you want empty directories copied too.</p>
22,468