instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I'm not talking about making something that's outright disproportionate of course. I've been working in Blender and I've use Absolute grid Snap to snap my vertices to the grid. The problem is that it (didn't seem) to always work perfectly for centimeters, and seemed to work better for meters.
(edit: I've learned wh... | <p>It depends on what you're working on. If you're producing mechanical/functional parts (even if that just means having to connect to one another or to some non-printed part), 3 mm (0.3 cm) error is almost surely going to prevent them from working. Even 0.3 mm error might be a problem.</p>
<p>If you're doing standalo... | <p>Welcome to the SE 3D Printing site. Your questions are also welcome, as well as your answers to your questions, and the questions of others.</p>
<p>I am not a Blender user. I use CAD systems because most of what I do I want to have a certain dimensional precision.</p>
<p>If the problem is as simple as "The overa... | 1,368 |
<p>I'd like to write Python scripts that drive Visual Studio 2008 and Visual C++ 2008. All the examples I've found so far use <code>win32com.client.Dispatch</code>. This works fine for Excel 2007 and Word 2007 but fails for Visual Studio 2008:</p>
<pre><code>import win32com.client
app1 = win32com.client.Dispatch( 'E... | <p>I don't know if this will help you with 2008, but with Visual Studio 2005 and win32com I'm able to do this:</p>
<pre><code>>>> import win32com.client
>>> b = win32com.client.Dispatch('VisualStudio.DTE')
>>> b
<COMObject VisualStudio.DTE>
>>> b.name
u'Microsoft Visual Studio... | <p>As of year 2013, better option can be to script <code>Visual Studio</code> via <code>IronPython</code> cause better <code>CLR</code>/<code>COM</code> and other MS stuff integration:</p>
<pre><code>
import clr
import System
t = System.Type.GetTypeFromProgID("AutoItX3.Control")
oAutoItX = System.Activator.CreateInst... | 27,442 |
<p>Question says it all, I've got a 500,000 line file that gets generated as part of an automated build process on a Windows box and it's riddled with <strong>^M</strong>'s. When it goes out the door it needs to <strong>*nix</strong> friendly, what's the best approach here, is there a handy snippet of code that could d... | <p>Here is a Perl one-liner, taken from <a href="http://www.technocage.com/~caskey/dos2unix/" rel="noreferrer">http://www.technocage.com/~caskey/dos2unix/</a></p>
<pre><code>#!/usr/bin/perl -pi
s/\r\n/\n/;</code></pre>
<p>You can run it as follows:</p>
<pre><code>perl dos2unix.pl < file.dos > file.unix
</code>... | <p>If it is just one file I use notepad++. Nice because it is free. I have cygwin installed and use a one liner script I wrote for multiple files. If your interest in the script leave a comment. (I don't have it available to me a this moment.)</p>
| 40,372 |
<p>I work in an multi-site environment that's currently using Rational ClearCase for source control and Rational ClearQuest for issue tracking (I accept your condolences ahead of time). As a rough estimate I would say this is supporting 200 engineers.</p>
<p>How would you effectively migrate this SCM methodology to a... | <p>First, why do you think this would improve developer productivity? I haven't used ClearCase much, and ClearQuest not at all. What about these tools is hindering development?</p>
<p>Once you know what you want, you need to look at various tools. I'm fond of Subversion for SCM, as a general rule, but there are sit... | <p>Condolences are not required, it seems that if you are working in a large scale development over more than one site, then you have the right tools for the job.</p>
<p>Attempting to make Open Source SCM products work over various sites will be a very interesting challenge - I've not seen something that will work sec... | 19,201 |
<p>Is this</p>
<pre><code>... T1 join T2 using(ID) where T2.VALUE=42 ...
</code></pre>
<p>the same as</p>
<pre><code>... T1 join T2 on(T1.ID=T2.ID) where T2.VALUE=42 ...
</code></pre>
<p>for all types of joins?</p>
<p>My understanding of <code>using(ID)</code> is that it's just shorthand for <code>on(T1.ID=T2.ID)<... | <p>I don't use the USING syntax, since </p>
<ol>
<li>most of my joins aren't suited to it (not the same fieldname that is being matched, and/or multiple matches in the join) and</li>
<li>it isn't immediately obvious what it translates to in the case with more than two tables</li>
</ol>
<p>ie assuming 3 tables with 'i... | <p>You got the answers here, I need not add to it. Once I did a performance test on this, and USING consistently and always ran faster than ON. Yes I am talking about 10 to 20 ms :) MySQL I am talking about</p>
| 48,368 |
<p>I tried but I guess Message Box only works with win forms. What is the best alternative to use in web forms?</p>
| <p>You can use <code>confirm</code> for yes/no questions and <code>alert</code> for "OK" messages in JavaScript.</p>
<p>The other alternative is to use JavaScript to pop up a new window that looks and acts like a message box. Modality in this case varied by browser. In Internet Explorer, the method </p>
<pre><code>... | <p>JavaScript:</p>
<pre><code>alert("This box has an OK button.");
</code></pre>
| 24,860 |
<p>What is the best way to keep a console application open as long as the CancelKeyPress event has not been fired?</p>
<p>I would prefer to not use Console.Read or Console.ReadLine as I do not want to accept input. I just want to enable the underlying application to print to the console event details as they are fire... | <p>I'm assuming that "gracefully shut down the application" is the part you are struggling with here. Otherwise your application will automatically exit on ctrl-c. You should change the title.</p>
<p>Here's a quick demo of what I think you need. It could be refined a bit more with use of locking and Monitors for no... | <p>Simply run your program or codes without debugging, on your keyboard key in <kbd>CTRL + f5</kbd> instead of F5(debugging).</p>
| 24,865 |
<p>What is the best OS for Java development? People from Sun are pushing the Solaris, yes Solaris have some extra features included in itself such as (dTrace, possibility for Performance tuning the JVM, etc.. ). Some friends of mine, had port their application on solaris, and they said to me that the performances was b... | <p>Of the three I've used (Mac OS X, Linux, Windows), I consider Linux the best place to do Java development.</p>
<p>My primary personal machine is a Mac, and I've done quite a lot of Java development there and been happy with it. Unfortunately, however, Apple lags behind the official JDK releases and you're pretty mu... | <p>I have had success before doing Java development in Windows with Eclipse. Sounds like you are also asking about deployment/hosting. Whichever OS is best to run your application on should not really predicate what OS you use to develop the application.</p>
| 31,964 |
<p>I have a class on which I want to allow several (~20+) configuration options.
Each option turns on or off a piece of functionality, or otherwise alters operations.
To facilitate this, I coded a separate options class with default values. However, I had to litter my code with guard conditions to determine how methods... | <p>How about the <a href="http://en.wikipedia.org/wiki/Decorator_Pattern" rel="nofollow noreferrer">Decorator pattern</a>? It's designed for dynamically adding behavior to a class.</p>
| <p>I'm thinking of a <a href="http://www.patterndepot.com/put/8/Behavioral.html" rel="nofollow noreferrer">Command</a> pattern.</p>
<p>It would look something like:</p>
<pre><code> public class MyClass {
interface Command {
void execute(int a);
}
static class DoThisSimpleCommand implements Command {
v... | 26,414 |
<p>I can't seem to retrieve the AlternateView from System.Net.Mail.AlternateView.</p>
<p>I have an application that is pulling email via POP3. I understand how to create an alternate view for sending, but how does one select the alternate view when looking at the email. I've have the received email as a System.Net.M... | <p>Mightytighty is leading you down the right path, but you shouldn't presume the type of encoding. This should do the trick:</p>
<pre><code>var dataStream = view.ContentStream;
dataStream.Position = 0;
byte[] byteBuffer = new byte[dataStream.Length];
var encoding = Encoding.GetEncoding(view.ContentType.CharSet);
stri... | <p>Its not immediately possible to parse an email with the classes available in the System.Net.Mail namespace; you either need to create your own MIME parser, or use a third party library instead.</p>
<p>This great Codeproject article by Peter Huber SG, entitled <a href="http://www.codeproject.com/KB/IP/Pop3MimeClient... | 37,202 |
<p>I need to decide on a GUI/Widget toolkit to use with Python for a new project. The target platforms will be Linux with KDE and Windows XP (and probably Vista). What Python GUI toolkit looks best and consistent with the native look and feel of the run time platform?</p>
<p>If possible, cite strengths and weaknesses ... | <p>Python binding of Wx is very strong since at least one of the core developer is a python guy itself. WxWdgets is robust, time proven stable, mature, but also bit more than just GUI. Even is a lot is left out in WxPython - because Python itself offers that already - you might find that extra convenient for your proje... | <p>Like others said, PyQt or wxPython... The technical difference between the two is more or less imaginary - it's a question of your comfort with the toolkit that matters, really.</p>
| 47,060 |
<p>What's the simplest-to-use techonlogy available to save an arbitrary Java object graph as an XML file (and to be able to rehydrate the objects later)?</p>
| <p>The easiest way here is to serialize the object graph.
Java 1.4 has built in support for serialization as XML.</p>
<p>A solution I have used successfully is XStream (<a href="http://x-stream.github.io/)-" rel="nofollow noreferrer">http://x-stream.github.io/)-</a> it's a small library that will easily allow you to s... | <p>If you are really only interested in serializing your objects to a file and then deserializing them later, then you might check out YAML instead of XML. YAML is much easier to work with than XML and the output files are very human-readable (which may or may not be a requirement). Check out <a href="http://yaml.org/"... | 8,814 |
<p>From the Apple <a href="http://developer.apple.com/internet/safari/faq.html" rel="noreferrer">developer faq</a></p>
<blockquote>
<p>Safari ships with a conservative
cookie policy which limits cookie
writes to only the pages chosen
("navigated to") by the user.</p>
</blockquote>
<p>By default Safari only al... | <p>This is an issue known as Same Origin Policy. Essentially it is a security measure against creating security loopholes. </p>
<p>When you have an iframe that points to a page on your own domain, JavaScript can access both the page you're on and the page within the Iframe. This is an acceptable parent to child and ch... | <p><a href="http://saizai.livejournal.com/897522.html" rel="nofollow noreferrer">This page</a> suggests that you place some javascript in your pages which detects the absence of an always-there cookie. When it finds that the cookie has not been set, it posts the required session data to a page which sets the cookie, a... | 20,759 |
<p>Let's say I have an array of lots of values (C++ syntax, sorry):</p>
<pre><code>vector<double> x(100000);
</code></pre>
<p>This array is sorted such that <code>x[n] > x[n-1]</code>.</p>
<p>I would like a function to retrieve an array of all values in the range [a, b] (that's inclusive). Some interface li... | <p>What you're asking is a bit confusing regarding the the exact range properties and the types. However, you can tweak the following C++ code to suit your needs. The basic intuition is to use lower_bound and upper_bound to find the positions in the array that delineate the range you're looking for.</p>
<pre><code>v... | <p>You already appear to know that a binary search can be used to find the range, and implementations of those are easily found.</p>
<p>Everything else is just getting trivial array manipulation.</p>
| 32,657 |
<p>Just a quick question.</p>
<p>I'm looking for a simple strip chart (aka. graphing) control similar to the windows task manager 'Performance' view. And have found a few, but they all rely on MFC or .NET :(</p>
<p>Am hoping that someone here might have or know where to get a simple strip chart Win32 control that ... | <p>If you have to go the roll-your-own route look at the polyline GDI call. That can draw the entire line for you in one call. </p>
<p>I work on a system that draws charts with custom code (no 3rd party controls, all win32 GDI). It sounds really hard, but it isn't that bad.</p>
<p>A little math to map the points from... | <p>I don't think there is a standard one in the Win32 common controls library. You'll either have to use someone else's widget library, or roll your own using GDI to draw the graphs. It probably isn't too difficult to roll your own - just create a bitmap control, and set the image every time your data updates to a gr... | 16,201 |
<p>I've googled around for this, but I still have trouble relating to what Django defines as "apps". </p>
<p>Should I create a new app for each piece of functionality in a site, even though it uses models from the main project? </p>
<p>Do you guys have good rule of thumb of when to split off a new app, and when to ke... | <p>James Bennett has a wonderful <a href="http://www.b-list.org/weblog/2008/mar/15/slides/" rel="noreferrer">set of slides</a> on how to organize reusable apps in Django.</p>
| <p>An 'app' could be many different things, it all really comes down to taste. For example, let's say you are building a blog. Your app could be the entire blog, or you could have an 'admin' app, a 'site' app for all of the public views, an 'rss' app, a 'services' app so developers can interface with the blog in their ... | 8,976 |
<p>Parsing a text file in vb.net and need to locate the latitude and longitude in these two sections of text. The patter is 6 digits space 7 digits (364800 0953600). The samples are from two different map files and have slightly differing formats.</p>
<pre><code>I 2H02 364800 0953600 ' SEC72 ... | <pre><code>Dim matches As MatchCollection
Dim regex As New Regex("\d{6} \d{7}")
matches = regex.Matches(your_text_string)
</code></pre>
| <p>Do a simple group capture. It appears your RegEx formula will be simple enough to handle both scenarios (be a little lose on the space detection). Then you can access the group properties of the match (either named or just basic index) and get the data you need.</p>
| 38,905 |
<p>I'd like to programatically determine the encoding of a page via JavaScript, or some other API from a browser. The reason I want this information is because I am attempting to fuzz major browsers on what character encodings they support, and obviously just because I sent the appropriate "Content-Type" doesn't mean t... | <p>Javascript can only report some of the things that are going on. Most browsers won't expose enough useful settings to you for you to base any hardcore tests on. </p>
<p>There are things such as <code>document.inputEncoding</code>, <code>document.characterSet</code> (non IE), <code>document.charset</code>, and <code... | <p>The original answer is quite old now and support for <code>document.characterSet</code> has improved greatly.</p>
<pre><code>>>> document.characterSet
</code></pre>
<p>IE 11:</p>
<pre><code>"utf-8"
</code></pre>
<p>Firefox 52, Chrome 55 and Chrome on Android, Safari 10:</p>
<pre><code>"UTF-8"
</code></... | 41,216 |
<p>In a .net 2 winforms application, what's a good way to set the culture for the entire application?<br>
Setting CurrentThread.CurrentCulture for every new thread is repetitive and error-prone.<br>
Ideally I'd like to set it when the app starts and forget about it.</p>
| <p>The culture for a thread in .NET is the culture for the system (as viewed by a single application/process). There is no way to override that in .NET, you'll have to continue setting the CurrentCulture for each new thread.</p>
| <p>You can set application current culture this way:</p>
<pre><code>static void Main()
{
System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("fi-FI");
Application.CurrentCulture = cultureInfo;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefaul... | 11,865 |
<p>I am working on ASP.NET MVC.</p>
<p>in order to use AjaxHelper, I inserted two javascript files in the site.master as following.</p>
<pre><code><script src="../../Scripts/MicrosoftMvcAjax.debug.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftAjax.debug.js" type="text/javascr... | <p>Absolutely. The MVCAjax classes will need to reference the more generic Ajax classes. Therefore, the generic ones get referenced first</p>
| <p>The MicrosoftMvcAjax.debug.jss file has code in it that references code in MicrosoftAjax.debug.js. Hence the order in which they are declared matters.</p>
| 49,773 |
<p>What does the pink color in Slic3r preview mean? Yellow is my model, green is support, and pink is..?</p>
<p>If the pink color is some kind of warning, how do I fix it?</p>
<p><a href="https://i.stack.imgur.com/2PIRU.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2PIRU.jpg" alt="Illustration fr... | <p>In slic3r preview, salmon (pink) represents infill, yellow represents perimeters, and green represents support material, including skirt and brim.</p>
| <p>Having had direct experience with Slic3r, I can offer up this information. Your model is composed of bottom layers, top layers, outside layers, infill, rafts, brims and perhaps something I've missed.</p>
<p>The program provides for color coding of these features. In the case of your image, the pink represents a top... | 569 |
<p>I have a VB6 legacy program which I need to change. I am unable to run the program from the IDE. When I activate one of the forms in the IDE I get an error which refers me to an error log file. The log file has the following in it</p>
<p>"Cannot load control SSPanel; license not found"</p>
<p>The SSPanel is part t... | <p>The solution that worked for me was to execute the file VBCTRLS.REG on the installation disc (common/tools/VB/controls). It registered the control. I stopped getting the error and I was able to run the program from the IDE</p>
| <p>If you have "Cannot load control <strong>SysInfo</strong>; license not found."</p>
<p>This reg fix the problem:</p>
<pre><code>[HKEY_CLASSES_ROOT\Licenses\E32E2733-1BC5-11d0-B8C3-00A0C90DCA10]
@="kmhfimlflmmfpffmsgfmhmimngtghmoflhsg"
</code></pre>
| 47,789 |
<p>Consider the following code in VB9:</p>
<pre><code>Dim text = "Line1<br/>Line2"
Dim markup = <span><%= text %></span>.ToString
</code></pre>
<p>While I was hoping markup would end up being <code><span>Line1<br/>Line2</span></code>, it actually evaluates to <code><span&g... | <p>This behavior is "By Design." When embedding a string expression inside an XML literal the value will be escaped to be a legal string value. </p>
<p>To get the behavior you are looking for you'll need to be embedding an XElement/XNode within an XML literal. Take the following example. It will correctly keep the... | <p>It can be done using XElementRaw.</p>
<pre><code>Dim markup = <span><%= text %></span>.ToHTML()
</code></pre>
<p>Here's the ToHTML() extension:</p>
<pre><code>''' <summary>
''' Convert an XElement to a string. Differences between this and .ToString():<br />
''' 1) Will not throw errors... | 37,824 |
<p>I have been looking at a few options for enabling localization and internationalization of a dynamic php application. There appears to be a variety of tools available such as gettext and Yahoo's R3 and I am interested in hearing from both developers and translators about which tools are good to use and what function... | <p>PHP gettext implementation works very smoothly. And po files with po edit and gettext are about as good a way as you can get to deal with localization bearing in mind that no solution of this kind can completely handle the complexities of the various languages. For example, the gettext method is very good on plural ... | <p>Xataface can be used to quite easily internationalize an arbitrary PHP/MySQL application. It support translation of both your static text, and your database data. All you have to do is add a line or 2 of code to a couple of places in your application and it's good to go.</p>
<p><a href="http://xataface.com/docume... | 18,834 |
<p>I want to check if a given date is more than a month earlier than today's date using LINQ.</p>
<p>What is the syntax for this?</p>
<p>Thanks in advance.</p>
| <p>I assume that you're talking about in the where clause. It's basically the same way you would compare two DateTime objects elsewhere.</p>
<pre><code>using (DataContext context = new DataContext()) {
var query = from t in context.table
where t.CreateDate.Date < DateTime.Today.AddMonths(-1)
... | <p>If you don't want your code to throw </p>
<pre><code>LINQ to Entities does not recognize the method 'System.DateTime AddYears(Int32)' method, and this method cannot be translated into a store expression.
</code></pre>
<p>I would suggest using DbFunctions.AddYears. Also, if you are concerned only about dates and no... | 26,358 |
<p>I am working on an object factory to keep track of a small collection of objects. The objects can be of different types, but they will all respond to <code>createInstance</code> and <code>reset</code>. The objects can not be derived from a common base class because some of them will have to derive from built-in coco... | <p>You can convert a string to a class using the function: NSClassFromString</p>
<pre><code>Class classFromString = NSClassFromString(@"MyClass");
</code></pre>
<p>In your case though, you'd be better off using the Class objects directly.</p>
<pre><code>MyClass * variable = [factory makeObjectOfClass:[MyClass class]... | <p>It sounds like you want something like:</p>
<pre><code>- (id)makeObjectOfClassNamed:(NSString *)className
{
Class klass = NSClassFromString(className);
assert([klass instancesRespondToSelector:@selector(reset)]);
id newInstance = [klass createInstance];
[managedObjects addObject:newInstance];
re... | 40,743 |
<p>Have you ever been in a situation where a menu function you really really want to use but can't cause it's disabled or worse gone all together?</p>
<p>There is an argument for always leaving menus enabled and then display a message to a user explaining why a menu function can not be activated when they click on it.... | <p>If you're refering to Joel's post <a href="http://www.joelonsoftware.com/items/2008/07/01.html" rel="noreferrer">Don't hide or disable menu items</a>, he <a href="https://stackoverflow.fogbugz.com/default.asp?W13086" rel="noreferrer">clarified in the StackOverflow podcast</a> that he intended that there be informati... | <p>I've always believed that you should hide as much as you can. (Your application shouldn't be any more complex than what the user can/should do.)</p>
<p>If you display a menu option that a user shouldn't be using, they may click on it, but think your application is broken because nothing happens.</p>
<p>That's wha... | 10,444 |
<p>I'm using C# and Microsoft.Jet.OLEDB.4.0 provider to insert rows into an Access mdb.</p>
<p>Yes, I know Access sucks. It's a huge legacy app, and everything else works OK.</p>
<p>The table has an autonumber column. I insert the rows, but the autonumber column is set to zero.</p>
<p>I Googled the question and re... | <p>In Access it is possible to INSERT an explicit value into an IDENTITY (a.k.a. Automnumber) column. If you (or your middleware) is writing the value zero to the IDENTITY column and there is no unique constraint on the IDENTITY column then that might explain it. </p>
<p>Just to be clear you should be using the syntax... | <p>When doing the insert, you need to be sure that you are NOT specifying a value for the AutoNumber column. Just like in SQL Server you don't insert a value for an identity column.</p>
| 18,461 |
<p><strong>This isn't a holy war, this isn't a question of "which is better".</strong></p>
<p>What are the pros of using the following format for single statement if blocks.</p>
<pre><code>if (x) print "x is true";
if(x)
print "x is true";
</code></pre>
<p>As opposed to</p>
<pre><code>if (x) { print "x is tru... | <p>I find this:</p>
<pre><code>if( true ) {
DoSomething();
} else {
DoSomethingElse();
}
</code></pre>
<p>better than this:</p>
<pre><code>if( true )
DoSomething();
else
DoSomethingElse();
</code></pre>
<p>This way, if I (or someone else) comes back to this code later to add more code to one of the ... | <p>For me, braces make it easier to see the flow of the program. It also makes it easier to add a statement to the body of the if statement. When there aren't braces, you have to add braces to add another statement.</p>
<p>I guess the pros of not using braces would be that it looks cleaner and you don't waste a line w... | 12,300 |
<p>I was working on my printer when something metallic came into contact with the pcb. I smelled smoke and quickly unplugged the printer. Anyway, this is the result and, of course, the heat bed won't heat. </p>
<p>Can this be salvaged or should I toss it and buy a new one? </p>
<p><a href="https://i.stack.imgur.com/W... | <p>What happend was short circuit of course. There is no doubt you overheated HB so copper detached from HB base plate. Because you wrote it doesn't work it means copper tracks are broken.</p>
<p>There is very low chance to fix it. I mean it - near to zero.</p>
<p>What you could do is:</p>
<ol>
<li>Detach HB from ar... | <p>Yes, it should be possible to fix, although you might choose to replace anyway on the basis that the repaired bed might give you concerns about how long it will be before your repair fails.</p>
<p>You will need to carefully remove the protective layer to expose the heating element (assuming you can identify where i... | 264 |
<p>How can I get Direct3D to work over a Remote Desktop connection? I am using Windows XP Professional.</p>
| <p>3D acceleration does not work on Remote Desktop or in Virtual PC/Server.
Software-rendered OpenGL works on both Remote Desktop and Virtual PC/Server. </p>
| <p>According to this article Direct3D is possible (but dog slow) when the box you're remoting into is running Vista.</p>
<p><a href="http://www.virtualdub.org/blog/pivot/entry.php?id=208" rel="nofollow noreferrer">http://www.virtualdub.org/blog/pivot/entry.php?id=208</a></p>
<p>I haven't verified this and cannot pers... | 34,307 |
<p>To be able to upload large files from a HTML page to a FTP server, I am looking for a Java/Flash FTP upload applet.</p>
<p>I really like the way <a href="http://www.dhtmlx.com/docs/products/dhtmlxVault/index.shtml" rel="noreferrer">dhtmlxVault</a> works, but I need it to upload to a FTP server instead of a HTTP fil... | <p>This is exactly what <a href="http://www.enterprisedt.com/products/integralftp/overview.html" rel="nofollow noreferrer">IntegralFTP</a> is - a Java applet wrapped by Javascript. The GUI is all implemented in Javascript, and so you can change it how you like. </p>
<p>It supports SFTP, FTP and FTPS.</p>
<p>You can u... | <p>Technically, any swing app would work with only small modifications if you have access to the code. If your ready to offer an applet, maybe you could even use java web start (would require even less changes).</p>
| 36,206 |
<h2>I've actually solved this, but I'm posting it for posterity.</h2>
<p>I ran into a very odd issue with the DataGridView on my dual-monitor system. The issue manifests itself as an EXTREMELY slow repaint of the control (<em>like 30 seconds for a full repaint</em>), but only when it is on one of my screens. When on t... | <p>You just need to make a custom class based off of DataGridView so you can enable its DoubleBuffering. That's it!</p>
<pre><code>
class CustomDataGridView: DataGridView
{
public CustomDataGridView()
{
DoubleBuffered = true;
}
}
</code></pre>
<p>As long as all of my instances of the grid are usi... | <p>We've experienced a similar problem using .NET 3.0 and DataGridView on a dual monitor system.</p>
<p>Our application would display the grid with a gray background, indicating that the cells could not be changed. Upon selecting a "change settings" button, the program would change the background color of the cells wh... | 14,428 |
<p>What is the best way to secure the use/loading of a DLL with a license file?</p>
| <p>A couple of things you might want to consider:</p>
<p>Check sum the DLL. Using a <a href="http://en.wikipedia.org/wiki/Cryptographic_hash_function" rel="nofollow noreferrer">cryptographic hash function</a>, you can store this inside the license file or inside the DLL. This provides a verification method to determin... | <p>You can check for a license inside of DllMain() and die if it's not found.</p>
| 13,182 |
<p>I'm having a Prusa i3 derivative printer with a capacitive sensor for the z-axis. It switches a tiny bit before the nozzle hits the print bed and hence needs a z-offset to be configured.</p>
<p>In Slic3r I have configured the z-offset to <code>-0.1</code> on the <em>General</em> page of the <em>Printer Settings</em... | <p>You can trick the printer into applying an offset using the <code>G92</code> command:</p>
<pre><code>G0 Z0
G92 Z0.1
</code></pre>
<p>First, we move the nozzle to <code>Z=0</code>. Next, through the <code>G92</code> command, we tell the printer to, from now on, treat the current position as <code>Z=0.1</code>. Thi... | <p>I built my printer five years ago with a similar issue and I strongly suggest that the physical 0 will be the actual 0 instead of tweeking it into the system. Especially if you are exploring and testing new methods, i.e. Cura vs Slic3r settings. In Marlin, you can insert a z adjustment for the endstops but it can cr... | 701 |
<p>I am using a third party application and would like to change one of its files. The file is stored in XML but with an invalid doctype.</p>
<p>When I try to read use a it errors out becuase the doctype contains "file:///ReportWiz.dtd"
(as shown, with quotes) and I get an exception for cannot find file. Is there a wa... | <p>Tell your DocumentBuilderFactory to ignore the DTD declaration like this:</p>
<pre><code>docFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
</code></pre>
<p>See <a href="http://xerces.apache.org/xerces2-j/features.html" rel="nofollow noreferrer">here</a> for a list of a... | <p>Another thing I was debating was storing all of the file in a string, then doing my manipulations and wiring the String out to a file.None of these seem clean or easy, but what is the best way to do this?</p>
| 46,689 |
<p>I'm using jmockit with my tests and with one class I wish to test, uses <code>InitialContext</code> directly. So I have the following:</p>
<pre><code>public class MyClass {
public void myMethod() {
InitialContext ic = new InitialContext();
javax.mail.Session mailSession = ic.lookup("my.mail.session");
... | <p>In general, to mock JNDI, you will need to use a framework, such as EJBMock, that can provide a mock container in which to deploy your beans.</p>
<p>The other alternative is to refactor creating the context out of your code so that it is passed in (this is dependency injection refactoring), and then you should be a... | <p>You're getting the NoClassDefFoundError because my.class.MockInitialContext doesn't exist. You need to create that class if you're going to pass it as an argument to Mockit.redefineMethods(). Your MockInitialContext class would just need a method named lookup() that accepts a String parameter and returns a javax.m... | 21,085 |
<p>I'm trying to get Unicode working properly in rails using MySQL. Now, Rails displays the text correctly, but it shows up as ??? in MySQL. Additionally, I am not able to filter the text.</p>
<p>My MySQL database has been configured with the utf8 character set. My client character is also UTF8. Likewise, rails is... | <p>Have you tried adding this to your database.yml under your environment?</p>
<p><code>encoding: utf8</code></p>
| <p>Perhaps whatever you're using to view your database isn't configured properly for unicode. For instance, if you're using a terminal in some linux distro: the terminal shell may not be configured correctly to display unicode characters.</p>
| 45,811 |
<p>One of the things I'd like to do in my browser-based application is allow the user to select some text (not in a <textarea>, just plain ol' text!), and have my application pop up a small toolbar that then can interact with the next (in my case, add annotations).</p>
<p>I've found a lot of stuff on google that... | <p>Have a look at <a href="http://jquery.com" rel="noreferrer">jQuery</a> and the <a href="http://plugins.jquery.com/project/wrapSelection" rel="noreferrer">wrapSelection plugin</a>. It may be what you are looking for.</p>
| <p>The behaviour of individual browsers with regard to selection is <a href="http://quirksmode.org/dom/w3c_range.html" rel="nofollow noreferrer">outlined here</a>.</p>
| 3,167 |
<p>Does TCP/IP prevent multiple copies of the same packet from reaching the destination? Or is it up to the endpoint to layer idempotency logic above it?</p>
<p>Please reference specific paragraphs from the TCP/IP specification if possible.</p>
| <p>It's the TCP stack's job to recover from duplicate packets:</p>
<blockquote>
<p>The TCP must recover from data that is
damaged, lost, duplicated, or
delivered out of order by the internet communication system. This
is achieved by assigning a sequence number to each octet
transmitted, and requ... | <p>You don't fully understand the problem.
See this link:
<a href="http://en.wikipedia.org/wiki/Transmission_Control_Protocol" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Transmission_Control_Protocol</a></p>
<p>On this page is write:</p>
<p>"TCP timestamps, defined in RFC 1323, help TCP compute the round-... | 17,045 |
<p>Is there a static analysis tool for PHP source files?</p>
<p>The binary itself can check for syntax errors, but I'm looking for something that does more, like:</p>
<ul>
<li>unused variable assignments</li>
<li>arrays that are assigned into without being initialized first</li>
<li>and possibly code style warnings</li... | <p>Run <code>php</code> in lint mode from the command line to validate syntax without execution:</p>
<p><code>php -l FILENAME</code></p>
<p>Higher-level static analyzers include:</p>
<ul>
<li><a href="http://www.program-transformation.org/PHP/PhpSat" rel="noreferrer">php-sat</a> - Requires <a href="http://strategoxt.or... | <p>There is a tool for static code analysis called <a href="https://github.com/scrutinizer-ci/php-analyzer" rel="nofollow noreferrer">PHP Analyzer</a>. PHP Analyzer is now a deprecated project, but you still can access it on the legacy branch.</p>
<p>Among many types of static analysis it also provides basic auto-fixin... | 49,644 |
<p>We are currently working on a new version of our main application. one thing that I really wish to work on is providing support for multiple monitors. Increasingly, our target users are adding second screens to their desktops and I think our product could leverage this extra space to improve user performance.</p>
... | <p>Few random tips:</p>
<ul>
<li>If multiple windows can be open at one time, allow users to have them on separate screens. Seems obvious, but some very popular apps (e.g. Visual Studio) fail miserably at this.</li>
<li>Remember the position of the last opened window, and open new windows on the same screen as before.... | <p>One thing to keep in mind is that the user may have more than two monitors. My main system has six monitors, and I've run 4+ monitors on Linux, Windows, and Mac OS. Many applications--even multi-monitor utilities--will support 2 monitors but freak out over more than 2.</p>
<p>Applications work best when they know... | 3,429 |
<p>I've been searching around for a Continuous Integration solution for Ruby on Rails, but haven't been too pleased with the results. I came from a .NET shop that used CruiseControl.NET and was really spoiled with its ease of use and rich status/reporting.</p>
<p>Ideally I'm looking for:</p>
<ul>
<li><p>The obvious ... | <p>I just went through the options here and thought I'd roll them up as of late 2011.</p>
<h2><a href="https://github.com/integrity/integrity" rel="noreferrer">Integrity</a></h2>
<p>After a <strong>near-death experience</strong> that left the still-linked-to <a href="http://integrityapp.com/" rel="noreferrer">website... | <p>I just published a very simple Continuous Integration App for RubyOnRails + SVN/GIT. Maybe you should give it a try:</p>
<p><a href="http://github.com/felipegiotto/Inotegration/tree/master" rel="nofollow noreferrer">http://github.com/felipegiotto/Inotegration/tree/master</a></p>
<p>I took some ideas of measurement... | 27,175 |
<p>What is their use if when you call the method, it might not exist?</p>
<p>Does that mean that you would be able to dynamically create a method on a dynamic object?</p>
<p>What are the practical use of this?</p>
| <p>You won't really be able to dynamically create the method - but you can get an implementation of <code>IDynamicMetaObject</code> (often by extending <code>DynamicObject</code>) to respond <em>as if the method existed</em>.</p>
<p>Uses:</p>
<ul>
<li>Programming against COM objects with a weak API (e.g. office)</li>... | <p>I see several dynamic ORM frameworks being written. Or heck write one yourself.</p>
<p>I agree with Jon Skeet, you might see some interesting ways of exploring objects.
Maybe with selectors like jQuery.</p>
<p>Calling COM and calling Dynamic Languages.</p>
<p>I'm looking forward to seeing if there is a way to do ... | 31,595 |
<p>I have a Panel and I am adding controls inside this panel. But there is a specific control that I would like to float. How would I go about doing that?</p>
<p>pnlOverheadDetails is the panel name</p>
<pre><code>pnlOverheadDetails.Controls.Add(lnkCalcOverhead);
</code></pre>
<p>The control named lnkCalcOverhead i... | <p>If you have a CSS class defined for the control, you could do this before calling the <code>Controls.Add</code> method:</p>
<pre><code>lnkCalcOverhead.CssClass = "MyClass";
</code></pre>
<p>If you want to use the style attribute directly, try this:</p>
<pre><code>lnkCalcOverhead.Style.Add("float", "left");
</code... | <p>IF you are talking about System.Windows.Forms here (and not WPF or ASP.NET):</p>
<p>When you are talking about float, do you mean you want to position it anywhere you want by code? If so, just set the .Location property of the control.</p>
<p>If you are talking about letting a control be moved around inside the pa... | 36,970 |
<p>Could someone compare and contrast on WCF Rest services vs. ADO.NET Data Services? What is the difference and when to use which?</p>
<p>Thanks,</p>
<p>Ray.</p>
<p><strong>Edit</strong>: thanks for the first answer, just to give a bit of background on what I'm looking to do: I have a web app I plan to put in the clou... | <p>Not sure I can give a complete answer here but I spent a lot of time at PDC trying to figure this out myself so here’s a go...</p>
<p>The short answer here is that ADO.Net Data Services are meant to provide an interface to the ADO.Net framework (DataContext, Datasets, DataTables etc…) that is seamlessly integrated ... | <p>WCF Data Services (previously known as ADO.NET Data Services),
<a href="http://msdn.microsoft.com/en-us/data/aa937697.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/data/aa937697.aspx</a></p>
| 43,389 |
<p>Is it possible to use a flash document embedded in HTML as a link?</p>
<p>I tried just wrapping the <code>object</code> element with an <code>a</code> like this:</p>
<pre><code><a href="http://whatever.com">
<object ...>
<embed ... />
</object>
</a>
</code></pre>
<p>I... | <p>Though the object really should respond to being wrapped in an a href tag, you could open the swf in vim and just throw in an <code>_root.onPress=function(){getURL("http://yes.no/");};</code> or if it's AS3, something like <code>_root.addEventHandler(MouseEvent.PRESS, function (e:event) {getURL("http://yes.no/");});... | <p>As an addition to dlamblin's answer it is often best to use the clickTAG technique to open URLS from a flash movie.</p>
<p>More information can be found here:</p>
<p><a href="http://www.adobe.com/resources/richmedia/tracking/designers_guide/" rel="nofollow noreferrer">http://www.adobe.com/resources/richmedia/track... | 5,350 |
<p>It seems that it is impossible to capture the keyboard event normally used for copy when running a Flex application in the browser or as an AIR app, presumably because the browser or OS is intercepting it first.</p>
<p>Is there a way to tell the browser or OS to let the event through?</p>
<p>For example, on an Adv... | <p>I did a test where I listened for key up events on the stage and noticed that (on my Mac) I could capture control-c, control-v, etc. just fine, but anything involving command (the key) wasn't captured until I released the command key, and then ctrlKey was false (even though the docs says that ctrlKey should be tru... | <p>Another incredibly annoying thing that I just realized is that ctrl-c can't be captured by <code>event.ctrlKey && event.keyCode = Keyboard.C</code> (or ...<code>event.charCode == 67</code>), instead you have to test for <code>charCode</code> or <code>keyCode</code> being <code>3</code>. It kind of makes sens... | 5,175 |
<p><a href="https://stackoverflow.com/users/9931/ryan-delucchi">Ryan Delucchi</a> asked <a href="https://stackoverflow.com/questions/194698/how-to-load-a-jar-file-at-runtime#194712">here</a> in comment #3 to <a href="https://stackoverflow.com/users/4725/tom-hawtin-tackline">Tom Hawtin</a>'s answer:</p>
<blockquote>
... | <p>The Java API documentation explains why (<a href="http://java.sun.com/javase/6/docs/api/java/lang/Class.html#newInstance()" rel="noreferrer">http://java.sun.com/javase/6/docs/api/java/lang/Class.html#newInstance()</a>):</p>
<blockquote>
<p>Note that this method propagates any exception thrown by the nullary const... | <p>I don't know why no one provided a simple example based explanation to this, as compared to <code>Constructor::newInstance</code> for example, since <em>finally</em> <code>Class::newInstance</code> was deprecated since java-9.</p>
<p>Suppose you have this very simple class (does not matter that it is broken):</p>
... | 23,725 |
<p>Say you have something like an ASP.NET ASP:DetailsView to show and edit a single record in a database.</p>
<p>It's simple to record the error cases... you add validation and a validation summary. When your update form fails validation it naturally makes noise: it shows the validation message and/or the validation ... | <p>As far as I know, there is no native way of doing this. You may rant about it, maybe Microsoft will hear it :).</p>
<p>Resetting the "success message" on Page_Load, or wherever in your code-behind, won't work. This is because ASP.NET validation is usually done both client and server-side. This means for every valid... | <p>Why not turn the validation message off in the Page_Load. I assume that if a post back occurs you'd want to get rid of the message so make sure it's always off. Or disable view state for the control by setting EnableViewState="False" in the markup (aspx page).</p>
<p>So:</p>
<pre><code>protected void ClearMessages... | 47,235 |
<p>Is there something special about Safari for Windows and AJAX?<br>
In other words: Are there some common pitfalls I should keep in mind?</p>
| <p>Safari is really standards compliant. Unless you're using some really esoteric browser features, in general if something works in Firefox, I've found it works without modification in Windows Safari.</p>
<p>Apple has <a href="http://developer.apple.com/internet/safari/" rel="nofollow noreferrer">a developer center ... | <p>One word of warning: Safari on Windows does not support XSLT.</p>
| 8,258 |
<p>I have used "traditional" version control systems to maintain source code repositories on past projects. I am starting a new project with a distributed team and I can see advantages to using a distributed system. Given that I understand SourceSafe, CVS, and Subversion; what suggestions do you have for a Git newbie?<... | <p>The <a href="http://git.or.cz/course/svn.html" rel="noreferrer">Git - SVN Crash Course</a> is a good read for getting going.</p>
| <p>I tried git in my company.
We used CVS and wanted to move to a better VC tool.
We have chosen git as a best tool for files versioning (Linus on GIT).
Its performance is just the best and it is a really great tools for a developer who understands version control in-depth but It is a nightmare for a regular developers... | 15,429 |
<p>I've been trying to solve this, and have been getting stuck, so I thought I'd ask.</p>
<p>Imagine two ActionBeans, A and B.</p>
<p><code>A.jsp</code> has this section in it:</p>
<pre><code>...
<jsp:include page="/B.action">
<jsp:param name="ponies" value="on"/>
</jsp:include>
<jsp:include p... | <p><a href="http://jqueryui.com/demos/slider/" rel="noreferrer">jQuery UI Slider</a> (<a href="http://docs.jquery.com/UI/Slider" rel="noreferrer">API docs</a>)</p>
| <p>The code below should be enough to get you started. Tested in Opera, IE and Chrome.</p>
<pre><code><script>
var l=0;
function f(i){
im = 'i' + l;
d=document.all[im];
d.height=99;
document.all.f1.t1.value=i;
im = 'i' + i;
d=document.all[im];
d.height=1;
l=i;
}
</script>
<center>
<form id='f1'>... | 20,851 |
<p>on some Windows PC, when I have both easyPHP and a standalone apache service configured on another network port and with a specific service name, I have a problem : when I stop easyphp, the other apache is stopped too.</p>
<p>The problem do not occur on all PC I have, but seems very strange to me.
Any idea?</p>
<p... | <p>Maybe how it's killing it is that it's finding all processes called "apache" or similar and just killing them, regardless of if it 'owns' it or not.</p>
| <p>i think Both are integrated together, i was not occur in all PC because of port number.</p>
| 11,638 |
<p>I need to update a record in a database with the following fields </p>
<pre><code>[ID] int (AutoIncr. PK)
[ScorerID] int
[Score] int
[DateCreated] smalldatetime
</code></pre>
<p>If a record exists for todays date (only the date portion should be checked, not the time) and a given scorer, I'd like to update the sco... | <pre><code>IF EXISTS (SELECT NULL FROM MyTable WHERE ScorerID = @Blah AND CONVERT(VARCHAR, DateCreated, 101) = CONVERT(VARCHAR, GETDATE(), 101))
UPDATE MyTable SET blah blah blah
ELSE
INSERT INTO MyTable blah blah blah
</code></pre>
| <pre><code>CREATE PROCEDURE InsertOrUpdateScorer(@ScorerID INT, @Score INT)
AS
BEGIN
IF EXISTS (
SELECT 1
FROM Scorer
WHERE ScorerID = @ScorerID AND DATEDIFF(dd, GETDATE(), DateCreated) = 0
)
BEGIN
UPDATE
Scorer
SET
Score = @Score
WHERE
ScorerID = @ScorerID
RETURN... | 44,223 |
<p>How can I consistently get the absolute, fully-qualified root or base url of the site regardless of whether the site is in a virtual directory and regardless of where my code is in the directory structure? I've tried every variable and function I can think of and haven't found a good way.</p>
<p>I want to be able t... | <p>In reading through the answer provided in Rick Strahl's Blog I found what I really needed was quite simple. First you need to determine the relative path (which for me was the easy part), and pass that into the function defined below:</p>
<p>VB.NET</p>
<pre><code>Public Shared Function GetFullyQualifiedURL(ByVal s... | <p>Have you tried AppSettings.RootUrl which is usually configured in the web.config file?</p>
| 14,829 |
<p>We have a 50 projects solution in VS 2005. </p>
<p>Is any way to get incremental build if nothing was changed? </p>
<p>It is kind of doing it now, but it executes all prebuild and post build events for each project. </p>
<p>The compiling itself is not happenning, but it iterates through all projects and exec... | <p><a href="https://stackoverflow.com/questions/227991/build-incrementally-in-vs-2005#231867">See my answer in the other question</a>.</p>
| <p>You could setup a separate project config, like Debug_INC, and no pre or post build events in those configs, then just run them when needed.</p>
| 28,678 |
<p>I am looking to create a search engine that will be based on 5 columns in a SQL 2000 DB. I have looked into Lucene.NET and read the documentation on it, but wondering if anyone has any previous experience with this?</p>
<p>Thanks</p>
| <p>IMHO it's not so much about performance, but about maintainability. In order to index your content using Lucene.NET you'll have to create some mechanism (service of triggered) which will add new rows (and remove deleted rows) from the Lucene index. </p>
<p>From a beginner's perspective I think it's probably easier ... | <p>i haven't dealt with Lucene yet but a friend of mine has and he said that their performance was 4 to 5 times better with lucene than full text indexing.</p>
| 43,545 |
<p>I have to work on several VB6 legacy projects and despite some good VB6 plugins (CodeSMART for example) I hate the IDE more and more, especially now where I have the opportunity to work with Java/Netbeans on a new project. Unfortunatly it will stay that way at least the next few years.</p>
<p>So I'm asking myself: ... | <p>I did a quick search to see if there is an available plugin to support Visual Basic on Netbeans, but was not able to find any.</p>
<p>As you've mentioned that you are willing to write VB support for Netbeans, you may want to take a look at <a href="http://www.netbeans.org/community/magazine/html/03/schliemann/" rel... | <p>No. Netbeans is primarily a Java IDE. Although it supports a lot of languages besides Java, there is no much interested for VB6 in the Java community.</p>
| 40,517 |
<p>I'd really like to handle this without monkey-patching but I haven't been able to find another option yet.</p>
<p>I have an array (in Ruby) that I need to sort by multiple conditions. I know how to use the sort method and I've used the trick on sorting using an array of options to sort by multiple conditions. How... | <p>How about:</p>
<pre>
<code>
ordered_list = [[1, "b"], [1, "a"], [2, "a"]]
ordered_list.sort! do |a,b|
[a[0],b[1]] <=> [b[0], a[1]]
end
</code>
</pre>
| <p>I had this same basic problem, and solved it by adding this:</p>
<pre><code>class Inverter
attr_reader :o
def initialize(o)
@o = o
end
def <=>(other)
if @o.is && other.o.is
-(@o <=> other.o)
else
@o <=> other.o
end
end
end
</code></pre>
<p>This is a... | 9,867 |
<p>Imagine this directory structure:</p>
<pre><code>app/
__init__.py
sub1/
__init__.py
mod1.py
sub2/
__init__.py
mod2.py
</code></pre>
<p>I'm coding <code>mod1</code>, and I need to import something from <code>mod2</code>. How should I do it? </p>
<p>I tried <code>from ..sub2 import... | <p>Everyone seems to want to tell you what you should be doing rather than just answering the question.</p>
<p>The problem is that you're running the module as '__main__' by passing the mod1.py as an argument to the interpreter.</p>
<p>From <a href="http://www.python.org/dev/peps/pep-0328/" rel="noreferrer">PEP 328</... | <p>This method queries and auto populates the path:</p>
<pre class="lang-py prettyprint-override"><code>import os
import inspect
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
os.sys.path.insert(1, parentdir)
# print("currentdir = &quo... | 9,845 |
<p>Is there an elegantish way in Swing to find out if there are any tooltips currently being displayed in my frame?</p>
<p>I'm using custom tooltips, so it would be very easy to set a flag in my <code>createToolTip()</code> method, but I can't see a way to find out when the tooltip is gone.</p>
<p><code>ToolTipManage... | <p>It appears that the isEnabled() property of the hideTipAction is directly tied to the tipShowing boolean. You could try this:</p>
<pre><code>public boolean isTooltipShowing(JComponent component) {
AbstractAction hideTipAction = (AbstractAction) component.getActionMap().get("hideTip");
return hideTipAction.... | <p>It looks like that is going to require looping over all of the components to see if they have a tooltip. I'm looking for a global value. It may be that a loop is doable, but it seems inefficient.</p>
| 42,949 |
<p>I have a PHP script that can encode a PNG image to a Base64 string.</p>
<p>I'd like to do the same thing using JavaScript. I know how to open files, but I'm not sure how to do the encoding. I'm not used to working with binary data.</p>
| <p>You can use <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/btoa" rel="noreferrer"><code>btoa()</code></a> and <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/atob" rel="noreferrer"><code>atob()</code></a> to convert to and from base64 encoding.... | <p><strong>Incase anyone wants to encode a string to base64 in Typescript</strong></p>
<p>I tweaked <a href="https://stackoverflow.com/a/26514148/8885582">Peter Mortensen's answer</a> and added types ( where needed )</p>
<pre><code>const Base64 = {
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01... | 30,637 |
<p>With SQL Server 2005 and transactional replication, can I remove the primary key constraints on the subscriber, while leaving the primary key constraints on the publisher?</p>
<p>Primary I want to do this because I want to cluster on different columns than the existing clustered constraints. I don't think I can co... | <p>Why don't you leave the primary key and create additional non clustered indexes on the subscriber or will this not resolve your problem? If the reason to have other columns indexed on the subscriber is performance then this should be a solution. </p>
| <p>I did my own homework, and came to the conclusion that you <em>can</em> drop the constraints on the subscriber.</p>
<p>I set up a simple transactional replication scenario, dropped the primary key on the subscriber, and then did some inserts, deletes and updates, and verified that the changes were replicated to the... | 44,065 |
<p>I have the following xml that's sent to me from a web service. I'm using .NET to deserialize it, but I'm getting an exception saying that its formatted wrong. <code>There is an error in XML document (2, 2)</code> Now, if I understand that correctly, it's not liking that it's finding the first <code><error></... | <p>This class works for me:</p>
<pre><code><XmlRoot(Namespace:="http://www.w3.org/1999/xml", ElementName:="messages")> _
Public Class cResponseMessage
<XmlElement> _
Public Property [error] As String
Get
Set(ByVal value As String)
End Property
<XmlElement> _
Publ... | <p>There is an error in XML document (2, 2) looks to me like it would be the m in <messages>.</p>
<p>Perhaps you don't have your XmlRoot set up correctly in cResponseMessage?</p>
| 39,000 |
<p>What is the best way to write bytes in the middle of a file using Java?</p>
| <p>Reading and Writing in the middle of a file is as simple as using a <a href="http://java.sun.com/javase/6/docs/api/java/io/RandomAccessFile.html" rel="noreferrer"><code>RandomAccessFile</code></a> in Java.</p>
<p><a href="http://java.sun.com/javase/6/docs/api/java/io/RandomAccessFile.html" rel="noreferrer"><code>Ra... | <p>Open the file in write mode without truncating it, seek to the desired offset, and write the desired data. Just be careful about text/binary mode.</p>
| 21,896 |
<p>I'm using caml query to select all documents which were modified or added by user. Query runs recursively on all subsites of specified site collection.</p>
<p>Now problem is I can't get rid of folders which are also part of result set. For now I'm filtering them from result datatable. But I'm wondering: Is it possi... | <p>This CAML actually does the trick:</p>
<pre><code><Where>
<Eq>
<FieldRef Name='FSObjType' />
<Value Type='Integer'>0</Value>
</Eq>
</Where>
</code></pre>
<p>that will not give you any folders.</p>
| <p>This is what worked for me</p>
<pre><code> <Where>
<Eq>
<FieldRef Name='FSObjType' />
<Value Type='Number'>1</Value>
</Eq>
</Where>
</code></pre>
| 43,204 |
<p>What would be the best way to fill an array from user input?</p>
<p>Would a solution be showing a prompt message and then get the values from from the user?</p>
| <pre><code>string []answer = new string[10];
for(int i = 0;i<answer.length;i++)
{
answer[i]= Console.ReadLine();
}
</code></pre>
| <p>Add the input values to a List and when you are done use List.ToArray() to get an array with the values.</p>
| 28,531 |
<p>Is there anything in the header of an HTTP request that would allow me to differentiate between an AJAX call and a direct browser request from a given client? Are the user agent strings usually the same regardless?</p>
| <p>If you use Prototype, jQuery, Mootools or YUI you should find a <strong>X-Requested-With:XMLHttpRequest</strong> header which will do the trick for you. It should be possible to insert whatever header you like with other libraries.</p>
<p>At the lowest level, given a <a href="http://www.w3.org/TR/XMLHttpRequest" re... | <p>After some research, it looks like the best approach would be to simply specify a custom user agent string when making AJAX calls and then checking for this custom user agent string on the server.</p>
| 26,577 |
<p>I am a C# developer. Still learning. I had not learn all the features of C# 2.0 and now the new version of c# is being released. how do we cope up with this.what is the best option to cope up with the latest programming skills.</p>
| <p>As Steve M said: Read. But don't stop there. You also have to write. </p>
<p>First: Write Code. Try out the stuff you read about. Look at open source software and how things are done by others. Try those new techniques out.</p>
<p>Second: Write text. Write a blog post or whatever on how to do something. You had a ... | <p>Read, read and when you're done reading, read some more. Reading also helps.</p>
<p>But seriously, sign up to relevant mailing lists and RSS feeds so that you can be updated as things happen.</p>
| 14,578 |
<p>I've got an application that is very graphics intensive and built on DirectX and Windows Forms. It has an automation and replay framework around which is built an automated testing system. Unfortunately, when the tests run unattended during a nightly build, the display is inactive or tied up with the screensaver, an... | <p>Since you're mentioned rendering pipeline, so I'm assuming you're using Direct3d, if so, you can save the backbuffer of the frame. I did that when I was still using VB.Net + MDX</p>
<pre><code>Dim tempSurface As Direct3D.Surface
tempSurface = device.GetBackBuffer(0, 0, Direct3D.BackBufferType.Mono)
Direct3D.Surface... | <p>Install a VM and run the application in that. If you're running a screen saver I doubt your video card is even generating the GUI for the application.</p>
| 22,138 |
<p>I am trying to figure out the best way to model a spreadsheet (from the database point of view), taking into account :</p>
<ul>
<li>The spreadsheet can contain a variable number of rows.</li>
<li>The spreadsheet can contain a variable number of columns.</li>
<li>Each column can contain one single value, but its typ... | <p>You may want to study EAV (Entity-attribute-value) data models, as they are trying to solve a similar problem.</p>
<p><a href="http://en.wikipedia.org/wiki/Entity-Attribute-Value_model" rel="nofollow noreferrer">Entity-Attribute-Value - Wikipedia</a></p>
| <p>That is a good question that calls for many answers, depending how you approach it, I'd love to share an opinion with you.
This topic is one the various we searched about at Zenkit, we even wrote an article about, we'd love your opinion on it: <a href="https://zenkit.com/en/blog/spreadsheets-vs-databases/" rel="nofo... | 29,471 |
<p>I am trying to write a C# client to a server that is written in Java. The server expects a 4 byte (DataInputStread readInt() in Java) message header followed by the actual message.</p>
<p>I am absolutely new to C#, how can I send this message header over to the Java Server? I tried it several ways (mostly trial and... | <p>It is, as other posters have pointed out, down to endianness.</p>
<p>The Java <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/DataInputStream.html" rel="noreferrer">DataInputStream</a> expects the data to be <a href="http://en.wikipedia.org/wiki/Endianness" rel="noreferrer">big-endian</a> (network byte ord... | <p>I dont know C# but you just need to do the equivalent of this:</p>
<pre><code>out.write((len >>> 24) & 0xFF);
out.write((len >>> 16) & 0xFF);
out.write((len >>> 8) & 0xFF);
out.write((len >>> 0) & 0xFF);
</code></pre>
| 11,772 |
<p>All,</p>
<p>So I've got all my select queries in LINQ-to-SQL converted to using CompiledQueries to speed things up. Works great so far for select statements, but I haven't been able to figure out how to pre-compile insert, update, or delete statements.</p>
<p>Granted, when you're inserting, deleting or updating i... | <p>There is a big difference. Linq-To-SQL select queries can be large complex expressions trees. Its these that may take sometime 'compiling'. In this case coalescing to some T-SQL that can be run against a SQL Server. So it makes sense to cache the result of an operation so that it can be re-used.</p>
<p>However ... | <p>L2S uses "sp_executeSQL" so after you run it the first time it will be in the stored procedure execution plan cache. Subsequent runs (of the same query - not same params) will reuse the compiled plan from the cache. So what you are asking for is automagically handled by SQL Server 'behind the scenes'.</p>
| 46,148 |
<p>I've been struggling with this check constraint for a few hours and was hoping someone would be kind enough to explain why this check constraint isn't doing what I think it should be doing.</p>
<pre><code>ALTER TABLE CLIENTS
add CONSTRAINT CHK_DISABILITY_INCOME_TYPE_ID CHECK ((IS_DISABLED IS NULL AND DISABILITY_INC... | <p>While I do not have Oracle, I did a quick test with PostgreSQL and your first example (<code>IS_DISABLED</code> being <code>NULL</code> and <code>DISABILITY_INCOME_TYPE_ID</code> being 1):</p>
<pre><code>postgres=> select (null is null and 1 is null);
?column?
----------
f
(1 registro)
postgres=> select (n... | <p>This solution works.</p>
<pre><code>CHECK
((IS_DISABLED IS NULL AND NVL(DISABILITY_INCOME_TYPE_ID, 0) = 0)
OR (IS_DISABLED = 0 AND NVL(DISABILITY_INCOME_TYPE_ID, 0) = 0)
OR (IS_DISABLED IS NOT NULL AND IS_DISABLED = 1));
</code></pre>
| 37,177 |
<p>I have made some changes to a site and need to re-host it as the current host is ceasing to exist. My client has received the following from the current host:</p>
<p>"The best thing to tell them is that, due to the fact that we are withdrawing our service completely, we would look to fully transfer the web site ad... | <p>an IPSTAG is a .uk only designation of the domain's registrar. basically, the webhost is asking you to transfer the domain name registration away from them to a new provider.</p>
<p>i would suggest you (or your client) find a new registrar, get their IPSTAG, and then send that to your old host, who will then be abl... | <p>A quick Google search turns up </p>
<blockquote>
<p>Each Domain Name registration agent is identified by a unique IPSTAG assigned by the UK Governing body for UK Domain Names, Nominet. If you want to move a UK domain name to another Internet Service Provider, you will need to know the Tag Name of your new ISP.</p... | 38,971 |
<p>I am trying to link to a file that has the '#' character in via a window.open() call. The file does exist and can be linked to just fine using a normal anchor tag.</p>
<p>I have tried escaping the '#' character with '%23' but when the window.open(myurl) gets processed, the '%23' becomes '%2523'. This tells me tha... | <p>You seek the dark magicks of <a href="http://www.w3schools.com/jsref/jsref_encodeURI.asp" rel="nofollow noreferrer">encodeURI</a>:</p>
<pre><code>window.open("http://your-url.com/" + encodeURIComponent("foo#123.jpg"));
</code></pre>
| <p>Did you try using the standard text escape char "\"?</p>
<pre><code>\#
</code></pre>
| 28,961 |
<p>Something i've never really done before, but what is the best way to make sure that any external assemblies/dll's that my application uses are available, and possibly the correct version.</p>
<p>I wrote an app that relies on the System.Data.SQLite.dll, i went to test it on a machine where that dll was missing, and ... | <p>What you want to do is use reflection to check and see if the assembly can be loaded into memory. Wrap that up in a try..catch block and handle any of the specific exceptions that come from it.</p>
<pre><code>Try
Assembly.Load("System.Data.SQLite, Version=1.0.22.0, Culture=neutral, PublicKeyToken=DB937BC2D44FF1... | <p>You should trap the error outside of your main loop.<br>
Or if you want to ship/locate your own assemblies you can try overriding the assembly probing: <a href="https://blogs.msdn.com/junfeng/archive/2006/03/27/561775.aspx" rel="nofollow noreferrer">Link</a>.</p>
| 13,371 |
<p>I'm looking for a good JavaScript RegEx to convert names to proper cases. For example:</p>
<pre><code>John SMITH = John Smith
Mary O'SMITH = Mary O'Smith
E.t MCHYPHEN-SMITH = E.T McHyphen-Smith
John Middlename SMITH = John Middlename SMITH
</code></pre>
<p>Well you get the idea.</p>
<p>Anyone come up with a... | <p>Something like this?</p>
<pre><code>function fix_name(name) {
var replacer = function (whole,prefix,word) {
ret = [];
if (prefix) {
ret.push(prefix.charAt(0).toUpperCase());
ret.push(prefix.substr(1).toLowerCase());
}
ret.push(word.charAt(0).toUpperCase())... | <p>Unfortunately there are too many different name formats to do this correctly. John-Joe MacDonald is always going to be a nuisance!</p>
| 31,198 |
<p>I have several properties that are dependent on the environment the application is running. For example, there are links to another application that is being developed concurrantly that get displayed in the header and footer. I want those links to be different depending on what environment they are in. </p>
<p>This... | <p>You can go with a custom config file. Check out <a href="https://stackoverflow.com/questions/110078/what-is-the-best-way-to-store-app-specific-configuration-in-rails#110834">this thread</a>.</p>
| <p>Running in production mode on UAT is definitely correct, you want that to work as closely to production as possible.</p>
<p>I assume the test server is not a server where you run CI on the project test suite but more some kind of integration server where people from inside the team can test new features before the ... | 14,854 |
<p>Hi i would to know how to se up a svn server? Now, i'm using VisualSVN a TortoiseSVN, but i don't know what are the directories "branch" "trunk" "tags".
Can anyone explain me how it works?
I read the svn book and many sites articles about it but i don't understand.</p>
| <p>How to setup a SVN server is a very different question than what "branch", "trunk" and "tags" are used for.</p>
<p>A SVN server can be setup using a lot of different methods: Apache (with dav_svn), svnserve over SSH or countless others.</p>
<p>Take a look at the <a href="http://svnbook.red-bean.com/en/1.5/svn.serv... | <p>I am a little uncertain whether your question concerns setting up an SVN server or whether you are more concerned with the structure of your project's evolution (setting up your trunk and various branches).</p>
<p>However, consider the possibility that you might <em>not</em> want to expend the time and energy neede... | 46,871 |
<p>Convert.ToString() only allows base values of 2, 8, 10, and 16 for some odd reason; is there some obscure way of providing any base between 2 and 16?</p>
| <p>Probably to eliminate someone typing a 7 instead of an 8, since the uses for arbitrary bases are few (But not non-existent).</p>
<p>Here is an example method that can do arbitrary base conversions. You can use it if you like, no restrictions.</p>
<pre><code>string ConvertToBase(int value, int toBase)
{
if (to... | <pre><code>string foo = Convert.ToString(myint,base);
</code></pre>
<p><a href="http://msdn.microsoft.com/en-us/library/14kwkz77.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/14kwkz77.aspx</a></p>
<p><strong>EDIT</strong>: My bad, this will throw an argument exception unless you pass in the ... | 12,073 |
<p>I'm trying to create a map application similar to <a href="http://flashden.net/item/zoom-pan-controls-with-dynamic-image-settings/15713" rel="nofollow noreferrer">this</a>. Click the SWF Preview tab on the left of the image. Specifically, noticed how you can pan around, and the clickable buttons on the map move with... | <p>Simple. Put your map <strong>and</strong> the clickable buttons into a new MovieClip, you could call it <em>interactiveMapContainer</em> or something similar, then call your startDrag method on <em>interactiveMapContainer</em> and you'll still be able to click the buttons once you've dragged it about.</p>
<p>Jakub ... | <p>can you add the movieclips to a parent clip and have the event handler drag the parent?</p>
| 13,004 |
<p>One for the mathematicians. This has gone around the office and we want to see who can come up with a better optimised version.</p>
<pre><code>(((a+p) <= b) && (a == 0 || a > 1) && (b >= p)) &&
((b - (a + p) == 0) || (b - (a + p) > 1))
</code></pre>
<p><strong>Edit</strong>: ... | <pre><code>(a + p <= b) && (a != 1) && (b - a - p != 1);
</code></pre>
| <pre><code>(((a+p) <= b) && (a == 0 || a > 1) && (b >= p)) && ((b - (a + p) == 0) || (b - (a + p) > 1))
</code></pre>
<p>since a >=0 (positive integers), the term (a == 0 || a > 1) is always true</p>
<p>if ((a+p) <= b) then (b >= p) is true when a,b,p are >=0</p>
<p>therefore (... | 49,913 |
<pre><code>void some_func(int param = get_default_param_value());
</code></pre>
| <p>Default parameter can be a subset of the full set of expressions. It must be bound at compile time and at the place of declaration of the default parameter. This means that it can be a function call or a static method call, and it can take any number of arguments as far as they are constants and/or global variables ... | <p><code>David Rodríguez - dribeas</code> answear is great, but doesn't provide a solution.<br>
It may look like there is no solution.</p>
<p>Solution is quite simple: repalce default parameter with <strong>function/method overload</strong>.</p>
<pre><code>void some_func(int param);
void some_func() {
some_func(g... | 43,431 |
<p>I've got a button that I'm adding as a subview of a table view's tableHeaderView. The button appears fine, and tap-and-holding on it works intermittently - for the most part, though, it's unresponsive. I've tried adding it as a subview of the table itself; the effect is about the same. I thought the problem might be... | <p>I had the same problem. In my case I had a container view instantiated in IB (that was applied as the table view header in code), with a UIImageView occupying the entire frame of that container. The misbehaving button resided in the image view.</p>
<p>Turns out I needed to have sizing struts in IB set as follows...... | <p>You should consider that this is not the intended sue of the headerView and that an implementation such as that might result in rejection from the AppStore as a result of a HIG violation. Given that the dimensions of a header are intended to be small, it is probably better to consider a restructuring of your view. ... | 38,033 |
<p>What's the difference between</p>
<pre><code>var A = function () {
this.x = function () {
//do something
};
};
</code></pre>
<p>and</p>
<pre><code>var A = function () { };
A.prototype.x = function () {
//do something
};
</code></pre>
| <p>The examples have very different outcomes.</p>
<p>Before looking at the differences, the following should be noted:</p>
<ul>
<li>A constructor's <em>prototype</em> provides a way to share methods and values among instances via the instance's private <code>[[Prototype]]</code> property.</li>
<li>A function's <em>th... | <p>When you use prototype, the function will only be loaded only once into memory (independently on the amount of objects you create) and you can override the function whenever you want.</p>
| 40,061 |
<p>I have a RDLC report which has a table, calling a subreport N times. This works perfectly in the control viewer and when I export to PDF. Yet when I export to Excel, I get the following error:</p>
<blockquote>
<p>Subreports within table/matrix cells
are ignored.</p>
</blockquote>
<p>Does anyone know why this... | <p>See MSDN forum link below...looks like this is not supported in 2000/2005, but there also seem to be some kludgey workarounds (nested lists). A Microsoft moderator claims that reporting services 2008 will export everything.</p>
<p><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1520229&SiteID=1"... | <p>Drop the table control from rdlc and Put your main report data into matrix control and put your sub reports below to maix control.
Run your report and export again.It will be solved.</p>
| 15,721 |
<p>I'm using <code>Microsoft's DSOFramer</code> control to allow me to embed an Excel file in my dialog so the user can choose his sheet, then select his range of cells; it's used with an import button on my dialog.</p>
<p>The problem is that when I call the <code>DSOFramer's OPEN</code> function, if I have Excel open... | <pre><code>C-u M-! date
</code></pre>
| <p>Here's my take on it. </p>
<pre class="lang-el prettyprint-override"><code>(defun modi/insert-time-stamp (option)
"Insert date, time, user name - DWIM.
If the point is NOT in a comment/string, the time stamp is inserted prefixed
with `comment-start' characters.
If the point is IN a comment/string, the time stam... | 31,387 |
<p>I've always been mystified how software vendors can ship their application or game, and then later provide a different set of executables that change the behaviors of the previous build. How is this done? Do the original application and the patch have to adhere to some kind of rule? Or does the patch crawl into the ... | <p>There are two main methods I have seen. Many programs are composed of a number of smaller parts that are dynamically loaded at runtime, often these files are simply replaced with newer versions. Since updates often only affect a relatively small number of these files the patch may be a small subset of the entire a... | <p>I suspect that most of the time, "patches" are just some replacement files.</p>
<p>It is, however, possible to compare two binary files, determine their differences, and create a set of edit commands that will change one into the other. The Unix utility "diff" can do this for text files, for example.</p>
| 29,375 |
<p><b>Executive Summary:</b> When assertion errors are thrown in the threads, the unit test doesn't die. This makes sense, since one thread shouldn't be allowed to crash another thread. The question is how do I either 1) make the whole test fail when the first of the helper threads crashes or 2) loop through and determ... | <p>Concurrency is one of those things that are very difficult to unit test. If you are just trying to test that the code inside each thread is doing what it is supposed to test, may be you should just test this code isolated of the context.
If in this example the threads collaborate to reach a result, may be you can ... | <p>Another popular option for Junit concurrent thread testing is Matthieu Carbou's method using a custom JunitRunner and a simple annotation.</p>
<p><a href="http://www.junit.org/node/589" rel="nofollow">See the full documentation</a></p>
| 40,595 |
<p>I am building an enclosure for an Ender 3 Pro printer, and am planning on the power supply and LCD unit being outside the enclosure. How important is it to move the printer controller (where the SD card is inserted) outside the enclosure?
Would leaving it in place affect its longevity?</p>
<p>Answers to the first r... | <p>It depends on what kinds of prints you make, and especially what kind of materials you want to use.</p>
<p>Certain materials (ABS especially, but also PETG to some degree) will print <em>much better</em> if the entire build area, which usually includes the printer chassis and controls, is enclosed to protect from dr... | <p>This guy placed the whole Ender in a 100C environment but he emphasises how important it is to leave the electronics cool:</p>
<p><div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/79r5D9nCQfM?start=1216"></iframe>
</div></div></p>
| 1,716 |
<p>Is it possible to reach the individual columns of table2 using HQL with a configuration like this?</p>
<pre><code><hibernate-mapping>
<class table="table1">
<set name="table2" table="table2" lazy="true" cascade="all">
<key column="result_id"/>
<many-to-many column="group... | <p>They're just properties of table1's table2 property.</p>
<pre><code>select t1.table2.property1, t1.table2.property2, ... from table1 as t1
</code></pre>
<p>You might have to join, like so</p>
<pre><code>select t2.property1, t2.property2, ...
from table1 as t1
inner join t1.table2 as t2
</code></pre>
<p>... | <p>Let's say table2 has a column "<code>color varchar(128)</code>" and this column is properly mapped to Hibernate.</p>
<p>You should be able to do something like this:</p>
<pre><code>from table1 where table2.color = 'red'
</code></pre>
<p>This will return all <code>table1</code> rows that are linked to a <code>tabl... | 10,086 |
<p>We have a few projects that involve building an application that is composed of maybe 50% custom functionality, but then pulls in, say, a wiki, a forum, and other components that are "wheels" that have already been invented that we do not wish to re-write from scratch.</p>
<p>These third-party applications usually ... | <p>Make sure that the interface between your application and the third-party application or library is such that you can replace it easily with something else just in case. In some cases the third-party software may just be an implementation of an standard API (Java does this a lot with JDBC, JMS, JNDI, ...). In othe... | <p>Donald Knuth said that even better then reusable code is modifiable code, so if there is no API, you should seek for an open source app that is written well and therefore possible to customize. </p>
<p>As for databases and login systems and other programming parts (i don't see how e.g. theming could benefit), you c... | 7,074 |
<p>I'm trying to create a function which takes an array as an argument, adds values to it (increasing its size if necessary) and returns the count of items.
So far I have:</p>
<pre><code>int main(int argc, char** argv) {
int mSize = 10;
ent a[mSize];
int n;
n = addValues(a,mSize);
for(i=0;i<n;i... | <p>The main problem here is that you're trying to use realloc with a stack-allocated array. You have:</p>
<pre><code>ent a[mSize];
</code></pre>
<p>That's automatic allocation on the stack. If you wanted to use realloc() on this later, you would create the array on the heap using malloc(), like this:</p>
<pre><cod... | <p>Xahtep explains how your caller can deal with the fact that realloc() might move the array to a new location. As long as you do this, you should be fine.</p>
<p>realloc() might get expensive if you start working with large arrays. That's when it's time to start thinking of using other data structures -- a linked li... | 44,355 |
<p>Unquestionably, I would choose to use the STL for most C++ programming projects. The question was presented to me recently however, "Are there any cases where you wouldn't use the STL?"...</p>
<p>The more I thought about it, the more I realized that perhaps there SHOULD be cases where I choose not to use the STL...... | <p>The main reasons not to use STL are that:</p>
<ol>
<li>Your C++ implementation is old and has horrible template support.</li>
<li>You can't use dynamic memory allocation.</li>
</ol>
<p>Both are very uncommon requirements in practice.</p>
<p>For a longterm project rolling your own containers that overlap in functi... | <p>I started programming C back in about 1984 or so and have never used the STL. Over the years I have rolled my own function librarys and they have evolved and grown when the STL was not stable yet and or lacked cross platform support. My common library has grown to include code by others ( mostly things like libjpeg,... | 21,028 |
<p>I have some controller methods I'd like to share. What is the best practice for doing this in ruby on rails? Should I create an abstract class that my controllers extend, or should I create module and add it in to each controller? Below are the controller methods I want to share:</p>
<pre><code>def driving_directio... | <p>In my opinion, normal OO design principles apply:</p>
<ul>
<li>If the code is really a set of utilities that doesn't need access to object state, I would consider putting it in a module to be called separately. For instance, if the code is all mapping utilities, create a module <code>Maps</code>, and access the me... | <p>Another possibility:</p>
<p>If your common code needs state and you want to share the behavior amongst controllers, you could put it in a plain old ruby class in either your <code>model</code> or <code>lib</code> directory. Remember that <code>model</code> classes don't have to be persistent even though all ActiveR... | 15,629 |
<p>Can anyone provide a clear explanation / example of what these functions do, and when it's appropriate to use them?</p>
| <p>Straight from <a href="http://www.postgresql.org/docs/8.3/static/ddl-constraints.html#DDL-CONSTRAINTS-FK" rel="noreferrer">the manual</a>...</p>
<blockquote>
<p>We know that the foreign keys disallow creation of orders that do not relate to any products. But what if a product is removed after an order is created ... | <p>I have a PostGreSQL database and I use On Delete when I have a user that I delete from the database and I need to delete it's information from other table. This ways I need to do only 1 delete and FK that has ON delete will delete information from other table.</p>
<p>You can do the same with ON Update. If you updat... | 27,924 |
<p>I have a Monthly Status database view I need to build a report based on. The data in the view looks something like this:</p>
<pre><code>Category | Revenue | Yearh | Month
Bikes 10 000 2008 1
Bikes 12 000 2008 2
Bikes 12 000 2008 3
Bikes 15 000 2008 ... | <p>The Case Statement is my best sql friend. You also need a table for time to generate your 0 rev in both months.</p>
<p>Assumptions are based on the availability of following tables:</p>
<blockquote>
<p>sales: Category | Revenue | Yearh |
Month</p>
</blockquote>
<p>and</p>
<blockquote>
<p>tm: Year | Mon... | <p>Using pivot and Dynamic Sql we can achieve this result</p>
<pre><code>SET NOCOUNT ON
IF OBJECT_ID('TEMPDB..#TEMP') IS NOT NULL
DROP TABLE #TEMP
;With cte(Category , Revenue , Yearh , [Month])
AS
(
SELECT 'Bikes', 10000, 2008,1 UNION ALL
SELECT 'Bikes', 12000, 2008,2 UNION ALL
SELECT 'Bikes', 12000, 2008,3 UNIO... | 3,790 |
<p>Is it possible to get a list of events (with recurring events expanded) out of Sharepoint's Calendar using the Web Service exposed through Lists.aspx?</p>
<p>This is evidently possible if you are using C# or VB, as described <a href="http://blogs.msdn.com/sharepoint/archive/2007/05/14/understanding-the-sharepoint-c... | <p>Finally got this to work correctly and return all recurrent events on a SharePoint Calendar. Here is the XML for the Web Service Query:</p>
<pre><code><GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
<listName>{your GUID goes here}</listName>
<query>
<Query>
<... | <p>Nope is not possible. You would need to use the SP Object model via, for example the SPQuery object. But that would mean that you would have to run that code directly on the sharepoint server, instead of calling in from a client.</p>
<p>Please see this post of mine; <a href="http://social.msdn.microsoft.com/Forums/... | 49,231 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.