instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I'd like to use visitor IP addresses into a company name. This will be used for displaying something like "Hello visitor from <strong>Apple Inc.</strong>" . Note I am looking for the company name, not the domain name. Extra points for determining the originating country. The app is written in Ruby on Rails, but exam...
<p>There are databases for this kind of thing, but they are hardly 100% accurate, so I'd think long and hard before using them to make assumptions regarding content you present to your visitors. If you still want to do it, here are two companies that offer databases that include organization level detail:</p> <p><a hr...
<p>You're very likely to get this more wrong than right, but you can get this from a whois client.</p> <p>For example, to see owners of US addresses (at least), you can whois from the CLI to play around:</p> <pre><code>whois -h whois.arin.net 17.18.19.20 </code></pre>
42,093
<p>I would like to automatically increment a field named `incrementID' anytime any field in any row within the table named 'tb_users' is updated. Currently I am doing it via the sql update statement. i.e "UPDATE tb_users SET name = @name, incrementID = incrementID + 1 .....WHERE id = @id;</p> <p>I'm wondering how I ca...
<p>This trigger should do the trick:</p> <pre><code>create trigger update_increment for update as if not update(incrementID) UPDATE tb_users SET incrementID = incrementID + 1 from inserted WHERE tb_users.id = inserted.id </code></pre>
<p>You could use a trigger for this (if I've read you correctly and you want the value incremented each time you update the row).</p>
11,703
<p>This may or may not be a multi-interface problem, but I'm doing something like this:</p> <pre><code>var mockInterface1 = new Mock&lt;IInterface1&gt;(); var mockInterface2 = mockInterface1.As&lt;IInterface2&gt;(); mockInterface1.Expect( foo =&gt; foo.Foo(It.IsAny&lt;IInterface3&gt;() ) ); ... otherObject.DoSomethi...
<p>I found this link: <a href="http://forum.castleproject.org/viewtopic.php?p=14322&amp;sid=6327e0e0b3a61cff948bf2d35a9e923d" rel="nofollow noreferrer">Castle Project Topic</a></p> <p>which seems to indicate that its a problem in Castle's DynamicProxy, which is used by Moq (and RhinoMocks).</p>
<p>I know this isn't an answer as such, but it does sound like a bug in MOQ. What version are you using? I just tried your example with 2.6 (2.6.1014.1) and I don't get an exception.</p>
39,267
<p>I have an XSL stylesheet with content in an <code>xsl:text</code> node like this:</p> <pre><code>&lt;xsl:text&gt; foo bar baz &lt;/xsl:text&gt; </code></pre> <p>The stylesheet itself is a text file with "unix-style" newline line terminators. I invoke this stylesheet on Windows as well as unix-like platforms. It wo...
<p>You could define a parameter for the stylesheet like so:</p> <pre><code>&lt;xsl:param name="br"&gt; &lt;xsl:text&gt;&amp;#10;&lt;/xsl:text&gt; &lt;/xsl:param&gt; </code></pre> <p>and pass in the appropriate end of line character(s) by using a nested param element in your Ant script. The default in this exampl...
<p>Well, I got mine to work (using Saxon) with a combination of 2 ideas above:</p> <pre><code>&lt;xsl:param name="br"&gt; &lt;xsl:text&gt;&amp;#xD;&amp;#xa;&lt;/xsl:text&gt; &lt;/xsl:param&gt; </code></pre> <p>and then using line(s) like these where needed.</p> <pre><code>&lt;xsl:value-of select="$br" /&gt; ...
22,385
<p>The <strong><a href="http://msdn.microsoft.com/en-us/library/4wyz8787(VS.80).aspx" rel="noreferrer">TRACE macro</a></strong> can be used to output diagnostic messages to the debugger when the code is compiled in <strong>Debug</strong> mode. I need the same messages while in <strong>Release</strong> mode. Is there a ...
<p>Actually, the TRACE macro is a lot more flexible than OutputDebugString. It takes a printf() style format string and parameter list whereas OutputDebugString just takes a single string. In order to implement the full TRACE functionality in release mode you need to do something like this:</p> <pre><code>void trace(c...
<p>In MFC, TRACE is defined as ATLTRACE. And in release mode that is defined as:</p> <pre><code>#define ATLTRACE __noop </code></pre> <p>So, using the out-the-box TRACE from MFC, you won't actually be able to read any TRACE text, because it won't even be written out. You could write your own TRACE function...
4,727
<p>My XML (<strong>a.xhtml</strong>) starts like this</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; ... </code></pre> <p>My code starts like this</p> <pre><code>use XML::XPath; use XML::XPath::XMLParser; my $xp = XML...
<p>XML::XPath is based on XML::Parser. There is an option in XML::Parser to NOT use LWP to resolve external entities (such as DTDs). And XML::XPath lets you pass an XML::Parser objetc, to use as the parser.</p> <p>So you can write this:</p> <pre><code>my $p = XML::Parser-&gt;new( NoLWP =&gt; 1); my $xp= XML::XPath-&g...
<p>Usually it's done by setting up local <a href="http://en.wikipedia.org/wiki/XML_Catalog" rel="nofollow noreferrer">XML catalog</a>. </p> <p>libxml-based parsers support it, so if you follow mirod's advice, you'll be able to get named entities and validation work without network access.</p>
38,994
<p>I want a splash screen to show while the application is loading. I have a form with a system tray control tied to it. I want the splash screen to display while this form loads, which takes a bit of time since it's accessing a web service API to populate some drop-downs. I also want to do some basic testing for depen...
<p>Well, for a ClickOnce app that I deployed in the past, we used the <code>Microsoft.VisualBasic</code> namespace to handle the splash screen threading. You can reference and use the <code>Microsoft.VisualBasic</code> assembly from C# in .NET 2.0 and it provides a lot of nice services.</p> <ol> <li>Have the main for...
<p>Actually mutlithreading here is not necessary.</p> <p>Let your business logic generate an event whenever you want to update splash screen. </p> <p>Then let your form update the splash screen accordingly in the method hooked to eventhandler.</p> <p>To differentiate updates you can either fire different events or p...
7,133
<p>I'm trying to use a dojo combobox with an Ajax data source. What I have is </p> <pre><code>&lt;div dojoType="dojo.data.ItemFileReadStore" jsId="tags" url="&lt;%=ResolveClientUrl("~/Tag/TagMatches")%&gt;" &gt; &lt;/div&gt; &lt;select dojoType="dijit.form.ComboBox" store="tags" value=""...
<p>If I understand you correctly, you want the client to load different set of data from the server based on some general condition defined elsewhere.</p> <p>Basically there is no need to have a <code>&lt;div&gt;</code> pre-defined. You can also create the <code>ItemFileReadStore</code> directly in JavaScript:</p> <p...
<p>Typically this isn't done with ItemFileReadStore, which is designed to download all the data up front rather than filtering on the server.</p> <p>Rather, you should use <a href="http://docs.dojocampus.org/dojox/data/QueryReadStore" rel="nofollow noreferrer">QueryReadStore</a>, <a href="http://docs.dojocampus.org/do...
34,123
<p>I'm working on a game for the iPhone that has a drawing/paint mechanic involved and I'm having problems trying to create a tool that would erase things already painted.</p> <p>The main problem is that the background being painted on is not a solid color but a static image or animation. I've tried using different bl...
<p>Draw a full-screen textured quad over your scene. When the user draws a brush stroke, use <code>glTexSubImage2D</code> to update the your texture. </p> <p>glReadPixels/glDrawPixels is slow.</p> <p>Using FrameBufferObjects is even better, but I doubt this extention is available on the iPhone (then again, I don't kn...
<p>Using glBlendFunc(GL_ONE, GL_ZERO) mode can earse.</p>
37,264
<p>I've got simple java-based ppt->swf sub-project that basically works. The open source software out there, <a href="http://www.openoffice.org/" rel="nofollow noreferrer">OpenOffice.org</a> and <a href="http://www.artofsolving.com/opensource/jodconverter" rel="nofollow noreferrer">JODConverter</a> do the job great.</...
<p>In modern browsers (IE9+, FF4+, Chrome5+, Opera12+, Safari5+) you can use the built in <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys" rel="noreferrer">Object.keys</a> method:</p> <pre><code>var keys = Object.keys(myObject); </code></pre> <p>The above has a full...
<p>The solution work on my cases and cross-browser:</p> <pre><code>var getKeys = function(obj) { var type = typeof obj; var isObjectType = type === 'function' || type === 'object' || !!obj; // 1 if(isObjectType) { return Object.keys(obj); } // 2 var keys = []; for(var i in ob...
25,508
<p>How to set the CVSROOT environment variable in WinCVS?</p>
<p>The simple answer is: You don't need to. The <code>CVSROOT</code> environment variable is terribly overrated. CVS(NT) will only use it if all other methods of determining the repository connection string have been exhausted. People often assume that it is the other way round and then wonder that changes they've made...
<p>You can set it in the preferences pane at the "General" tab.</p>
40,958
<p>I am writing a desktop application written in Swing developed using Java 1.5. Some of the users seem to be using Mac, but I am interested in Java 6's scripting feature (Java 6 ships with Rhino). Java 6, although it came out almost 2 years ago, doesn't seem to be widely in use. I also hear <a href="https://stackoverf...
<p>As far as I know, it already is, and has been for some time now. Swing's just fine for writing native looking apps.</p> <p>It is true though, that if you are targeting older Macs, you'll never be able to use Java 6.</p> <p>Are you asking about Java 6 Update 10 (AKA, the consumer oriented JRE)? That just came out, ...
<p>From what I can tell most of the really successful Java desktop applications aren't using Swing. It's gotten much faster, but most people want their windows to "look native", and Swing just isn't good at that. If you are intending a real "professional" looking end-user application, you may want to take a look at...
29,930
<p>I have a statusItem application written in PyObjC. The statusItem has a menuItem which is supposed to launch a new window when it is clicked:</p> <pre><code># Create statusItem statusItem = NSStatusBar.systemStatusBar().statusItemWithLength_(NSVariableStatusItemLength) statusItem.setHighlightMode_(TRUE) statusItem....
<p>You need to send the application an activateIgnoringOtherApps: message and then send the window makeKeyAndOrderFront:. </p> <p>In Objective-C this would be:</p> <pre><code>[NSApp activateIgnoringOtherApps:YES]; [[self window] makeKeyAndOrderFront:self]; </code></pre>
<p>I have no idea of PyObjC, never used that, but if this was Objective-C code, I'd say you should call <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html#//apple_ref/occ/instm/NSWindow/makeKeyAndOrderFront:" rel="nofollow noreferrer">makeKey...
18,383
<p>Examples:</p> <pre><code>"1" yes "-1" yes "- 3" no "1.2" yes "1.2.3" no "7e4" no (though in some cases you may want to allow scientific notation) ".123" yes "123." yes "." no "-.5" yes "007" yes "00" yes </code></pre>
<p>This allows for optional "+" and "-" in front. And allows trailing or initial whitespace.</p> <pre><code>/^\s*[+-]?(?:\d+\.?\d*|\d*\.\d+)\s*$/ </code></pre>
<p>Depending on the language you are coding in this functionality may already exist.</p>
16,479
<p>As in a title, does anyone know how to freeze GridView header in ASP.NET ? </p>
<p>Option (a) buy into a UI package that includes a souped-up GridView with this functionality built-in.</p> <p>Option (b) roll your own - it's not simple. Dino Esposito <a href="http://weblogs.asp.net/despos/archive/2003/12/12/43091.aspx" rel="nofollow noreferrer">has one approach</a>. </p> <p>EDIT: Just noticed tha...
<pre><code> &lt;script src=&quot;Scripts/jquery-1.7.1.js&quot;&gt;&lt;/script&gt; &lt;script language=&quot;javascript&quot; &gt; $(document).ready(function () { var gridHeader = $('#&lt;%=GridView1.ClientID%&gt;').clone(true); // Here Clone Copy of Gridview with style ...
19,052
<p>I have a standard windows server that inherits from the ServiceBase class.</p> <p>On the OnStart method I want to check for certain conditions before I get to the main purpose of what my service does.</p> <p>For example:</p> <pre><code>protected override void OnStart(string[] args) { if (condition == false) {...
<p>Checkout the source for the wordpress app. They might be using XML-RPC. :)</p> <p><a href="http://iphone.wordpress.org/" rel="nofollow noreferrer">http://iphone.wordpress.org/</a></p>
<p><a href="https://stackoverflow.com/questions/147062/does-iphone-support-xml-rpc#147071">"Airsource Ltd"</a> is really <em>really</em> <em>incredibly</em> wrong about that document. That document is specific to Mac OS X and <em>NOT</em> the iPhone. In fact (almost) all Apple iPhone documentation is hidden away behind...
17,707
<p>The following exception is thrown:</p> <p>Error Message: Microsoft.SqlServer.Management.Smo.FailedOperationException: Drop failed for Database '4d982a46-58cb-4ddb-8999-28bd5bb900c7'. ---> Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL stateme...
<p>As a guess, I wonder if your connection pool is counting against you - i.e. you have previously executed some commands on a <code>SqlConnection</code> that is now being kept around for re-use. You could try disabling pooling? (pooling=false in the connection string, IIRC).</p> <p>Also - have you been careful to cl...
<p>As a guess, I wonder if your connection pool is counting against you - i.e. you have previously executed some commands on a <code>SqlConnection</code> that is now being kept around for re-use. You could try disabling pooling? (pooling=false in the connection string, IIRC).</p> <p>Also - have you been careful to cl...
40,715
<p>I need to create a form with, half linear view (textboxes and dropdownlists in separate line) and the other half, non linear view i.e. the textboxes will appear next to each other, like first name and last name will be next to each other. </p> <p>I am aware how to acomplish the linear view with CSS. I am using</p> ...
<p>if you also float:left, set a width and display:inline the other input fields, the should appear on the same line</p>
<p><code>display: inline</code> puts the item on the same line. </p> <p><code>display: block</code> gives the item an entire line of its own.</p> <p><code>float: left</code> floats the item to the left.</p>
32,112
<p>I'm trying to handle this possible exploit and wondering what is the best way to do it? should i use apache's common-validator and create a list of known allowed symbols and use that?</p>
<p>From the <a href="http://en.wikipedia.org/wiki/HTTP_response_splitting" rel="nofollow noreferrer">wikipedia article</a>:</p> <blockquote> <p>The generic solution is to URL-encode strings before inclusion into HTTP headers such as Location or Set-Cookie.</p> <p>Typical examples of sanitization include casting to inte...
<p><a href="http://en.wikipedia.org/wiki/HTTP_response_splitting" rel="nofollow noreferrer">Use PHP</a>? ;)</p> <p>According to Wikipedia and the PHP CHANGELOG, PHP's had protection against it in PHP4 since 4.4.2 and PHP5 since 5.1.2.</p> <hr> <p>Only skimmed it -- but, <a href="http://www.ddj.com/security/184405766...
20,121
<p>I regularly want to check if an object has a member or not. An example is the creation of a singleton in a function. For that purpose, you can use <code>hasattr</code> like this:</p> <pre><code>class Foo(object): @classmethod def singleton(self): if not hasattr(self, 'instance'): self.in...
<p>These are two different methodologies: №1 is LBYL (look before you leap) and №2 is EAFP (easier to ask forgiveness than permission).</p> <p>Pythonistas typically suggest that EAFP is better, with arguments in style of "what if a process creates the file between the time you test for it and the time you try to creat...
<p>I have to agree with Chris. Remember, don't optimize until you actually need to do so. I really doubt checking for existence is going to be a bottleneck in any reasonable program.</p> <p>I did see <a href="http://code.activestate.com/recipes/52558/" rel="nofollow noreferrer">http://code.activestate.com/recipes/52...
24,998
<p>This happens repeatedly and is very annoying. I upload some PHP code to a client's server. A few weeks pass. They ask for a change to be made and I re-download the code as they've made some changes. However, my code which used to be neat and tidy the last time I looked at it now has an extra lines of whitespace adde...
<p>Upload in binary mode instead of ascii. Ascii mode is changing all your linefeeds (unix end of line character) into carriage returns + linefeeds (Windows end of line characters).</p>
<p>You may also be having a problem with the other editor using tabs when you are using spaces (you are using spaces, right?). I have seen similar problems when sharing source between developers on Linux/OSX and Windows.</p>
40,301
<p>In analogy to: <a href="https://3dprinting.stackexchange.com/q/6723/4762">What glues for bonding printed PLA to injection-molded plastic?</a>, what are the best glues to use for PETG?</p> <p>I mostly print in PETG and have occasional failed prints which I usually reprint. But what if I'd like to repair a print e.g. ...
<p>From <a href="https://forum.simplify3d.com/viewtopic.php?t=9281" rel="nofollow noreferrer">forum</a></p> <blockquote> <p>Bison plastic - works great for me, only it's not "quick dry" but it's very strong, not brittle, holds PETG and PLA very strongly. Buy paint stripper that is/contains methylene chloride (di...
<p>If Carl's answer that cyanoacrylate glue works is accurate, I would suggest Loctite 420 or equivalent. It's diluted with solvents sufficiently to behave as a liquid rather than a gel, and in my experience on PLA it not only bonds the joint, but wicks between the extrusions and bonds walls/layers together much more s...
1,578
<p>Could anyone please introduce books/papers/articles that I should read If I want to write a high-performance RPC server in Java, which handles large number of concurrent connections(C10K or over), is fault-tolerant, can be scaled out, and maintains high throughput? Thanks! </p>
<p>A few years ago Ebay reimplemented their platform in Java and there are a few white papers and presentations floating around that describe it. Here are some:</p> <ul> <li><a href="http://www.sun.com/2003-0624/feature/index.html" rel="nofollow noreferrer">http://www.sun.com/2003-0624/feature/index.html</a></li> <li>...
<p>A few years ago Ebay reimplemented their platform in Java and there are a few white papers and presentations floating around that describe it. Here are some:</p> <ul> <li><a href="http://www.sun.com/2003-0624/feature/index.html" rel="nofollow noreferrer">http://www.sun.com/2003-0624/feature/index.html</a></li> <li>...
25,866
<p>I need to randomly 'sort' a list of integers (0-1999) in the most efficient way possible. Any ideas?</p> <p>Currently, I am doing something like this:</p> <pre><code>bool[] bIndexSet = new bool[iItemCount]; for (int iCurIndex = 0; iCurIndex &lt; iItemCount; iCurIndex++) { int iSwapIndex = random.Next(iItemCo...
<p>A good linear-time shuffling algorithm is the <a href="http://en.wikipedia.org/wiki/Fisher-Yates_shuffle" rel="noreferrer">Fisher-Yates shuffle</a>.</p> <p>One problem you'll find with your proposed algorithm is that as you near the end of the shuffle, your loop will spend a lot of time looking for randomly chosen ...
<p>I made a method using a temporary Hashtable, allowing the Hashtable's natural key sort to randomize. Simply add, read and discard.</p> <pre><code>int min = 1; int max = 100; Random random; Hashtable hash = new Hashtable(); for (int x = min; x &lt;= max; x++) { random = new Random(DateTime.Now.Millisecond + x); ...
49,118
<p>I am considering buying an Apple MacBook Pro. Are there any pitfalls developing C#/.NET code in a virtual machine running on a Mac?</p> <p>Also, is it better to run Vista or XP Pro for this purpose?</p>
<p>I can't tell you any specific experiences since I don't have a Mac, but I did want to point out that there was an awesome episode of the DeepFriedBytes podcast that discussed this very topic. It made me want to give it a try. They discuss the pros and cons of going this route - well worth the listen IMO if this is s...
<p>Probably better not to run vista in a VM. Especially if you want the Aero UI turned on. VMs aren't very good with advanced graphics, so you'll probably want to run XP, or Vista in classic mode.</p>
4,794
<p>As part of our build process we run a database update script as we deploy code to 4 different environments. Further, since the same query will get added to until we drop a release into production it <em>has</em> to be able to run multiple times on a given database. Like this:</p> <pre><code>IF NOT EXISTS (SELECT *...
<p>Are you looking for <a href="http://msdn.microsoft.com/en-us/library/ms176011.aspx" rel="noreferrer">sys.schemas</a>?</p> <pre><code>IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'jim') BEGIN EXEC('CREATE SCHEMA jim') END </code></pre> <p>Note that the <code>CREATE SCHEMA</code> must be run in its own batc...
<pre><code>IF NOT EXISTS (SELECT TOP (1) 1 FROM [sys].[schemas] WHERE [name] = 'Person') BEGIN EXEC ('CREATE SCHEMA [Person]') END IF NOT EXISTS (SELECT TOP (1) 1 FROM [sys].[tables] AS T INNER JOIN [sys].[schemas] AS S ON S.schema_id = T.schema_id WHERE T.[name] = 'Guests' AND S.[nam...
27,942
<p>I recently built a program that parses a remote file from <strong>\some_server\c$\directory\file.xls</strong> and it works fine on my local machine as just a normal aspx page. </p> <blockquote> <p>Then I put the program into web part form on my VM SharePoint server and I get this error: Access to the path '...
<p>Salamander is right, SharePoint doesn't run with trust to do this. </p> <p>Changing the trust level for SharePoint in it's web.config from WSS_Medium to Full is the quick solution, but there are security implications..</p>
<p>SharePoint usually runs in a separate application pool. Please check the identity of this application pool.</p>
24,975
<p>Is there anyway to change the ASPNETDB and also using SQLExpress (2005) user instance ?</p> <p>I have changed my web.config's connectin string to </p> <pre><code>&lt;remove name="LocalSqlServer"/&gt; &lt;add name="LocalSqlServer" connectionString="Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory...
<ol> <li><p>Run aspnet_regsql.exe from your Framework 2.0 folder, mine is:</p> <p>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727</p></li> <li><p>Go through the wizard and choose the database that you wish to add the AspNetDB tables too.</p></li> <li><p>Set the connectionstring to connect to your database e.g. (Anything...
<ol> <li><p>Run aspnet_regsql.exe from your Framework 2.0 folder, mine is:</p> <p>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727</p></li> <li><p>Go through the wizard and choose the database that you wish to add the AspNetDB tables too.</p></li> <li><p>Set the connectionstring to connect to your database e.g. (Anything...
48,513
<p>I have signed numbers (2s complement) stored in 32-bit integers, and I want to extract 16-bit fields from them. Is it true that if I extract the low 16 bits from a 32-bit signed number, the result will be correct as long as the original (32-bit) number fits into 16 bits ?</p> <p>For positive numbers it is trivially...
<p>Yes, in two's complement the sign bits extend "all the way" to the left. When you cast a signed short to a signed int then the number is <a href="http://en.wikipedia.org/wiki/Sign_extension" rel="nofollow noreferrer">"sign extended"</a> and has the same value.</p> <p>Example: <a href="http://en.wikipedia.org/wiki/N...
<p>From my (second) reading of your question, it doesn't seem as if you need to "extract" any bits, but rather convert the whole number?</p> <p>I.e. do something like this:</p> <pre><code>int negative = -4711; short x = (short) negative; </code></pre> <p>In this case, the compiler will make sure that as much as poss...
32,214
<p>I've printed a 2x2x2&nbsp;cm test cube with Slic3r (left) and Ultimaker Cura (right) and my Prusa i3 derivative machine with tight belts. The print settings should be quite equal (0.15&nbsp;mm layer height, 40&nbsp;mm/s outer wall speed, default accelerations/jerks). Though the top surface of the Ultimaker Cura-cube...
<p>Those wavy lines could be artefacts caused by closely-spaced infill, but they could also be resonance patterns caused by noisy stepper motors and over-tight belts. Since you have said that you have your belts nice and tight, I would suggest reducing the tension on them and see what happens. I know that some pundits ...
<p>It is difficult to see with the lighting and the shiny green, but try printing a more complex object, like the usual <a href="https://www.thingiverse.com/thing:1278865" rel="nofollow noreferrer">XYZ cube</a>. Does it look like this one? which means big waves after a change of direction, but then getting smaller?</p>...
704
<p>I've heard many programmers, particularly Delphi programmers scorn the use of 'with'. </p> <p>I thought it made programs run faster (only one reference to parent object) and that it was easier to read the code if used sensibly (less than a dozen lines of code and no nesting).</p> <p>Here's an example:</p> <pre><...
<p>One annoyance with using with is that the debugger can't handle it. So it makes debugging more difficult.</p> <p>A bigger problem is that it is less easy to read the code. Especially if the with statement is a bit longer.</p> <pre><code>procedure TMyForm.ButtonClick(...) begin with OtherForm do begin Left :=...
<p>We've recently banned it in our Delphi coding stnadards. </p> <p>The pros were frequently outweighing the cons.</p> <p>That is bugs were being introduced because of its misuse. These didn't justify the savings in time to write or execute the code.</p> <p>Yes, using with can led to (mildly) faster code execution...
9,691
<p>We are trying to develop an application to view and annotate PDF files in ASP.net. </p> <p>The function involves capturing x,y coordinates from a click and placing the annotation on that specific location.</p> <p>Are there available components to do this?</p> <p>Thanks in advance.</p>
<p>I must admit I've never understood the difference between "curry" and "partial". I use the following function to do more or less what you want to do:</p> <pre><code>package { public function partial( func : Function, ...boundArgs ) : Function { return function( ...dynamicArgs ) : * { return func.apply(n...
<p>Ended up with (heavily inspired by dojo's implementation):</p> <pre><code>public static function curry(func:Function, ... args:Array):* { var arity:int = func.length; var currying:Function = function(func:Function, arity:int, args:Array):* { return function(... moreArgs:Array):* { if...
46,915
<p>Consider the following code:</p> <pre><code>client.Send(data, data.Length, endpoint); byte[] response = client.Receive(ref endpoint); </code></pre> <p>While, according to WireShark (network sniffer), the remote host does reply with data, the application here just waits for data forever... it does not receive the a...
<p>You probably want to setup two UdpClients: one for listening, one for sending.</p> <p>For the receiving UdpClient, use the constructor that takes a port.</p>
<p>probably the remote host has firewall then couldn't response to request, before send request set the </p> <pre><code>client.Client.ReceiveTimeout = 5000; </code></pre> <p>so when the response couldn't get the request you have a exception </p>
27,343
<p>In what cases,or for what kind of algorithms, do you start using your objects as data structure with methodes outside of the objects (ie : Tree Walking, etc...). </p> <p>What scheme do you use ? (Visitor ? pattern-matching ?)</p> <p>Or do you think an object should always be the only one allowed to act on its own ...
<p>Objects should have a single responsibility. If the operation you're doing is acting on an object but has nothing to do with the responsibility of that object. It's better to put it outside that object.</p>
<blockquote> <p>Or do you think an object should always be the only one allowed to act on its own data?</p> </blockquote> <p>That is my philosophy (except for objects that are only entities; ie: they map something else, like an xml file or something and only contain properties)</p>
13,148
<p>i want to know how to edit a single row (which i select) from a data grid</p> <p>for example i have a datagrid with columns A, B and C and i have a couple rows of data, approx 10 rows.</p> <p>lets say i want to change the value of data within row 4.</p> <p>how would i do this?</p> <p>i am using visual studio 200...
<p>All grid-like components of asp.net have the same machanism as it comes to starting to edit a single row. Actually it's default for asp.net only to edit a single row in a grid.</p> <p>Needed to start editing is to include asp:button or asp:linkbutton in the ItemTemplate with the CommandName set to "Edit". This one ...
<p>Is your data in a DataTable before making it a DataGrid, or can you put it in a DataTable? You can update/delete/edit rows in a DataTable, here's a link with code snippets, pretty straight forward:</p> <p><a href="http://msdn.microsoft.com/en-us/library/tat996zc(VS.80).aspx" rel="nofollow noreferrer">http://msdn.mi...
26,724
<p>OK we are at the end of our rope here, and I’d really appreciate feedback from the SO community.</p> <p>Our basic issue is slow performance by our MOSS-based intranet-- </p> <p>Some environment info:</p> <p>We have a MOSS standard edition for a collaboration based site. </p> <ul> <li>The sitedb is 29 Gb </li> ...
<p>You don't say how much memory your front end servers have - given that they are 32bit, I'll assume the maximum per worker process of roughly 2gb + change. </p> <p>My advice? Switch to 64 bit, add more memory, and check that you are not using just one w3wp worker process per front end. Have a dig into "web gardens,"...
<p>Definitely check the disk usage. If you have two VMs and they run of the same disk / SAN, make sure it isn't too busy. Overloaded SANs kill performance</p>
38,282
<p>I have config.time_zone in environment.rb set to "UTC", and my mySQL server returns the current time in my local time zone when I issue "select now();" and in utc when I ask for "select utc_timestamp;"</p> <p>I'm running rails 2.1.2, the mysql gem 2.7.3, activerecord gem 2.1.2, and mysql --version returns "Ver 14.1...
<p>We had the same issue regarding dates, time zones and MySQL. The latter assumes you provide it with date/time values in the timezone it's configured with. </p> <p>But, since you configured Rails to handle time in UTC, ActiveRecord converts any date/time values in UTC (thus Tue Nov 25 17:40:48 -0800 2008 becomes Wed...
<p>After editing the environment.rb file, did you restart your server before making a new record to your database?</p>
41,316
<p>I am attempting to deploy .NET 2.0 web services on IIS that has both 1.0 and 2.0 installed. This web server primarily serves a large .NET 1.0 application. </p> <p>I have copied by .NET 2.0 web service project to the server and have created a virtual directory to point to the necessary folder. </p> <p>When I set th...
<p>These statements are not identical. The cast method is a normal method invocation (<code>invokevirtual</code> JVM instruction) while the other is a language construct (<code>checkcast</code> instruction). In the case you show above, you should use the second form: <code>(TrTuDocPackTypeDto) packDto</code></p> <p>Th...
<p>Both of these statements are identical. Pick whichever one you find more readable. The second method is more common in my experience, and it is the once that I prefer.</p> <p>I tend to use the cast method solely when I am working with reflection, and it reads nicer in that situation. All other times I find myself u...
30,210
<ol> <li>How precise is the VB6 <code>Date</code> data type (by way of fractions of a second)?</li> <li>How to format it to show fractions of a second?</li> </ol> <p>I'm revisiting VB6 after many years absence, and for the life of me can't remember the things I used to know. I considered putting a <a href="/questions/...
<p>1) Seconds only, and</p> <p>2) There's no way.</p>
<p>I think that the Date Datatype in VB6 can not handle fractions of a second.</p>
22,585
<p>I've been trying to build a simple prototype application in Django, and am reaching the point of giving up, sadly, as it's just too complicated (I know it would be worth it in the long-run, but I really just don't have enough time available -- I need something up and running in a few days). So, I'm now thinking of g...
<p>"where I just can't figure out what model I need to produce the HTML form I want, which seems such a basic thing that I fear for my chances of doing anything more complex" </p> <p>Common problem.</p> <p>Root cause: Too much programming.</p> <p>Solution. Do less programming. Seriously.</p> <p>Define the Django...
<p>For an easy access of Java classes from PHP scripts you can use a php-java bridge.</p> <p>There is a open source solution: <a href="http://php-java-bridge.sourceforge.net/pjb/" rel="nofollow noreferrer">http://php-java-bridge.sourceforge.net/pjb/</a> <br>or a solution from Zend (<a href="http://www.zend.com/en/prod...
38,439
<p>I am trying to retrieve an image stored in an oracle blob and place it in a new System.Drawing.Image instance. I know I can write the stream to a temp.bmp file on the disk and read it from there but thats just not l33t enough for me. How do I convert the blob object directly to an image?</p>
<p>Assuming :</p> <ul> <li>you are using the Microsoft client (<code>System.Data.OracleClient</code>).</li> <li>you have a proper <code>OracleConnection</code> instance (<code>connection</code>).</li> <li>you have an <code>OracleCommand</code> ready (<code>command</code>, based on <code>SELECT my_blob FROM my_table WH...
<p>I know this uses sql but it should be similar for your needs</p> <pre><code>Dim cn As SqlConnection = Nothing Dim cmd As SqlCommand = Nothing Dim da As SqlDataAdapter = Nothing Dim ms As MemoryStream = Nothing Dim dsImage As Data.DataSet = Nothing Dim myBytes() As Byte = Noth...
22,306
<p>I just picked up Agile Web Development with Rails 3rd Ed., and I'm going thru the Depot Application chapters, and I have a question about Product/Item options.</p> <p>If I wanted to modify the product catalog and store so that products could have options (size, color, whatever), where/how would I do that?</p> <p>Let...
<p>Ok, it's 2 days later, and I figured it out. This is what I had to do-</p> <h1>1, in my store view:</h1> <pre><code>&lt;% form_for @product, :url =&gt; {:action =&gt; "add_to_cart", :id =&gt; @product} do |f| %&gt; &lt;select name="productsize" id="productsize"&gt; &lt;option value="L"&gt;L&lt;/option&gt; ...
<p>I'd drop the <code>button_to</code> helper and use a proper form, submitting the product properties to the <code>add_to_cart</code> action.</p> <pre><code>&lt;% form_for(@product) do |f| %&gt; &lt;%= f.select :size, ['S', 'M', 'L', 'XL', 'XXL'] %&gt; # other properties... &lt;%= f.submit 'Add to Cart' %&gt; &lt;% e...
34,806
<p>I want to grab the value of a hidden input field in HTML.</p> <pre><code>&lt;input type="hidden" name="fooId" value="12-3456789-1111111111" /&gt; </code></pre> <p>I want to write a regular expression in Python that will return the value of <code>fooId</code>, given that I know the line in the HTML follows the form...
<p>For this particular case, BeautifulSoup is harder to write than a regex, but it is much more robust... I'm just contributing with the BeautifulSoup example, given that you already know which regexp to use :-)</p> <pre><code>from BeautifulSoup import BeautifulSoup #Or retrieve it from the web, etc. html_data = ope...
<pre><code>/&lt;input type="hidden" name="fooId" value="([\d-]+)" \/&gt;/ </code></pre>
7,914
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/517915/when-to-use-strictfp-keyword-in-java">When to use &ldquo;strictfp&rdquo; keyword in java?</a> </p> </blockquote> <p>What is the use of Strictfp method in java?</p>
<p><code>strictfp</code> is a method or class modifier that forces the JVM to do floating point math a certain way that is guaranteed to be the same across different JVM implementations (stopping the JVM from cutting corners to improve performance and possibly lose some precision / accuracy).</p> <p>More information c...
<p><code>strictfp</code> makes sure that the floating-point operations in the marked code will act the same across all platforms. It's something you might use in 2D/3D programming where you need to make certain you get exactly the same results regardless of what platform you run the program on.</p>
47,806
<p>I am using a Windows XP Home Edition. I need to install a few extensions to PHP -- memcache, APC, .etc. And I would very much like to use PECL to make this happen. The problem is PECL takes it for granted that I will have certain programs on my computer. On another post, I read, for instance, that you need to have M...
<p>The only way I can think of is: manually. Yeah, I know, but this is pretty easy comparatively.</p> <p>If you have the compiler, then you can at least compile an extension if you have the source. Otherwise you're stuck with trying to locate a binary distribution (like me).</p> <p>Here's what you do, from what I u...
<p>For memcache you will need the memcache server located here -> <a href="http://code.jellycan.com/memcached/" rel="nofollow noreferrer">http://code.jellycan.com/memcached/</a> and download the win32 binary</p> <p>Never used APC :P I use eAccelerator0953_5.2.6 to cache the code</p>
31,210
<p>What is the best free way to get your maintenance plan-generated backups compressed?</p> <p>I know there are non-free tools that will compress the backups, but I'm not interested in them.</p> <p>Options:</p> <ol> <li>Have a T-SQL task after the backups that will run a script through xp_cmdshell that compresses ev...
<p>I'm the author of an open source project (GPL v3) that might be what you are looking for (It's not maintenance-plan based though). It is a command line tool (to schedule in Scheduled Tasks in Windows) and backs up to gzip, zip (specifically zip64 due to the 4GB limitation with regular zip files), or bzip2 files. Y...
<p>I'd schedule a task after the backup to do it as you already suggest. Also, I believe SQL2008 (at least some flavours) will do compressed backups.</p> <p>However, if you are at the point where you NEED to compress backups for disk-space reasons, I'd suggest looking at more storage. Unless you are trying to keep the...
37,755
<p>Running something like:</p> <p>@users = User.find(:first, :select => "name, lastname, salary") for @user in @users do @user.salary = 100000 @user.save end</p> <p>After this looking up in the Mysql table, the users aren't updated.</p>
<p>ActiveRecord doesn't know the object's id, in order to save the data. So include the id field in :select, like the example below:</p> <p>@users = User.find(:first, :select => "id, name, lastname, salary")</p>
<p>Try using .update or .update_attributes instead: those are designed for edits (as opposed to .save, which is for creating new rows)</p>
11,258
<p>How can I determine if a string is an IP address? Either <em>IPv4</em> or <em>IPv6</em>?</p> <p>What is the least and most number of characters?</p> <p>I assume this would be a <strong>regex</strong> answer.</p>
<p>In .NET there's an IPAddress type which has a handy method <a href="http://msdn.microsoft.com/en-us/library/system.net.ipaddress.tryparse.aspx" rel="noreferrer">TryParse</a>.</p> <p>Example: </p> <pre><code>if(System.Net.IPAddress.TryParse(PossibleIPAddress, validatedIPAddress)){ //validatedIPAddress is good }...
<p>IPv4 becomes: <code>/\d\d?\d?.\d\d?\d?.\d\d?\d?.\d\d?\d?/</code></p> <p>I'm not sure about the IPv6 rules.</p>
6,379
<p>I've created a workflow/flowchart style designer for something. At the moment it is using relatively simple Bezier curve lines to connect up the various end points of the "blocks" on the workflow.</p> <p>However I would like something a bit more intuitive for the user. I want the lines to avoid obstacles like other...
<h2>Try this</h2> <p>I'm not a guru, but this appears to work. </p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xs:element name="customer" type="customerType"/&gt; &lt;xs:complexType name="customerType"&gt; &lt;xs:sequence&gt; ...
<p>Hum, this is the kind of work xsd is really not handy for. Anyway, this should do the trick if I did not make a mistake:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/NewXMLSchema" xmlns:tns="http://www.example...
41,407
<p>I have a full text catalog with two tables in it.</p> <p>tableA has 4 columns (a1, a2, a3, a4) of which 3 are indexed in the catalog, a2,a3,a4. a1 is the primary key.</p> <p>tableB has 3 columns (b1, b2, b3, b4), two of which are indexed in the catalog, b3 and b4. b1 is the PK of this table, b2 is the FK to tableA.<...
<p>I'm not positive that I understood what you were trying to do. I interpreted your question as you want to return all items in Table A that matched the search term. Furthermore you wanted to sum the rank from the item in TableA plus the matching items in TableB.</p> <p>The best way I can think to do this is to use...
<p>I'm not positive that I understood what you were trying to do. I interpreted your question as you want to return all items in Table A that matched the search term. Furthermore you wanted to sum the rank from the item in TableA plus the matching items in TableB.</p> <p>The best way I can think to do this is to use...
25,254
<p>Whenever we have to update the database; we delete the values from the table first and then add the latest values. This ensures that everything is updated correctly.</p> <p>This adds little bit overhead to the system but we haven't faced any performance issues because of this.</p> <p>Is this always the best thing ...
<p>No.</p> <p>Use the UPDATE statement. </p> <p>Additionally, if you worried about integrity, scope it within a transaction:</p> <pre><code>BEGIN TRAN T1 -- This update is part of T1 UPDATE Table1 SET Col1='New Value' WHERE Col2 = @Id; -- Time to commit your changes. -- If for any reason something fails, -- ever...
<p>A delete-insert is a higher cost operation than an update.</p> <p>If the reason is not obvious, it is because you have to store undo/redo information for the complete row being removed, including the modification of all index entries and checks for referential integrity violations caused by the deletion, followed b...
45,190
<p>Say I wanted to have a project, and one-to-many with to-do items, and wanted to re-order the to-do items arbitrarily? </p> <p>In the past, I've added a numbered order field, and when someone wants to change the order, had to update all the items with their new order numbers. This is probably the worst approach, si...
<p>I hate this problem ... and I run into it all the time.</p> <p>For my most recent Django site we had a Newsletter which contained N Articles and, of course, order was important. I assigned the default order as ascending Article.id, but this failed if Articles were entered in something other than "correct" order.</p...
<p>This is a late answer to the question, but I just wanted to chime in and point out that B-Trees are a great data structure for this sort of thing, especially if your access patterns don't require you to retrieve the entire list at once.</p> <p><a href="http://en.wikipedia.org/wiki/B-tree" rel="nofollow noreferrer">...
48,378
<p>Any thoughts on why this isn't working? I really thought 'ignore' would do the right thing.</p> <pre><code>&gt;&gt;&gt; 'add \x93Monitoring\x93 to list '.encode('latin-1','ignore') Traceback (most recent call last): File "&lt;interactive input&gt;", line 1, in ? UnicodeDecodeError: 'ascii' codec can't decode byt...
<p>…there's a reason they're called "encodings"…</p> <p>A little preamble: think of unicode as the norm, or the ideal state. Unicode is just a table of characters. №65 is latin capital A. №937 is greek capital omega. Just that.</p> <p>In order for a computer to store and-or manipulate Unicode, it has to <em>encode</e...
<p>This seems to work:</p> <pre><code>'add \x93Monitoring\x93 to list '.decode('latin-1').encode('latin-1') </code></pre> <p>Any issues with that? I wonder when 'ignore', 'replace' and other such encode error handling comes in?</p>
48,152
<p>I am building my first report in <a href="http://www.eclipse.org/birt/phoenix/" rel="nofollow noreferrer">BIRT</a>.</p> <p>Very quickly I ran into a problem in which I wanted to display some text or data based on an expression that included data from two different tables (not tables that can/should be joined - (hyp...
<p>I have not tried to do this for a while. The immediate answer that pops to mind is that you need to put the third data set into a table (can have visibility set to false) and you would need to populate the table values to a GlobalValue. Then you could get at the GlobalValues from the data control through script. <...
<p>Use the <pre> this.getValue() </pre> which will return the current column's binding value instead of <pre> dataSetRow["RUN"]</pre></p>
17,010
<p>So I'm having a really weird issue with my App_Code folder on a new website I'm designing. </p> <p>I have a basic class inside of a namespace in the App_Code folder. Everything works fine in the IDE when I setup the namespace and make an object from the class. It brings up the class summary on hover, and when yo...
<p>The problem that your classes are not compiled, You'll solve this issue simply by going to the properties of any class in the App_Code folder and change it's 'Build Action' property from "Content" to "Compile"</p>
<p>For those that follow...I had this same set of issues but it was caused because I named a class in App_Code, 'HTML'. Took a long while to figure out that it was just a name conflict because the compiler wasn't being very helpful about telling me what the problem was.</p>
11,505
<p>I want to know how to fully uninstall <code>MSSQL 2005</code>. </p> <p>I've been using the Trial version of SQL Server Reporting Services for a while now. My company finally purchased the software from an online distributor, and for support of Oracle, we needed to upgrade to MSSQL 2005 SP2. Anyway, the "full" v...
<p>@Mark Struzinski</p> <p>I actually discovered that it was a problem with the installer, when installing the "Full Version". I discovered, since the product was downloaded, instead of delivered on CD/DVD, that the installer was looking for information in a path that was not correct. There was a MS Knowledge Bas...
<p>I had the exact same problem, and this article helped me clean up all the related files from my system and do a fresh install of both Visual Studio and the SQL client components. Give it a try and let me know if it helps you out:</p> <p><a href="http://support.citrix.com/article/CTX115270" rel="nofollow noreferrer"...
3,639
<p>I want to match any line that does not end with 'CA' or 'CA[any number]'. How can I do that using rlike in MySQL? (Note it doesn't support ?! etc).</p> <p>Here's the regex for a positive match, I just need a way to negate it: <code>'^.*[C][A][0-9]?$'</code></p> <p>(Due to an embarrassing architecture limitation...
<p>The trick is turning it into a description of what you <em>do</em> want to match. Something doesn't end in CA or CA(digit) when:</p> <p>It ends with something other than A or digit, or</p> <p>It ends with something other than A, then a digit, or</p> <p>It ends with something other than C, then A, then a digit, or...
<blockquote> <p>Well the regex is coming from a column in a table, and most of the patterns there already work. So it would easiest if I could make this pattern work within the existing structure.</p> </blockquote> <p>I did something similar once, what I did was create another column (I think I used a bitfie...
43,434
<p>I'm looking to calculate the number of months between 2 date time fields.</p> <p>Is there a better way than getting the Unix timestamp and then dividing by 2 592 000 (seconds) and rounding up within MySQL?</p>
<h1>Month-difference between any given two dates:</h1> <p>I'm surprised this hasn't been mentioned yet:</p> <p>Have a look at the <a href="http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_timestampdiff" rel="noreferrer"><strong><em>TIMESTAMPDIFF()</em></strong></a> function in MySQL.</p> ...
<p>This query worked for me:)</p> <pre><code>SELECT * FROM tbl_purchase_receipt WHERE purchase_date BETWEEN '2008-09-09' AND '2009-09-09' </code></pre> <p>It simply take two dates and retrieves the values between them.</p>
36,789
<p>I have a RESTful web service deployed at <a href="http://example.com/v1/SomeResource" rel="noreferrer">http://example.com/v1/SomeResource</a>. One day, a new protocol version (<strong>that is not backwards compatible</strong>) is deployed to <a href="http://example.com/v2/SomeResource" rel="noreferrer">http://exampl...
<p><strong>Best practice:</strong> </p> <p>It's probably better to keep the versioning out of the URL and to make the new resources backwards compatible with the old. </p> <p><strong>Backwards compatible:</strong> </p> <p>If you must keep the v1 in the URL, and are making v2 URLs, then you have to decide whether yo...
<p>I would recomend instead the use of the 301 (301 Moved Permanently). Read <a href="http://www.bombaycrow.com/blog/index.php/2008/03/e-directing-web-content-for-seo-301-moved-permanently/" rel="nofollow noreferrer">why</a>.</p> <p>Hope it helps, Bruno Figueiredo</p>
35,192
<p>Problem:</p> <pre><code>edited files on windows, using git-bash, to fix IE7 problems committed, pushed to github repo booted back into linux pulled from repo merge conflict in dozens of files used 'git reset --hard' </code></pre> <p>What can I do to get back on track?</p> <p>UPDATE: please look at the follow...
<p>It sounds like you need to set the line ending options in Windows:</p> <pre><code>git config core.autocrlf true </code></pre> <p>This will convert the line endings from LF to CRLF on Windows and back again on <code>git add</code>. Without this, git thinks that you changed the whole file's line endings from LF to C...
<p>I'm not sure why you posted this whole transcript, it does show you're not just having line ending problems. Perhaps you assume that the several problems you had all had one cause.</p> <p>I'll guess that you created this repo on your linux system, then uploaded it to GitHub, then cloned to your Windows system. When...
42,346
<p>i'm trying to send fake keyboard input to an application that's running in a Remote Desktop session. i'm using:</p> <pre><code>Byte key = Ord("A"); keybd_event(key, 0, 0, 0); // key goes down keybd_event(key, 0, KEYEVENTF_KEYUP, 0); // key goes up </code></pre> <p>Now this code does send the character "a" to any ...
<h2>Answer</h2> <p>Although Microsft says you don't need to, <a href="http://msdn.microsoft.com/en-us/library/aa453245.aspx" rel="nofollow noreferrer">and you should not</a>, send the OEM code, you need to send the OEM scan codes. In this example i need to send the OEM scan codes for</p> <ul> <li>key A goes down</li>...
<p>You could use SendMessage(); It's really a much better simulator for keys. Well, good luck on this! </p>
44,904
<p>i'm having an issue with creating a query in oracle which doesnt seem to want to join on missing values </p> <p>the table i have is this:</p> <pre><code>table myTable(refnum, contid, type) values are: 1, 10, 90000 2, 20, 90000 3, 30, 90000 4, 20, 10000 5, 30, 10000 6, 10, 20000 7, 20, 20000 8, 30, 20000 </code></...
<p>You are correct in saying that left joins will return nulls for the right where there is no match, but you are not allowing these nulls to be returned when you add this restriction to your where clause:</p> <pre><code>and b.id_tp_cd = 10000 and c.id_tp_cd = 20000 </code></pre> <p>You should be able to put these in...
<p>Or using the Oracle syntax instead of ansi</p> <pre><code>select a.refnum, b.refnum, c.refnum from myTable a, mytable b, mytable c where a.contid=b.contid(+) and a.contid=c.contid(+) and a.type = 90000 and b.type(+) = 10000 and c.type(+) = 20000; REFNUM REFNUM REFNUM ---------- ---------- ---------- ...
47,324
<p>I was wondering if there was a way to get at the raw HTTP request data in PHP running on apache that doesn't involve using any additional extensions. I've seen the <a href="http://au2.php.net/http" rel="noreferrer">HTTP</a> functions in the manual, but I don't have the option of installing an extension in my environ...
<p>Do you mean the information contained in <code>$_SERVER</code>?</p> <pre><code>print_r($_SERVER); </code></pre> <p>Edit:</p> <p>Would this do then?</p> <pre><code>foreach(getallheaders() as $key=&gt;$value) { print $key.': '.$value."&lt;br /&gt;"; } </code></pre>
<pre><code>GET / host: domain.com; all-other-headers: &lt;its-value&gt;; request-content: &lt;as-per-content-type&gt; </code></pre>
20,003
<p>I have a 1GB file containing pairs of string and long. What's the best way of reading it into a Dictionary, and how much memory would you say it requires?</p> <p>File has 62 million rows. I've managed to read it using 5.5GB of ram.</p> <p>Say 22 bytes overhead per Dictionary entry, that's 1.5GB. long is 8 bytes, t...
<p>It's important to understand what's happening when you populate a Hashtable. (The Dictionary uses a Hashtable as its underlying data structure.)</p> <p>When you create a new Hashtable, .NET makes an array containing 11 buckets, which are linked lists of dictionary entries. When you add an entry, its key gets hash...
<p>Loading a 1 GB file in memory at once doesn't sound like a good idea to me. I'd virtualize the access to the file by loading it in smaller chunks only when the specific chunk is needed. Of course, it'll be slower than having the whole file in memory, but 1 GB is a real mastodon...</p>
44,734
<p>I'm trying to put a Message back into an MSMQ when an exception is thrown. The following code appears to work but the Message is not put back in the queue?</p> <pre><code>Message msg = null; try { MessageQueue MQueue = new MessageQueue(txtMsgQPath.Text); msg = MQueue.ReceiveById(txtQItemToRead.Text); lb...
<p>Couple of points: The best way to do this would be using a transaction spanning both queues; that way you'll know you won't lose a message.</p> <p>The second part of it is to be careful about how the queues are created and how you submit messages to the second queue. In particular, MSMQ sometimes appears to "fail s...
<p>I managed to get the code above to work by creating a new queue and pointing the code at the new queue.</p> <p>I then compared the 2 queues and noticed that the new queue was multicast (the first queue wasn't) and the new queue had a label with the first didn't. Otherwise the queues appeared to be the same.</p>
35,284
<p>I can't seem to find in the SDK how to programatically sense the mute button/switch on the iPhone. When my app plays background music, it responds properly to the volume button without me having any code to follow that but, when I use the mute switch, it just keeps playing away.</p> <p>How do I test the position o...
<p>Thanks, JPM. Indeed, the link you provide leads to the correct answer (eventually. ;) For completeness (because S.O. should be a source of QUICK answers! )...</p> <pre><code>// "Ambient" makes it respect the mute switch // Must call this once to init session if (!gAudioSessionInited) { AudioSessionInterruptio...
<p>Olie,</p> <p>I believe you can find the answer to your question here:</p> <p><a href="https://devforums.apple.com/message/1135#1135" rel="nofollow noreferrer">https://devforums.apple.com/message/1135#1135</a></p> <p>I'm assuming you have access to the Developer Forums at Apple.com :)</p>
36,582
<p>I am calling, through reflection, a method which may cause an exception. How can I pass the exception to my caller without the wrapper reflection puts around it?<br> I am rethrowing the InnerException, but this destroys the stack trace.<br> Example code:</p> <pre><code>public void test1() { // Throw an exceptio...
<p>In <strong>.NET 4.5</strong> there is now the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.runtime.exceptionservices.exceptiondispatchinfo" rel="noreferrer"><code>ExceptionDispatchInfo</code></a> class.</p> <p>This lets you capture an exception and re-throw it without changing the stack-trace:</p> <p...
<p>This is just a nice clean, modern implementation of some of the other ideas here, tested in .NET 6:</p> <pre><code>public static class ExceptionExtensions { [DoesNotReturn] public static void Rethrow(this Exception ex) =&gt; ExceptionDispatchInfo.Capture(ex).Throw(); } </code></pre> <p>I wanted the ...
8,159
<p>On Linux (or Solaris) is there a better way than hand parsing <code>/proc/self/maps</code> repeatedly to figure out whether or not you can read, write or execute whatever is stored at one or more addresses in memory?</p> <p>For instance, in Windows you have <code>VirtualQuery</code>. </p> <p>In Linux, I can <code>...
<p>I do not know an equivalent of <code>VirtualQuery</code> on Linux. But some other ways to do it which may or may not work are:</p> <ul> <li><p>you setup a signal handler trapping SIGBUS/SIGSEGV and go ahead with your read or write. If the memory is protected, your signal trapping code will be called. If not your si...
<p>There sorta is/was /proc/[pid|self]/pagemap, documentation in the kernel, caveats here: <a href="https://lkml.org/lkml/2015/7/14/477" rel="nofollow">https://lkml.org/lkml/2015/7/14/477</a> So it isn't completely harmless...</p>
33,827
<p>I'm trying to maintain a Setup Project in <code>Visual Studio 2003</code> (yes, it's a legacy application). The problem we have at the moment is that we need to write registry entries to <code>HKCU</code> for every user on the computer. They need to be in the <code>HKCU</code> rather than <code>HKLM</code> because t...
<p>First: Yes, this is something that belongs in the Application for the exact reson you specified: What happens after new user profiles are created? Sure, if you're using a domain it's possible to have some stuff put in the registry on creation, but this is not really a use case. The Application should check if there ...
<p>I'm partway to my solution with this entry on MSDN (don't know how I couldn't find it before).</p> <p>User/Machine Hive<br> Subkeys and values entered under this hive will be installed under the HKEY_CURRENT_USER hive when a user chooses "Just Me" or the HKEY_USERS hive or when a user chooses "Everyone" during inst...
2,323
<p>I've a table with two columns are a unique key together and i cannot change the schema.</p> <p>I'm trying to execute an update using psql in which i change the value of one of the column that are key. The script is similar to the following:</p> <pre><code>BEGIN; UPDATE t1 SET P1='23' where P1='33'; UPDATE t1 SET P...
<p>One of the examples which was loaned straight from this <a href="http://www.youtube.com/watch?v=cq7wpLI0hco" rel="noreferrer">Aspect Oriented Programming: Radical Research in Modularity, Youtube video</a> was painting to a display. In the example you have a drawing program, which consists of points, shapes, etc and ...
<p>Security - checking that users have appropriate permissions prior to executing certain methods.</p>
42,165
<p>Which is better to use for timing in Python? time.clock() or time.time()? Which one provides more accuracy?</p> <p>for example:</p> <pre><code>start = time.clock() ... do something elapsed = (time.clock() - start) </code></pre> <p>vs.</p> <pre><code>start = time.time() ... do something elapsed = (time.time() - s...
<p>As of 3.3, <a href="https://docs.python.org/3/library/time.html#time.clock" rel="noreferrer"><em>time.clock()</em> is deprecated</a>, and it's suggested to use <strong><a href="https://docs.python.org/3/library/time.html#time.process_time" rel="noreferrer">time.process_time()</a></strong> or <strong><a href="https:/...
<p>Comparing test result between Ubuntu Linux and Windows 7.</p> <p><strong>On Ubuntu</strong></p> <pre><code>&gt;&gt;&gt; start = time.time(); time.sleep(0.5); (time.time() - start) 0.5005500316619873 </code></pre> <p><strong>On Windows 7</strong></p> <pre><code>&gt;&gt;&gt; start = time.time(); time.sleep(0.5); (...
11,099
<p>I use <a href="http://xpath.alephzarro.com/" rel="noreferrer">XPather Browser</a> to check my XPATH expressions on an HTML page.</p> <p>My end goal is to use these expressions in Selenium for the testing of my user interfaces.</p> <p>I got an HTML file with a content similar to this:</p> <pre> &lt;tr&gt; &lt;td...
<p>It seems that <a href="http://www.openqa.org/" rel="noreferrer">OpenQA</a>, guys behind Selenium, have already addressed this problem. They defined some variables to explicitely match whitespaces. In my case, I need to use an XPATH similar to <code>//td[text()="${nbsp}"]</code>.</p> <p>I reproduced here the text ...
<p>Search for <code>&amp;nbsp;</code> or only <code>nbsp</code> - did you try this?</p>
30,693
<p>How can I center an image horizontally and aligned to the bottom of the container at the same time? </p> <p>I have been able to center the image horizontally by its self. I have also been able to align the bottom of the container by its self. But I have not been able to do both at the same time. </p> <p>Here is wh...
<pre><code>.image_block { width: 175px; height: 175px; position: relative; } .image_block a { width: 100%; text-align: center; position: absolute; bottom: 0px; } .image_block img { /* nothing specific */ } </code></pre> <p><strong>explanation</strong>: an element positioned absol...
<p>Remove the <code>position: relative;</code> line. I'm not sure why exactly but it fixes it for me.</p>
38,435
<p>I recently had to work on a project where the previous developer modified the wp-admin directory. It seems like a bad idea to me, since Wordpress is constantly updated. Am I just not at that level of expertise with modifying Wordpress?</p>
<p>Being open source, I think it's a common thing for software like WordPress to be modified and extended at any point.</p> <p>To modify or not to modify is a choice between trade-offs. New features can be encapsulated as modules, which may, perhaps, cause their functionality to be less integrated than desired. Howeve...
<p>On one blog/forum combination, we hacked together the signup procedure so that people filled in one form to sign up to both WordPress and phpBB at the same time. I'm sure there's a better way to do that with plugins, but it did have one unexpected benefit - it really confuses the spambots. Despite having several of ...
24,904
<p>We're writing a records management product for schools and one of the requirements is the ability to manage course schedules. I haven't looked at the code for how we deal with this (I'm on a different project at the moment), but nonetheless I started wondering how best to handle one particular part of this requireme...
<p>I would avoid the string option for the sense of purity: it adds an extra layer of encoding/decoding that you do not need. It may also mess you up in the case of internationalization. </p> <p>Since the number of days in a week is 7, I would keep seven columns, perhaps boolean. This will also facilitate subsequent q...
<p>If performance is an issue I would recommend a cleaner varation of #3.</p> <p>Link your course to a "schedule" table.</p> <p>Which is in turn linked to a days_in_schedule table.</p> <p>The days_in_schedule table has columns the schedule_name, and the date in_schedule_day. With a row for each valid day in that sc...
40,406
<p>I'm still a little unclear and when to wrap a <em>lock</em> around some code. My general rule-of-thumb is to wrap an operation in a lock when it reads or writes to a static variable. But when a static variable is ONLY read (e.g. it's a readonly that is set during type initialization), accessing it doesn't need to b...
<p>Since none of the code you've written modifies the static field after initialization, there is no need for any locking. Just replacing the string with a new value won't need synchronization either, unless the new value depends on the results of a read of the old value.</p> <p>Static fields aren't the only things tha...
<p>As for your "which is better" question, they're the same since the function scope isn't used for anything else.</p>
13,076
<p>Should I still be using tables anyway?</p> <p>The table code I'd be replacing is:</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt;Name&lt;/td&gt;&lt;td&gt;Value&lt;/td&gt; &lt;/tr&gt; ... &lt;/table&gt; </code></pre> <p>From what I've been reading I should have something like</p> <pre><code...
<p>I think that definition lists are pretty close semantically to name/value pairs.</p> <pre><code>&lt;dl&gt; &lt;dt&gt;Name&lt;/dt&gt; &lt;dd&gt;Value&lt;/dd&gt; &lt;/dl&gt; </code></pre> <p><a href="http://www.maxdesign.com.au/presentation/definition" rel="noreferrer">Definition lists - misused or misunders...
<p>use the float: property eg: css:</p> <pre class="lang-css prettyprint-override"><code>.left { float:left; padding-right:20px } </code></pre> <p>html:</p> <pre><code>&lt;div class="left"&gt; Name&lt;br/&gt; AnotherName &lt;/div&gt; &lt;div&gt; Value&lt;br /&gt; AnotherValue &lt;/div&gt; </code></pre>
8,654
<p>I recently found out carbon fiber and glow in the dark PLA can damage the printer nozzle, now I'm suspicious of all the "exotic" filaments.</p> <p>So, does wood filament cause damage to the nozzle? (under normal use, or at least what someone who only used PLA/ABS before would consider normal use)</p> <p>Let's assu...
<p>If you haven't been to their site before, you should check out the forums on 3DHubs. There's a lot of how-to's. A quick Google search yields <a href="https://www.3dhubs.com/talk/thread/accelerated-nozzle-wear" rel="noreferrer">this</a> link to a similar question.</p> <p>The key thing to note is that in all technica...
<p>If you haven't been to their site before, you should check out the forums on 3DHubs. There's a lot of how-to's. A quick Google search yields <a href="https://www.3dhubs.com/talk/thread/accelerated-nozzle-wear" rel="noreferrer">this</a> link to a similar question.</p> <p>The key thing to note is that in all technica...
175
<p>I want to log on to a server inside my program using Windows authentication of the current user logged in. I thought that perhaps I could use </p> <p>System.Security.Principal.WindowsIdentity.GetCurrent().Name</p> <p>but while that does give a name, I do not see how I can find out the password of the user to enter...
<p>There's absolutely no way to get the Windows user's password since Windows doesn't even store it (all it stores is an irreversible hash).</p>
<p>If you are going to use the Windows User Authentication, you should probably use some part of it that is more secure than the simple username/password combination. (And there is probably no way to access the password, as that would mean that every .NET application could access your full account information.)</p> <p...
12,041
<p>Somewhat-simplified example situation: I have entities A and B which are incredibly "heavy" domain objects. Loading one from the database is a pretty big deal. Then I have an entity C, which is a very simple object that has a label string, one A, and one B -- both lazy.</p> <p>I'm doing some low-level querying to c...
<p>Wow, I'm surprised that no one is advocating using the English as a key. I used this style in a couple of software projects, and IMHO it worked out pretty well. The code readability is great, and if you change an English string it becomes obvious that the message needs to be considered for re-translation (which is...
<p>In addition to the considerations above, there are many cases where you'd want the "key" (msgid) to be different from the source text (English). For example, in the HTML view, I might want to say [yyyy] where the destination and label of that anchor tag depend on the locale of the user. E.g. it might be a link to a ...
26,613
<p>I have been hearing a lot about Ruby and possibly even Javascript being "true" object oriented languages as opposed to C++ and C# which are class oriented (or template based) languages. What is meant by true OO and what are the advantages of this over the class/template approach?</p>
<p>It's a subjective term used to promote languages. I've seen it used to say C# and Java are true object oriented languages in comparison to C++ because everything must be in a class (no global functions or variables) and all objects inherit from one Object class. </p> <p>For Ruby, it may refers to how Ruby treats ev...
<p>Not sure about the distinction you're after from the examples provided. But I do know what it isn't! When OO is bolted on to a language as an afterthought, e.g. Perl OO.</p>
31,108
<p>I used this code to upload the picture. I got this code from stackoverflow. I am still unable to upload the image. I changed the db connection settings in table settings 2. I made the table but I am not sure whether the properties of the table I created are correct.</p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;title...
<p>There is a whole (very useful) thread on things that 2.2 broke over on the Apple dev forums. It includes this issue (though without any fix). I've seen it mentioned elsewhere as well.</p> <p>It's worth checking it out</p> <p><a href="https://devforums.apple.com/message/12297#12297" rel="nofollow noreferrer">https:...
<p>It appears this new behaviour is the "intended" behaviour, which makes sense.</p> <p>It's just a shame it'll be difficult to make my app render correctly in 2.1 <em>and</em> 2.2.</p> <p>It also seems that if I fiddle with my UINavigationBar transparent/opaque setting I will find some right combination of bugs that...
46,965
<p>Scenario: a web application written in PHP utilizes an <a href="http://aws.amazon.com/" rel="nofollow noreferrer">Amazon Web Service</a> and must keep the Access Key ID and a Secret Access Key handy in order to function. Are there current recommendations and/or API's out there for storing this data securely?</p> <...
<p>Ah. The question of security. </p> <p>I think the question you should be asking here is what do you do with say, for example mySQL passwords in your php config files?</p> <p>To be quite frank, I would say that if someone managed to get a copy of your files, then your security needs rethinking anyway. For my own us...
<blockquote> <p><em>My thought is to symmetrically encrypt it into a file based on a key created from local server variables. That way it's [hopefully] gibberish if someone gets a copy of the file through FTP, lost laptop with files copied, etc. The concern I have is that a skilled attacker could just upload their ow...
45,127
<p>I have breakpoints set but Xcode appears to ignore them.</p>
<p>First of all, I agree 100% with the earlier folks that said turn <strong>OFF</strong> <code>Load Symbols Lazily</code>.</p> <p>I have two more things to add.</p> <p>(My first suggestion sounds obvious, but the first time someone suggested it to me, my reaction went along these lines: "come on, please, you really t...
<p>I have Xcode Version 4.6.3 and Breakpoints were never working in sub-groups of included projects. The project would compile and run fine; it would even attach to the debugger and spit out NSLog output appropriately.</p> <p>The issue was related to my Header Search Paths. I had some of them set 'recursive' instead o...
9,040
<p>I have a 'framework' in Flex which loads and destroys child 'sections', which are instances of module classes. These have a lot of webservice and animation in them and are part of a public facing site.</p> <p>Before I remove a section from the screen I call a 'hideSection()' interface method on the instance. In thi...
<p><a href="http://gskinner.com/talks/resource-management/" rel="nofollow noreferrer">http://gskinner.com/talks/resource-management/</a></p> <p>this is grand skinner's talk about garbage collection. Around slide 32 he talks about his janitor system. you can read over then and then grab his source files.</p> <p>also m...
<p>You could remove all active event listeners in the hideSection() method.</p> <pre><code>removeEventListener(this, listenerFunction, eventType); </code></pre> <p>If you added the event listener with a <a href="http://www.gskinner.com/blog/archives/2006/07/as3_weakly_refe.html" rel="nofollow noreferrer">weak referen...
26,583
<p>I found a nice model for a ship from the game "Eve". It doesn't have a flat bottom, so it needs support material. But Slic3r generates several dozen tiny support pillars, and one by one they break loose from the build plate. As they get tall, the leverage of course increases, and since they're so tiny they don't hav...
<p>I know many Slic3r users - myself included - add support material to the model itself <em>before</em> importing it into Slic3r. </p> <p>I personally favour <a href="http://www.meshmixer.com/" rel="noreferrer">MeshMixer</a> for support generation, as the supports are much more predictable and easily removable. In co...
<p>In my point of view it seems that the bed offset not optimal. I see that you are using the blue tape, which is better than any other tape. As a next step I would recommend to try different types of glue.</p> <p>I agree with Tormod Haugene and can also recommend Cura. You can also experiment there with a lot of para...
275
<p>vi is for cool kids.</p>
<p>After @joe's answer, Jared Parsons created the great <a href="http://github.com/jaredpar/VsVim" rel="noreferrer">VsVim</a>. It's been featured on <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/59ca71b3-a4a3-46ca-8fe1-0e90e3f79329" rel="noreferrer">Visual Studio Gallery</a>. It's a ready extension packa...
<p>Have you tried the gvim OLE package? I have used it with previous versions of Visual Studio and it worked okay.</p> <p><a href="http://www.vim.org/download.php#pc" rel="nofollow noreferrer">http://www.vim.org/download.php#pc</a> -- gvim##ole.zip </p> <p>A GUI version with OLE support. This offers a few extra feat...
13,573
<p>Can I get a 'when to use' for these and others? </p> <pre><code>&lt;% %&gt; &lt;%# EVAL() %&gt; </code></pre> <p>Thanks</p>
<p>Check out the <a href="http://quickstarts.asp.net/QuickStartv20/aspnet/doc/pages/syntax.aspx#expressions" rel="noreferrer">Web Forms Syntax Reference</a> on MSDN.</p> <p>For basics, </p> <ul> <li><p>&lt;% %> is used for pure code blocks. I generally only use this for if statements</p> <blockquote> <br/> &n...
<p>In ASP.NET 4.0, comes &lt;%: %> syntax for writing something html encoded.</p> <pre><code>&lt;%: "&lt;script&gt;alert('Hello XSS')&lt;/script&gt;" %&gt; </code></pre> <p>The above can be used instead of the belove.</p> <pre><code>&lt;%= Html.Encode("&lt;script&gt;alert('Hello XSS')&lt;/script&gt;")%&gt; </cod...
4,787
<p>Merging project/solution files is a well-known disaster among developers/SCM admins performing merges in their source control. </p> <p>Take, for example, a common scenario: development is done on a project/solution in two different branches. When time comes to merge back into a main development line, there is a ver...
<p>I created a tool to compare and merge solution file (<a href="http://slntools.codeplex.com" rel="nofollow noreferrer">http://slntools.codeplex.com</a>). It's a lot easier to merge a solution with the tool compared to a 'generic merger'. It cannot handle project files thought.</p>
<p>I've written a small Perl-script to merge solution files:<br/> <a href="http://blog.tedd.no/index.php/2011/01/06/merging-multiple-visual-studio-solution-sln-files-into-one/" rel="nofollow">http://blog.tedd.no/index.php/2011/01/06/merging-multiple-visual-studio-solution-sln-files-into-one/</a></p> <p>The script coul...
48,676
<p>Can someone give some hints of how to delete the last n lines from a file in Perl? I have a very large file of around 400 MB, and I want to delete some 125,000 last lines from it.</p>
<p>You can use <a href="http://search.cpan.org/dist/Tie-File" rel="nofollow noreferrer">Tie::File</a> to handle the file as an array.</p> <pre>use Tie::File; tie (@File, 'Tie::File', $Filename); splice (@File, -125000, 125000); untie @File; </pre> <p>An alternative is to use <code>head</code> and <code>wc -l</code> i...
<p>The most efficient way would be to seek to the end of the file, then incrementally read segments, while counting the number of newlines in each, and then use truncate (see perldoc -f truncate) to trim it down. There is also a module or two on CPAN for reading a file backwards.</p>
44,957
<p>If you had to provide a wizard like form entry experience in mvc how would you abstract the page flow?</p>
<p>Investigate the post-redirect-get pattern.</p> <p><a href="http://weblogs.asp.net/mhawley/archive/tags/MVC/default.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/mhawley/archive/tags/MVC/default.aspx</a><br> <a href="http://devlicio.us/blogs/tim_barcz/archive/2008/08/22/prg-pattern-in-the-asp-net-mvc-framew...
<p>There are a couple ways, create an action for each step of the wizard process, or create a parameter that is passed in to the action method. Like <em>step</em> that will allow you to know what the state of the wizard is in.</p>
3,705
<p>Is it possible in Word 2007 to create a revision history table automatically using track changes or some other method?</p> <p>e.g.</p> <p><strong>Revision History</strong></p> DateVersionDescriptionAuthor 16/09/20081.0CreatedJohn Smith 17/09/20081.1Fixed dumb spelling errorsColin Jones
<p>I don't think it's possible to do automatically.</p> <p>I'd suggest that you keep track manually with a table like you suggested, and then keep all your documents in a version control system under a separate documentation branch in order to have an automatic revision history. If you feel up to it, you could also cr...
<p>It is really a serendipity as I was grappling with the exact same issue a few days back. Although the approach I used was manual, it was quite intuitive.</p> <p>There is an option to compare documents in word 2007 in the review tab.You can choose to generate a new document with only the changes. Open the change doc...
10,850
<p>I'm aware of <a href="http://www.fusioncharts.com/" rel="noreferrer">FusionCharts</a>, are there other good solutions, or APIs, for creating charts in Adobe Flash?</p>
<p>Is there a reason that you want it in Flash? If a plain, old PNG will work, try the <a href="http://code.google.com/apis/chart/" rel="noreferrer">Google Chart API</a>.</p>
<p>Adobe's data visualization package is now free after the release of Flash Builder 4.</p> <p>Charting and other libraries are on this site - <a href="http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4" rel="nofollow noreferrer">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4</a></p>
2,468
<p>I have a postgres database with a user table (userid, firstname, lastname) and a usermetadata table (userid, code, content, created datetime). I store various information about each user in the usermetadata table by code and keep a full history. so for example, a user (userid 15) has the following metadata:</p> <pr...
<p>I suppose you're not willing to modify your schema, so I'm afraid my answe might not be of much help, but here goes...</p> <p>One possible solution would be to have the time field empty until it was replaced by a newer value, when you insert the 'deprecation date' instead. Another way is to expand the table with an...
<p>A subselect is the standard way of doing this sort of thing. You just need a Unique Constraint on UserId, Code, and Date - and then you can run the following:</p> <pre><code>SELECT * FROM Table JOIN ( SELECT UserId, Code, MAX(Date) as LastDate FROM Table GROUP BY UserId, Code ) as Latest ON Table.UserI...
4,484
<p>I am using a query like this on my postgres database:</p> <pre><code>SELECT TableA.id FROM TableA , TableB WHERE TableA.id = 100; </code></pre> <p>Each TableA.id is unique (it's an autoincrement), I am getting more than 1 result. Am I missing something in here?</p>
<p>You're doing a cross-join - effectively every row in TableB against the single row in TableA. If you select something from TableB as well, this will be more obvious :) The fact that you don't currently select anything from TableB doesn't stop the (TableA, TableB) pairs from being the result of the join, before the p...
<p>You need a join before the where clause:</p> <pre><code>INNER JOIN TableB ON TableA.Id = TableB.Id </code></pre>
38,286
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/12249056/executing-sql-server-agent-job-from-a-stored-procedure-and-returning-job-result">Executing SQL Server Agent Job from a stored procedure and returning job result</a> </p> </blockquote> <p>Is there a way...
<p>This <a href="http://blog.boxedbits.com/archives/124" rel="noreferrer">article</a> describes an SP to launch a sql agent job and wait.</p> <pre><code>-- output from stored procedure xp_sqlagent_enum_jobs is captured in the following table declare @xp_results TABLE ( job_id UNIQUEIDENTIFIER NOT NU...
<p>I actually had to do this recently, and this is how I'm thinking of implementing it. I'm creating a temporary job through sp_add_job and sp_add_jobstep, and setting the @delete_level to 3 (always delete after run).</p> <p>I'm not 100% sold on this approach, as you can probably tell from the title of the stored pro...
47,677
<p>I know that some people swear against using a language-specific IDE ever (vim/emacs or die! type stuff) and that some people are really uncomfortable with coding/compiling in the terminal at all, so my question has the following parts.</p> <ul> <li>When do you switch from one to the other</li> <li>Is it even necess...
<p>IDE usage is very subjective to personal opinion. With that disclaimer, here's mine.</p> <p>Know your tools and know your platforms. Developing software is your domain, so be good at it.</p> <p>When do you switch? When your knowledge tells your intuition that it would be easier with the other tool.</p> <p>Should...
<p>I use IDE for debugging, or for every big project that require to go on many different file. Lot of IDE have quick click to move from one class to an other. IDE for that is more productive. I use IDE too when I use big FrameWork that has a lot of folder and file, more easy to manage.</p> <p><strong>Update because q...
20,321
<p>I need to change the date format from US (mm/dd/YYYY) to UK (dd/mm/YYYY) on a single database on a SQL server machine.</p> <p>How can this be done?</p> <p>I've seen statements that do this for the whole system, and ones that do it for the session, but I can't change the code now as it will have to go through QA ag...
<p>You could use <strong>SET DATEFORMAT</strong>, like in this example</p> <pre><code>declare @dates table (orig varchar(50) ,parsed datetime) SET DATEFORMAT ydm; insert into @dates select '2008-09-01','2008-09-01' SET DATEFORMAT ymd; insert into @dates select '2008-09-01','2008-09-01' select * from @dates </code>...
<p>You do realize that format has nothing to do with how SQL Server stores datetime, right?</p> <p>You can use <code>set dateformat</code> for each session. There is no setting for database only.</p> <p>If you use parameters for data insert or update or where filtering you won't have any problems with that.</p>
42,874
<p>And how to fix it. I'd like to log every thrown exception for maintenance purpose.</p>
<p>This is a known issue in .Net - Application_Error never fires for a web service. Not sure if there's any reason it would be by design, but it just doesn't work.</p> <p>Jeff Atwood had a <a href="http://blog.codinghorror.com/throwing-better-soap-exceptions/" rel="noreferrer">post</a> (and <a href="http://blog.coding...
<p>For anyone looking for Microsoft's word on this topic, see here: &quot;<a href="https://learn.microsoft.com/en-us/previous-versions/bb552862(v=vs.100)?redirectedfrom=MSDN" rel="nofollow noreferrer">Handling and Throwing Exceptions in XML Web Services</a>&quot;.</p> <p>This is the relevant section:</p> <blockquote> <...
25,998
<p>Okay. I know this looks like the typical <em>"Why didn't he just Google it or go to <a href="http://www.unicode.org/" rel="noreferrer">www.unicode.org</a> and look it up?"</em> question, but for such a simple question the answer still eludes me after checking both sources.</p> <p>I am pretty sure that all three of ...
<p>No, they're simply different encoding methods. They all support encoding the same set of characters.</p> <p>UTF-8 uses anywhere from one to four bytes per character depending on what character you're encoding. Characters within the ASCII range take only one byte while very unusual characters take four.</p> <p>UTF-...
<p>All of the UTF-8/16/32 encodings can map all Unicode characters. See <a href="http://en.wikipedia.org/wiki/Comparison_of_Unicode_encodings" rel="nofollow noreferrer">Wikipedia's Comparison of Unicode Encodings</a>.</p> <p>This IBM article <a href="http://www.ibm.com/developerworks/xml/library/x-utf8/" rel="nofollow...
15,837