instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>How do I get a function's name as a string?</p> <pre><code>def foo(): pass &gt;&gt;&gt; name_of(foo) &quot;foo&quot; </code></pre>
<pre><code>my_function.__name__ </code></pre> <p>Using <code>__name__</code> is the preferred method as it applies uniformly. Unlike <code>func_name</code>, it works on built-in functions as well:</p> <pre><code>&gt;&gt;&gt; import time &gt;&gt;&gt; time.time.func_name Traceback (most recent call last): File "&lt;s...
<p>You can get a function's name as a string by using the special <code>__name__</code> variable.</p> <pre class="lang-py prettyprint-override"><code>def my_function(): pass print(my_function.__name__) # prints &quot;my_function&quot; </code></pre>
31,319
<p>When I was taking CS in college (mid 80's), one of the ideas that was constantly repeated was to always write loops which test at the top (while...) rather than at the bottom (do ... while) of the loop. These notions were often backed up with references to studies which showed that loops which tested at the top were...
<p>I always follow the rule that if it should run zero or more times, test at the beginning, if it must run <em>once</em> or more, test at the end. I do not see any logical reason to use the code you listed in your example. It only adds complexity.</p>
<p>In a typical Discrete Structures class in computer science, it's an easy proof that there is an equivalence mapping between the two.</p> <p>Stylistically, I prefer while (easy-expr) { } when easy-expr is known up front and ready to go, and the loop doesn't have a lot of repeated overhead/initialization. I prefer d...
27,680
<p>Been thinking, what's the difference between declaring a variable with [] or * ? The way I see it:</p> <pre><code>char *str = new char[100]; char str2[] = "Hi world!"; </code></pre> <p>.. should be the main difference, though Im unsure if you can do something like</p> <pre><code>char *str = "Hi all"; </code></pre...
<p>Let's look into it (for the following, note <code>char const</code> and <code>const char</code> are the same in C++):</p> <h2>String literals and char *</h2> <p><code>"hello"</code> is an array of 6 const characters: <code>char const[6]</code>. As every array, it can convert implicitly to a pointer to its first el...
<p>The first option dynamically allocates 100 bytes.</p> <p>The second option statically allocates 10 bytes (9 for the string + nul character).</p> <p>Your third example shouldn't work - you're trying to statically-fill a dynamic item.</p> <p>As to the <code>upperCaseString()</code> question, once the C-string has b...
39,704
<p>I have an enumeration of delivery status codes. And when I save delivery data to the database they are stored with a foreign key to a table containing the same data (i.e. the same delivery codes)</p> <p>What is the best strategy for keeping an enumeration in synch with data in a database?</p> <p>Do you just remem...
<p>I use T4 templates in Visual Studio 2008. This way, I can force code generation during build and it generates Enums for each table that I want. </p> <p>A good starting point would be <a href="http://dotnet.org.za/hiltong/archive/2008/08/06/generating-enums-from-database-tables.aspx" rel="nofollow noreferrer">Hilton...
<p>When I use a enumeration in the code, I usually store the formatted name as a varchar in the database rather than keep a table of the enumeration values in the database. I realize that this is not as normalized as one might like, but I believe it is better than trying to keep the database and my enumeration synche...
41,780
<p>I am trying to generate some code at runtime using the DynamicMethod class in the Reflection.Emit namespace but for some reason its throwing a "VerificationException". Here is the IL code I am trying to use...</p> <pre><code>ldarg.1 ldarg.0 ldfld, System.String FirstName callvirt, Void Write(System.String) ldarg.1 ...
<p>I have found some more help here...</p> <p><a href="http://blogs.msdn.com/haibo_luo/archive/2005/10/25/484861.aspx" rel="noreferrer">DebuggerVisualizer for DynamicMethod (Show me the IL) </a> It's is a debugger visualizer using which you will be able to see the generated IL at runtime!</p> <p>And even better is <a...
<p>There is no way to debug IL directly in the sense of using a debugger (not builtin at least). You really only have two options here</p> <ol> <li>Ask Rob suggested. Manually type out the IL and ilasm into a DLL/EXE. Then run peverify on the resulting DLL to see your error.</li> <li>If you are actually wanting to ...
41,567
<p>I'm using a winforms webbrowser control to display some content in a windows forms app. I'm using the DocumentText property to write the generated HTML. That part is working spectacularly. Now I want to use some images in the markup. (I also would prefer to use linked CSS and JavaScript, however, that can be wor...
<p>Here's what we do, although I should mention that we use a custom web browser to remove such things as the ability to right-click and see the good old IE context menu:</p> <pre><code>public class HtmlFormatter { /// &lt;summary&gt; /// Indicator that this is a URI referencing the local /// file path. ...
<p>I ended up using something that's basically the same as what Ken suggested. However, instead of manually appending the file prefix, I used the UriBuilder class to build the complete URI with the "file" protocol.</p> <p>This also solved a subsequent problem when we tested the app in a more realistic location, Progr...
9,767
<p><p>How to include any assembly code lines into my C program ? <p>In turbo c is there a possibility to add an assembly code file (.asm) to a project of few .c files?</p>
<p>One way to include assembly code is to add a wrapper function and write the assembly code in the asm block, as shown in the example below:</p> <pre><code>void wrapper_function() { asm { /* your assembly code */ } } </code></pre>
<p>You can also link in the object files. But inline assembler is much easier to maintain.</p>
28,845
<p>Is there an elegant way to have performant, natural sorting in a MySQL database?</p> <p>For example if I have this data set:</p> <ul> <li>Final Fantasy</li> <li>Final Fantasy 4</li> <li>Final Fantasy 10</li> <li>Final Fantasy 12</li> <li>Final Fantasy 12: Chains of Promathia</li> <li>Final Fantasy Adventure</li> <...
<p>Here is a quick solution:</p> <pre><code>SELECT alphanumeric, integer FROM sorting_test ORDER BY LENGTH(alphanumeric), alphanumeric </code></pre>
<p>I know this topic is ancient but I think I've found a way to do this:</p> <pre><code>SELECT * FROM `table` ORDER BY CONCAT( GREATEST( LOCATE('1', name), LOCATE('2', name), LOCATE('3', name), LOCATE('4', name), LOCATE('5', name), LOCATE('6', name), LOCATE('7', name), LOCATE('8', na...
18,551
<p>I am looking for a redistributable component to convert HTML to PDF.</p> <p>I would - at the moment - like to avoid using a "PDF printer", as this requires a printer installation and some user "playing around" in the printers panel might break that feature.</p> <p>The HTML is available in a Browser control or as e...
<p><a href="http://sourceforge.net/projects/pdfcreator/" rel="nofollow noreferrer">PDFCreator</a> can function as a virtual printer but it's also usable via COM. The default setup even includes COM examples.</p> <p>You can check the COM samples in the SourceForge SVN repository right here: <a href="http://pdfcreator.s...
<p>You might want to have a look at <a href="http://www.realobjects.com/PDFreactor.808.0.html" rel="nofollow noreferrer"><strong>PDFReactor</strong></a></p>
41,853
<p>Are there any <strong>tools</strong> to facilitate a migration from <a href="http://www.sourcegear.com/vault/index.html" rel="noreferrer">Sourcegear's Vault</a> to <a href="http://subversion.tigris.org/" rel="noreferrer">Subversion</a>?</p> <p>I'd really prefer an existing tool or project (I'll buy!).</p> <p><stro...
<p>We are thinking about migrating from vault to git. I wrote vault2git converter that takes care of history and removes vault bindings from *.sln, *.csproj files.</p> <p>Once you have git repo, there is git2svn.</p> <p>I know it sounds like going rounds, but it might be faster than writing vault2svn from scratch.</p...
<p>Free. The vault user license costs have tripled since we went to it.</p>
8,181
<p>V8's documentation explains <a href="http://code.google.com/apis/v8/embed.html#dynamic" rel="noreferrer">how to create a Javascript object that wraps a C++ object</a>. The Javascript object holds on to a pointer to a C++ object instance. My question is, let's say you create the C++ object on the heap, how can you ge...
<p>The trick is to create a <code>Persistent</code> handle (second bullet point from the linked-to API reference: "<code>Persistent</code> handles are not held on a stack and are deleted only when you specifically remove them. ... Use a persistent handle when you need to keep a reference to an object for more than one...
<p>In general, if a garbage-collected language can hold references to resources outside of the language engine (files, sockets, or in your case C++ objects), you should provide a 'close' method to release that resource ASAP, no point waiting until the GC thinks it's worthwhile to destroy your object.</p> <p>it gets wo...
20,889
<p>I'm developing a website (in Django) that uses OpenID to authenticate users. As I'm currently only running on my local machine I can't authenticate using one of the OpenID providers on the web. So I figure I need to run a local OpenID server that simply lets me type in a username and then passes that back to my main...
<p>The libraries at <a href="http://openidenabled.com/" rel="noreferrer">OpenID Enabled</a> ship with examples that are sufficient to run a local test provider. Look in the examples/djopenid/ directory of the python-openid source distribution. Running that will give you an instance of <a href="http://openidenabled.co...
<p>Why not run an OpenID provider from your local machine?</p> <p>If you are a .Net developer there is an OpenID provider library for .Net at <a href="http://code.google.com/p/dotnetopenid/" rel="nofollow noreferrer">Google Code</a>. This uses the standard .Net profile provider mechanism and wraps it with an OpenID la...
20,736
<p>I'd like to split a string using one or more separator characters.</p> <p>E.g. "a b.c", split on " " and "." would give the list ["a", "b", "c"].</p> <p>At the moment, I can't see anything in the standard library to do this, and my own attempts are a bit clumsy. E.g.</p> <pre><code>def my_split(string, split_char...
<pre><code>&gt;&gt;&gt; import re &gt;&gt;&gt; re.split('[ .]', 'a b.c') ['a', 'b', 'c'] </code></pre>
<p>Not very fast but does the job:</p> <pre><code>def my_split(text, seps): for sep in seps: text = text.replace(sep, seps[0]) return text.split(seps[0]) </code></pre>
48,844
<p>I am just learning php as I go along, and I'm completely lost here. I've never really used join before, and I think I need to here, but I don't know. I'm not expecting anyone to do it for me but if you could just point me in the right direction it would be amazing, I've tried reading up on joins but there are like...
<p>Updating board___forums whenever a post or a reply is inserted is - regarding performance - not the worst idea. For displaying the index page you only have to select data from one table board_forums - this is definitely much faster than selecting a second table to get the "last posts' information", even when using a...
<p>The simple solution will result in numerous queries, some optional, as you're already discovered.</p> <p>The classic approach to this is to cache the results, and only retrieve it once in a while. The cache doesn't have to live long; even two or three seconds on a busy site will make a significant difference.</p> ...
49,754
<p>As stated above, I am trying to solve a problem I've had for a long time. Unfortunately, this has recently intensified to the point where it causes layer splitting/detaching from each other. I have tried various ways to fix this and, while decreasing the temperature and extrusion multiplier improved the situation, t...
<p>I saw PETG printed at 100 mm/s, but 150! That's a lot.</p> <p>One solution to avoid blobs may be to limit the maximum speed to a value you can actually achieve with reliable results.</p> <p>Simple test to find your machine limits (each combination filament brand + nozzle + temperature has a different value): extru...
<p>Even not extruding anything but just performing travel moves over PETG at 100 mm/s or higher will <em>tear it up and drag material all over the place</em>. The result is blobs stuck to the nozzle, possibly even stringing, and choppy lines that the next layer will not properly adhere to. PETG simply cannot be printed...
1,673
<p>We have simple HTML form with <code>&lt;input type="file"&gt;</code>, like shown below:</p> <pre><code>&lt;form&gt; &lt;label for="attachment"&gt;Attachment:&lt;/label&gt; &lt;input type="file" name="attachment" id="attachment"&gt; &lt;input type="submit"&gt; &lt;/form&gt; </code></pre> <p>In IE7 (and probab...
<p>For preview in Firefox works this - attachment is object of attachment element in first example:</p> <pre><code> if (attachment.files) previewImage.src = attachment.files.item(0).getAsDataURL(); else previewImage.src = attachment.value; </code></pre>
<p>Simply you cannot do it with FF3.</p> <p>The other option could be using applet or other controls to select and upload files.</p>
10,675
<p>I have recently run into an issue where I wanted to add a folder to the directory structure of my project that would become the new 'root' directory for the previously housed files. I've been getting help in a <a href="https://stackoverflow.com/questions/87458/can-you-specify-filenames-using-wildcards-or-regexes-in...
<p>You can do it pretty easily if you use some GUI for SVN. Personally I love <a href="http://tortoisesvn.tigris.org/" rel="nofollow noreferrer">TortoiseSVN</a> for when I'm working in Windows. You just open up the "Repository Browser", right-click on some folder, and choose "Move...". Or, you have the option of doing ...
<p>Moves in subversion are done by removing the old files and adding the new ones, so there's nothing special to do. The series of 'svn mv' commands in a loop recommended in the other question should probably work just fine.</p>
11,321
<p>I'm looking for a tool which can generate a <a href="https://en.wikipedia.org/wiki/Make_(software)#Makefile" rel="nofollow noreferrer">Makefile</a> for a C/C++ project for different compilers (<a href="https://en.wikipedia.org/wiki/GNU_Compiler_Collection" rel="nofollow noreferrer">GCC</a>, <a href="https://en.wikip...
<p>Other suggestions you may want to consider:</p> <ul> <li><p><a href="http://www.scons.org/" rel="nofollow noreferrer">Scons</a> is a cross-platform, cross-compiler build library, uses Python scripting for the build systems. Used in a variety of large projects, and performs very well.</p> </li> <li><p>If you're using...
<p>One issue to consider is do you want a "makefile" creator or a replacement build system? The problem with replacement build systems is that you typically don't get good IDE integration for platforms whose users expect this (Visual C++). If you do want a makefile creator instead of a replacement build system, take a...
3,095
<p>Does anyone have a recommendation about web service security architecture in Java (preferably under JBoss)? Any recommended reading?</p> <p>I want to expose a fairly rich web service to the world but the data are sensitive and it requires authentication from the current client (Flex), accessed via RPC. I definite...
<p>For web services security in JBoss, I would start by reading <a href="http://jbossws.jboss.org/mediawiki/index.php?title=User_Guide#WS-Security" rel="nofollow noreferrer">8.4 WS-Security</a> of the <a href="http://jbossws.jboss.org/mediawiki/index.php?title=User_Guide" rel="nofollow noreferrer">JBossWS User Guide</a...
<p>WSSE is simple and works well.</p> <p><a href="http://www.xml.com/pub/a/2003/12/17/dive.html" rel="nofollow noreferrer">http://www.xml.com/pub/a/2003/12/17/dive.html</a></p> <p><a href="http://www.sixapart.com/developers/atom/protocol/atom_authentication.html" rel="nofollow noreferrer">http://www.sixapart.com/deve...
32,052
<p>I have a query that is dynamically built after looking up a field list and table name. I execute this dynamic query inside a stored proc. The query is built without a where clause when the two proc parameters are zero, and built with a where clause when not.</p> <p>When I execute the proc with SET FMTONLY ON...
<p>Perhaps it is related to the fact that the passed parameters are NULL, check how your query is build perhaps it behaves in different way then expected when you pass NULL. Does you proc returns expected results when you call: SET FMTONLY OFF exec [cpExportRecordType_ListByExportAgentID] null, null ?</p> <p>Othe...
<p>Perhaps it is related to the fact that the passed parameters are NULL, check how your query is build perhaps it behaves in different way then expected when you pass NULL. Does you proc returns expected results when you call: SET FMTONLY OFF exec [cpExportRecordType_ListByExportAgentID] null, null ?</p> <p>Othe...
9,780
<p>In evaluating different systems integration strategies, I've come across some words of encouragement, but also some words of frustration over BizTalk Server. </p> <p>What are some pros and cons to using BizTalk Server (both from a developer standpoint and a business user), and should companies also consider open so...
<p>My experience with BizTalk was basically a frustrating waste of time.</p> <p>There are so many edge cases and weird little business logic tweaks you have to make when you are doing B2B data integration (which is probably the hardest part of any enterprise application) that you just need to roll your own solution.</...
<p>I have no direct experience with JitterBit, but I have heard very good things from coworkers.</p>
8,666
<p>There are some good examples on how to calculate word frequencies in C#, but none of them are comprehensive and I really need one in VB.NET.</p> <p>My current approach is limited to one word per frequency count. What is the best way to change this so that I can get a completely accurate word frequency listing?</p> ...
<pre><code>Public Class CountWords Public Function WordCount(ByVal str As String) As Dictionary(Of String, Integer) Dim ret As Dictionary(Of String, Integer) = New Dictionary(Of String, Integer) Dim word As String = "" Dim add As Boolean = True Dim ch As Char str = str.ToL...
<p>This might be helpful:</p> <p><a href="https://stackoverflow.com/questions/90580/word-frequency-algorithm-for-natural-language-processing">Word frequency algorithm for natural language processing</a></p>
27,739
<p>How do YOU reduce compile time, and linking time for VC++ projects (native C++)?</p> <p>Please specify if each suggestion applies to debug, release, or both.</p>
<p>It may sound obvious to you, but we try to use forward declarations as much as possible, even if it requires to write out long namespace names the type(s) is/are in:</p> <pre><code>// Forward declaration stuff namespace plotter { namespace logic { class Plotter; } } // Real stuff namespace plotter { namespace ...
<p><strong>Compile Time:</strong><br> If you have IncrediBuild, compile time won't be a problem. If you don't have a IncrediBuild, try the "unity build" method. It combine multiple cpp files to a single cpp file so the whole compile time is reduced. <br> <strong>Link Time:</strong><br> The "unity build" method also con...
47,553
<p>How do I iterate over the words of a string composed of words separated by whitespace?</p> <p>Note that I'm not interested in C string functions or that kind of character manipulation/access. I prefer elegance over efficiency. My current solution:</p> <pre><code>#include &lt;iostream&gt; #include &lt;sstream&gt; #in...
<p>For what it's worth, here's another way to extract tokens from an input string, relying only on standard library facilities. It's an example of the power and elegance behind the design of the STL.</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;sstream&gt; #include &lt;algorithm&gt; #i...
<p>For a ridiculously large and probably redundant version, try a lot of for loops.</p> <pre><code>string stringlist[10]; int count = 0; for (int i = 0; i &lt; sequence.length(); i++) { if (sequence[i] == ' ') { stringlist[count] = sequence.substr(0, i); sequence.erase(0, i+1); i = 0; ...
29,219
<p>I have a WinForms application (I'm using VB) that can be minimized to the system tray. I used the "hackish" methods described in multiple posts utilizing a NotifyIcon and playing with the Form_Resize event. </p> <p>This all works fine aesthetically, but the resources and memory used are unaffected. I want to be abl...
<p>Calling MiniMizeMemory() will do a garbage collection, trim the process working size, then compact the process' heap.</p> <pre><code>public static void MinimizeMemory() { GC.Collect(GC.MaxGeneration); GC.WaitForPendingFinalizers(); SetProcessWorkingSetSize( Process.GetCurrentProcess().Handle, ...
<p>While this is in C#, look at the source code, it will solve any issues you have:</p> <p><a href="http://www.codeproject.com/KB/cs/NotifyIconExample.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/cs/NotifyIconExample.aspx</a></p>
32,952
<p>I am trying to do this...</p> <pre><code>&lt;Image x:Name="imgGroupImage" Source="Images\unlock.png" Margin="0,0,5,0" /&gt; </code></pre> <p>But I get this error...</p> <blockquote> <p>Cannot convert string 'Images\unlock.png' in attribute 'Source' to object of type 'System.Windows.Media.ImageSource'. Cannot lo...
<p>Try slashes rather than backslashes, and use an absolute path by leading with a slash:</p> <pre><code>Source="/Images/unlock.png" </code></pre> <p>That generally works for me.</p> <p>Failing that, take a look at <a href="http://msdn.microsoft.com/en-us/library/aa970069.aspx" rel="noreferrer">Pack URIs</a>.</p>
<p>Have you tried setting the source to a <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapimage.aspx" rel="nofollow noreferrer">BitmapImage</a>?</p> <pre><code>&lt;Image x:Name="imgGroupImage" Margin="0,0,5,0" &gt; &lt;Image.Source&gt; &lt;BitmapImage UriSource="Images/unl...
35,229
<p>I've recently started developing applications for the Blackberry. Consequently, I've had to jump to Java-ME and learn that and its associated tools. The syntax is easy, but I keep having issues with various gotchas and the environment. </p> <p>For instance, something that surprised me and wasted a lot of time is...
<p>This <a href="http://crfdesign.net/programming/top-10-differences-between-java-and-c" rel="noreferrer">guy here</a> had to make the inverse transition. So he listed the top 10 differences of Java and C#. I'll take his topics and show how it is made in Java:</p> <h2>Gotcha #10 - Give me my standard output!</h2> <p>...
<p>The short answer is - it's going to be annoying, but not difficult.</p> <p>Java and C# have all the same underlying concepts, and a lot of the libraries are very close in style, but you're going to keep bumping your head across various differences.</p> <p>If you're talking about class properties, Java has those. T...
11,592
<p>On a web page that is to be displayed on an iPhone, is there a way to get the number pad to come up when the user taps in the field, instead of the qwerty keypad? </p> <p><a href="http://www.bennadel.com/blog/1197-Defaulting-To-The-Numeric-Keyboard-On-The-iPhone.htm" rel="nofollow noreferrer">This guy says here's h...
<p>If you use the HTML5 <code>number</code> input type, the keyboard will default to showing numbers. It's not the number-only keyboard, but it's a bit better than just <code>text</code>.</p>
<p>You can make calls from JavaScript to Objective-C and then display what ever you want. If you want a framework to help you out you could check out QuickConnectiPhone. It is available at <a href="https://sourceforge.net/projects/quickconnect/" rel="nofollow noreferrer">https://sourceforge.net/projects/quickconnect/...
35,320
<p>It seems like v2 of Log4j has been in development for literally years. The <a href="http://logging.apache.org/" rel="noreferrer">Apache Log4J site</a> no longer lists a roadmap, the dev mailing list seems almost entirely about 1.2 (which is appreciated!), use of v1.3 is discouraged, and the 2.0 branch is listed as ...
<p>Log4j development has for all practical purposed stalled. Consider switching to logback, log4j's successor. Logback is conceptually similar to log4j and if you like log4j, you should like logback even better. It has many nice features and is well-documented.</p> <p>Disclosure: I am the founder of both log4j and log...
<p>Well then I guess you already answered your own question, the devs have obviously stopped focusing on 2.0 builds a long time ago and have instead decided to continue the 1.x codebase.</p> <p>And if you are on their mailing list, then ask them, the source of the issue.</p>
37,065
<p>I have a Robo 3D. However A while ago, the print bed was fractured, and now it has a long crack cutting it in half. The bed still works because it is held together, by the screws holding the bed to the tracks. So I want to continue using it, because it still is fairly good, the heating element works fine, and a repl...
<p>A little chip is fine, but I wouldn't print with that big of a crack. <strong>However</strong>, that doesn't mean you need to spend $80 on a new sheet of glass.</p> <p>Option #1- If you want borosilicate glass, you can get a sheet from either McMaster (about $40+shipping for a 10"x10" piece, less for smaller) or fr...
<p>If your heatbed itself is aluminum/copper/other metal: Get a glass cut and replace it. The current one is probably attached to the heatbed with adhesive glue. If it the adhesive is cyanocrylate based, you can remove by rubbing with acetone. If silicone type, it will come off by some force. Don't worry, you won't dam...
178
<p>I'm starting a new job and am inheriting a asp .net web application on the 2.0 .net framework. The application works alright. It published successfully from vs 2005. I created a new virtual directory in IIS and pointed to the precompiled directory just published.</p> <p>When I load my application, I get an error th...
<p><em>sigh</em></p> <p>Okay found the answer. Ironically it too was on stack overflow. Here it is:</p> <p><a href="https://stackoverflow.com/questions/233478/aspnet-20-application-on-iis-5-resulting-in-error-aspnetwpexe-pid-xxxx-stopped">ASP.NET 2.0 Application on IIS 5 Resulting in Error (aspnet_wp.exe (PID: XXXX) ...
<p>You may also need to install Microsoft WSE extensions.</p> <p>Something like this: <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=018a09fd-3a74-43c5-8ec1-8d789091255d&amp;displaylang=en" rel="nofollow noreferrer">http://www.microsoft.com/downloads/details.aspx?FamilyID=018a09fd-3a74-43c5-8ec1-8d7...
33,301
<p>I have an app that needs to open a new window (in the same domain) so the user can view a report, but on some browsers* the new window doesn't share the non-persistent cookie of the original window, which causes the user to have to sign in again. Is there anything I can do to stop the user having to sign in again in...
<p>I thought IE7 shared non-persistent cookies with tabs in the same window, as well as windows that were generated from the current window (whether or not this is the same for manual opens like File->New, or programmatic script opens, I'm not sure), but that fresh instances did not.</p> <p>Firefox shares them across ...
<p>They <em>should</em> share cookies. That has been my experience in the past. I'll edit once I've had a play.</p>
15,792
<p>How would you program a C/C++ application that could run without opening a window or console? </p>
<p>When you write a WinMain program, you automatically get the /SUBSYSTEM option to be windows in the compiler. (Assuming you use Visual Studio). For any other compiler a similar option might be present but the flag name might be different. </p> <p>This causes the compiler to create an entry in the executable file for...
<p>If you are using <strong>MSVC</strong> or <strong>Visual Studio</strong> just use the new <strong>Project Wizard</strong> and select the <strong>Console Application</strong>.</p>
27,697
<p>Are all the additions to C# for version 4 (dynamic, code contracts etc) expected to run on the current .NET CLR, or is there a planned .NET upgrade as well?</p>
<p>C# 4 will require the .NET 4.0 CLR. </p>
<p>You don't have to wait for 4.0 to use Code Contracts as it runs on .NET 3.5, the download link for the academic preview release is <a href="http://research.microsoft.com/contracts/#downloads" rel="nofollow noreferrer">here</a>.</p>
43,608
<p>Given an aggregation of class instances which refer to each other in a complex, circular, fashion: is it possible that the garbage collector may not be able to free these objects?</p> <p>I vaguely recall this being an issue in the JVM in the past, but I <em>thought</em> this was resolved years ago. yet, some inves...
<p>Only a very naive implementation would have a problem with circular references. Wikipedia has a good <a href="http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)" rel="noreferrer">article</a> on the different GC algorithms. If you really want to learn more, try (Amazon) <a href="https://rads.stackover...
<p>The garbage collector is a very sophisticated piece of software -- it has been tested in a huge JCK test-suite. It is NOT perfect BUT there is a very good chance that as long as the java compiler(javac) will compile all of your classes and JVM will instantiate it, then you should be good.</p> <p>Then again, if you ...
21,286
<p>When I am creating a test project in Visual Studio, do I just create a C# console project type, then import Nunit?</p> <p>Does the GUI then hook into this project somehow?</p> <p>There seems to be tons of nunit related .dll's, which ones do I need?</p>
<p>Just create a class library (i.e. a DLL). You only need to import nunit.framework.dll.</p> <p>Yes, the nUnit GUI loads your assembly (which can be a DLL or a .EXE) and finds all the <strong>public</strong> classes which have been marked with the appropriate attributes.</p>
<p>I'd recommend checking out the TestDriven.Net Visual Studio plugin. It allows you to run your tests right from VS, so there's no need to fire up the NUnit GUI.</p> <p><a href="http://www.testdriven.net/" rel="nofollow noreferrer">http://www.testdriven.net/</a></p>
44,419
<p>When displaying the value of a decimal currently with <code>.ToString()</code>, it's accurate to like 15 decimal places, and since I'm using it to represent dollars and cents, I only want the output to be 2 decimal places. </p> <p>Do I use a variation of <code>.ToString()</code> for this?</p>
<pre><code>decimalVar.ToString(&quot;#.##&quot;); // returns &quot;.5&quot; when decimalVar == 0.5m </code></pre> <p>or</p> <pre><code>decimalVar.ToString(&quot;0.##&quot;); // returns &quot;0.5&quot; when decimalVar == 0.5m </code></pre> <p>or</p> <pre><code>decimalVar.ToString(&quot;0.00&quot;); // returns &quot;0.5...
<pre><code> var arr = new List&lt;int&gt;() { -4, 3, -9, 0, 4, 1 }; decimal result1 = arr.Where(p =&gt; p &gt; 0).Count(); var responseResult1 = result1 / arr.Count(); decimal result2 = arr.Where(p =&gt; p &lt; 0).Count(); var responseResult2 = result2 / arr.Count(); decim...
19,934
<p>Has anyone got <a href="http://perldoc.perl.org/Sys/Syslog.html" rel="nofollow noreferrer">Sys::Syslog</a> to work on Solaris? (I'm running Sys::Syslog 0.05 on Perl v5.8.4 on SunOS 5.10 on SPARC). Here's what doesn't work for me:</p> <pre><code>openlog "myprog", "pid", "user" or die; syslog "crit", "%s", "Test fr...
<p>By default, Sys::Syslog is going to try to connect with one of the following socket types:</p> <pre><code>[ 'tcp', 'udp', 'unix', 'stream' ] </code></pre> <p>On Solaris, though, you'll need to use an inet socket. Call:</p> <pre><code>setlogsock('inet', $hostname); </code></pre> <p>and things should start workin...
<p>setlogsock('inet') didn't do it for me (it looks for host "syslog") but building and installing Sys::Syslog from CPAN did. The Sys::Syslog that comes with Solaris 10 is ancient.</p>
9,331
<p>Is there anyway to automatically run <code>javascript:window.print()</code> when the page finishes loading? </p>
<p><code>&lt;body onload="window.print()"&gt;</code> or <code>window.onload = function() { window.print(); }</code></p>
<p>For me, adding <code>&lt;script&gt;window.print();&lt;/script&gt;</code> to the end of the page worked.</p> <hr> <p>I didn't need the <code>type="text/javascript"</code> attribute, or even for the page to be wrapped in a <code>&lt;body&gt;</code> tag. However, all of my previous attempts to intuitively use the ans...
29,902
<p>I'm trying to create an OS X Service. I found <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/SysServices/Tasks/providing.html#//apple_ref/doc/uid/20000853" rel="nofollow noreferrer">Providing System Services</a> in Apple's documentation, however I'm finding it less than clear on what exactly I ne...
<p>Make sure your NSServices dictionary has everything it needs. If you're not sure, please post it so we can tell you.</p>
<p>You might want to look at some commercial products to help you with this. See this posting on <a href="http://pmougin.wordpress.com/2008/01/28/become-a-mac-os-x-services-ninja/" rel="nofollow noreferrer">Fun Script</a>.</p>
33,528
<p>I have an application in C# (2.0 running on XP embedded) that is communicating with a 'watchdog' that is implemented as a Windows Service. When the device boots, this service typically takes some time to start. I'd like to check, from my code, if the service is running. How can I accomplish this?</p>
<p>I guess something like this would work:</p> <p>Add <code>System.ServiceProcess</code> to your project references (It's on the .NET tab).</p> <pre><code>using System.ServiceProcess; ServiceController sc = new ServiceController(SERVICENAME); switch (sc.Status) { case ServiceControllerStatus.Running: re...
<p>Here you get all available services and their status in your local machine. </p> <pre><code>ServiceController[] services = ServiceController.GetServices(); foreach(ServiceController service in services) { Console.WriteLine(service.ServiceName+"=="+ service.Status); } </code></pre> <p>You can Compare your...
21,464
<p>I am running GNU Emacs on Windows so entering:</p> <pre><code>M-x shell </code></pre> <p>launches the Windows command-line DOS shell. However, I would like to instead be able to run the Cygwin Bash Shell (or any other non-Windows shell) from within Emacs. How can this be easily done?</p>
<p><code>shell-file-name</code> is the variable that controls which shell Emacs uses when it wants to run a shell command.</p> <p><code>explicit-shell-file-name</code> is the variable that controls which shell <code>M-x shell</code> starts up.</p> <p><a href="https://stackoverflow.com/questions/235254/how-can-i-run-c...
<p>In addition to @Chris Jones' answer about avoiding the --login argument to bash, I set the following command line arguments:</p> <pre><code> (setq explicit-bash-args '("--noediting" "-i")) </code></pre> <p>The --noediting option prevents interference with the GNU readline library and the -i option specifies that t...
29,118
<p>Is there a way to know which file is being selected in windows explorer? I've been looking at the tutorial posted here <a href="https://stackoverflow.com/questions/140312/tutorial-for-windows-shell-extensions">Idiots guide to ...</a> but the actions described are:</p> <p>hover</p> <p>context </p> <p>menu properti...
<p>I Found the Answer</p> <p>Ok, not sure if it is kewl answering my own question, but here we go. For some reason the enumeration needed to be marked with the [EnumMember] Attributes as below:</p> <pre><code>[DataContract] public enum Priority { [EnumMember] Low, [EnumMember] Medium, [EnumMember...
<p>Someone on this thread posted that adding this element to the endpoint behavior fixed the issue.</p> <pre><code>&lt;dataContractSerializer maxItemsInObjectGraph="2147483647" /&gt; </code></pre> <p>This worked but it had to be added not only to the endpoint behavior but the service behavior too (which makes sense s...
28,728
<p>How do I connect to the database(MYSQL) in connection bean using JSF to retrieve its contents. Also please let me know how do I configure the web.xml file?</p>
<p>To get connected to mysql: </p> <pre><code>public void open() { try { String databaseName = "custom"; String userName = "root"; String password = "welcome"; // String url = "jdbc:mysql://localhost/" + databaseName; Class.forName("com...
<p>Here is an <a href="http://blog.exadel.com/?p=8" rel="nofollow noreferrer">example using Hibernate and HSQL</a> - but the basic ideas of separating the db stuff out should be valid and it includes a configured web.xml.</p>
41,376
<p>Is there an easy way to move around controls on a form exactly the same way as the tab key? This includes moving around cells on a datagridview etc.</p>
<p>using winforms you should set the Form KeyPreview property to true</p> <p>and in the keypress event for the form you should have </p> <pre><code>private void Form1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) GetNextControl(ActiveControl, true).Focus(); } </code></pre>
<pre><code>protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { Keys keyPressed = (Keys)msg.WParam.ToInt32(); switch (keyPressed) { case Keys.Enter: case Keys.Tab: Control ctrl = this.GetNextControl(this.ActiveControl, true); while (ctrl is TextBox == false) { ...
45,338
<p>Is there a way to get the path for the assembly in which the current code resides? I do not want the path of the calling assembly, just the one containing the code. </p> <p>Basically my unit test needs to read some xml test files which are located relative to the dll. I want the path to always resolve correctly ...
<p><strong>Note</strong>: Assembly.CodeBase is deprecated in .NET Core/.NET 5+: <a href="https://learn.microsoft.com/en-us/dotnet/api/system.reflection.assembly.codebase?view=net-5.0" rel="noreferrer">https://learn.microsoft.com/en-us/dotnet/api/system.reflection.assembly.codebase?view=net-5.0</a></p> <p><strong>Origin...
<p>I use this to get the path to the Bin Directory:</p> <pre><code>var i = Environment.CurrentDirectory.LastIndexOf(@"\"); var path = Environment.CurrentDirectory.Substring(0,i); </code></pre> <p>You get this result:</p> <blockquote> <p>"c:\users\ricooley\documents\visual studio 2010\Projects\Windows_Test_Proje...
7,611
<p>I am looking for a relatively good and well supported, and preferably open source blog application that runs on <a href="http://en.wikipedia.org/wiki/ASP.NET" rel="nofollow noreferrer">ASP.NET</a> and <a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server" rel="nofollow noreferrer">SQL&nbsp;Server</a>. It doesn’...
<p>I used <a href="http://www.dotnetblogengine.net/" rel="nofollow noreferrer">BlogEngine.NET</a> for one of <a href="http://blog.atomium.be/" rel="nofollow noreferrer">my clients</a>, can definitely recommend it.</p>
<p>There are two I know of: BlogEngine.NET and DasBlog</p> <p>I'm using BlogEngine.NET. It is very easy to extend as it uses the providers for membership and such. It can be configured to run on SQL&nbsp;Server, but by default it will run using XML.</p> <p>DasBlog should also be a great blog engine, although I have n...
18,309
<p>I'm trying to get the following bit of code to work in LINQPad but am unable to index into a var. Anybody know how to index into a var in LINQ?</p> <pre><code>string[] sa = {"one", "two", "three"}; sa[1].Dump(); var va = sa.Select( (a,i) =&gt; new {Line = a, Index = i}); va[1].Dump(); // Cannot apply indexing with...
<p>As the comment says, you cannot apply indexing with <code>[]</code> to an expression of type <code>System.Collections.Generic.IEnumerable&lt;T&gt;</code>. The IEnumerable interface only supports the method <code>GetEnumerator()</code>. However with LINQ you can call the extension method <code>ElementAt(int)</code>.<...
<p>You can't apply an index to a var unless it's an indexable type:</p> <pre><code>//works because under the hood the C# compiler has converted var to string[] var arrayVar = {"one", "two", "three"}; arrayVar[1].Dump(); //now let's try var selectVar = arrayVar.Select( (a,i) =&gt; new { Line = a }); //or this (I find...
6,678
<p>We're using Prototype for all of our Ajax request handling and to keep things simple we simple render HTML content which is then assigned to the appropriate div using the following function:</p> <pre><code>function ajaxModify(controller, parameters, div_id) { var div = $(div_id); var request = new Ajax.Req...
<p>The parameter is:</p> <pre><code>evalScripts:true </code></pre> <p>Note that you should be using <strong>Ajax.Updater</strong>, not <strong>Ajax.Request</strong></p> <p>See: <a href="http://www.prototypejs.org/api/ajax/updater" rel="noreferrer">http://www.prototypejs.org/api/ajax/updater</a></p> <p>Ajax.Request ...
<p>you need to use eval() function to run the javascript in Ajax repose this can be use full to separate the script and run it </p> <pre> function PaseAjaxResponse(somemixedcode) { var source = somemixedcode; var scripts = new Array(); while(source.indexOf(&quot;&lt;script&quot;) &gt; -1 || source.index...
35,115
<p>I know Windows has SMTP capabilities under IIS, but I thought a basic SMTP would be a good project for learning Windows application development. I don't want a relay. I want an actual SMTP server that will send email from localhost anonymously. Obviously, it is only to be used for routing emails sent during a develo...
<p>You'll need to understand the SMTP protocol (or at least a reasonable subset of it). If you're familiar with C++, you could grab the source code for <a href="http://sourceforge.net/projects/blat" rel="nofollow noreferrer">Blat</a> to get an idea of how to create a simple mailing system.</p>
<p>You should read a book on networking protocols. If you want to do this from scratch, you need to keep an outgoing mail queue, you need to parse email addresses to find their hostnames, look up the DNS MX records of those domains, contact the server on port 25 and then talk SMTP.</p>
39,290
<p>I have used the XML Parser before, and even though it worked OK, I wasn't happy with it in general, it felt like I was using workarounds for things that should be basic functionality.</p> <p>I recently saw SimpleXML but I haven't tried it yet. Is it any simpler? What advantages and disadvantages do both have? Any o...
<p>I would have to say <a href="http://php.net/manual/simplexml.examples.php" rel="noreferrer">SimpleXML</a> takes the cake because it is firstly an extension, written in C, and is very fast. But second, the parsed document takes the form of a PHP object. So you can "query" like <code>$root-&gt;myElement</code>.</p>
<p>the crxml parser is a real easy to parser.</p> <p>This class has got a search function, which takes a node name with any namespace as an argument. It searches the xml for the node and prints out the access statement to access that node using this class. This class also makes xml generation very easy.</p> <p>you ca...
22,844
<p>I know most of the ins and outs of Python's approach to private variables/members/functions/...</p> <p>However, I can't make my mind up on how to distinguish between methods for external use or subclassing use.</p> <p>Consider the following example:</p> <pre><code>class EventMixin(object): def subscribe(self,...
<pre><code>use no underscores for the external API, one underscore for the subclassable API, and two underscores for the private/internal API </code></pre> <p>This is a reasonable and relatively common way of doing it, yes. The double-underline-for-actually-private (as opposed to ‘protected’ in C++ terms) is in practi...
<pre><code>use no underscores for the external API, one underscore for the subclassable API, and two underscores for the private/internal API </code></pre> <p>This is a reasonable and relatively common way of doing it, yes. The double-underline-for-actually-private (as opposed to ‘protected’ in C++ terms) is in practi...
29,251
<p>I know this is possible via a simple registry change to accomplish this as long as IE/firefox is being used. However, I am wondering if there is a reliable way to do so for other browsers,</p> <p>I am specifically looking for a way to do this via an installer, so editing a preference inside a specific browser wil...
<p>Here is the best I can come up with:</p> <p><strong>IE</strong>: <a href="http://msdn.microsoft.com/en-us/library/aa767914(VS.85).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/aa767914(VS.85).aspx</a></p> <p><strong>FireFox</strong>: <a href="http://kb.mozillazine.org/Register_protocol" rel="noref...
<p>Yes. Here is how to do it with FireFox:</p> <p><a href="http://kb.mozillazine.org/Register_protocol" rel="nofollow noreferrer">http://kb.mozillazine.org/Register_protocol</a></p> <p>and Opera:</p> <p><a href="http://www.opera.com/support/kb/view/535/" rel="nofollow noreferrer">http://www.opera.com/support/kb/view...
47,631
<p>I'm writing some mail-processing software in Python that is encountering strange bytes in header fields. I suspect this is just malformed mail; the message itself claims to be us-ascii, so I don't think there is a true encoding, but I'd like to get out a unicode string approximating the original one without throwin...
<p>+1 for the <a href="http://web.archive.org/web/20110709171259/http://chardet.feedparser.org/docs/faq.html" rel="noreferrer">chardet</a> module (suggested by <a href="https://stackoverflow.com/questions/269060/is-there-a-python-library-function-which-attempts-to-guess-the-character-encoding/269105#269105"><code>@insi...
<p>The best way to do this that I've found is to iteratively try decoding a prospective with each of the most common encodings inside of a try except block.</p>
33,784
<p>I am having trouble creating a mapping when the List type is an interface. It looks like I need to create an abstract class and use the discriminator column is this the case? I would rather not have to as the abstract class will just contain an abstract method and I would rather just keep the interface.</p> <p>I ha...
<p>I think that it is possible to to make an interface the supertype of a mapping. You may not be able to use annotations though. Annotations play well with xml config files so you might have to add a hibernate config file to your project with the mappings that you need. But you will be able to keep the annotations for...
<p>You can also introduce an abstract class without removing the interface.</p> <pre><code>// not an entity public interface Account { public void doStuff(); } @Entity public abstract class BaseAccount { public void doStuff(); } @Entity public class OverSeasAccount extends AbstractAccount { public void ...
35,619
<p>Is there a USB HID pen driver in Windows Vista? If so, what are the requirements for USB descriptors, in order to make Windows Vista recognize the pen and load the pen driver?</p> <p>What I'm searching for is the pen equivalent to the HID mouse driver, HID keyboard driver and mass storage driver. The mentioned exa...
<p>I checked out the C++ standard. In section 9.2, paragraph (or clause or whatever) 12, it says "The order of allocation of nonstatic data members separated by an access-specifier is unspecified." "Unspecified" means implementation-dependent behavior that need not be documented.</p> <p>Therefore, the standard is ex...
<p>The way I interpret the standard, it sees the code example as follows: since there is no access specifier between i and j, the address of i must come before the address of j. The proposed ordering satisfies this. Idem for k and n. So in my interpretation, compilers <em>are</em> allowed to use this ordering.</p>
36,882
<ul> <li>I start up my application which uses a Jetty server, using port 9000.</li> <li>I then shut down my application with Ctrl-C</li> <li>I check with "netstat -a" and see that the port 9000 is no longer being used.</li> <li>I restart my application and get:</li> </ul> <blockquote> <pre><code>[ERROR,9/19 15:31:08] ...
<p>During your first invocation of your program, did it accept at least one incoming connection? If so then what you are most likely seeing is the socket linger in effect. </p> <p>For the best explanation dig up a copy of TCP/IP Illustrated by Stevens </p> <p><a href="https://i.stack.imgur.com/DNDVu.gif" rel="nofollo...
<p>I'm not sure about Jetty, but I have noticed that sometimes Tomcat will not shut down cleanly on some of our Linux servers. In cases like that, Tomcat will restart but not be able to use the port in question because the previous instance is still bound to it. In such cases, we have to find the rogue process and ex...
12,739
<p>I'm trying to programmatically restrict the memory consumption of plugins running in a .Net AppDomain, but I can't find any setup parameters for this, nor can I find a way to query an AppDomain to figure out how much memory it is consuming. Any ideas?</p>
<p>Old question, but in the meantime (since .Net framework 4.0) a new solution is available. You will have to enable ARM (Application domain Resource Monitoring). From that point on, you can request information on total consumed processor time, memory usage etc.</p> <p><a href="https://msdn.microsoft.com/en-us/library...
<p>Using the mscoree.CorRuntimeHostClass interop from C:\WINDOWS\Microsoft.NET\Framework\vXXXXXX\mscoree.tlb</p>
4,566
<p>Is there in Ruby some functionality/syntax to compare two floats with delta? Something similar to <em>assert_in_delta(expected_float, actual_float, delta)</em> from <em>test/unit</em> but returning Boolean?</p>
<pre><code>(expected_float - actual_float).abs &lt;= delta </code></pre>
<p>you may also need a relative tolerance / delta calculation</p> <p><a href="http://realtimecollisiondetection.net/blog/?p=89" rel="nofollow noreferrer">http://realtimecollisiondetection.net/blog/?p=89</a></p>
29,607
<p>I'm trying to figure out if it's worth buying a 3D printer or using an online printing service like e.g. <a href="https://treddy.it" rel="nofollow noreferrer">this one</a> in the long run. Anyone have any cost analysis?</p>
<h1>It depends</h1> <p>If it is worth to invest in a print made for you compared to getting a printer depends on the needs you have. Thee can be informed by the type of material you want to print and the requirements that has on you. Let me give you some examples when it is simply worth it to pay:</p> <ul> <li>A metal ...
<p>I would think it depends on your future needs. If you will rarely need things printed then online is more convenient than buying a printer and doing the whole learning curve, storing materials etc,.</p> <p>From what I have seen online, most people printing are not printing things they actually need.</p> <p>If you wa...
2,131
<p>What is the cheap and good way to make a serial (RS232) programmer for AVR atMega and atTiny? There are several circuits in the Internet, but which one is better?</p> <p>I'd like to be able to program my controller from Linux and Windows using some standard tools.</p>
<p>Try the <a href="http://www.adafruit.com/index.php?main_page=product_info&amp;cPath=16&amp;products_id=26" rel="nofollow noreferrer">Serial port AVR programmer (DASA) Kit</a> from Adafruit Industries. It's only $7.50, is very popular with the <a href="http://www.arduino.cc/en/Guide/Introduction" rel="nofollow norefe...
<p>If usb can be used, I really don't think the original programmer (<a href="http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3808" rel="nofollow noreferrer">AVR ISP mkII</a>) is that expensive, the pricing today was about 34$.</p>
15,986
<p>I sometimes use the feature 'Reconcile Offline Work...' found in Perforce's P4V IDE to sync up any files that I have been working on while disconnected from the P4 depot. It launches another window that performs a 'Folder Diff'.</p> <p>I have files I never want to check in to source control (like ones found in bin ...
<p>As of version 2012.1, Perforce supports the <code>P4IGNORE</code> environment variable. I updated my answer to <a href="https://stackoverflow.com/a/3103898/4228">this question about ignoring directories</a> with an explanation of how it works. Then I noticed this answer, which is now superfluous I guess.</p> <hr> ...
<p>If you are using the Eclipse Perforce plugin, then <a href="http://perforce.com/perforce/doc.091/manuals/p4wsad/topics/adding.html" rel="nofollow noreferrer">the plugin documentation</a> lists several ways to ignore files.</p>
7,923
<p>Given the constraint of only using T-Sql in Sql Server 2005, is there a better way to remove the decimal point from a money datatype than a conversion to a varchar (here implicitly) and then a replace of the decimal point?</p> <p>Here is what I have currently.</p> <pre><code>SELECT REPLACE(1.23, '.', ''), REPLACE(...
<p>Multiply by 100 and then convert to an int.</p>
<p>Could you be a little more specific about the use case? Removing the decimal point from the representation is a little unusual given that you'll lose all information about the scale. Are you assuming that there will always be two digits? If so, you could simplify multiply by 100 and then round before converting t...
2,594
<p>I would like to add a BuildListener to my headless build process, which is building an Eclipse product. The docs on how to do this are, shall we say, a bit scanty. I think I need to put my custom jar in a plugin and then use the org.eclipse.ant.core.extraClasspathEntries extension point to make that jar visible to A...
<p>I had this problem when I had two plugins providing an <code>ant.jar</code>.</p> <p>Make sure you use the <code>org.apache.ant</code> plugin and that there is no other plugin providing another <code>ant.jar</code>.</p> <p>Another thing I just stumbled upon: The jar containing your contribution must not be in the p...
<p>Follow the instructions as for working with contributed tasks and types found here: <a href="http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/ant_developing.htm" rel="nofollow noreferrer">Developing Ant tasks</a> and <a href="http://help.eclipse.org/ganymede/index.jsp?topic=/org.e...
22,130
<p>a question that a co-interviewer asked in interviews. I always thought it was a silly question. </p> <p>Assume single processor and not dual core.</p>
<p>Yes you can if DMA is not available. In that case you could end up using the CPU to move data around from I/O to I/O through central memory, if the I/O bandwidth on both devices is high enough you will effectively saturate the CPU. </p>
<p>I'd also look for places where IO devices are virtualized and encrypted. This is probably an unusual case, but not an impossible case.</p>
48,305
<p>My LCD rotates. The software that comes with my ATI card to rotate the desktop just crashes (<em>I've uninstalled, reinstalled and rolled them back, still crashes</em>). Is there any other way to rotate a Windows XP Desktop by 90 degree increments? I am looking for either software or code (any language is fine.) ...
<p>IRotate: <a href="http://www.entechtaiwan.net/util/irotate.shtm" rel="nofollow noreferrer">http://www.entechtaiwan.net/util/irotate.shtm</a>.<br> Have not used it but heard good things.</p> <p>Same people that make Powerstrip <a href="http://www.entechtaiwan.net/util/ps.shtm" rel="nofollow noreferrer">http://www.en...
<p>I hate to give you the answer you probably already know, but yeah this is a video card driver software thing and if the ATI software crashes then it's either corrupted or buggy or your Windows install has gone rotten.</p> <p>I've done this before on my NVidia-based cards without issue. I've never owned an ATI card....
6,917
<p>Is it possible to create a .NET equivalent to the following code?</p> <pre><code>&lt;?php if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'Text to send if user hits Cancel button'; exit; } else { echo "&lt;p&g...
<p>The easiest way to achieve the same as with the PHP code would be to directly send the same headers via <a href="http://msdn.microsoft.com/en-us/library/system.web.httpresponse.appendheader(VS.80).aspx" rel="nofollow noreferrer">Reponse.AppendHeader()</a>.</p> <p>Still I would suggest you to read an <a href="http:/...
<p>Yes, you can add to web.config and use forms authentication. I dont know php, so i cant help witjh the rest of your question</p> <p><a href="http://msdn.microsoft.com/en-us/library/aa720092(VS.71).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa720092(VS.71).aspx</a>\</p>
17,999
<p>I have recently started exploring Maven, but I feel a bit overwhelmed of all xml configuration in all the pom files. Are there any good tools i can use?</p>
<p><a href="http://m2eclipse.codehaus.org/" rel="noreferrer">m2eclipse</a>, it provides a very nice form-based editor. But I only use the XML view most of the time. </p>
<p>I don't. I use <a href="http://incubator.apache.org/buildr/" rel="nofollow noreferrer">buildr</a>, which has a lot more compact ruby based syntax to describe your project.</p>
41,702
<p>I've been using various javascript frameworks including mootools, jquery, prototype and scriptaculous and have found them all good, but difficult to extend to more complex ideas.</p> <p>If I am going to knuckle down and learn one, which is the simplest to extend and use whilst staying powerful enough to use in a va...
<p>I propose jQuery.</p> <p>I'll give you some of the major arguments from the presentation that my team put on yesterday for senior management to convince them of that.</p> <p>Reasons:</p> <ol> <li><p>Community acceptance. Look at <a href="http://google.com/trends?q=jquery%2C+prototype%2C+yui%2C+scriptaculous+&amp;...
<p>Another vote for jQuery. It's small, focussed, and yet very powerful. It's also reasonable well documented, by the (generally awful) standards of JS libraries.</p> <p>It's also very easy to extend, once you get your head around the syntax.</p>
16,901
<p>The question is a fairly open one. I've been using Stored Procs with MS SQLServer for some time with classic ASP and ASP.net and love them, lots.</p> <p>I have a small hobby project I'm working on and for various reasons have gone the LAMP route. Any hints/tricks/traps or good starting points to get into using stor...
<p>Forget about <code>mysqli</code>, it's much harder to use than PDO and should have been already removed. It is true that it introduced huge improvements over mysql, but to achieve the same effect in mysqli sometimes requires enormous effort over PDO i.e. associative <code>fetchAll</code>.</p> <p>Instead, take a loo...
<p>I have been using ADODB, which is a great thing for abstracting actual commands to make it portable between different SQL Servers (ie mysql to mssql). However, Stored procedures do not appear to be directly supported. What this means, is that I have run a SQL query as if it is a normal one, but to "call" the SP. A...
14,424
<p>The backstory: I'm installing a pigeon net in my home. Because of the shape of the opening I'm installing the net in and the material on the sides it's difficult to anchor the net using the normal means but I can print clips that will hold the net in place.</p> <p>The clips will be outside and will be exposed to th...
<p>Ok, I tried all 3 materials.</p> <p>PLA failed after less then one day, I believe it deformed from the constant pressure and fell out (I didn't find the part but I didn't really search for it, there's some tall grass below the window)</p> <p>ABS lasted about a year, it fell strait down and I found the part, it loo...
<p>What colour was your PLA? PLA will soften around 60C and a dark colour will easily get hotter than that in direct sun on a 30C day. Clear PLA seems to have much, much better temperature resistance, but any sort of PETG will kick it's butt in that regard.</p>
565
<p>What's the best way to detect that Adobe Acrobat Reader is installed from a web browser? I'm assuming it would have to be done on the client-side (I don't think Adobe adds any user-agent strings). Preferably in JavaScript and in Internet Explorer, although it would be nice if it could also be done in FireFox, Safa...
<p>Also note that, even if someone does not have the Acrobat Reader plugin, he might still be able to read PDF files (for instance, by telling the browser to launch an external reader such as kpdf). So allow the user to download the PDF even if the plugin cannot be found. Not to mention the people with Javascript disab...
<p><a href="http://support.adobe.com/devsup/devsup.nsf/docs/52970.htm" rel="nofollow noreferrer">This article</a> from the Adobe website should get you what you need.</p> <p><strong>EDIT</strong></p> <p>In testing this it isn't 100% though, as I have acrobat, but it doesn't detect it in IE 6.</p>
30,638
<p>The bossman wants to know how to delete a user in Sharepoint. We've got him convinced that deleting a user is too difficult because of traces of that user through the system, so now he wants to be able to change the username to all Xs or somesuch. I've poked around the DB and found a couple of UserInfo tables, one...
<p>Please don't access the database directly as it's not supported ; you may even destroy integrity in the process.</p> <p>If you <strong>really</strong> want to "remove" all trace of a user, I suggest looking to "<code>stsadm -o migrateuser</code>" to rename the user to a dummy XXX user created in your membership pro...
<p>The reason you cannot remove users from SharePoint is because users are not stored in SharePoint. Users are stored in the respective membership provider: AD, aspnetsqlmembershipprovider, etc.</p> <p>The process for removing a user from SharePoint's environment is to first go to your membership provider and delete ...
44,735
<p>I have 2 columns in a Grid. When I click a button, I want the first column to animate to the left from it's current position to 0. So, in effect, it collapses and I'm left with just viewing a single column.</p>
<p>Shouldn't be too hard. You'd need to create an EventTrigger that has a BeginStoryboard that targets the grid and uses a DoubleAnimation to shrink the column width. <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.doubleanimation.aspx" rel="noreferrer">The example here has a similar s...
<p>You can also achieve this with GridLength animation , see an example here <a href="http://marlongrech.wordpress.com/2007/08/20/gridlength-animation/" rel="nofollow noreferrer">http://marlongrech.wordpress.com/2007/08/20/gridlength-animation/</a> Using this approach you can manipulate any given Grid.Column or Grid.R...
24,083
<p>When I enter an object into the DB with Linq-to-SQL can I get the id that I just inserted without making another db call? I am assuming this is pretty easy, I just don't know how. </p>
<p>After you commit your object into the db the object receives a value in its ID field.</p> <p>So:</p> <pre><code>myObject.Field1 = "value"; // Db is the datacontext db.MyObjects.InsertOnSubmit(myObject); db.SubmitChanges(); // You can retrieve the id from the object int id = myObject.ID; </code></pre>
<p>Try this:</p> <pre><code>MyContext Context = new MyContext(); Context.YourEntity.Add(obj); Context.SaveChanges(); int ID = obj._ID; </code></pre>
13,914
<p>Windows Forms:</p> <p>For <code>System.Drawing</code> there is a way to get the font height. </p> <pre><code>Font font = new Font("Arial", 10 , FontStyle.Regular); float fontHeight = font.GetHeight(); </code></pre> <p>But how do you get the other text metrics like average character width?</p>
<p>Use Graphics.MeasureString Method</p> <pre><code>private void MeasureStringMin(PaintEventArgs e) { // Set up string. string measureString = "Measure String"; Font stringFont = new Font("Arial", 16); // Measure string. SizeF stringSize = new SizeF(); stringSize = e.Graphics.MeasureString(me...
<p>I've never seen an average character width property in .NET. You can get the width of a particular string in a particular font by using Graphics.MeasureString or TextRenderer.MeasureString.</p>
39,793
<p>I have created a C# class file by using a XSD-file as an input. One of my properties look like this:</p> <pre><code> private System.DateTime timeField; [System.Xml.Serialization.XmlElementAttribute(DataType="time")] public System.DateTime Time { get { return this.timeField; } set { ...
<p>You could create a string property that does the translation to/from your timeField field and put the serialization attribute on that instead the the real DateTime property that the rest of the application uses.</p>
<p>You could create a string property that does the translation to/from your timeField field and put the serialization attribute on that instead the the real DateTime property that the rest of the application uses.</p>
12,700
<p>I just migrated to Windows Ultimate 64 SP1, because my system's hard drive crashed. I installed Visual Studio 2005 SP1 and all the patches that Microsoft has recommended. I finally got my source code from my SCM, but now debugging does not stop on any of my breakpoints I have set. This is just a plain Winforms app, ...
<p>This is listed as a <a href="http://msdn.microsoft.com/en-us/vstudio/aa964140.aspx#question20a" rel="nofollow noreferrer">known issue for VS2005 on Vista (Via MSDN):</a></p> <blockquote> <p><strong>Title</strong>: Just-In-Time (JIT) Debugging of an elevated process will fail</p> <p><strong>Description</str...
<p>I am using Visual Studio 2005 with the same patch level on both Windows Server 2008 x64 and Vista x64 SP1 without any issues. </p> <p>Are you running it as admin? When all else fails, try uninstalling and reinstalling.</p>
30,889
<p>I have a table in a DB (Postgres based), which acts like a superclass in object-oriented programming. It has a column 'type' which determines, which additional columns should be present in the table (sub-class properties). But I don't want the table to include all possible columns (all properties of all possible typ...
<p>The design you're experimenting with is a variation of <a href="http://en.wikipedia.org/wiki/Entity-attribute-value_model" rel="nofollow noreferrer">Entity-Attribute-Value</a>, and it comes with a whole lot of problems and inefficiencies. It's not a good solution for what you're doing, except as a last resort.</p> ...
<p>The only workaround (while retaining your strucure) is to have separate tables:</p> <pre><code>create table IntProps(...); create table StringProps(...); create table CurrencyProps(...); </code></pre> <p>But I do not think that this is a good idea...</p>
45,718
<p>I would like to convert an array if IDs, into a string of comma separated values, to use in a MySQL UPDATE query. How would I do this?</p>
<p>Remember to escape values:</p> <pre><code>'"' . implode('","', array_map('mysql_real_escape_string', $data)) . '"' </code></pre>
<p>This is probably better if all ids should be numerical. Check that it consists of at least one integer with </p> <pre><code>$ids = array_filter($ids, 'is_int'); if (!$ids) { //no valid ids returned. die('or something'); } $sql .= '(' . implode(',', $ids) . ')'; </code></pre>
38,103
<p>I'm mostly familiar with Java, C and C++ in which there are ways to control that only one thread is accessing a resource at any given time. Now I'm in search for something similar but in PHP 5.x.</p> <p>To formulate my problem with one example:</p> <p>I have an ASCII-file which only stores a number, the value of a...
<p>You could try php's variant of flock (<a href="http://www.php.net/flock" rel="noreferrer">http://www.php.net/flock</a>)</p> <p>I would envision something similar to (this assumes that the file /tmp/counter.txt already exists and has a counter in the file):</p> <pre><code>&lt;?php $fp = fopen("/tmp/counter.txt", "...
<p>PHP's flock() function is the route to go. However, you have to make sure that <em>all</em> accesses to the file are protected by a call to flock() first. PHP won't check if the file is locked unless you explicitly make the call to do so.</p> <p>The concept is virtually identical as with mutexes (protecting share...
22,395
<p>I've got the following two tables (in MySQL):</p> <pre><code>Phone_book +----+------+--------------+ | id | name | phone_number | +----+------+--------------+ | 1 | John | 111111111111 | +----+------+--------------+ | 2 | Jane | 222222222222 | +----+------+--------------+ Call +----+------+--------------+ | id | ...
<p>There's several different ways of doing this, with varying efficiency, depending on how good your query optimiser is, and the relative size of your two tables:</p> <p>This is the shortest statement, and may be quickest if your phone book is very short:</p> <pre><code>SELECT * FROM Call WHERE phone_number NOT...
<pre><code>SELECT name, phone_number FROM Call a WHERE a.phone_number NOT IN (SELECT b.phone_number FROM Phone_book b) </code></pre>
48,017
<p>Is there a way in SWT to get a monospaced font simply, that works across various operating systems?</p> <p>For example. this works on Linux, but not Windows:</p> <pre> <code> Font mono = new Font(parent.getDisplay(), "Mono", 10, SWT.NONE); </code> </pre> <p>or do I need to have a method that tries loading varying...
<p>According to the section on <a href="http://java.sun.com/javase/6/docs/technotes/guides/intl/fontconfig.html" rel="noreferrer">Font Configuration Files</a> in the JDK documentation of <a href="http://java.sun.com/javase/6/docs/technotes/guides/intl/" rel="noreferrer">Internationalization Support</a>-related APIs, th...
<p>If you want just a Monospaced font use "Courier" => <code>new Font(display, "Courier", 10, SWT.NORMAL)</code></p>
27,315
<p>I created a simple dialog-based application, and in the default CDialog added three buttons (by drag-and-dropping them) using the Visual Studio editor. </p> <p>The default OK and Cancel buttons are there too.</p> <p>I want to set the focus to button 1 when I click button 3.</p> <p>I set the property Flat to true ...
<p>Use <code>WM_NEXTDLGCTL</code>.</p> <p>See <a href="http://blogs.msdn.com/oldnewthing/archive/2004/08/02/205624.aspx" rel="nofollow noreferrer">Reymond Chen's "How to set focus in a dialog box"</a>:</p> <pre><code>void SetDialogFocus(HWND hdlg, HWND hwndControl) { SendMessage(hdlg, WM_NEXTDLGCTL, (WPARAM)hwndC...
<p>By calling UpdateWindow, the button is being redrawn before the focus change can take effect. The Invalidate should be sufficient by itself, the window will get repainted when everything settles down.</p>
48,299
<p>I have the handle of process 'A' on a Pocket PC 2003 device. I need to determine if that process is still running from process 'B'. Process 'B' is written in Embedded Visual C++ 4.0.</p>
<p>GetExitCodeProcess will return STILL_ACTIVE if the process was running when the function was called.</p>
<p>Process handles are waitable. They are signalled - will release any waiting thread - when the process exits. You can use them with WaitForSingleObject, WaitForMultipleObjects, etc.</p>
10,212
<p>In an actionscript function (method) I have access to arguments.caller which returns a Function object but I can't find out the name of the function represented by this Function object. Its toString() simply returns [Function] and I can't find any other useful accessors that give me that... Help :-/</p>
<p>I found an answer and I'll paste it below.</p> <p>@fenomas: yes, you are right of course, functions are just objects and what I'm looking for is a the name of the reference to them (if exists, i.e. the function is not anonymous). You also right that in general this doesn't look like the best way to do programming ;...
<p>As far as I know, not in AS2 AS3 only.</p>
32,840
<p>I have an application that seems to throw exceptions only after the program has been closed. And it is very inconsistent. (We all know how fun inconsistent bugs are...)</p> <p>My guess is there is an error during the clean up process. But these memory read/write errors seem to indicate something wrong in my "unsa...
<p>If your app is multi-threaded you could be getting errors from worker threads which aren't properly terminating and trying to access disposed objects.</p>
<p>try this to force the bug to happen while under program control</p> <pre><code> //set as many statics as you can to null; GC.Collect(); GC.WaitForPendingFinalizers(); } //exit main </code></pre>
22,071
<p>So, when playing with the development I can just set <code>settings.DEBUG</code> to <code>True</code> and if an error occures I can see it nicely formatted, with good stack trace and request information.</p> <p>But on kind of production site I'd rather use <code>DEBUG=False</code> and show visitors some standard er...
<p>Well, when <code>DEBUG = False</code>, Django will automatically mail a full traceback of any error to each person listed in the <code>ADMINS</code> setting, which gets you notifications pretty much for free. If you'd like more fine-grained control, you can write and add to your settings a middleware class which def...
<p>You can use the logging library in Python, no need to <code>pip install</code> anything.</p> <p>Replace any <code>print()</code> with <code>logging.debug()</code> but,</p> <blockquote> <p>Django Sentry is a good way to go</p> </blockquote> <p>as EMP said.</p>
29,452
<p>I was wondering if InnoDB would be the best way to format the table? The table contains one field, primary key, and the table will get 816k rows a day (est.). This will get very large very quick! I'm working on a file storage way (would this be faster)? The table is going to store ID numbers of Twitter Ids that have...
<p>I'd recommend you start <a href="http://dev.mysql.com/doc/refman/5.1/en/partitioning.html" rel="nofollow noreferrer">partioning</a> your table by ID or date. Partioning splits a large table into several smaller table according to some defined logic (like splitting it by date ranges), which makes them much more manag...
<p>If you have an index on your id column, select min(id) should be O(1), there shouldn't be much of a memory requirement for this.</p> <p>If your primary key is on the twitter id then you have an index on it.</p>
47,704
<pre><code>public static void main(String[] args) { List&lt;? extends Object&gt; mylist = new ArrayList&lt;Object&gt;(); mylist.add("Java"); // compile error } </code></pre> <p>The above code does not allow you to add elements to the list and wild cards can only be used as a signature in methods, again not ...
<p>Let's say you have an interface and two classes:</p> <pre><code>interface IResult {} class AResult implements IResult {} class BResult implements IResult {} </code></pre> <p>Then you have classes that return a list as a result:</p> <pre><code>interface ITest&lt;T extends IResult&gt; { List&lt;T&gt; getResult();...
<p>This works:</p> <pre><code>List&lt;? super Object&gt; mylist = new ArrayList&lt;Object&gt;(); mylist.add("Java"); // no compile error </code></pre> <p>From O'Reilly's <a href="http://oreilly.com/catalog/9780596527754/" rel="nofollow noreferrer">Java Generics</a>:</p> <blockquote> <p>The Get and Put Principle: u...
9,506
<p>I didn't see the option to point the workspace (or it's VS equivalent, I'm still learning the terminology for Visual Studio, but it is called a workspace in Eclipse) to My Documents/Programming instead of -- well -- wherever it is now.</p>
<p>What Craig said, plus if you do want to change the default it's in Tools -> Options -> Projects And Solutions.</p> <p>I've never changed the default and never created a solution/project in the default location, which might tell you something about how relevant it is...</p>
<p>When you create the project you can specify whatever directory you want, you are not limited to the default.</p>
5,592
<p>Wondering if anyone knows how to see what parts of the .NET framework need to be installed to get cerftain functions working on older machines. Is there a way I can install them with my application without installing the entire .NET framework?</p>
<p>You could use <a href="http://mono-project.com" rel="nofollow noreferrer">Mono</a>, the open source implementation of the .NET framework. The Mono installer is smaller than the .NET installer. Also, Mono works with Windows versions older than XP. </p> <p>With Mono you can use the <a href="http://www.mono-project.c...
<p>As far as I know this is not possible, you must have the .NET framework runtimes fully installed for them to work. Trying to piece it together just doesn't sound like a good idea at all anyway, in my opinion.</p>
43,507
<p>Where should I start learning about version control systems? I've used SVN, Team Foundation, and Sourcesafe in the past but I don't really feel like I grasp it completely, and my team doesn't seem to grasp it either.</p> <p>Which points are the most important to master? I realise this differs from VCS to VCS, but f...
<p>The wikipedia article on Revision Control is a great place to start </p> <p><a href="http://en.wikipedia.org/wiki/Revision_control" rel="nofollow noreferrer">Revision control</a></p> <p>When trying to teach my colleagues, I found getting him to understand the vocabulary at the end was a great way to start to intro...
<p><a href="http://ericsink.com/vcbe/" rel="nofollow">Version control by example by Eric Sink</a> is good and easy to follow</p>
3,024
<p>Greetings – To automate testing of our database SPROCs, we’ve been using dynamically created databases inside of a User Instance. This has been working very well – the build server and, until very recently, all the developers could all run the tests. However, one of our developer machines is now returning the foll...
<p>Okay, I tried all of the above fixes again, and then I restarted the entire system and it appears to work. Strange! I had restarted my system in the past, but it looks like you have to apply these fixes first and then restart. I think I'll try switching the service back to logging in as Network Service.</p> <p>T...
<p>I found the same issue on my azure VM. Then I opened the SQL Server Configuration Manager, opened SQL Server Network Configuration, -Protocols for and found that "Named Pipes" and "TCP/IP" were disabled. I enabled them, and the error went away.</p>
44,360
<p>I can connect to my SQL Server database via sqlcmd from a DOS command window, but not from a Cygwin window. From DOS:</p> <pre><code>F:\Cygnus&gt;sqlcmd -Q "select 'a test'" -S .\SQLEXPRESS </code></pre> <hr> <p>a test</p> <p>(1 rows affected)</p> <pre><code>F:\Cygnus&gt; </code></pre> <p>=====================...
<p>The backslash is being eaten by cygwin's bash shell. Try doubling it:</p> <pre><code>sqlcmd -Q "select 'a test'" -S .\\SQLEXPRESS </code></pre>
<p>You may have to allow remote connections for this, and give the full server name i.e SERVER\SQLEXPRESS</p>
13,771
<p>When running a vim instance in gnu screen hitting shift enter in insert mode adds an 'M' and then a newline, rather than just a newline.</p> <p>Does anybody know what the problem might be, or where to look?</p> <p>Relevant system info:</p> <blockquote> <p>Ubuntu 8.04.1</p> <p>Screen version 4.00.03 (FAU) 2...
<p>Missing info from your question:</p> <ol> <li>Where do you run screen and see this issue? Some terminal app (KTerminal, Gnome terminal, virtual console etc) or remote session (eg putty, ssh from another computer)</li> <li>do a “echo $TERM” and tell us its output</li> <li>do a “cat -v”, press Shift-Enter, then Enter...
<p>First, you could fix your $TERM for within konsole. Install "ncurses-term" and configure konsole to set $TERM=konsole-256color. Then configure screen with "term screen-256color". Or 'konsole' and 'screen', respectively, if that's your preference. Konsole and screen are <em>not</em> xterm and doesn't support ever...
8,884
<p>I have a table of music albums. I have a second table of album art. Unfortunately, not every album has some album art data. As such, i will need to do an OUTER JOIN between music and album art.</p> <p>Assumption: both tables just contain ints and varchars .. no blobs, etc.</p> <p><em>Question</em></p> <ul> <li>Is...
<p>The only reason I can see to keep them in separate tables is if one album can contain multiple pieces of artwork. If each table only contains, and will only ever contain, 1 piece of artwork, then sticking them in the same table should be fine. If you are joining these two tables in a lot of different instances, yo...
<p>Just use one table, with nulls for albums with no art. I don't see any advantage to having a second table...unless you have a lot of albums that share the same art.</p>
41,333
<p>I'm creating a bunch of migrations, some of which are standard "create table" or "modify table" migrations, and some of which modify data. I'm using my actual ActiveRecord models to modify the data, a la:</p> <pre><code>Blog.all.each do |blog| update_some_blog_attributes_to_match_new_schema end </code></pre> <p...
<p>The answer is yes!</p> <pre><code>Blog.reset_column_information </code></pre>
<p>Create new instances:</p> <hr> <pre><code>Old_blogs = Blog.all </code></pre> <blockquote> <p># change/modify db table in here</p> </blockquote> <pre><code>New_blogs = Blog.all # this should be reloaded or you could use the .reload on this </code></pre> <blockquote> <p># change information, load old into new...
24,508
<p>The following code</p> <pre><code>public class GenericsTest2 { public static void main(String[] args) throws Exception { Integer i = readObject(args[0]); System.out.println(i); } public static &lt;T&gt; T readObject(String file) throws Exception { return readObject(new ObjectIn...
<p>I'd say it's the bug in the Sun compiler reported <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302954" rel="noreferrer">here</a> and <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=98379" rel="noreferrer">here</a>, because if you change your line to the one below it works with both, which seem...
<p>If you can modify your method readObject to work transparently when called, you may also use following:</p> <pre><code>public static &lt;T&gt; T readObject(String file, Class&lt;T&gt; type) throws Exception { return type.cast(readObject(new ObjectInputStream(new FileInputStream(file)))); } </code></pre> <p>Thi...
40,593
<p>I have a many-to-one relationship where the child table can have hundreds of thousands of records. In this case, calling Parent.ChildCollection.Count forces a lazy initialization of the child collection which is extremely expensive.</p> <p>In Hibernate 3.0 there is a feature lazy="extra" which allows you to check ...
<p>Depends on your network configuration of vmware product you are using (player, server, workstation). If it is set for a bridged mode, then you can do it as any other machine - by host machine's IP. If it is a "host only" or NAT mode - check what is the gateway IP for the guest (/sbin/route), and try using it:</p> <...
<p>Depends on your network configuration of vmware product you are using (player, server, workstation). If it is set for a bridged mode, then you can do it as any other machine - by host machine's IP. If it is a "host only" or NAT mode - check what is the gateway IP for the guest (/sbin/route), and try using it:</p> <...
43,532