instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>What are some key UI design tips that every developer should know?</p>
<p>While there are a number of UI resources for developers (for example, Joel Spolsky's <a href="https://rads.stackoverflow.com/amzn/click/com/1893115941" rel="noreferrer" rel="nofollow noreferrer">User Interface Design for Programmers</a>), I'm... | <ul>
<li>use a standard menubar (amateur GUI designers seem to like to chart their own course here for some reason). Make sure the first items are File, Edit and View, and the last one is Help</li>
<li>don't worry about color themes or skins; stick to a standard look that is consistent with your platform</li>
<li>use t... | <p>If you do use a popup from an editor, make sure to return your insertion point or state to whatever it was before the popup. Too many programs just leave you "hanging" and having to find your way back.</p>
| 36,162 |
<p>I would like to offer a database connection prompt to the user. I can build my own, but it would be nice if I can use something that somebody else has already built (maybe something built into Windows or a free library available on the Internet). Anybody know how to do this in .Net?</p>
<p><strong>EDIT:</strong> I ... | <p>You might want to try using <a href="http://msdn.microsoft.com/en-us/magazine/cc163409.aspx" rel="nofollow noreferrer">SQL Server Management Objects</a>. This MSDN article has a good sample for prompting and connecting to a SQL server.</p>
| <p>The only "built in" connection string functionality that I could think of is the one that comes up when you run a CMD script (essentially a batch file) that runs SQL scripts. However I'm not sure if it's something built into Visual Studio.</p>
<p>It's really simple to make one anyway. If you don't want the user to ... | 7,663 |
<p>I have a radio button list on a page that is used to configure products. when the page loads the first time the first list of options is displayed. you select one of them then click a "Next Step" button and the page posts back and shows a new radio button list for step 2. Now if i click a "Previous Step" button i ca... | <p>It sounds like you are causing a redirect to happen. You aren't by chance doing a Response.Redirect in order to "get back" to the original page? This would cause the functionality you describe. You would first get the Postback from the Previous button to leave the page, and then you would get a fresh Request (IsPost... | <p>Try setting <code>AutoEventWireup = False</code> in the page.</p>
| 8,456 |
<p>Which is the most correct code?</p>
<pre><code>if (HttpContext.Current.Response.Cookies[authCookieName] != null) {
HttpContext.Current.Response.Cookies[authCookieName].Value = "New Value";
}
</code></pre>
<p>or </p>
<pre><code>if (HttpContext.Current != null)
if (HttpContext.Current.Response != null)
... | <p>If any one of HttpContext, HttpContext.Current, HttpContext.Current.Response, or Http.Current.Response.Cookies is null, you're already in trouble. Let the exception happen and fix your web server.</p>
| <p>Neither is really more correct, though I would avoid the second, as deeply nested conditionals tend to be hard to understand and maintain.</p>
<p>If you would prefer you get a null pointer exception, use the first. If you want to deal with nulls in another way or silently, use the second (or a refactored version o... | 19,988 |
<p>Can I use this approach efficiently?</p>
<pre><code>using(SqlCommand cmd = new SqlCommand("GetSomething", new SqlConnection(Config.ConnectionString))
{
cmd.Connection.Open();
// set up parameters and CommandType to StoredProcedure etc. etc.
cmd.ExecuteNonQuery();
}
</code></pre>
<p>My concern is : Will... | <p>No, Disposing of the <code>SqlCommand</code> will not effect the Connection. A better approach would be to also wrap the <code>SqlConnection</code> in a using block as well: </p>
<pre><code>using (SqlConnection conn = new SqlConnection(connstring))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand(cmds... | <p>I use this pattern. I have this private method somewhere in my app:</p>
<pre><code>private void DisposeCommand(SqlCommand cmd)
{
try
{
if (cmd != null)
{
if (cmd.Connection != null)
{
cmd.Connection.Close();
cmd.Connection.Dispose();
... | 8,600 |
<p>I'm writing a wizard for an Eclipse RCP application. After doing some processing on a file and taking some user input, I don't want to let the user go back to make changes. At this point they must either accept or reject the changes they are about to make to the system.</p>
<p>What I can't seem to find is a metho... | <p>You can return null from the getPreviousPage() method in your wizard page implementation.</p>
| <p>There is no way to do this using standard JFace wizard APIs. My team accomplished this by writing a custom WizardDialog. We did this on an Eclipse RCP application and not on an eclipse plugin. Disabling the back button is breaking convention, but our business analysts really wanted the functionality.</p>
| 6,787 |
<p>I have this clogging problem on my 3D printer that I am having a really hard time to solve. I am a hobbiest so in no way am I a professional with regards to 3D printers. I also know that this is a popular issue and I have tried a lot of the proposed solutions (going through a lot of PLA filament and failed prints) t... | <h2>A Scriptable Process for Generating Multi-Material STL Files:</h2>
<p>I am now using interactive CAD software to define the more complex features of the object I am printing (in the current case, clock faces), and then using OpenSCAD to do the boolean volume operations. </p>
<p>To print the composite object, I n... | <p>You do not necessarily need a specific design tool, you can use any tool you want to create your multiple material product. It is the slicer software that manages the materials by assigning the correct extruder. E.g. Cura is able to join 2 STL files that fit together and assign each part a specific extruder and thus... | 861 |
<p>What single aspect of agile development should we implement first to improve our development process, and why? </p>
<p>I'm in a situation that's requiring me to "tweak" my process, rather than re-engineer it, and "agile" seems to be the mantra of the day. If we can make only one change that will improve something... | <p>Iterative development. Work in small iterations (say 2 weeks), have 'ready' application by the end of each and single iteration, i.e. your testers should be happy to release the results to your customers.</p>
<p>This is the core. You could build on this.</p>
| <p>I think the two most valuable and easy to implement aspects of Agile are</p>
<ol>
<li><p>daily stand ups - have a brief daily meeting with the team to review status. Use the 3 questions. Avoid cross-talk, chatter, and bitching. Keep it quick and on on-point.</p></li>
<li><p>time-boxed iterations - breaking the p... | 29,296 |
<p>Every time I start a print, midway during printing, my printer starts to under extrude.</p>
<p>I tried lots of different models every time the problem occurs.</p>
<p>What should I do about this?</p>
| <p>This is some kind of filament stuck in the hotend tube problem. Just like "heat creep" as mentioned above. PTFE pipes should be checked, all parts should be carefully cleaned. I also add checking the extruder (gears, tightness) to the list. The plastic extruder can structurally loosen or break over time. I... | <p>If everything is stock on the machine and all other setting are properly configured, this is most likely <a href="https://all3dp.com/2/3d-printer-heat-creep/" rel="nofollow noreferrer">heat creep</a>. This is caused when the PFTE tubing is not properly set within the hot end itself leaving a small gap. As filament... | 1,926 |
<p>Is there a built in dll that will give me a list of links from a string. I want to send in a string with valid html and have it parse all the links. I seem to remember there being something built into either .net or an unmanaged library.</p>
<p>I found a couple open source projects that looked promising but I thoug... | <p>I don't think there is a built-in library, but the <a href="http://www.codeplex.com/htmlagilitypack" rel="noreferrer">Html Agility Pack</a> is popular for what you want to do.</p>
<p>The way to do this with the raw .NET framework and no external dependencies would be use a regular expression to find all the 'a' tag... | <p>A simple regular expression - </p>
<blockquote>
<p>@"<a.*?>"</p>
</blockquote>
<p>passed in to <a href="http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.matches(VS.71).aspx" rel="nofollow noreferrer">Regex.Matches</a> should do what you need. That regex may need a tiny bit of tw... | 14,951 |
<p>How do I create a background process with Haskell on windows without a visible command window being created?</p>
<p>I wrote a Haskell program that runs backup processes periodically but every time I run it, a command window opens up to the top of all the windows. I would like to get rid of this window. What is the ... | <p>You should really tell us how you are trying to do this currently, but on my system (using linux) the following snippet will run a command without opening a new terminal window. It should work the same way on windows.</p>
<pre><code>module Main where
import System
import System.Process
import Control.Monad
main ::... | <p>The simplest way I can think of is to run the rsync command from within a Windows Shell script (vbs or cmd).</p>
| 7,390 |
<p>How can we connect a <code>PHP</code> script to <code>MS Access (.mdb)</code> file?</p>
<p>I tried by including following <code>PHP</code> code:</p>
<pre><code>$db_path = $_SERVER['DOCUMENT_ROOT'] . '\WebUpdate\\' . $file_name . '.mdb';
$cfg_dsn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" . $db_path;
$odbcco... | <p>Here's a sample for a connect and a simple select...</p>
<pre><code><?php
$db_conn = new COM("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("./Northwind.mdb").";";
$db_conn->open($connstr);
$rS = $db_conn->execute("SELECT * FROM Employees");
$f1 = $rS->Fields... | <p>In the filename, I'm looking at '\WebUpdate\' - it looks like you have one backslash at the beginning at two at the end. Are you maybe missing a backslash at the beginning?</p>
| 14,029 |
<p>How can I receive and send email in python? A 'mail server' of sorts.</p>
<p>I am looking into making an app that listens to see if it receives an email addressed to foo@bar.domain.com, and sends an email to the sender.</p>
<p>Now, am I able to do this all in python, would it be best to use 3rd party libraries? </... | <p>Here is a very simple example:</p>
<pre><code>import smtplib
server = 'mail.server.com'
user = ''
password = ''
recipients = ['user@mail.com', 'other@mail.com']
sender = 'you@mail.com'
message = 'Hello World'
session = smtplib.SMTP(server)
# if your SMTP server doesn't need authentications,
# you don't need the ... | <p>You can use <a href="https://pypi.org/project/emailpy" rel="nofollow noreferrer">emailpy</a></p>
<p>Install via <code>pip3 install emailpy</code></p>
<pre><code>import emailpy
manager = emailpy.EmailManager('your email', 'your password')
msg = manager.send(['who you are sending to', 'the other email you are sending ... | 45,330 |
<p>I am writing a windows service. This service runs another process I've developed through Process class methods, but I want to run this process on debug mode also, using breakpoints, for instance.</p>
<p>How can I do this?</p>
| <p>When debugging a service, DebugBreak() is very nice. You can even debug the startup of the service, which can be very hard to time if you try to attach the process.</p>
<p>In C# </p>
<pre><code>#if DEBUG
System.Diagnostics.Debugger.Break();
#endif
</code></pre>
<p>In C++ </p>
<pre><code>#if DEBUG
System.Di... | <p>As well as the "attach process" mode, I've sometimes found it's handy to have an executable that you can run directly from Visual Studio (or just as a console app). I can't remember whether there were any difficulties in doing so, but I don't <em>think</em> there were... you just need to provide a normal entry point... | 37,749 |
<p>Is there a way to disallow publishing of debug builds with ClickOnce?</p>
<p>I only want to allow release builds through, but right now human error causes a debug build to slip through once in a while. </p>
<p>We're publishing the build from within Visual Studio.</p>
| <p>I have started to modify the .csproj files to include the following code to throw an error for debug deploys, effectively preventing the deploy from happening:</p>
<pre><code><!-- The following makes sure we don’t try to publish a configuration that defines the DEBUG constant -->
<Target Name="BeforePublis... | <p>I have chosen another solution that worked for me:</p>
<p>I couldn't change my build process. So I did <em>Tools</em> → <em>Customize...</em> and change the text of the action, adding an alert like "Publish [CONFIGURE TO RELEASE!]", and placing the Publish button next to the Debug/Release configuration option. It's... | 6,930 |
<p>Yes, I know you could use regular objects as associative arrays in JavaScript, but I'd like to use something closer to java's Map's implementation (HashMap, LinkedHashMap etc). Something that could have any kind of data used as key. Are there any good hash(code/table) in JavaScript implementation out there?</p>
| <p>In javascript, <strong>objects are literally a hash implementation</strong>. A Java HashMap will be a little bit of a fake-out, so I'd <strong>challenge you</strong> to re-think your needs.</p>
<p>The <strong>straight answer is no</strong>, I don't believe that there is a great implementation of Java's HashMap in ... | <p>Here's a naive implementation I just put together - as keparo mentioned in a comment, one of the big issues is equality checking:</p>
<pre><code>var ObjectMap = function()
{
this._keys = [];
this._values = [];
};
ObjectMap.prototype.clear = function()
{
this._keys = [];
this._values = [];
};
Objec... | 27,854 |
<p><strong>How can I verify a Google authentication access token?</strong></p>
<p><strong>I need to somehow query Google and ask: Is [given access token] valid for the [example@example.com] Google account?</strong></p>
<h2>Short version</h2>
<p>It's clear how an access token supplied through the <a href="https://code.g... | <p>For user check, just post
get the access token as accessToken and post it and get the response</p>
<pre><code>https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=accessToken
</code></pre>
<p>you can try in address bar in browsers too, use httppost and response in java also</p>
<p>response will be like </p... | <p>Check below URL. It works well. Its official document from Google itself.</p>
<p>Using one of the Google API Client Libraries (e.g. Java, Node.js, PHP, Python) is the recommended way to validate Google ID tokens.</p>
<p><a href="https://developers.google.com/identity/sign-in/android/backend-auth#using-a-google-api-c... | 46,892 |
<p>I am developing a GPL-licensed application in Python and need to know if the GPL allows my program to use proprietary plug-ins. This is <a href="http://www.gnu.org/licenses/gpl-faq.html" rel="noreferrer">what the FSF has to say</a> on the issue:</p>
<blockquote>
<p><strong>If a program released under the GPL uses pl... | <blockquote>
<p>he distinction between fork/exec and dynamic linking, besides being kind of artificial,</p>
</blockquote>
<p>I don't think its artificial at all. Basically they are just making the division based upon the level of integration. If the program has "plugins" which are essentially fire and forget with ... | <p>How much info are you sharing between the Plugins and the main program? If you are doing anything more than just executing them and waiting for the results (sharing no data between the program and the plugin in the process) then you could most likely get away with them being proprietary, otherwise they would probabl... | 5,135 |
<p>We have an Java application running on Weblogic server that picks up XML messages from a JMS or MQ queue and writes it into another JMS queue. The application doesn't modify the XML content in any way. We use BEA's XMLObject to read and write the messages into queues.</p>
<p>The XML messages contain the encoding ty... | <blockquote>
<p>once we write it to the destination queue, the £ symbol is lost and is replaced with £ instead</p>
</blockquote>
<p>That tells me the character is being <em>written</em> as UTF-8, but it's being <em>read</em> as if it were in a single-byte encoding like ISO-8859-1. (For any character in the range U... | <p>Without a few more specifics, I'd guess that there is a method that optionally takes an encoding somewhere that isn't specified and is defaulting to ISO-8859-1. Commonly, check anything that passes between an InputStream/OutputStream and a Reader/Writer.</p>
<p>For instance, an <a href="http://java.sun.com/j2se/1.4... | 33,809 |
<p>Is it possible to programmatically, or otherwise, increase the width of the Windows console window? Or do I need to create a wrapper program that looks and acts like the console somehow? Are there any programs around that do this already? I use Cygwin extensively in my development, and it seems a little ridiculous t... | <p>You can increase it manually by right-clicking the tray icon and entering the options dialog.</p>
<p>There are also third-party terminal emulators for Windows, such as <a href="http://sourceforge.net/projects/console/" rel="nofollow noreferrer">Console</a>:</p>
<p><a href="https://i.stack.imgur.com/qHaXc.jpg" rel=... | <p>Click on the icon on the top left of the console frame (the one that looks like "C:\"), then select Properties . This lets you customize all kinds of stuff. The "layout" tab has the width of the window.</p>
| 23,123 |
<p>I need to manually migrate modified stored procedures from a DEV SQL Server 2005 database instance to a TEST instance. Except for the changes I'm migrating, the databases have the same schemas. How can I quickly identify which stored procedures have been modified in the DEV database for migration to the TEST insta... | <p>instead of using sysobjects which is not recommended anymore use sys.procedures</p>
<pre><code>select name,create_date,modify_date
from sys.procedures
order by modify_date desc
</code></pre>
<p>you can do the where clause yourself but this will list it in order of modification date descending</p>
| <p>You can use following type of query to find modified stored procedures , you can use any number then 7 as per your needs</p>
<pre><code>SELECT name
FROM sys.objects
WHERE type = 'P'
AND DATEDIFF(D,modify_date, GETDATE()) < 7
</code></pre>
| 11,058 |
<p>In rpc.h, the GUID structure is declared as follows:</p>
<pre><code>typedef struct _GUID
{
DWORD Data1;
WORD Data2;
WORD Data3;
BYTE Data[8];
} GUID;
</code></pre>
<p>I understand Data1, Data2, and Data3. They define the first, second, and third sets of hex digits when writing out a GUID (XXX... | <p>It's because a GUID is a special case of a <a href="http://en.wikipedia.org/wiki/UUID" rel="noreferrer">UUID</a>. For information on what all the fields mean, you can look at <a href="http://www.ietf.org/rfc/rfc4122.txt" rel="noreferrer">RFC 4122</a>.</p>
| <p><a href="http://en.wikipedia.org/wiki/Globally_Unique_Identifier" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Globally_Unique_Identifier</a> and <a href="http://www.opengroup.org/onlinepubs/9629399/apdxa.htm" rel="nofollow noreferrer">http://www.opengroup.org/onlinepubs/9629399/apdxa.htm</a> (DCE's orgina... | 34,870 |
<p>We are automating Excel using VB.Net, and trying to place multiple lines of text on an Excel worksheet that we can set to not print. Between these we would have printable reports.
We can do this if we add textbox objects, and set the print object setting to false. (If you have another way, please direct me)</p>
<p>... | <p>If you have the cell name or position, you can do:</p>
<pre><code>With ActiveSheet
.Shapes.AddTextbox msoTextOrientationHorizontal, .Cells(3,2).Left, .Cells(3,2).Top, .Cells(3,2).Width, .Cells(3,2).Height
End With
</code></pre>
<p>This will add a textbox over cell B3. When B3 is resized, the textbox is also.</p>... | <p>When you copy & paste a textbox, Excel will place the new textbox over whichever cell is currently selected. So you can achieve this very easily by simply using the VBA copy & paste commands. This can be particularly useful if you are going to be using a lot of very similar textboxes, as you are effectivel... | 9,252 |
<p>I would like to send HTML email with graphic elements included. I have no idea to attach garaphics to this email.</p>
| <p>You probably don't want to do an inline attachment by hand, it's far easier, and less error prone to use a library, like <a href="http://phpmailer.codeworxtech.com/" rel="nofollow noreferrer">PHPMailer</a>.<br>
It can attach the inline images, or if you give it some HTML code, it will attach the images by itself and... | <p>I'm not going to bore you with a mediocre explanation here so instead let me link to this great tutorial over at Sitepoint which explained it to me in plain English! - <a href="http://www.sitepoint.com/article/advanced-email-php/" rel="nofollow noreferrer">advanced-email-php</a></p>
| 19,022 |
<p>I have created a bunch of movie clips which all have similar names and then after some other event I have built up a string like:</p>
<pre><code>var clipName = "barLeft42"
</code></pre>
<p>which is held inside another movie clip called 'thing'.</p>
<p>I have been able to get hold of a reference using:</p>
<pre><... | <p>Movie clips are collections in actionscript (like most and similar to javascript, everything is basically key-value pairs). You can index into the collection using square brackets and a string for the key name like:</p>
<pre><code>_root.thing[ "barLeft42" ]
</code></pre>
<p>That should do the trick for you...</p>
| <p>The better way, which avoids using the deprecated <code>eval</code>, is to index with square brackets:</p>
<pre><code>var movieClip = _root.thing[ "barLeft42" ]
</code></pre>
<p>But the best way is to keep references to the clips you make, and access them by reference, rather than by name:</p>
<pre><code>var movi... | 15,079 |
<p>There are many ASP.MVC blog post bits and pieces scattered over different web sites, as well as couple of resource questions here - <a href="https://stackoverflow.com/questions/14599/aspnet-model-view-controller-mvc-where-do-i-start-from">ASP.NET Model-view-controller (MVC) - where do I start from?</a> and <a href="... | <p>Have you looked at <a href="http://www.codeplex.com/mvcsamples" rel="noreferrer">MVC Samples</a> on CodePlex? Rob Conery has some screencasts that go along with the creation of the site at <a href="http://blog.wekeroad.com/mvc-storefront/" rel="noreferrer"><a href="http://blog.wekeroad.com/mvc-storefront/" rel="nore... | <p>In addition to the above mentioned:</p>
<ul>
<li><a href="http://weblogs.asp.net/stephenwalther" rel="nofollow noreferrer">http://weblogs.asp.net/stephenwalther</a></li>
<li><a href="http://www.manning.com/palermo/" rel="nofollow noreferrer">Asp.net MVC in Action</a> looks to be a good book.</li>
</ul>
| 7,591 |
<p>For some reason the only the top layers keep failing or underextruding on my prints, for no clear reason. Here are my settings:</p>
<ul>
<li>Slicer: Simplify3D</li>
<li>Filament: 1.75 mm Black PLA from Filamentive</li>
<li>Resolution: 0.1 mm on a 0.4 mm nozzle</li>
<li>Temperature: 200 °C nozzle and 50 °C bed</li>
... | <p>If you decrease layer thickness, you should increase bottom and top layer amount, or set it to a fixed shell thickness. The thinner the layers the more difficult to span over the infill (there is much less filament extruded). </p>
<p>You could try extra part cooling, higher percentage infill, reduced hotend tempera... | <p>The holes in your part tops are the result of a combination of poor bridging and too few top layers.</p>
<p>What's happening is that when the printer tries to lay down the first layer of the top/roof, it has to "bridge" over the top layer of the infill. If you are trying to lay down that layer too quickly, with too... | 1,550 |
<pre><code>/etc/init.d/*
/etc/rc{1-5}.d/*
</code></pre>
| <p><code>/sbin/chkconfig</code> — The <code>/sbin/chkconfig</code> utility is a simple command line tool for maintaining the <code>/etc/rc.d/init.d/</code> directory hierarchy. </p>
| <p>in one word: <code>init</code>.</p>
<p>This process always has pid of 1 and controls (spawns) all other processes in your unix according to the rules in <code>/etc/init.d</code>.</p>
<p>init is usually called with a number as an argument, e.g. <code>init 3</code> This will make it run the contents of the <code>rc3... | 12,666 |
<p>I am new to decoding techniques and have just learnt about base64, sha-1, md5 and a few others yesterday. </p>
<p>I have been trying to figure out what "orkut" worms actually contain. </p>
<p>I was attacked by many orkut spammers and hackers in the past few days, and there is a similarity in the URLs that they sen... | <blockquote>
<p>The encoding above appears to be base64 but it is not, because when-ever I try to decode
it using online base64 decoders I get raw output and it doesn't decode accurately.</p>
</blockquote>
<p>What makes you think that the decoding is incorrect? Typically you'd base64 or hex encode binary content s... | <p>Often times Foo+whatever is the result of a salted hash. It is common to store hash results with salt, and the salt can be stored in the clear. To separate the salt from the actual hash value, a + sign is commonly used.</p>
<p>Base64 is used, so that the binary result of the hash can be stored in text. You can tell... | 36,877 |
<p>My current position is this: if I thoroughly test my ASP.NET applications using web tests (in my case via the VS.NET'08 test tools and WatiN, maybe) with code coverage and a broad spectrum of data, I should have no need to write individual unit tests, because my code will be tested in conjunction with the UI through... | <blockquote>
<p>Code coverage will ensure I'm <em>hitting</em> every functional piece of code</p>
</blockquote>
<h3>"Hit" <em>does not</em> mean "Testing"</h3>
<p>The problem with only doing web-testing is that it only ensures that you <em>hit</em> the code, and that it <em>appears</em> to be correc... | <p>It depends on how the ASP.NET application architecture. If the web pages are merely hooking up an underlying business logic layer or data access layer, then unit tests working independently of the ASP.NET state model are faster to developer and run than similar WaitiN tests.</p>
<p>I recently developed an area of ... | 21,234 |
<p>is there an easy way to solve the following problem.</p>
<p>Let's say I fetch a IList with some books in my controller from my model. Now I want to enrich the output and fetch a preview from Amazon with another model from an outside framework and get another IList.</p>
<p>Now I put both ILists into a property bag.... | <p>Look here:
<a href="http://www.castleproject.org/monorail/faq.html#NVelocity%20View%20Engine" rel="noreferrer">http://www.castleproject.org/monorail/faq.html#NVelocity%20View%20Engine</a></p>
<p>You might access a dictionary in NVelocity via</p>
<pre><code>$amazonbook.get_Item($index)
</code></pre>
| <p>There may be a simpler solution, but I would create a third class like such</p>
<pre><code>class BookList{
MyBookObject a;
AmazonBookObject b;
}
</code></pre>
<p>a list of this third class could be passed to your view at once.</p>
| 40,723 |
<p>In VIM in command line mode a "%" denotes the current file, "cword" denotes the current word under the cursor. I want to create a shortcut where I need the current line number. What is the symbol which denotes this?</p>
| <p>If you want to pass the current line number to a shell command, you could do</p>
<pre><code>:exe "!echo " . line(".")
</code></pre>
| <p>Commands in vim works on the current line so:</p>
<pre><code>:s/foo/bar/g
</code></pre>
<p>will transform every <em>foo</em> in <em>bar</em> on the line you are currently on.</p>
| 33,398 |
<p>When I load <code>script/console</code>, sometimes I want to play with the output of a controller or a view helper method.</p>
<p>Are there ways to:</p>
<ul>
<li>simulate a request?</li>
<li>call methods from a controller instance on said request?</li>
<li>test helper methods, either via said controller instance o... | <p>To call helpers, use the <code>helper</code> object:</p>
<pre><code>$ ./script/console
>> helper.number_to_currency('123.45')
=> "R$ 123,45"
</code></pre>
<p>If you want to use a helper that's not included by default (say, because you removed <code>helper :all</code> from <code>ApplicationController</code... | <p>One possible approach for Helper method testing in the Ruby on Rails console is:</p>
<pre><code>Struct.new(:t).extend(YourHelper).your_method(*arg)
</code></pre>
<p>And for reload do:</p>
<pre><code>reload!; Struct.new(:t).extend(YourHelper).your_method(*arg)
</code></pre>
| 18,209 |
<p>I am having difficulty reliably creating / removing event sources during the installation of my .Net Windows Service.</p>
<p>Here is the code from my ProjectInstaller class:</p>
<pre><code>// Create Process Installer
ServiceProcessInstaller spi = new ServiceProcessInstaller();
spi.Account = ServiceAccount.LocalSys... | <p>The <code>ServiceInstaller</code> class automatically creates an <code>EventLogInstaller</code> and puts it inside its own Installers collection.</p>
<p>Try this code:</p>
<pre><code>ServiceProcessInstaller serviceProcessInstaller = new ServiceProcessInstaller();
serviceProcessInstaller.Password = null;
servicePro... | <p>I experienced some similar weird behaviour because I tried to register an event source with the same name as the service I was starting. </p>
<p>I notice that you also have the DisplayName set to the same name as your event Source.</p>
<p>On starting the service up, we found that Windows logged a "Service started ... | 14,080 |
<p>What is the best method for date of birth selector?</p>
<ul>
<li>3 text inputs (month / day / year) or one mask input. User MUST use keyboard</li>
<li>3 select boxes. User can use keyboard or mouse. </li>
<li>One nice <a href="http://jqueryui.com/demos/datepicker/" rel="noreferrer">datepicker</a>.</li>
</ul>
<p>I ... | <p>If your goal is to make sure "the user won't be confused at all," I think this is the best option.</p>
<p><img src="https://farm4.static.flickr.com/3102/3081701077_ffe742fa2b.jpg?v=0" alt="three dropdowns for month, day, year"></p>
<p>I wouldn't recommend a datepicker for <strong>date of birth</strong>. First you ... | <p>I created three dropdowns for Date of Birth selection and number of days changes dynamically based on the year and month selection. <a href="http://jsfiddle.net/ravitejagunda/FH4VB/10/" rel="nofollow">http://jsfiddle.net/ravitejagunda/FH4VB/10/</a> </p>
<pre><code>daysInMonth = new Date(year,month,1,-1).getDate();
... | 44,155 |
<p>what are your advices on building a very minimalistic version of Python(2.x) for my application's scripting needs. </p>
<p>My main motive here is to keep the foot print (both memory and disk wise) as low as possible so that my native application won't suffer from any major performance hit. Even the Python DLL size ... | <p>Have you tried <a href="http://www.tinypy.org/" rel="nofollow noreferrer">Tiny Python</a>?</p>
| <p>You can use only the dll</p>
| 46,472 |
<p>I'm working on some code that uses the System.Diagnostics.Trace class and I'm wondering how to monitor what is written via calls to Trace.WriteLine() both when running in debug mode in Visual Studio and when running outside the debugger.</p>
| <p>Try <a href="http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx" rel="nofollow noreferrer">Debug View</a>. It works quite nicely.</p>
| <p>I use a simple little program called '<a href="http://www.baremetalsoft.com/baretail/" rel="nofollow noreferrer">BareTail</a>' which displays plain text files, updating it's display as the file gets written to and follows (or wraps) to the bottom of the file.</p>
<p>When running outside the debugger you'll need to ... | 7,846 |
<p>I was using <a href="http://en.wikipedia.org/wiki/CodeRush" rel="nofollow noreferrer">CodeRush</a> quite while ago and now I'm planning to use it again. I've installed the trial but I forgot all the cool features except <kbd>Alt</kbd> + <kbd>Home</kbd> (drop a marker). And when you don't know some cool tricks it's r... | <p>I recently installed the Xpress version and went on a similar hunt. <a href="http://community.devexpress.com/blogs/markmiller/archive/2008/11/24/shortcuts-and-templates-quick-start-sheets-for-coderush.aspx" rel="noreferrer">This cheat-sheet</a> is what I found so far. The XPress version is pretty gimped BTW so I'm t... | <p>This is an <a href="http://community.devexpress.com/forums/t/57572.aspx" rel="nofollow noreferrer">old post on the DevExpress Coderush Forum</a>:</p>
<p>In it is a setting suggestion by Mark Miller to enhance the default "Embed in Parenthesis" feature of CodeRush.</p>
<p>Once in place ... highlight some text and h... | 45,608 |
<p>How does the compiler know the prototype of sleep function or even printf function, when I did not include any header file in the first place?</p>
<p>Moreover, if I specify <code>sleep(1,1,"xyz")</code> or any arbitrary number of arguments, the compiler still compiles it.
But the strange thing is that gcc is able t... | <p>Lacking a more specific prototype, the compiler will assume that the function returns int and takes whatever number of arguments you provide.</p>
<p>Depending on the CPU architecture arguments can be passed in registers (for example, a0 through a3 on MIPS) or by pushing them onto the stack as in the original x86 ca... | <p>Depends on the compiler, but with gcc (for example, since that's the one you referred to), some of the standard (both C and POSIX) functions have builtin "compiler intrinsics". This means that the compiler library shipped with your compiler (libgcc in this case) contains an implementation of the function. The comp... | 9,436 |
<p>Handling multiple merges onto branches in Subversion or CVS is just one of those things that has to be experienced. It is inordinately easier to keep track of branches and merges in Mercurial (and probably any other distributed system) but I don't know why. Does anyone else know?</p>
<p>My question stems from the f... | <blockquote>
<p>In Subversion (and CVS), the repository is first and foremost. In git
and mercurial there is not really the concept of a repository in the
same way; here changes are the central theme.</p>
</blockquote>
<p>+1</p>
<p>The hassle in CVS/SVN comes from the fact that these systems do <strong>not</str... | <p>I only have experience with Subversion but I can tell you that the merge screen in TortoiseSVN is horribly complicated. Luckily they include a dry run button so that you can see if you are doing it right. The complication is in the configuration of what you want to merge to where. Once you get that set up for the... | 6,562 |
<p>Which is your favorite way to go with strings in C++? A C-style array of <code>char</code>s? Or <code>wchar_t</code>? <code>CString</code>, <code>std::basic_string</code>, <code>std::string</code>, <code>BSTR</code> or <code>CComBSTR</code>?</p>
<p>Certainly each of these has its own area of application, but anyway... | <p>std::string or std::wstring, depending on your needs. Why?</p>
<ul>
<li>They're standard</li>
<li>They're portable</li>
<li>They can handle I18N</li>
<li>They have performance guarantees (as per the standard)</li>
<li>Protected against buffer overflows and similar attacks</li>
<li>Are easily converted to other type... | <p>I like to use TCHAR which is a define for wchar or char according to the projects settings.
It's defined in tchar.h where you can find all of the related definitions for functions and types you need.</p>
| 16,145 |
<p>I've got a group of inter-related classes that are all overridden together to create a particular implementation. I'm wondering if it is a good idea to enclose the interrelated subclasses in a namespace.</p>
<p>For example purposes, consider the following namespaces and classes:</p>
<pre><code>namespace Protocol
{... | <p>I think you are perhaps worrying too much!</p>
<p>Does it make sense logically? Do you know where to find your code within the namespaces?</p>
<p>I would much rather see a codebase like the above with a small number of classes, relevant to the name with a hierarchy, than one large namespace where everything is int... | <p>If this were me, I would define 2 namespaces:</p>
<pre><code>Protocol
</code></pre>
<p>and</p>
<pre><code>Protocol.Driver
</code></pre>
<p>Dividing the namespace like this separates your "library code" vs your "executable / test code."
I also create my namespaces to match the directory structure; it will give lo... | 3,915 |
<p>Does anybody know of an up to date tutorial on using Ajax with ASP.net MVC? Most of what I can find seems to talk about older versions of MVC and I suspect that this is an area where there has been a lot of change of late. </p>
| <p>Stephen Walter just blogged about this:
<a href="http://weblogs.asp.net/stephenwalther/archive/2008/09/22/asp-net-mvc-application-building-forums-6-ajax.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/stephenwalther/archive/2008/09/22/asp-net-mvc-application-building-forums-6-ajax.aspx</a></p>
| <p>Stephen Walter's post "<a href="http://weblogs.asp.net/stephenwalther/archive/2008/09/22/asp-net-mvc-application-building-forums-6-ajax.aspx" rel="nofollow noreferrer">ASP.NET MVC Application Building: Forums #6 – Ajax</a>" seems to be focused on Microsoft ASP.NET AJAX.</p>
<p>A quick search on google for "<a href=... | 17,932 |
<p>I have a table that holds only two columns - a ListID and PersonID. When a person is merged with another in the system, I was to update all references from the "source" person to be references to the "destination" person.</p>
<p>Ideally, I would like to call something simple like</p>
<pre><code>UPDATE MailingList... | <pre><code>--out with the bad
DELETE
FROM MailingListSubscription
WHERE PersonId = @SourcePerson
and ListID in (SELECT ListID FROM MailingListSubscription WHERE PersonID = @DestPerson)
--update the rest (good)
UPDATE MailingListSubscription
SET PersonId = @DestPerson
WHERE PersonId = @SourcePerson
</code></pre>
| <p>I have to agree with David B here. Remove all the older stuff that shouldn't be there and then do your update.</p>
| 16,373 |
<p>I would like to create a simple program (in Java) which edits text files - particularly one which performs inserting arbitrary pieces of text at random positions in a text file. This feature is part of a larger program I am currently writing.</p>
<p>Reading the description about java.util.RandomAccessFile, it appea... | <p>Okay, this question is pretty old, but FileChannels exist since Java 1.4 and I don't know why they aren't mentioned anywhere when dealing with the problem of replacing or inserting content in files. <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/channels/FileChannel.html">FileChannels</a> are fast, use t... | <p>As @xor_eq answer's edit queue is full, here in a new answer a more documented and slightly improved version of his:</p>
<pre><code>public static void insert(String filename, long offset, byte[] content) throws IOException {
File temp = Files.createTempFile("insertTempFile", ".temp").toFile()... | 36,945 |
<p>I have seen this syntax in MSDN: <a href="https://msdn.microsoft.com/en-us/library/9k7k7cf0.aspx" rel="noreferrer"><code>yield break</code></a>, but I don't know what it does. Does anyone know?</p>
| <p>It specifies that an iterator has come to an end. You can think of <code>yield break</code> as a <code>return</code> statement which does not return a value.</p>
<p>For example, if you define a function as an iterator, the body of the function may look like this:</p>
<pre><code>for (int i = 0; i < 5; i++)
{
... | <p>The yield keyword is used together with the return keyword to provide a value to the enumerator object. <strong>yield return</strong> specifies the value, or values, returned. When the yield return statement is reached, the current location is stored. Execution is restarted from this location the next time the itera... | 28,707 |
<p>I am developing an application using MVC Preview 5. I have used typed views.</p>
<p>After setting debug="false", I have found that I am receiving errors of the form:</p>
<blockquote>
<p>"The model item passed into the
dictionary is of type
'blah.Models.UserAdmin.IndexData' but
this dictionary requires a m... | <p>Yes, the bug has been reported. Best leave debug on for now, or modify the offending code (sorry cant recall where).</p>
| <p>I Think your usercontrol and view have same name.</p>
| 21,468 |
<p>I understand access modifiers at the class level and below, but why would an entire assembly be private? I assume by default, assemblies are public?</p>
| <p>Well, in the context of assemblies, private means the assembly cannot be referenced by another application outside the directory it's contained in. Therefore, private to the application it's being used for.</p>
<p>As for your question about the default being public....someone correct me if I'm wrong, but there is n... | <p>Private assembly is an assembly which is particularly an assembly which can't be referred outside the application while a public or shared or we can say it Global can be easily referred outside an assembly. </p>
| 19,057 |
<p>Using VBA, how can I:</p>
<ol>
<li>test whether a file exists, and if so,</li>
<li>delete it?</li>
</ol>
| <p>1.) Check <a href="http://www.tek-tips.com/faqs.cfm?fid=1936" rel="noreferrer">here</a>. Basically do this:</p>
<pre><code>Function FileExists(ByVal FileToTest As String) As Boolean
FileExists = (Dir(FileToTest) <> "")
End Function
</code></pre>
<p>I'll leave it to you to figure out the various error ha... | <p>A shorter version of the first solution that worked for me:</p>
<pre><code>Sub DeleteFile(ByVal FileToDelete As String)
If (Dir(FileToDelete) <> "") Then
' First remove readonly attribute, if set
SetAttr FileToDelete, vbNormal
' Then delete the file
Kill FileToDelete
End... | 9,340 |
<p>I have a webservice running under sharepoint, on a bog-standard Server2003/IIS6 setup. This webservice needs to open and read a file from a share on another machine in the same domain. At the moment I am getting a </p>
<p>System.UnauthorizedAccessException: Access to the path '\strand\DROPBOXES\MattTrinder\Sharepo... | <p>The account you grant access to, has to exist on the target (where the share exists) as well (either the same domain account, or a local account with the same password). Since the IIS-user normally has an auto-generated password and is local, this is hard.</p>
<p>The way we solve this, is to run the website as a di... | <p>Classic asmx web services by default run as the IUSR_ account. This may not have permission to access the network path. You can change this to a domain account by changing the application pool identity. </p>
| 36,915 |
<p>As part of a JavaScript Profiler for IE 6/7 I needed to load a custom debugger that I created into IE. I got this working fine on XP, but couldn't get it working on Vista (full story here: <a href="http://damianblog.com/2008/09/09/tracejs-v2-rip/" rel="nofollow noreferrer">http://damianblog.com/2008/09/09/tracejs-v... | <p>It would help to know what the error result was.</p>
<p>Possible problems I can think of:</p>
<p>If your getting permission denied, your most likely missing some requried <a href="http://msdn.microsoft.com/en-us/library/aa375728(VS.85).aspx" rel="nofollow noreferrer">Privilege</a> in your ACL. New ones are someti... | <p>I'm not familiar with these interfaces, but unexpected failures in Vista may require being past a UAC prompt. Have you tried starting the debugger with admin privileges?</p>
| 8,528 |
<p>I have a JSON as follows</p>
<pre><code>{
columns : [RULE_ID,COUNTRY_CODE],
RULE_ID : [1,2,3,7,9,101,102,103,104,105,106,4,5,100,30],
COUNTRY_CODE : [US,US,CA,US,FR,GB,GB,UM,AF,AF,AL,CA,US,US,US]
}
</code></pre>
<p>I need to retrive the column names from the columns entry and then use it to search... | <pre><code>jQuery.each(data.columns, function(i,column) {
jQuery.each(data[column], function(i, row) {
....
});
});
</code></pre>
| <p>Some comments:</p>
<p>Paolo is right, you can use data[column] to get the list of values:</p>
<pre><code>jQuery.each(data.columns, function(iCol,column) {
jQuery.each(data[column], function(iRow, row) {
....
});
});
</code></pre>
<p>Do you need the columns information ? You could get the list of "colu... | 45,894 |
<p>I've got an MSI based install that I've wrapped in an EXE file as per my installation packaging software (which is Wise Package Studio 7.0 SP2).</p>
<p>I've made many changes to the install, and every time I've tested them, they've worked just fine... up until now.</p>
<p>I changed some text on a dialog box for wh... | <p>Try running on a different machine, this will definitely rule out any local caching.</p>
<p>Check that the changes you have made are actually in the MSI. (use <a href="http://msdn.microsoft.com/en-us/library/aa370557.aspx?ppud=4" rel="nofollow noreferrer">Orca</a> to do this.) </p>
| <p>Try running on a different machine, this will definitely rule out any local caching.</p>
<p>Check that the changes you have made are actually in the MSI. (use <a href="http://msdn.microsoft.com/en-us/library/aa370557.aspx?ppud=4" rel="nofollow noreferrer">Orca</a> to do this.) </p>
| 32,957 |
<p>Despite an earlier question (<a href="https://stackoverflow.com/questions/223894/opengl-rotation-using-gldrawpixels">asked here</a>), our project is constrained to using glDrawPixels, so we have to do some hackery.</p>
<p>One of the feature requirements is to be able to have a magnified view show up on a clicked re... | <p>Here's the answer. The problem is that the LUT is being applied twice, so before calling the copy, call:</p>
<pre><code>Gl.glPixelTransferi(Gl.GL_MAP_COLOR, Gl.GL_FALSE);
</code></pre>
<p>Then, once done, call:</p>
<pre><code>Gl.glPixelTransferi(Gl.GL_MAP_COLOR, Gl.GL_TRUE);
</code></pre>
<p>That way, the 'extr... | <p>Please, pretty please with loads of sugar, molasses, sprinkles and a mist of high-fructose corn syrup on top and all over, explain <i>why</i> you cannot just use <b>texture-mapping</b> to draw this imagery.</p>
<p>Texture-mapping is a core, basic, everyday, run of the mill, garden-variety, standard, typical, expect... | 33,523 |
<p>What is the standard way for allowing and implementing a plugin system for your application?</p>
<p>In my last application I made a simple interface for all plugins that they must implement. I then load all assemblies in the apps directory and toss out any that don't implement that interface.</p>
<p>One of the me... | <p>Check out the System.AddIn namespace as per <a href="https://stackoverflow.com/questions/14278/how-to-load-plugins-in-net#14305">this response</a> to a similar question.</p>
| <p>From a strictly design pattern perspective, you may want to take a look at <a href="http://www.osgi.org" rel="nofollow noreferrer">OSGi</a> (this is highly Java oriented, but is considered to be a very, very good plugin/module system). Might be overkill for what you are trying to achieve, but there is a <em>lot</em... | 21,336 |
<p>We currently are using both Visual Source Safe and Team Foundation Server at work (VSS for old projects, TFS for current or new projects).</p>
<p>We have always used Labels in source control for each build. In VSS if you chose to see a file history you could include labels. In TFS I cannot find an option to inclu... | <p>In the 2008 version of TFS, you don't see labels in the standard history of files and folders. If you really want to know why - see Brian Harry's blog post "<a href="http://blogs.msdn.com/bharry/archive/2005/11/18/494439.aspx" rel="noreferrer">Why TFS Labels are not like VSS Labels</a>".</p>
<p>To find labels in V... | <p>I've used <a href="http://www.codeplex.com/TFSBranchHistory" rel="nofollow noreferrer">TFS branch history</a> for this before. It's not the greatest UI in the world and only lets you show history per file but it gets the job done.</p>
| 18,593 |
<p>As a hobby project I am currently trying to create a small browser-based game - and I thought it would be the "right thing" to code it using the MVC pattern, separating the game's "engine" from presentation. It would be a simple "rpg" game, where the player's character wander the world fighting monsters and gatherin... | <p>"but it is a character that does most of the actions:"</p>
<p>Yes, but...</p>
<p>First, separate the human user ("player") from their character. The character is not the player.</p>
<p>You have a large number of objects. Locations, passive things, active things (monsters), and the character. They all interact ... | <p>I am a bit confused about your question. </p>
<p>MVC is a separate pattern from you game engine design - you will still need an MVC pattern regardless of what the underlying engine structure looks like - users will interact with Views, which submit back to the Control. In your case the "M" may be a quite complex mo... | 32,143 |
<p>I often run into the problem that I have one stream full of data and want to write everything of it into another stream.</p>
<p>All code-examples out there use a buffer in form of a byte-array.</p>
<p>Is there a more elegant way to this?</p>
<p>If not, what's the ideal size of the buffer. Which factors make up th... | <p>In .NET 4.0 we finally got a <a href="http://msdn.microsoft.com/en-us/library/system.io.stream.copyto(v=vs.110).aspx" rel="noreferrer"><code>Stream.CopyTo</code></a> method! Yay!</p>
| <p>As some people have suggested, <code>CopyTo</code> and <code>CopyToAsync</code> should do the job. Here is an example of a TCP server that listens for external connections on port <code>30303</code> and pipes them with local port <code>8085</code> (written in .NET 5). Most streams should work the same, just pay atte... | 15,722 |
<p>I have a multi-timezone web application that stores all of the datetime values in UTC in the database, when actions happen on the server, I can easily convert the time into UTC.</p>
<p>However, when a client enters a time or time span, what is the best way to detect and store it?</p>
<p>I am currently doing the fo... | <p>I was doing something very similar, but I now think I prefer to use <em>javascript</em> to convert all times to local on the client-side. The server will give all times in UTC in the generated page, and the <em>javascript</em> will convert it once the page loads.</p>
<p>This eliminates confusion on the server-side c... | <p>You could use the "header" property of the HttpRequest Object to query the "If-Modified-Since" header sent by the client. This header should contain a date in a format that includes the timezone of the client, like this:</p>
<pre><code>If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
</code></pre>
<p>a simple subs... | 21,698 |
<p>What web app architecture works well receiving/sending SMS text messages? By "architecture, I mean specific architecture, not generally, such as MVC.</p>
<p>Background: I'm building a web app that receives queries from/sends answers to cell phones. The app design (and business model) expects to communicate with cel... | <p>This depends on how you will be receiving and sending the SMS messages.</p>
<p>There is a specific Short message protocol (SMPP - <a href="http://en.wikipedia.org/wiki/SMPP" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/SMPP</a>).
For that you will need an SMPP server.</p>
<p>If you are using a one of the... | <p>I've made one of these before using rails. I created a budget tracker I could send commands to with my cell phone. I used it to create a list of items i needed to buy/take care of on the upcoming paycheck. When the check came in, I would send commands to mark each item off the list. I included commands to query a li... | 17,722 |
<p>Developing an electronic product for which I'll need an enclosure. It's about 50x30x20mm and should survive higher temperatures (50-60 degrees). Because of the low volume (under 500 required per year), I'd like to go for an enclosure option that doesn't require a huge upfront cost. So ended up at 3d printing. As th... | <p>ABS should be able to handle the the temperatures you describe. ABS will have a similar finish to PLA when it first comes off the printer, but you can refine and smooth your results via an acetone vapor treatment. This only takes a few minutes per piece, and can cost as little as a $1 bottle of fingernail polish rem... | <p>ABS would be ok for these temperatures. But 3d-printing, cleaning up the print and smoothing the surface to get a marketable device takes time and effort.
So I guess that for a few hundred enclosures you'd be far better/cheaper off having them manufactured (in China?) than trying to print them yourself.
Unless the d... | 1,389 |
<p>I have a database table on a development server that is now fully populated after I set it running with an import routine for a CSV file containing 1.4 million rows.</p>
<p>I ran the Database Publishing Wizard on the table, and now I have a 286MB SQL script on my local machine. The problem is, I can't figure out h... | <p>use the <a href="http://msdn.microsoft.com/en-us/library/ms170572.aspx" rel="noreferrer">sqlcmd</a> tool to execute the file..</p>
<pre><code>sqlcmd -S myServer\instanceName -i C:\myScript.sql
</code></pre>
<p>In case your have an unexplained "script error" for large sql files (> 100MB) which includes several INSE... | <p>Running something that large inside a single transaction is not a good idea. Therefore, I'd recommend breaking up the file into smaller, more manageable chunks. </p>
<p>Another option is to look at some of the other ways to import CSV data directly.</p>
| 27,440 |
<p>I want to extend a CFC in a different directory and I have a couple of options, but can't figure out how to do this:</p>
<p>A) Use a dynamic mapping (this will have to be dynamic based on the site, e.g. for the live site it would be cfc.myPackage.MyCFC but on a dev site it would be myCfcRoot.myPackage.MyCFC) - I've... | <p>Daniel is basically correct, you need a mapping. However, there are 3 workarounds.</p>
<p>CFCs will pick the current path as a relative root mapping, so if your CFCs are all in the same directory, you can just say </p>
<pre><code><cfcomponent name="MyComponent" extends="Example">
</code></pre>
<p>Or if your... | <p>In regards to Method B. It can be done using an additional file in your example. It's one extra file per cfc that you want to extend per directory that you want to extend from.</p>
<p>The 3 files that are required.</p>
<ul>
<li>/somepathtobasecomponent/basecomponent.cfc (your base component file)</li>
<li>/path... | 36,529 |
<p>I'd like to dynamicly parse in text wiki-content.
I found <a href="http://sourceforge.net/projects/jswiki" rel="nofollow noreferrer">JsWiki</a> but its in beta form, and looks like with no community even developers). Any other?</p>
| <p>It depends what you mean by wiki content. There are many wiki frameworks just as there are many formats for wiki text. If you're looking for something that parses mediawiki content, such as wikipedia, there's a <a href="http://www.mediawiki.org/wiki/Alternative_parsers" rel="nofollow noreferrer">good list of parsers... | <p>There is another beautiful Javascript (only) based wiki editor. I just loved the idea itself. Check it out <a href="http://tiddlywiki.com" rel="nofollow">TiddlyWiki</a></p>
| 42,895 |
<p>Similar question as <a href="https://stackoverflow.com/questions/56722/automated-processing-of-an-email-in-java">this one</a> but for a Microsoft Environment.</p>
<p>Email --> Exchange Server -->[something]</p>
<p>For the [something] I was using Outlook 2003 & C# but it <em>feels</em> messy (A program is tryin... | <p><a href="http://www.codeproject.com/KB/IP/NetPopMimeClient.aspx" rel="nofollow noreferrer">This</a> library provides you basic support for the POP3 protocol and MIME, you can use it to check specified mailboxes and retrieve emails and attachments, you can tweak it to your needs.</p>
<p>Here is <a href="http://www.c... | <p>I am trying <a href="http://csharpopensource.com/openpopdotnet.aspx" rel="nofollow">http://csharpopensource.com/openpopdotnet.aspx</a>, it have been recently updated and it is not bad. It lack good documentation but it also work with gmail/ssl.</p>
| 25,916 |
<p>I need to execute MDX query from command line (MS AS 2005). I have heard, that there is a program named ascmd, which can do this. Unfortunately, when I went to codeplex page I found that page supposed to deliver an ascmd doesn't work. Please help if you know any other page, where I can download ascmd or any other pr... | <p>ascmd.exe is included in this <a href="http://www.codeplex.com/SqlServerSamples/Release/ProjectReleases.aspx?ReleaseId=4000" rel="noreferrer">MS-SQL Server samples download</a>. This is a different page than the one you probably went to originally, it has moved. Just click on the SqlServerSamples.msi link.</p>
| <p>With MS AS 2005 you should have under "sample_inst\Analysis Services\Administrator\ascmd\CS".</p>
<p>where sample_inst is the folder where you have installed the samples</p>
<p>Typcally:</p>
<p>"C:\Program Files\Microsoft SQL Server\90\Samples"</p>
| 33,243 |
<p>I am creating a little testing component and am running into a problem</p>
<p>Basically the component is a decorator on a class that controls all access to the database, it creates a form with a two buttons on it: "Simulate Lost Connection" and "Reconnect". Press the button, and instead of letting function calls p... | <p>You will need to start a message loop on the newly created thread. You can do that by calling Application.Run(form).</p>
| <p>It sounds like you aren't holding on to your thread. It's an object, like everything else, so if it is scoped to your method, it will fall out of scope once your method exits. Try making it an instance variable.</p>
| 48,300 |
<p>I have an enum </p>
<pre><code>public enum FileExtentions {
mp3,
mpeg
}
</code></pre>
<p>And I have a FileInfo of which I want to check if the extension is in the previous enum.
I was hoping I could do a </p>
<pre><code>FileExtensions.Any(e=>e.ToString().Equals(file.Extension));
</code></pre>
<p>But t... | <p>What's the reason behind <code>Any</code> … <code>Equals</code>? Did you overlook <code>Contains</code>?</p>
<pre><code>bool result = Enum.GetNames(typeof(FileExtensions)).Contains("mp3");
</code></pre>
| <p>You can do that with the System.Enum type:</p>
<pre><code>string extension = Enum.GetName(typeof(FileExtensions), FileExtensions.mp3);
if (extension == file.Extension)
// do something here
</code></pre>
<p><strong>Update:</strong></p>
<p>Ah, I misunderstood that you want to check the entire enum for the extens... | 42,525 |
<p>I'm building a C++/MFC program in a multilingual environment. I have one main (national) language and three international languages. Every time I add a feature to the program I have to keep the international languages up-to-date with the national one. The resource editor in Visual Studio is not very helpful because ... | <p>In my experience, internationalization requires a little more than translating strings. Many strings when translated, require more space on a dialog. Because of this it's useful to be able to customize the dialogs for each language. Otherwise you have to create dialogs with extra space for the translated strings whi... | <p><a href="http://resxcrunch.com" rel="nofollow noreferrer">ResxCrunch</a> will be out soon, it will edit multiple resource files in multiple languages in one single table.</p>
| 7,517 |
<p>The need arose, in our product, to determine how long the current user has been logged on to Windows (specifically, Vista). It seems there is no straight forward API function for this and I couldn't find anything relevant with WMI (although I'm no expert with WMI, so I might have missed something).</p>
<p>Any ideas... | <p>For people not familiar with WMI (like me), here are some links:</p>
<ul>
<li>MSDN page on using WMI from various languages: <a href="http://msdn.microsoft.com/en-us/library/aa393964(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa393964(VS.85).aspx</a></li>
<li>reference about Win3... | <p>Using WMI, the Win32Session is a great start. As well, it should be pointed out that if you're on a network you can use Win32_NetworkLoginProfile to get all sorts of info.</p>
<pre><code>Set logins = objWMIService.ExecQuery _
("select * from Win32_NetworkLoginProfile")
For Each objSession in logins
Wscript.Ec... | 3,451 |
<p>I know there is already a <a href="https://stackoverflow.com/questions/133883/stop-and-start-a-service-via-batch-or-cmd-file">question</a> about this but my issue is more oriented to remote scenarios.</p>
<p>With <em>net start/stop</em> you can specify a <em>/y</em> parameter to bounce users off current sessions bu... | <p>I think the /y just answers Yes to the "Are you sure?" prompt. I'd think that sc could be used as well, though it may time out waiting for the service to stop if there's a lot of inflight transactions. Does it give you any specifics of why it can't stop?</p>
<p>Here's a couple of other methods to stop a remote SQL ... | <p>Using SSMS is the best make sure you have the proper privileges to shutdown and check to see the status of replications and ALWAYS ON and Log Shipping. </p>
| 19,552 |
<p>Simple question. How do you disable the text selection of DocumentViewer in WPF? This is the feature where an XPS document is displayed by the viewer and then text can be highlighted via mouse. The highlighted text can also be copied but I have already disabled this. I just don't know how to disable the highlighting... | <p>We have solved this by overriding the ControlTemplate of the ScrollViewer embedded in the DocumentViewer control. Insert the Style below in "Window.Resources":</p>
<pre><code><Style TargetType="{x:Type ScrollViewer}" x:Key="CustomScrollPresenter">
<Setter Property="Template">
<Setter.Val... | <p>Implement the following code in xaml.cs part (DocumentViewerInstance x:Name of your DocumentViewer in your xaml.) </p>
<pre><code>DocumentViewerInstance.GetType().GetProperty("IsSelectionEnabled", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(DocumentViewerInstance, false, null);
</code></pre>
<p>You c... | 48,069 |
<p>I would like to trim long sequences of the same value from a binary file in python. A simple way of doing it is simply reading in the file and using re.sub to replace the unwanted sequence. This will of course not work on large binary files. Can it be done in something like numpy?</p>
| <p>If you don't have the memory to do <code>open("big.file").read()</code>, then numpy wont really help.. It uses the same memory as python variables do (if you have 1GB of RAM, you can only load 1GB of data into numpy)</p>
<p>The solution is simple - read the file in chunks.. <code>f = open("big.file", "rb")</code>, ... | <p>You need to make your question more precise. Do you know the values you want to trim ahead of time?</p>
<p>Assuming you do, I would probably search for the matching sections using <code>subprocess</code> to run "<code>fgrep -o -b <search string></code>" and then change the relevant sections of the file using... | 27,284 |
<p>I have a comma separated list of strings like the one below.</p>
<pre><code>a,b ,c ,d, , , , ,e, f,g,h .
</code></pre>
<p>I want to write a regular expression that will replace the empty values i.e., strings that contain only white spaces to 'NA'. So the result should be</p>
<pre><code>a,b ,c ,d,NA,NA,N... | <p><code>(?<=,)\s+(?=,)</code></p>
<p>This is a lookbehind for a comma, then whitespace, then a lookahead for a comma</p>
| <p>Here you are:</p>
<p><code>echo a,b ,c ,d, , , , ,e, f,g,h . | perl -p -e 's/, +[^a-z|A-Z]/,Na/g'</code></p>
<p>Or:</p>
<p><code>echo a,b ,c ,d, , , , ,e, f,g,h . | perl -p -e 's/, +\S/,Na/g'</code></p>
<p>if you want to make it work with non <code>a-Z</code> characters also (thanks for the comment... | 28,856 |
<p>Where can I find sample code on mouse movements and polygon spins in OpenGL?
I am using Java, so sample code in Java is preferred.</p>
| <p>You'd probably find this useful:</p>
<p><a href="http://pepijn.fab4.be/software/nehe-java-ports/" rel="nofollow noreferrer">http://pepijn.fab4.be/software/nehe-java-ports/</a></p>
| <p>If you would like to use the JOGL java libraries very useful sample code can be found <a href="http://www.cs.umd.edu/~meesh/kmconroy/JOGLTutorial/" rel="nofollow noreferrer">here</a>.</p>
<p>JOGL is pretty straight foreword and easy to grasp. Just be aware, the object oriented nature might make future/more advanced... | 35,393 |
<p>How can I get a full call stack for a c++ application developed with Visual Studio 2005? I would like to have a full call stack including the code in the system libraries.</p>
<p>Do I have to change some settings in Visual Studio, or do I have to install additional software?</p>
| <ol>
<li><p>Get debug information for all project dependencies. This is specified under the "Configuration Properties -> C/C++ -> General" section of the project properties.</p></li>
<li><p>On the menu, go to "Tools -> Options" then select "Debugging -> Symbols". </p></li>
<li><p>Add a new symbol location (the folder i... | <p>Agree with Clay, but for Symbols Server you should get the latest symsrv.DLL from "Debugging Tools For Windows", a free Microsoft download. </p>
<p>(Since you explicitly asked what you need to download, I presume you don't have it yet)</p>
| 13,619 |
<p>I am currently writing a system that stores meta data for around 140,000 ish images stored within a legacy image library that are being moved to cloud storage. I am using the following to get the jpg data...</p>
<pre><code>System.Drawing.Image image = System.Drawing.Image.FromFile("filePath");
</code></pre>
<p>Im ... | <p>If you get your image directly from file, you can use the following code to get size of original file in bytes. </p>
<pre><code> var fileLength = new FileInfo(filePath).Length;
</code></pre>
<p>If you get your image from other source, like getting one bitmap and composing it with other image, like adding watermar... | <p><code>System.Drawing.Image</code> won't give you the file length of size. You have to use another library for that. </p>
<pre><code>int len = (new System.IO.FileInfo(sFullPath)).Length;
</code></pre>
| 27,275 |
<p>The log4j network adapter sends events as a serialised java object. I would like to be able to capture this object and deserialise it in a different language (python). Is this possible?</p>
<p><em>NOTE</em> The network capturing is easy; its just a TCP socket and reading in a stream. The difficulty is the deseriali... | <p>Generally, no.</p>
<p>The stream format for Java serialization is defined <a href="http://java.sun.com/j2se/1.4/pdf/serial-spec.pdf" rel="nofollow noreferrer">in this document</a>, but you need access to the original class definitions (and a Java runtime to load them into) to turn the stream data back into somethin... | <p>If you can have a JVM on the receiving side and the class definitions for the serialized data, and you only want to use Python and no other language, then you may use Jython:</p>
<ul>
<li>you would deserialize what you received using the correct Java methods</li>
<li>and then you process what you get with you Pytho... | 4,916 |
<p>I would like to make the update of the web application as automated as possible.<br>
I'm looking for a tool that can compare two instances of a database and generate an update script for me. As part of the build process create a instance of the last version of the database (ie currently in production) and compare th... | <p>I like <a href="http://sqldbtools.com" rel="noreferrer">SqlDbDiff</a>. Way cheaper than <a href="http://www.red-gate.com/products/SQL_Compare/index.htm" rel="noreferrer">RedGate's SQL Compare</a></p>
| <p>See</p>
<p><a href="https://stackoverflow.com/questions/1607/mechanisms-for-tracking-db-schema-changes#22535">Mechanisms for tracking DB schema changes</a></p>
<p>I believe the <a href="https://stackoverflow.com/questions/175451/how-do-you-version-your-database-schema#175473">profluence</a> of this question on SO ... | 21,239 |
<p>Suppose I have a variable of type Int = 08, how can I convert this to String keeping the leading zero?</p>
<p>For instance:</p>
<pre><code>v :: Int
v = 08
show v
</code></pre>
<p>Output: 8</p>
<p>I want the output to be "08".</p>
<p>Is this possible?</p>
| <p>Use <code>Text.Printf.printf</code>:</p>
<pre><code>printf "%02d" v
</code></pre>
<p>Make sure to import <code>Text.Printf.printf</code> first.</p>
| <p>The <code>printf</code> way is probably best, but it's easy enough to write your own function:</p>
<pre><code>show2d :: Int -> String
show2d n | length (show n) == 1 = "0" ++ (show n)
| otherwise = show n
</code></pre>
<p>Works as follows:</p>
<pre><code>Prelude> show2d 1
"01"
Prelude> show2d 1... | 49,352 |
<p>In <a href="http://www.joelonsoftware.com/articles/GuerrillaInterviewing3.html" rel="noreferrer">The Guerilla Guide to Interviewing</a> Joel says that guys who want to get things done, but are not smart will do stupid things like using a visitor design pattern where a simple array would be sufficient.</p>
<p>I find... | <p>I often find that using test driven development helps guide me when faced with these questions.</p>
<ul>
<li><em>When is a simple approach
sufficient?</em> It is always sufficient
to use the simplest approach to get
the next test to pass. But knowing
when/how to refactor is the real art
form. </li>
<li><em>What i... | <p>One of the nice things about the the original GoF book is that there is discussion of the scenarios where the pattern would best solve problem. Reviewing these discussions can help you determine if "it's time".</p>
<p>Another good place to start is with Head First Design Patterns. The exercises that illustrate th... | 32,966 |
<p>I'm sending mail from my C# Application, using the SmtpClient. Works great, but I have to decide if I want to send the mail as Plain Text or HTML. I wonder, is there a way to send both? I think that's called multipart.</p>
<p>I googled a bit, but most examples essentially did not use SmtpClient but composed the who... | <p>What you want to do is use the AlternateViews property on the MailMessage</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.alternateviews.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.alternateviews.aspx</a></p>
| <p>For anyone who bumped into this issue you might want to check if you have preheader tags in your html.</p>
<p>In my html I've added a tag with a phrase of "Activate your client admin account by clicking the link.".</p>
<p>It seems like gmail is flagging the phrase "clicking the link" after remov... | 6,652 |
<p>I'm coding a framework along with a project which uses this framework. The project is a Bazaar repository, with the framework in a subfolder below the project.</p>
<p>I want to give the framework a Bazaar repository of its own. How do I do it?</p>
| <p>You use the split command:</p>
<pre><code>bzr split sub_folder
</code></pre>
<p>This creates an independant tree in the subfolder, which you can now export and work on separately.</p>
| <p>As far as I know, there is not a way to do this easily with bazaar. One possibility is to take the original project, branch it, and then remove everything unrelated to the framework. You can then move the files in the subdir to the main dir. It's quite a chore, but it is possible to preserve the history. </p>
<... | 9,260 |
<p>I am using a JEditorPane as an editor to write comments in my application. The content type is set "text/plain". When I am writing text in it and the text fills the available space and I go on typing, the text is not moving upward to show the cursor. So I dont know where I am typing and what I am typing since it wou... | <p>You need to put the editor inside a JScrollPane. The ScrollPane will automatically add scrollbars and remove the need to resize the editor.</p>
| <p>Edited to add full solution</p>
<p>You have to add a JScrollPane first. Then, if you don't want the scrollbars to be visible, but you want the text area to autoscroll, set </p>
<pre><code>scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setVerticalScrollBarPolicy(... | 34,208 |
<p>Is there an open source alternative (similar to ultraedit) to handle files with filesize >200 MBytes?</p>
| <p><a href="http://www.vim.org/" rel="nofollow noreferrer">vim or gvim</a> (graphical vim) should handle that with pleasure.</p>
| <p>My specs: Windows XP - 2 GByte RAM</p>
<p>Testfilesize: 280 MBytes</p>
<p>I used a standard installation of the editors below without any further configuration:</p>
<p>Notepad++: Did not open the file (error message: File ist too big to be opened by Notepad++)</p>
<p>Emacs: Did not open the file (error message: ... | 21,771 |
<p>Considering the following architecture:</p>
<ul>
<li>a base object 'Entity'</li>
<li>a derived object 'Entry:Base'</li>
<li>and a further derived object 'CancelledEntry:Entry'</li>
</ul>
<p>In EntitySQL I can write the following: </p>
<pre><code>[...] where it is of (only MyEntities.Entry) [...]
</code></pre>
<p... | <p>Why don't you apply an extension method on IQueryable< Entry > called ApplyBaseEntryFilter() which would apply this filter and return an IQueryable< Entry >. </p>
<p>This is an example of how to reuse linq query fragments. Using extension methods on IQueryable< Entity > is a great way to re-use queries as ... | <p>Ok, I have found a partial solution:</p>
<pre><code>EntityContext.EntitySet.OfType<Entry>().Where( obj => !(obj is CancelledEntry) )
</code></pre>
<p>This is quite awful however, since if I create a new derived object, I have to go in all the queries and specifically add a condition to remove it.</p>
<p>... | 13,398 |
<p>Can <a href="http://en.wikipedia.org/wiki/Unicode" rel="noreferrer">Unicode</a> characters be encoded and decoded with <a href="http://en.wikipedia.org/wiki/Base64" rel="noreferrer">Base64</a>?</p>
<p>I have attempted to encode the string 'الله', but when I decoded it all I got was '????'.</p>
| <p>Base64 converts <em>binary</em> to text. If you want to convert text to a base64 format, you'll need to convert the text to binary using some appropriate encoding (e.g. UTF-8, UTF-16) first.</p>
| <p>You didn't specify which language(s) you're using, but try converting the string to a byte array (however that's done in your language of choice) and then base64 encoding that byte array.</p>
| 39,239 |
<p>Can somebody point me to a resource that explains how to go about having 2+ IIS web server clustered (or Webfarm not sure what its called) ?</p>
<p>All I need is something basic, an overview how and where to start.
Can't seem to find anything...</p>
| <p>This MSDN magazine article has a good overview of the technologies involved:</p>
<p><a href="http://msdn.microsoft.com/en-us/magazine/cc500561.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/magazine/cc500561.aspx</a></p>
| <p>A couple of good articles for those who are looking nowadays for information about <strong>Server Farms</strong> - <strong>Load Balancing</strong> and <strong>Application Request Rooting</strong> that I found and wanted to share are these: </p>
<p>HTTP Load Balancing using Application Request Routing:
<a href="http... | 3,893 |
<p>I have a list of ranked users, and would like to select the top 50. I also want to make sure one particular user is in this result set, even if they aren't in the top 50. Is there a sensible way to do this in a single mysql query? Or should I just check the results for the particular user and fetch him separately, i... | <p>If I understand correctly, you could do:</p>
<pre><code>select * from users order by max(rank) desc limit 0, 49
union
select * from users where user = x
</code></pre>
<p>This way you get 49 top users plus your particular user.</p>
| <pre><code>declare @topUsers table(
userId int primary key,
username varchar(25)
)
insert into @topUsers
select top 50
userId,
userName
from Users
order by rank desc
insert into @topUsers
select
userID,
userName
from Users
where userID = 1234 --userID of special user
select * from @topUsers
... | 13,188 |
<p>How can I permanently enable line numbers in IntelliJ IDEA?</p>
| <h2>IntelliJ 14.X Onwards</h2>
<p>From version 14.0 onwards, the path to the setting dialog is slightly different, a <strong>General</strong> submenu has been added between <strong>Editor</strong> and <strong>Appearance</strong> as shown below</p>
<p><img src="https://i.stack.imgur.com/9DL9q.png" alt="enter image des... | <p>On Mac Intellij 12.1.2 there is no File-Settings:</p>
<p>There is an application-name menu item to the left of "File" with a "preferences" menu item:</p>
<p><img src="https://i.stack.imgur.com/veG7t.png" alt="Choosing "Preferences" on the Mac."></p>
<p>and within that is the "Settings" dialog shown by t... | 3,468 |
<p>I found a wonderful open source Java program that I'm translating into C#. The built-in translator in Visual Studio got me started and I've now spent about a month translating the rest manually line by line. I've completed over 15,000 lines of translation and the only thing that remains is trying to figure out how t... | <p>The standard .NET <a href="http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx" rel="nofollow noreferrer"><code>System.Drawing.</code><strong><code>Bitmap</code></strong></a> class in the <code>System.Drawing.dll</code> assembly comes close to what I know of the <code>MemoryImageSource</code> (i.e., a... | <p>Look at the System.Drawing namespace. This wraps the standard windows GDI+ native code.</p>
<p>System.Drawing.BitMap is probably what you want.</p>
| 24,353 |
<p>Is there any way to do this in the Powerbuilder properties window for a datawindow's textbox?</p>
| <p>That kind of depends on how you define "textbox", but in general the only way to mix normal and superscript text is with a richtext control. In PB 11.5, you can even use richtext as a column style. </p>
<p>Good luck,</p>
<p>Terry.</p>
| <p>We ended up using two separate text fields. It's a butt-ugly solution, but it works. The superscript field has a smaller font and is nudged a little higher up.</p>
<p>I think newer PB versions support superscripts.</p>
<p>Thanks for the help.</p>
<p>Glenn</p>
| 18,000 |
<p>Does anybody have best practices for exception handling ?</p>
<p>When searching the web I find a lot of best practices on a code level (don't catch general exceptions, don't rethrow new exceptions etc.) What I am looking for is best practises on a higher level, stuff like :</p>
<ul>
<li>within an application catch... | <p>@Ilya:</p>
<p>That is probably one of the worst article Joel has ever written (for those who haven't read the link, he is arguing "Exceptions considered harmful", so do not use them).</p>
<p>Joel has two problems with exceptions:</p>
<ol>
<li><p>They are invisible in the source code.</p>
<ul>
<li>But so are unha... | <p>You could do a lot worse than look through the code and documentation for Microsoft's <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=8CA8EB6E-6F4A-43DF-ADEB-8F22CA173E02&displaylang=en" rel="nofollow noreferrer">Exception Management Application Block</a>. It's probably overkill for a lot of sc... | 30,030 |
<p>Python 2.6 was basically a stepping stone to make converting to Python 3 easier. A lot of the features destined for Python 3 were implemented in 2.6 if they didn't break backward compatibility with syntax and the class libs.</p>
<p>Why weren't set literals (<code>{1, 2, 3}</code>), set comprehensions (<code>{v for... | <p>It wasn't done because nobody took the time to do it. There are bugs opened for months, and no one commented on them:</p>
<ul>
<li><a href="http://bugs.python.org/issue2333" rel="nofollow noreferrer">http://bugs.python.org/issue2333</a></li>
<li><a href="http://bugs.python.org/issue2334" rel="nofollow noreferrer">h... | <p>All these are syntax/grammar changes. Such changes are traditionally introduced first in a Python x.y version with a <code>from __future__ import …</code> statement, and implemented at least on Python x.(y+1) version. Such a transition hasn't happened yet for these changes.</p>
<p>Technically, I've answered your "w... | 44,935 |
<p>I am looking to refactor a c# method into a c function in an attempt to gain some speed, and then call the c dll in c# to allow my program to use the functionality.</p>
<p>Currently the c# method takes a list of integers and returns a list of lists of integers. The method calculated the power set of the integers s... | <p>This returns one set of a powerset at a time. It is based on python code <a href="http://groups.google.com/group/comp.lang.python/browse_thread/thread/d9211cd6c65e1d3a/" rel="noreferrer">here</a>. It works for powersets of over 32 elements. If you need fewer than 32, you can change long to int. It is pretty fast -- ... | <p>P Daddy:</p>
<p>You could change your Combination() code to this:</p>
<pre><code> static long Combination(long n, long r)
{
r = (r > n - r) ? (n - r) : r;
if (r == 0)
return 1;
long result = 1;
long k = 1;
while (r-- > 0)
{
result... | 44,694 |
<p>I've read in several places that the rectangle functions in emacs are very useful. I've read a bit about them, and I can't quite figure why. I mean, when you want to kill a paragraph, you mark the first row/column and then the last one, and that's actually a rectangle, right? But you can still use the normal kill..... | <p>If you have data in columns in a text file with <code>M-x delete-rectangle</code> or <code>M-x kill-rectangle</code> you can delete a single column of data. Similarly, <code>M-x yank-rectangle</code> will paste in a column of text.</p>
<p>For example, take the following text:</p>
<pre><code>1. alligator alphor... | <p>In emacs24+ there's also function for numbering lines:</p>
<pre><code>(rectangle-number-lines START END START-AT &optional FORMAT)
Insert numbers in front of the region-rectangle.
START-AT, if non-nil, should be a number from which to begin
counting. FORMAT, if non-nil, should be a format string to pass
to `... | 8,331 |
<p>I have a template class that I serialize (call it C), for which I want to specify a version for boost serialization. As BOOST_CLASS_VERSION does not work for template classes. I tried this:</p>
<pre><code>namespace boost {
namespace serialization {
template< typename T, typename U >
struct version<... | <pre><code>#include <boost/serialization/version.hpp>
</code></pre>
<p>:-)</p>
| <p>To avoid premature dependency of your library on Boost.Serialization you can forward declare:</p>
<pre><code>namespace boost {
namespace serialization {
template<typename T> struct version;
} // end namespace serialization
} // end namespace boost
</code></pre>
<p>Instead of including the header.
To declar... | 10,828 |
<p>I was hanging out in my profiler for a while trying to figure out how to speed up a common log parser which was bottlenecked around the date parsing, and I tried various algorithms to speed things up.</p>
<p>The thing I tried that was fastest for me was also by far the most readable, but potentially non-standard C.... | <p>Solaris 10 - SPARC - SUN Compiler.</p>
<p>Test code:</p>
<pre><code>#include <stdio.h>
static int parseMonth(const char *input) {
int rv=-1;
int inputInt=0;
int i=0;
for(i=0; i<4 && input[i]; i++) {
inputInt = (inputInt << 8) | input[i];
}
switch(inputInt) ... | <p>Machine word size issues aside, your compiler may promote input[i] to a negative integer which will just set the upper bits of inputInt with or operation, so I suggest you to be explicit about signedness of char variables.</p>
<p>But since in US, no one cares about the 8th bit, it is probably a non-issue for you.</... | 42,537 |
<p>I have a strange problem with my cake (cake_1.2.0.7296-rc2).
My start()-action runs twice, under certain circumstances, even though only one request is made.</p>
<p>The triggers seem to be :
- loading an object like: <code>$this->Questionnaire->read(null, $questionnaire_id);</code>
- accessing $this-data </p>... | <p>Check your layout for non-existent links, for example a misconfigured link to favicon.ico will cause the controller action to be triggered for a second time. Make sure favicon.ico points towards the webroot rather than the local directory, or else requests will be generated for /controller/action/favicon.ico rather ... | <p>I had the same problem in chrome, I disabled my 'HTML Validator' add on. Which was loading the page twice</p>
| 8,932 |
<p>I have a function that I use called sqlf(), it emulates prepared statements. For instance I can do things like:</p>
<pre>
$sql = sqlf("SELECT * FROM Users WHERE name= :1 AND email= :2",'Big "John"','bj@example.com') ;
</pre>
<p>For various reasons, I cannot use prepared statements, but I would like to emulate the... | <p>Null is the only value that you can guarantee is not in the set. How come it is not an option? Anything else can be seen as part of the potential set, they are all values.</p>
| <p>The only way I can think to do it would be to make your <code>sqlf()</code> function scan to see if a particular substitution comes soon after an "IN (" and then if the passed variable is an empty array, put in something which you know for certain won't be in that column: <code>"m,znmzcb~~1"</code>, for example. It'... | 15,157 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.