instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I'm familiar with a handful of the free static analysis tools available for Java, such as FindBugs and PMD. What I'd like to know is how the commercial products such as Klocwork and Coverity stack up against these. What are their strengths and weaknesses?</p>
| <p>We use a suite of open source and commercial static analysis tools. The different tools find different kinds of bugs and some are tuned for lower false positive rates, at the expense of possibly missing some real problems.</p>
<p>In my experience, Findbugs does a good job of finding real problems, especially if you... | <p>here's a list of commercial analysis tools : <a href="http://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis#Java_2" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis#Java_2</a></p>
<p>coverity has several tools : <br>
<a href="http://www.coverity.com/html/co... | 25,448 |
<p>If I had a dictionary <code>dict</code> and I wanted to check for <code>dict['key']</code> I could either do so in a <code>try</code> block (bleh!) or use the <code>get()</code> method, with <code>False</code> as a default value.</p>
<p>I'd like to do the same thing for <code>object.attribute</code>. That is, I alr... | <p>A more direct analogue to <code>dict.get(key, default)</code> than <code>hasattr</code> is <code>getattr</code>.</p>
<pre><code>val = getattr(obj, 'attr_to_check', default_value)
</code></pre>
<p>(Where <code>default_value</code> is optional, raising an exception on no attribute if not found.)</p>
<p>For your exa... | <p>For checking if a key is in a dictionary you can use <code>in</code>: <code>'key' in dictionary</code>.</p>
<p>For checking for attributes in object use the <code>hasattr()</code> function: <code>hasattr(obj, 'attribute')</code></p>
| 46,342 |
<pre><code>private IEnumerable<string> Tables
{
get
{
yield return "Foo";
yield return "Bar";
}
}
</code></pre>
<p>Let's say I want iterate on those and write something like processing #n of #m. </p>
<p>Is there a way I can find out the value of m without iterating before my main ite... | <p><code>IEnumerable</code> doesn't support this. This is by design. <code>IEnumerable</code> uses lazy evaluation to get the elements you ask for just before you need them.</p>
<p>If you want to know the number of items without iterating over them you can use <code>ICollection<T></code>, it has a <code>Count</c... | <p>I would suggest calling ToList. Yes you are doing the enumeration early, but you still have access to your list of items.</p>
| 20,386 |
<p>Not sure if this is intended behavior or a bug or a wrong function that I'm using, but the problem is that PathCombine() returns a wrong path on a Vista box.</p>
<p>The relative path is (as exported by the WMP to a playlist):</p>
<p><code>..\..\..\Public\Music\Sample Music\Amanda.wma</code></p>
<p>The path it's r... | <p>The <a href="http://msdn.microsoft.com/en-us/library/bb773571(VS.85).aspx" rel="nofollow noreferrer">documentation for PathCombine</a> specifies that the second parameter, <em>lpszDir</em>, is "A pointer to a null-terminated string of maximum length MAX_PATH that contains the directory path." You appear to be passi... | <p>When you combine your two strings, you get the following.</p>
<pre><code>C:\Users\userX\Music\Playlists\playlist.wpl\..\..\..\Public\Music\Sample Music\Amanda.wma
</code></pre>
<p>Since each "<code>..</code>" will wipe out the preceding section, you end u[p with the following sequence:</p>
<pre><code>C:\Users\use... | 45,760 |
<p>Any good tutorial with source that will demonstrate how to develop neural network (step bay step for dummies ;-))</p>
| <p>Here is good example:
<a href="http://www.codeproject.com/KB/dotnet/neuralnetwork.aspx" rel="noreferrer">Brainnet 1 - A Neural Netwok Project - With Illustration And Code - Learn Neural Network Programming Step By Step And Develop a Simple Handwriting Detection System</a> that will demonstrate some practical uses of... | <p>You can have a look at <a href="http://generation5.org/articles.asp?Action=List&Topic=Neural+Networks" rel="nofollow">http://generation5.org/articles.asp?Action=List&Topic=Neural+Networks</a> which contains a lot of articles about various types of neural networks targeting both beginners and advanced fields.... | 12,578 |
<p>What actually happens to the file system when you do a Subclipse Share Project on an Eclipse project that was externally checked out from Subversion? All the .svn folders are already in place. I get an error when I try to Share Project the right way, and I'd rather not delete and re-checkout the projects from the ... | <p>Dunno exactly what happens within eclipse, I presume it does some funky stuff in the .metadata directory of the workspace. That said, I would recommend the following to get eclipse to learn about the svn settings of the project:</p>
<ul>
<li>Delete the project from the workspace (keep "Delete project contents on d... | <p>I'm not sure what version of Eclipse you are using or whether this will apply since I'm using Subversive instead of Subclipse. When I use the share project feature to commit the project into svn when I already have all of the .svn directories in place, I get a choice of like "Use current project settings" and then ... | 6,650 |
<p>Is there any way of pulling in a CSS stylesheet into FireFox 2 or 3 that is not a static file? </p>
<p>Bellow is the code we are using to pull in a stylesheet dynamically generated by a CGI script.</p>
<pre><code><link rel="stylesheet" href="/cgi-bin/Xebra?ShowIt&s=LH4X6I2l4fSYwf4pky4k&shw=795430-0&am... | <p>Is the Content Type from the server the correct one for the file that is served up?</p>
<pre><code>Content-type: text/css
</code></pre>
| <p>I've done the same thing in the past - <a href="http://support.specorp.com" rel="nofollow noreferrer">a former employer's site</a> uses a link tag much like yours, and works fine in FF2 at least (I just checked it, though I tested it in FF when we added that link). If it's not working, I'd suspect it's something abo... | 34,339 |
<p>I notice sometimes with my parent/child objects or many-to-many relationships, I need to call either <code>SaveOrUpdate</code> or <code>Merge</code>. Usually, when I need to call <code>SaveOrUpdate</code>, the exception I get on calling <code>Merge</code> has to do with transient objects not being saved first.</p>
... | <p>This is from section <a href="http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/objectstate.html" rel="noreferrer">10.7. Automatic state detection</a> of the Hibernate Reference Documentation:</p>
<blockquote>
<p>saveOrUpdate() does the following:</p>
<ul>
<li>if the object is already persistent in... | <pre><code>@Entity
@Table(name="emp")
public class Employee implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="emp_id")
private int id;
@Column(name="emp_name")
private String name;
@Column(name="sala... | 20,620 |
<p>This is ASP classic, not .Net. We have to get a way to SFTP into a server to upload and download a couple of files, kicked off by a user.</p>
<p>What have other people used to do SFTP in ASP classic? Not necessarily opposed to purchasing a control.</p>
| <p>If you have the ability to use WScript.Shell then you can just execute pscp.exe from the <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/" rel="noreferrer">Putty</a> package. Obviously this is less then ideal but it will get the job done and let you use SCP/SFTP in classic ASP.</p>
| <p>December 2020 :</p>
<ul>
<li>ASP is dead, it has been superseded by ASP .Net 18 years ago.</li>
<li>At this time, the most common way to use SFTP in .Net is to use the <a href="https://github.com/sshnet/SSH.NET/" rel="nofollow noreferrer">SSH.NET NuGet package</a>.</li>
</ul>
<p>Maybe this question should be closed ... | 2,322 |
<p>Which is the best, user-friendliest performance tool for MySQL? I'd like help with pinpointing the bottle neck of my setup. Is the problem in the SQL statements, the settings variables, or something else?</p>
| <p>The bad news: there are GUI tools to help with this, but its a skilled and wide ranging job. So they don't cover everything, its likely you will need to use command line stuff/sql statements etc to help. I've only really used the command line tools. I'll give a bit of an overview of things I know/have used:</p>
<p>... | <p>I found <a href="http://webyog.com/en/" rel="nofollow noreferrer">MONyog</a> to be a BIG help when I had a suffering mysql server.</p>
<p>It's a webbased system that analyses your system 24/7 and gives you decent suggestions for better values of system variables, cache sizes, etc...</p>
<p>It also has a built in my... | 47,272 |
<p>What is the proper way to terminate a Swing application from the code, and what are the pitfalls?</p>
<p>I'd tried to close my application automatically after a timer fires. But just calling <code>dispose()</code> on the <code>JFrame</code> didn't do the trick - the window vanished but the application did not termi... | <p>Your JFrame default close action can be set to "<code>DISPOSE_ON_CLOSE</code>" instead of <code>EXIT_ON_CLOSE</code> (why people keep using EXIT_ON_CLOSE is beyond me).</p>
<p>If you have any undisposed windows or non-daemon threads, your application will not terminate. This should be considered a error (and solvin... | <p>I think, the idea is here the WindowListener - you can add any code there that you'd like to run before the thing shuts down</p>
| 32,211 |
<p>Is there a cross-platform way to list the processes running on one's computer through a python script? For Unix based system "ps -ef" works, but I am new to Python and don't know a way to write something that would work across any platform.</p>
<p>Thanks!</p>
| <p>Python itself doesn't offer any such functionality. On PyPI, there is the <a href="http://pypi.python.org/pypi/enumprocess/0.1" rel="nofollow noreferrer">enumprocess</a> package, which supposedly helps; there is also the <a href="http://www.psychofx.com/psi/trac/wiki/" rel="nofollow noreferrer">PSI</a> package. I ha... | <p>While <a href="https://bitbucket.org/chrismiles/psi/wiki/Home" rel="nofollow">PSI</a> page lists some alternatives, what you need is <a href="http://code.google.com/p/psutil/" rel="nofollow">psutil</a>. It is the only one that supports Windows, or as it states on a home page:</p>
<blockquote>
<p>Linux, Windows, O... | 47,914 |
<p>I have a .jar file that i've placed in my D:\Coldfusion8\wwwroot\web-inf\lib\ directory. The file is abcdef.jar</p>
<p>This is my first time doing this, not sure what the path should be in my createObject().</p>
<pre><code><cfset abcObj = createObject("java","com.abcdef") />
<cfset result = acbObj.doStuf... | <p>Have you restarted the Coldfusion Service? </p>
<p>Even when in the class path, jars are only loaded at server start.</p>
<p>Info moved up from the comments:</p>
<ul>
<li>Make sure the file is in the System class path, or in the one of the configured class paths of ColdFusion.</li>
<li>As for the class name param... | <p>Have you restarted the Coldfusion Service? </p>
<p>Even when in the class path, jars are only loaded at server start.</p>
<p>Info moved up from the comments:</p>
<ul>
<li>Make sure the file is in the System class path, or in the one of the configured class paths of ColdFusion.</li>
<li>As for the class name param... | 37,820 |
<p>I'm trying to show in the screen a table...</p>
<p>Basically I create a custom UITableViewController with the methods needed for the UITableView delegate and data source which is self since UITableViewController does it for you.</p>
<p>When I put it in the <code>-initWithRootView:</code> controller, and add the na... | <p>You can do it yourself, or you can do it with boost: <a href="http://www.boost.org/doc/libs/1_37_0/libs/serialization/doc/index.html" rel="nofollow noreferrer">http://www.boost.org/doc/libs/1_37_0/libs/serialization/doc/index.html</a>. What you currently try is just view the map as a plain old datatype, which essent... | <p>Great question. Problem here is that the default containers don't support serialization - you have to write it yourself, it's a pain, but it's possible.</p>
<p>Here's how you could serialize a <code>std::map</code> to a textual format. You can adapt it to write to whatever binary format you need. Just replace the <... | 45,774 |
<p>Hypothetical situation: let's say I have a 3rd party .net assembly being used in the ASP.Net web system that I'm working on that just kinda crashes every now and then. When it does so, all calls to it throw exceptions until the system is rebooted. This is, obviously, a little sub-optimal.</p>
<p>Is there a way to... | <p>Calling HttpRuntime.UnloadAppDomain() will force the application to terminate itself and restart when the next web request arrives. This results in everything being reloaded from scratch and should eliminate the corrupted assembly data.</p>
<p>Granted, this will kill any active sessions, but if the application is e... | <p>It may be that when it crashes weirdly it still leaves an active process alive that hoses any subsequent attempts to call the DLL. If so, you may be able to find it programatically and kill it, which may fix the problem that was requiring a reboot.</p>
| 36,628 |
<p>My users would like to be able to hit <kbd>Ctrl</kbd>+<kbd>S</kbd> to save a form. Is there a good cross-browser way of capturing the <kbd>Ctrl</kbd>+<kbd>S</kbd> key combination and submit my form?</p>
<p>App is built on Drupal, so jQuery is available.</p>
| <pre><code>$(window).keypress(function(event) {
if (!(event.which == 115 && event.ctrlKey) && !(event.which == 19)) return true;
alert("Ctrl-S pressed");
event.preventDefault();
return false;
});
</code></pre>
<p>Key codes can differ between browsers, so you may need to check for more t... | <p>example:</p>
<pre><code>shortcut.add("Ctrl+c",function() {
alert('Ok...');
}
,{
'type':'keydown',
'propagate':false,
'target':document
});
</code></pre>
<p>usage</p>
<pre><code><script type="text/javascript" src="js/shortcut.js"></script>
</code></pre>
<p>link for download: <a href="h... | 11,927 |
<p>I have a rails app that is working fine except for one thing.</p>
<p>When I request something that doesn't exist (i.e. /not_a_controller_or_file.txt) and rails throws a "No Route matches..." exception, the response is this (blank line intentional):</p>
<pre><code>HTTP/1.1 200 OK
Date: Thu, 02 Oct 2008 10:28:02 GMT... | <p>This is a fairly old thread, but for what it's worth I found a great resource that includes a detailed description of the problem and the solution. Apparently this bug affects Rails < 2.3 when used with Mongrel.</p>
<ul>
<li><a href="http://billkirtley.wordpress.com/2009/03/03/failsafe-handling-with-rails/" rel=... | <p>This is coming from rails itself.</p>
<p><a href="http://github.com/rails/rails/tree/master/actionpack/lib/action_controller/dispatcher.rb#L60" rel="nofollow noreferrer">http://github.com/rails/rails/tree/master/actionpack/lib/action_controller/dispatcher.rb#L60</a></p>
<p>The dispatcher is return an error page wi... | 19,538 |
<p>Imagine I have a file with </p>
<pre><code>Xpto,50,30,60
Xpto,a,v,c
Xpto,1,9,0
Xpto,30,30,60
</code></pre>
<p>that txt file can be appended a lot of times and when I open the file I want only to get the values of the last line of the txt file... How can i do that on python? reading the last line?</p>
| <p>I think my answer from the <a href="https://stackoverflow.com/questions/260273/most-efficient-way-to-search-the-last-x-lines-of-a-file-in-python">last time this came up</a> was sadly overlooked. :-)</p>
<blockquote>
<p>If you're on a unix box,
<code>os.popen("tail -10 " +
filepath).readlines()</code> will pro... | <p>Not sure about a python specific implementation, but in a more language agnostic fashion, what you would want to do is skip (seek) to the end of the file, and then read each character in backwards order until you reach the line feed character that your file is using, usually a character with value 13. just read for... | 42,485 |
<p>I have an Ender 3, currently in stock Bowden extruder configuration.</p>
<p>I want to be able to print nylon and TPU, both of which require temperature too high for the tolerance of the PTFE Bowden tube (as well as the issues with the flexible filament in the tube).</p>
<p>Therefore, I've considered converting my pr... | <p>Direct Drive v.s. Bowden has no relation to the maximum print temperature. What determines the maximum print temperature is the design of the hotend itself. There are "all-metal" designs, where the PTFE tube (Bowden or not) stops in the cold zone and the heatbreak and all other components that get hot are ... | <p>Bowden tubes extending to the nozzle to make a seal will damage the Teflon (PTFE) tube if exceeding 250°C for an extended time. An all-metal hotend for a Bowden would have either the nozzle sealed against the heatbreak or an integrated nozzle and heatbreak. Then the Bowden tube would attach with a minimum gape wi... | 1,959 |
<p>A lot of useful features in Python are somewhat "hidden" inside modules. Named tuples (new in <a href="http://docs.python.org/whatsnew/2.6.html" rel="nofollow noreferrer">Python 2.6</a>), for instance, are found in the <a href="http://docs.python.org/library/collections.html" rel="nofollow noreferrer">collections</a... | <p>The most impressive new module is probably the <code>multiprocessing</code> module. First because it lets you execute functions in new processes just as easily and with roughly the same API as you would with the <code>threading</code> module. But more importantly because it introduces a lot of great classes for co... | <p>May be <a href="http://www.python.org/dev/peps/pep-0361/" rel="nofollow noreferrer">PEP 0631</a> and <a href="http://docs.python.org/whatsnew/2.6.html" rel="nofollow noreferrer">What's new in 2.6</a> can provide elements of answer. This last article explains the new features in Python 2.6, released on October 1 2008... | 20,371 |
<p>I'm reading this C++ open source code and I came to a constructor but I don't get it ( basically because I don't know C++ :P ) </p>
<p>I understand C and Java very well.</p>
<pre><code> TransparentObject::TransparentObject( int w, int x, int y, int z ) :
_someMethod( 0 ),
_someOtherMethod( 0 ),
_so... | <p>The most common case is this:</p>
<pre><code>class foo{
private:
int x;
int y;
public:
foo(int _x, int _y) : x(_x), y(_y) {}
}
</code></pre>
<p>This will set <code>x</code> and <code>y</code> to the values that are given in <code>_x</code> and <code>_y</code> in the constructor parameters. This is oft... | <p>Without using the initialiser list all class members will simply have their default constructor called so this is the only place that you can control <em>which</em> constructor is called (for non-dynamically allocated members). The same is true for which parent class constructor will be called.</p>
<p>Class members... | 25,854 |
<p>I'm starting to use CUDA at the moment and have to admit that I'm a bit disappointed with the C API. I understand the reasons for choosing C but had the language been based on C++ instead, several aspects would have been a lot simpler, e.g. device memory allocation (via <code>cudaMalloc</code>).</p>
<p>My plan was ... | <p>I would go with the placement new approach. Then I would define a class that conforms to the std::allocator<> interface. In theory, you could pass this class as a template parameter into std::vector<> and std::map<> and so forth.</p>
<p>Beware, I have heard that doing such things is fraught with difficul... | <p>There are several projects that attempt something similar, for example <a href="http://cudpp.github.io/" rel="nofollow noreferrer">CUDPP</a>.</p>
<p>In the meantime, however, I've implemented my own allocator and it works well and was straightforward (> 95% boilerplate code).</p>
| 38,418 |
<h2>What I'm trying to accomplish</h2>
<ul>
<li>My app generates some tabular data</li>
<li>I want the user to be able to launch Excel and click "paste" to place the data as cells in Excel</li>
<li>Windows accepts a format called "CommaSeparatedValue" that is used with it's APIs so this seems possible</li>
<li>Putting... | <p>The .NET Framework places <code>DataFormats.CommaSeparatedValue</code> on the clipboard as Unicode text. But as mentioned at <a href="http://www.syncfusion.com/faq/windowsforms/faq_c98c.aspx#q899q" rel="noreferrer">http://www.syncfusion.com/faq/windowsforms/faq_c98c.aspx#q899q</a>, Excel expects CSV data to be a UTF... | <p>I got the most success defeating formatting issues by using a CSV library (<a href="https://github.com/kentcb/KBCsv" rel="nofollow noreferrer">KBCsv</a>) to write the data into a CSV file in the temp folder then open it in Excel with <code>Process.Start()</code>. Once it is in Excel the formatting bit is easy(er), c... | 42,739 |
<p>I'm having trouble coming up with the proper syntax for allowing either a string or a NULL to be passed to the database. Here's my code:</p>
<pre><code>string insertString = String.Format(
@"INSERT INTO upload_history (field1, field2, field3)
VALUES ('{0}', '{1}', '{2}')",
varField1, varField2, varFiel... | <p>Don't concatenate the string (<code>string.Format</code>) - use parameters (<code>@p1</code> etc) - then you can pass <code>DBNull.Value</code> to mean null to SQL Server</p>
<pre><code>SqlCommand cmd = new SqlCommand();
cmd.CommandText = @"INSERT INTO upload_history (field1, field2, field3)
VALUES (@p1, @p2, @... | <p>In the spirit of answering the question as it was asked, and being fully aware that refactoring the code to paramaterizing the queries is the correct solution, you could write a function that returns either a single-quoted string or a non-quoted NULL string value, then remove the single-quotes from the query string.... | 48,981 |
<p>I have 2 detail sections on my report (details a and details b).
Fields in both sections can grow up to 10 lines.</p>
<p>How do I force the Crystal Report to print both sections on one page?
Currently the report on bottom page print section "details a", but section "details b" prints on next page.
How do I prevent... | <p><a href="http://linux.die.net/man/1/file" rel="nofollow noreferrer"><code>file(1)</code></a> should give you some useful information. You can also use ImageMagick's <a href="http://www.imagemagick.org/script/identify.php" rel="nofollow noreferrer"><code>identify(1)</code></a> program (optionally with the <code>-ver... | <p>CF stands for "Compression Factor". CF-10 means factor ten, and I don't think it's different from any "standard" jpeg.</p>
| 13,876 |
<p>How can I create a empty .mdb file? I'm using ADO.NET and C#. Thanks!</p>
| <p>Copy a pre-existing .mdb file is the best way. </p>
<p>The same is true for most of the other filebased database formats that ADO.NET can connect to, such as Excel files. Since a file based database system is using the filesystem as it's host and API for communication with the outside world (as opposed to say MSS... | <p>I don't think there is a ".NET native" way to do it, but you still can wrap ADOX:</p>
<pre><code>using ADOX; // add a COM reference to "Microsoft ADO Ext. x.x for DDL and Security"
static void CreateMdb(string fileNameWithPath)
{
ADOX.Catalog cat = new ADOX.Catalog();
string connstr = "Provider=Microsoft.Jet... | 45,095 |
<p>I'm relatively new to 3d printing, and wanted to get a few things understood.
Firstly, I am unclear on how Hexagonal infill is stronger than, say, diamond pattern. </p>
<p>Can anyone explain how the different shape causes the structure to be stronger? I saw a few places that hex is stronger; usually, more vertices ... | <p>Hex grids are used for different reasons than triangular grids (such as you often see on bridges and roof systems). Triangles are especially good at being <em>rigid</em>, while hex grids are very material-efficient for a given strength. The second reason ($) is typically more important for 3D printing.</p>
<p>Trian... | <p>Correction: I believe I found what you are looking for:</p>
<p><a href="https://engineerdog.com/2015/09/02/mechanical-testing-3d-printed-parts-results-and-recommendations/" rel="nofollow noreferrer">Report from EngineerDog.com</a></p>
<p>The author concludes that rectilinear infill with a zero degree offset is the... | 531 |
<p>I have a user control that I'm building. It's purpose is to display the status of a class to the user. Obviously, this does not matter, and will slow things down when the control runs in the IDE, as it does as soon as you add it to a form.</p>
<p>One way to work around this would be to have the control created an... | <pre><code>public static bool IsInRuntimeMode( IComponent component ) {
bool ret = IsInDesignMode( component );
return !ret;
}
public static bool IsInDesignMode( IComponent component ) {
bool ret = false;
if ( null != component ) {
ISite site = component.Site;
if ( null != site ) {
... | <p>This is the method I used in my project:</p>
<pre><code>//use a Property or Field for keeping the info to avoid runtime computation
public static bool NotInDesignMode { get; } = IsNotInDesignMode();
private static bool IsNotInDesignMode()
{
/*
File.WriteAllLines(@"D:\1.log", new[]
{
LicenseManag... | 43,694 |
<p>The following two forms of jQuery selectors seem to do the same thing:</p>
<ul>
<li>$("div > ul.posts") </li>
<li>$("div ul.posts")</li>
</ul>
<p>which is to select all the "ul" elements of class "posts" under "div" elements.</p>
<p>Is there any difference?</p>
| <p>Concerning <code>$("div > ul.posts")</code>, only direct descendants of <code>DIV</code>s will be selected.</p>
<pre><code><div>
<ul class="posts"> <!--SELECTED-->
<li>List Item</li>
<ul class="posts"> <!--NOT SELECTED-->
<li>Sub lis... | <p>I'm just adding a familiar reference here. I realize it's years after the original question but it was on the first page on Google and maybe this will help someone else.</p>
<p>Think of real-world ancestors and parents. Parent and Child are always one generation apart, but ancestors and their descendants can be hun... | 24,922 |
<p>I have 3 Linux machines, and want some way to keep the dotfiles in their home directories in sync. Some files, like .vimrc, are the same across all 3 machines, and some are unique to each machine.</p>
<p>I've used SVN before, but all the buzz about DVCSs makes me think I should try one - is there a particular one t... | <p>I've had the same problem, and built a tool on top of Subversion that adds permission, ownership and secontext tracking, keeps the .svn directories out of the actually versioned trees, and adds a concept of layers so you can for example track all your config related to development, which you then only check out on m... | <p>Version control software isn't really great for home directories. Worse, some software doesn't really like the .svn folders or starts to interpret their contents. You could of course try to fix this with some very complex mirroring setup, but that's hard.</p>
| 5,928 |
<p>Could anyone provide any example of NAnt script for C++ project build automation?</p>
<p>Thanks!</p>
| <p>If you're talking Microsoft Visual C++ then I think you get the most control by shelling out msbuild.exe from the nant script and passing it your solution file on the command line. This is supported in Visual Studio 2005/.Net Framework 2.0 and above. e.g.:</p>
<pre><code><property name="msbuild.dir" value="C:\... | <p>If the project is in Visual Studio then you can use the <code><Solution></code> task, I think. That's the simplest/ugliest way of doing it.</p>
<p><strong>edit:</strong> Just realised that SO filtered out my little XML tag there. </p>
| 27,235 |
<p>VB.net web system with a SQL Server 2005 backend. I've got a stored procedure that returns a varchar, and we're finally getting values that won't fit in a varchar(8000).</p>
<p>I've changed the return parameter to a varchar(max), but how do I tell the OleDbParameter.Size Property to accept any amount of text?</p>
... | <p>Upvoted Ed Altofer. (He answered first, so if you like my answer vote his too).</p>
<p>OleDb is your problem. It's a generic database connection that needs to talk to more than just SQL Server, and as a result you have a lowest common denominator situation where only the weakest composite feature set can be fully... | <p>The short answer is use TEXT instead of VARCHAR(max). 8K is the maximum size of a database page, where all your data columns should fit in except BLOB and TEXT. Meaning, your available capacity is less than 8k because of your other columns. </p>
<p>BLOB and TEXT is so Web 1.0. Bigger rows mean bigger database repli... | 27,475 |
<p>What's the best way to manage a slew of browser UI tests? I'm looking for an approach that may have worked for you in the past when dealing with numerous automated browser tests. Obvious answers such as "they should be refactored into lower-level UI tests" aren't what I'm looking for. Ultimately these tests are incr... | <p>In other threads about Web UI testing, <a href="http://selenium.openqa.org/" rel="nofollow noreferrer">Selenium</a> was a popular and highly recommended choice.</p>
| <p>Factor out common sequences of actions and just put them in one subtest each. Run only the subtests you need for any given feature. </p>
| 12,492 |
<p>I need to write a desktop application that can run on Mac (Windows and Linux soon) that can get data from MySQL and allow users to transfer files from their desktop to the server.</p>
<p>I know I can write a desktop app in AIR, how would Fireworks play into this?</p>
<p>Can AIR connect to MySQL?</p>
<p>Can one FT... | <p>Do you mean Adobe Fireworks? I would use Fireworks for the interface design. It also has some customizable assets.</p>
<p>Here is the product page where they have a lot more info on what it's capable of.</p>
<p><a href="http://www.adobe.com/products/fireworks/features/?view=topnew" rel="nofollow noreferrer">http:/... | <p>Fireworks is my design tool of preference. If you are working with digital graphics there is little need to look beyond FW to things like Photoshop and Illustrator. All of the CS5 software intro screens were designed in Fireworks. It has the best 32 bit PNG output I have seen and the colors are dead on without th... | 47,768 |
<p>Suppose <code>xmlNode</code> is a XML DOM node, how do you get its XML system independently? </p>
<p>For IE, it is <code>xmlNode.xml;</code></p>
<p>For Netscape, it is <code>new XMLSerializer().serializeToString(xmlNode)</code>. </p>
<p>In jQuery, is there any built-in method I can leverage?</p>
| <p>I don't know of a native JQuery function to do it, but there's a cross-browser JavaScript way to get XML from an XML DOM node. Look at the xml2Str function in the answer to this Stack Overflow question:
<a href="https://stackoverflow.com/questions/43455/how-do-i-serialize-a-dom-to-xml-text-using-javascript-in-a-cros... | <pre><code>$(xmlNode).html();
</code></pre>
| 30,849 |
<p>I can't seem to find that option.</p>
<p>Surely it's in there?</p>
| <p>That would be Tools > Options</p>
<p>Text Editor > All Languages > Line Numbers (at the bottom right)</p>
| <p>Tools -> Options -> Text Editor -> All languages. Near the bottom.</p>
| 8,332 |
<p>I have been trying to get PEAR::mail to successfully deliver emails to hotmail users without being flagged as SPAM and ending up in the junk folder, i have no problems with yahoo/gmail only with hotmail.</p>
<p>google suggested that this is a common problem with hotmail and that possible causes can include</p>
<ul... | <p>My company does professional e-mail marketting campaigns (through strongmail servers) we send thousands of (sollicited) emails a day to all kinds of addresses.</p>
<p>The problem you are facing is that you have no authority. You could just be some spammer trying to send loads of spam. </p>
<p>The thing you need to... | <p>I'd suggest modifying the headers you send to match 100% what outlook sends, and see if that solves the problem. Really it's a tough one though, hotmail is known for having a super crappy spam filter, sending lots of legit email to junk, and lots of spam to your inbox.</p>
| 31,129 |
<p>I am new to all the anonymous features and need some help. I have gotten the following to work:</p>
<pre><code>public void FakeSaveWithMessage(Transaction t)
{
t.Message = "I drink goats blood";
}
public delegate void FakeSave(Transaction t);
public void SampleTestFunction()
{
Expect.Call(delegate { _dao... | <p>That's a well known error message. Check the link below for a more detailed discussion.</p>
<p><a href="http://staceyw1.wordpress.com/2007/12/22/they-are-anonymous-methods-not-anonymous-delegates/" rel="noreferrer">http://staceyw1.wordpress.com/2007/12/22/they-are-anonymous-methods-not-anonymous-delegates/</a> </p>... | <p>Try something like:</p>
<pre><code>Expect.Call(delegate { _dao.Save(t); }).Do(new EventHandler(delegate(Transaction t2) { t2.CheckInInfo.CheckInMessage = "I drink goats blood"; }));
</code></pre>
<p>Note the added EventHandler around the delegate.</p>
<p>EDIT: might not work since the function signatures of Event... | 8,413 |
<p>Does anyone know of a good program where I can paste in xml (getting it from a System.out in my java class) and it will format the xml so it's not a really long line of text?</p>
| <p>I like <a href="http://www.wmhelp.com/" rel="nofollow noreferrer">XMLPad</a>. It has a nice formatter plus a bunch of visualisers such as tree view and grid view. There is also a nice interactive XPath query tool and probably many more features. </p>
| <p>If you'd like more control over how the formatted text looks, you could try an <a href="http://www.kitebird.com/software/xmlformat/" rel="nofollow noreferrer">XML formatter</a></p>
| 23,117 |
<p>I have found that there is generally a singe type or namespace that takes in any particular enum as a parameter and as a result I have always defined those enums there. Recently though, I had a co-worker make a big deal about how that was a stupid thing to do, and you should always have an enum namespace at the root... | <p>Why treat enums differently to other types? Keep them in the same namespace as they're likely to be used - and assuming they're going to be used by other classes, make them top-level types in their own files.</p>
<p>The only type of type which I <em>do</em> commonly clump together is delegates - I sometimes have a ... | <p>I tend to define them, where their use is evident in the evident. If I have a typedef for a struct that makes use of it for some reason...</p>
<pre><code>typedef enum {
HI,
GOODBYE
} msg_type;
typdef struct {
msg_type type;
union {
int hivar;
float goodbyevar;
}
} msg;
</code></pre>
| 26,261 |
<p>I have an Asp.Net repeater, which contains a textbox and a checkbox. I need to add client-side validation that verifies that when the checkbox is checked, the textbox can only accept a value of zero or blank.</p>
<p>I would like to use one or more of Asp.Net's validator controls to accomplish this, to provide a co... | <p>I think the best way would be to inherit BaseValidator in a new class, and pass those IDs to your control as attributes. You should be able to resolve the IDs within your validator, without knowing the full client side ID that is generated at runtime. You should get the data validating on the server first, and on ... | <p>Can you not put the CustomValidator inside the repeater? If not, you can create it dynamically when the repeater is bound and user FindControl()</p>
<pre><code>protected MyDataBound(object sender, RepeaterItemEventArgs e) {
(CheckBox)cb = (CheckBox)e.Item.FindControl("myCheckboxName");
(TextBox)tb = (TextBox)e.... | 11,397 |
<p>I assume that you can't use a JavaScript code snippet to validate if the browser user has turned off JavaScript. So what can I use instead? Can someone offer a code sample?</p>
<p>I'm looking to wrap an if/then statement around it.</p>
<p>I often code in CFML, if that helps.</p>
| <p>Use the <noscript> HTML tags.</p>
| <p>You might have javascript execute some AJAX query and check to see if it has. Those that download the page and don't execute the query either have JS disabled or they're robots.</p>
| 6,691 |
<p>I am new to 3D printing. I have a Longer LK5 Pro. I was making a part that has raised letters, and wanted to have white letters on the black part. I used a Post Processing script on the Cura program called "change filament", which is supposed to stop printing, retract the head, and allow you to change the ... | <p>I've done it a few ways depending on the desired effect I'm after.</p>
<p>Manually pausing the machine is what seems to come out best. If you design for it, you can sometimes have it pause while it's over infill and therefore has no blobs to worry about. I haven't looked into doing it automatically, but perhaps it's... | <p>I found that raised letters look and work better when picked-out using paint or permanent marker.</p>
<p>Print your lettering in your part but don't even bother changing filament. Instead carefully use a marker pen or paint brush to colour in the top of the lettering. Depending on the paint you might choose to do... | 2,213 |
<p>I have a 10 second sound effect wave file. What I would like to do is take that file and repeat it n number of times and then save the longer WAV file to disk. This way I can create a much longer background effect rather than auto-repeat on the media player which is a bit stuttered between repeats. I am trying to do... | <p>If you only need to do this with a small number of files, you might as well do it by hand with <a href="http://audacity.sourceforge.net/" rel="nofollow noreferrer">Audacity</a>.</p>
| <p>If you're using .Net 2.0 or higher then you can use the <a href="http://msdn.microsoft.com/en-us/library/system.media.soundplayer.aspx" rel="nofollow noreferrer">System.Media.SoundPlayer</a> class and specifically its <a href="http://msdn.microsoft.com/en-us/library/system.media.soundplayer.playlooping.aspx" rel="no... | 25,784 |
<p>I find from reading perldoc perlvar, about a thousand lines in is help for %ENV. Is there a way to find that from the command line directly?</p>
<p>On my Windows machine, I've tried the following</p>
<pre><code>perldoc ENV
perldoc %ENV
perldoc %%ENV
perldoc -r ENV (returns info about Use Env)
perldoc -r %ENV
perld... | <p>Check out the latest development version of <a href="http://search.cpan.org/~ferreira/Pod-Perldoc-3.14_07/" rel="noreferrer">Pod::Perldoc</a>. I submitted a patch which lets you do this:</p>
<pre><code>$ perldoc -v '%ENV'
%ENV
$ENV{expr}
The hash %ENV contains your current environment. Setting a value in
"ENV" ch... | <p>If you'd like to see the contents of your %ENV, you can use Data::Dumper to print it out in a rather readable format:</p>
<p>perl -MData::Dumper -e 'print Dumper \%ENV'</p>
| 11,009 |
<p>Where I work we have a little bit of a dilemma... I work on a small team developing an application for internal use. We recently just received a new PM to the project. She would like to have access to our database and our sourcecode (stored in svn). Our previous PM did not see a need, nor want, to have access to ... | <p>Give her access. Make her check it out of source control and track her like anyone else. If she changes anything you'll have a history. If she makes suggestions about the implementation, it might help. If she's a bully and start ranting about the source code well... she probably would have found a way to do that... | <p>Give her full access, if she wants it. She's supposed to manage the project you are developing, and to do that efficiently, she might need to be able to look at any part of the project.</p>
<p>Of course, there's always danger that she might do something stupid or malicious. If you have as part of your process audit... | 17,223 |
<p>I would like to create a DLNA server in VB.NET.
Since a lot of multimedia devices start supporting DLNA, i would like to see what is possible. Not only streaming video/audio and pictures but see what else can be done.</p>
<h2>Anybody any starting points? protocol info, some basic code to get started?</h2>
<p>DLNA ... | <p>You have to be a member of the DLNA community or pay $500 to be able to get a full specification of the protocol according to their <a href="http://www.dlna.org/industry/certification/guidelines/" rel="noreferrer" title="homepage">homepage</a>.</p>
<p>Intel has a <a href="http://www.intel.com/cd/ids/developer/asmo-... | <p>The Mono Project has a pretty good open source implementation of the UPnP protocol.
<a href="https://github.com/mono/mono-upnp" rel="nofollow">https://github.com/mono/mono-upnp</a></p>
| 34,577 |
<p>I am trying to resolve Euler Problem 18 -> <a href="http://projecteuler.net/index.php?section=problems&id=18" rel="nofollow noreferrer">http://projecteuler.net/index.php?section=problems&id=18</a></p>
<p>I am trying to do this with c++ (I am relearning it and euler problems make for good learning/searching ... | <p>Ok so first off, I'm a little unclear as to what you think the problem is. I can't parse that second-last sentence at all...</p>
<p>Secondly you might want to re-think your design here. Think about functions that perform a single discrete task and are not intertwined with the rest of the application (ie read up on ... | <p>I'm a little confused by the problem.. <br>
I'd start by cleaning up your code. </p>
<pre><code>long long unsigned countNums(short x,
short y,
short array[][15],
short size,
bool goright,
... | 37,609 |
<p>Internet explorer 6 seems totally ignore CSS classes or rules on select, option or optgroup tags.</p>
<p>Is there a way to bypass that limitation (except install a recent version of IE) ?</p>
<p><strong>Edit</strong> : to be more precise, I'm trying to build a hierarchy between options like that example:</p>
<p>H... | <p>This won't do exactly what you want, but rather than using CSS, you could just use a number of</p>
<pre><code>&nbsp ;
</code></pre>
<p>for the indents, or dashes so:</p>
<p>Level 1</p>
<p>-Level 2</p>
<p>--Level 3</p>
<p>etc.</p>
<p>If you don't particularly like that, you could surround them with </p>
... | <p>You could emulate the whole thing using a drop-down menu script instead. It would give you complete control.</p>
| 21,995 |
<p>Are there any good resources for planning how exceptions will be used from an architecture perspective? (Or provide your suggestions directly here.) In projects on which I have worked I find that a few common Exceptions are used over and over again and tend to lose their meaning.
From: <a href="http://jamesjava.bl... | <p>I generally find that obsessing over checked exceptions is overkill. Exceptions should be reserved for unexpected error conditions from which the program cannot reasonably recover. For these, I tend to agree with what you've observed, that special error types tend to lose their meaning.</p>
<p>As a general rule, th... | <p><a href="http://java.sun.com/docs/books/effective" rel="nofollow noreferrer">"Effective Java," 2nd. ed. Bloch</a>, has some good advice in chapter 9.</p>
<p><p><a href="http://oreilly.com/catalog/9780596005689" rel="nofollow noreferrer">"Hardcore Java," Simmons</a>, has some good advice in chapter 5.</p>
<p><p>I'l... | 11,289 |
<p>I'm trying to build GNU grep, and when I run make, I get:</p>
<pre><code>[snip]
/bin/bash: line 9: makeinfo: command not found
</code></pre>
<p>What is makeinfo, and how do I get it?</p>
<p>(This is Ubuntu, if it makes a difference)</p>
| <p>In (at least) Ubuntu when using <code>bash</code>, it tells you what package you need to install if you type in a command and its not found in your path. My terminal says you need to install 'texinfo' package.</p>
<pre><code>sudo apt-get install texinfo
</code></pre>
| <p>If it doesn't show up in your package manager (i.e. <code>apt-cache search texinfo</code>) and even <code>apt-file search bin/makeinfo</code> is no help, you may have to enable non-free/restricted packages for your package manager.</p>
<p>For ubuntu, <code>sudo $EDITOR /etc/apt/sources.list</code> and add <code>res... | 43,914 |
<p>We have a database library in C# that we can use like this:</p>
<pre><code>DatabaseConnection conn = DatabaseConnection.FromConnectionString("...");
</code></pre>
<p>This library hides many of the differences between different database engines, like SQL function names, parameter names and specifications, etc.</p>
... | <p>This is possible in Python, but is probably not the best way to do it. The class factory pattern is essentially a workaround for languages that don't have first class classes. Since Python does have first class classes, you can store a class in a variable, and use that class directly to create instances. To chang... | <p>The first one is absolutely possible, and preferable in my opinion. In python, there's really not a whole lot of magic behind constructors. For all intents and purposes, they're just like any other function. I've used this design pattern a few times to indicate that a class shouldn't be instantiated directly, for... | 21,713 |
<p>I have an SQL query that takes the following form:</p>
<pre><code>UPDATE foo
SET flag=true
WHERE id=?
</code></pre>
<p>I also have a PHP array which has a list of IDs. What is the best way to accomplish this other than with parsing, as follows, ...</p>
<pre><code>foreach($list as $item){
$querycondition = $... | <p>This would achieve the same thing, but probably won't yield much of a speed increase, but looks nicer.</p>
<pre><code>mysql_query("UPDATE foo SET flag=true WHERE id IN (".implode(', ',$list).")");
</code></pre>
| <p>I haven't ever seen a way to do that other than your foreach loop.</p>
<p>But, if $list is in any way gotten from the user, you should stick to using the prepared statement and just updating a row at a time (assuming someone doesn't have a way to update several rows with a prepared statement). Otherwise, you are w... | 6,096 |
<p>I would like to create a file format for my app like Quake, OO, and MS Office 07 have.</p>
<p>Basically a uncompressed zip folder, or tar file.</p>
<p>I need this to be cross platform (mac and windows).</p>
<p>Can I do something via command prompt and bash?</p>
| <p>Have a look at the open source <a href="http://www.7-zip.org/" rel="nofollow noreferrer">7Zip</a> compression format. For your specific needs, you can use it in an "Archive" mode, zero compression but very fast.</p>
<p>It provides a powerful SDK, LZMA, from the site:</p>
<p>"LZMA is the default and general compre... | <p>First thing you should ask yourself is, "Do I really need to make my own?"</p>
<p>Depending on what you want to use it for, you are probably better off using a common format and some pre-made libraries which already handle one of those formats very well.</p>
<p>Good places to start:
<a href="http://www.destructor.... | 10,453 |
<pre><code>dir(re.compile(pattern))
</code></pre>
<p>does not return pattern as one of the lists's elements. Namely it returns:</p>
<pre><code>['__copy__', '__deepcopy__', 'findall', 'finditer', 'match', 'scanner', 'search', 'split', 'sub', 'subn']
</code></pre>
<p>According to the manual, it is supposed to contain... | <p>For the <strong>complete</strong> list of attributes, the short answer is: no. The problem is that the attributes are actually defined as the arguments accepted by the <code>getattr</code> built-in function. As the user can reimplement <code>__getattr__</code>, suddenly allowing any kind of attribute, there is no po... | <p>This is how I do it, useful for simple custom objects to which you keep adding attributes:</p>
<p>Given an object created with <code>obj = type("Obj",(object,),{})</code>, or by simply: </p>
<pre><code>class Obj: pass
obj = Obj()
</code></pre>
<p>Add some attributes:</p>
<pre><code>obj.name = 'gary'
obj.age = 32... | 23,190 |
<p>I currently have an INSERT TRIGGER which in Oracle 10g runs a custom defined function that generates a funky alpha-numeric code that is used as part of the insert.</p>
<p>I really need to make sure that the function (or even trigger) is thread safe so that if two users activate the trigger at once, the function use... | <p>No need to work out the exclusivity here. Oracle does that by managing your transactions.</p>
<p>The key is that each invocation of your "custom defined function" needs to return a unique code.</p>
<p>That means NOT using the system date/time, but something else to ensure uniqueness.</p>
<p>I recommend this:</p>
... | <p>"You don't need to know at all what it is, its just a code that the function generates"
It must be time based then, because anything else and we WOULD need to know to be able to give an appropriate answer. Not sure whether on youur throughput.
You could look at DBMS_LOCK.REQUEST as 1a, DBMS_LOCK.SLEEP as 2a and DB... | 48,341 |
<p>I have one user who gets an error message when he closes his browser. This only happens when he has visited a page which contains my applet. It seems to have been registered as a bug at Sun but that was many years ago. He is using Java 1.6 and IE7.</p>
<p>Has anyone seen this before and know a solution or work-arou... | <p>I used to get that error a lot for just about every applet that was loaded in the browser. I never figured out <em>how</em>, but Google Desktop was breaking java in some way. After uninstalling google desktop the error went away.</p>
| <p>Have you had them try 1.6u10? It was released last week, and supposedly fixes a number of applet issues. Otherwise, what build of 1.6 are they using?</p>
| 27,970 |
<p>I need a little help on this subject.</p>
<p>I have a Web application written in ASP.NET plus I have the .bak file of the SQL Express database, my question is: How can I install this in a simple click and go way in the client?</p>
<p>how can I write a script that will create a new database, restore the bak file in... | <p>You could use <a href="http://wix.sourceforge.net/" rel="nofollow noreferrer">WiX</a> to create a .msi that you can use to install your application at your clients. WiX takes a bit to get used to, but once you get the hang of it, you'll meet your needs above, and be able to extend them as your application grows or ... | <p>While WIX is certainly very flexible if you aren't comfortable with the learning curve (and there is a bit of a learning curve IMO) then perhaps you should check out the <a href="http://weblogs.asp.net/scottgu/archive/2008/01/28/vs-2008-web-deployment-project-support-released.aspx" rel="nofollow noreferrer" title="S... | 28,320 |
<p>Java has <a href="http://www.scala-lang.org/" rel="noreferrer">Scala</a> and .NET has <a href="http://research.microsoft.com/fsharp/" rel="noreferrer">F#</a>. Both of these languages are very highly integrated into the respective Java and .NET platforms. Classes can be written in Scala then extended in Java for ex... | <p>C++ doesn't have an ecosystem in the sense of Java or .NET. There's no virtual machine, no runtime environment even, there's only a highly specialized standard library that by design doesn't operate well in a purely functional environment. C++ doesn't even have an <a href="http://en.wikipedia.org/wiki/Application_bi... | <p>C++ may not be a pure functional language, but parts of STL are certainly functional.</p>
<p>See <a href="http://www.research.att.com/~bs/bs_faq.html" rel="nofollow noreferrer">Bjarne Stroustrup FAQ</a> (the inventor of the c++)</p>
| 4,465 |
<p>I'm running an upgrade script against a database hosted in Microsoft SQL Server. It's taking a while. Some of the queries are not worth optimising any further, for various reasons.</p>
<p>I'm the only person using this database: Is there a way that I can tell SQL Server to not bother with transactions/locking?</p>
... | <p>See <a href="http://blogs.neudesic.com/blogs/phil_scott/archive/2005/12/05/11.aspx" rel="nofollow noreferrer">SQL Query Performance - Do you feel dirty? (Dirty Reads)</a>.</p>
<p>Edit: This is just speculation, but if you are the only connection to the SQL Server, you could get exclusive lock at the table level usi... | <p>Turn off Autocommit (aka implicit transactions); you'll need to do a commit() at the end. The log file will grow correspondingly large, be sure you've got enough disk space.
Is tempdb on the same disk? </p>
| 45,430 |
<p>I am having the problem that I cannot select a specific XML node which needs to be deleted. I have already tried to select the node by using the XPath which works fine for some XML files but I cannot figure out the correct XPath for a node in a more complex file.</p>
<p>Does anybody know a freeware tool which can l... | <p>This is a default namespace issue. Try including the following code after you load in the XML:</p>
<pre><code>objDom.SetProperty "SelectionNamespaces", "xmlns:cf=""http://schemas.microsoft.com/SystemsManagementServer/2005/03/ConsoleFramework"""
</code></pre>
<p>You then use this <code>cf</code> prefix in your XPat... | <p>Given the following XML:</p>
<pre><code><root>
<anything foo="bar">value1</anything>
<anything foo="qux">value2</anything>
</root>
</code></pre>
<p>...you can obtain the value of the second anything node using the XPath expression:</p>
<pre><code>/root/anything[@foo="qux"]
... | 20,930 |
<p>Is there a way in Delphi to get the currect application's exe size in one or two lines of code?</p>
| <p>Just for grins...you can also do this with streams Just slightly more than 2 lines of code. Generally the application filename including path is also stored into Paramstr(0).</p>
<pre><code>var
fs : tFilestream;
begin
fs := tFilestream.create(paramstr(0),fmOpenRead or fmShareDenyNone);
try
result := fs.... | <p>I would like to modify the code provided by skamradt, to make it two lines of code as you requested ;-)</p>
<pre><code> with tFilestream.create(paramstr(0),fmOpenRead or fmShareDenyNone) do
ShowMessage(IntToStr(size));
</code></pre>
<p>but I would prefer to use the code as <strong>skamradt</strong> wrote, bec... | 26,766 |
<p>Looks like my data warehouse project is moving to Teradata next year (from SQL Server 2005).</p>
<p>I'm looking for resources about best practices on Teradata - from limitations of its SQL dialect to idioms and conventions for getting queries to perform well - particularly if they highlight things which are signifi... | <p>One place to start is here: <a href="http://www.teradataforum.com/" rel="noreferrer">http://www.teradataforum.com/</a></p>
<p>This might be a little late, but there are a few things which I can warn you about Teradata which I have learned.</p>
<p>Use the most recent version as often as possible.
For V12 the opt... | <p>Top of the list on a Google search for "Teradata Best Practices" gave me <a href="http://www.businessobjects.com/pdf/partners/teradata_advisory_group.pdf" rel="nofollow noreferrer">TERADATA ADVISORY GROUP SETS BEST PRACTICES FOR BUSINESS OBJECTS AND TERADATA CUSTOMERS</a></p>
<p><em>EDIT</em>: Seeing as that's just... | 41,274 |
<p>Which IDE if any, are people using to develop Ironruby in?</p>
| <p>Visual Studio?</p>
<p>According to the <a href="http://www.ironruby.net/" rel="nofollow noreferrer">IronRuby website</a> Visual Studio C# Express can be used (and in turn, any commercial version of Visual Studio 2005+ I'll assume).</p>
<p>From the IronyRuby.net home page:</p>
<blockquote>
<p>Today, you must che... | <p>Sapphire has a version now specifically targeted at IronRuby. Furthermore, not only is the alpha free now but they claim production will be free as well.</p>
<p>edit:forgot to include <a href="http://www.sapphiresteel.com/IronRuby-IDE-The-Visual-Form" rel="nofollow noreferrer">linkage</a></p>
| 48,561 |
<p>You can save a SQL Server 2000 DTS package as a VB .BAS file. Is is possible to open a .BAS file in SQL Server Enterprise Manager (or some other way) to add the DTS package to the server? Initally, it appears that SQL Server only lets you import .DTS files.</p>
| <p>Actually, it is possible although it's fiddly:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa176248(SQL.80).aspx" rel="nofollow noreferrer">Running a DTS Package Saved as a Visual Basic File</a></p>
| <p>Yes, it is possible, follow the link in the prior answer. Just one other little thing...when you uncomment the goPackage.SaveToSQLServer, you can use the flags parameter to specify a trusted connection like so:</p>
<p>goPackage.SaveToSQLServer "(local)", , , DTSSQLStgFlag_UseTrustedConnection</p>
<p>That way you ... | 36,196 |
<p>I'm building my app in vc2008 and testing it on a network of machines.</p>
<p>Is there any way, other than installing Visual Studio 2008, to run a debug build of a C++ program on another machine? (i.e. that doesn't have vc2008 installed)</p>
<p>Installing the redist package only installs the release mode support D... | <p>You can't, because there's no installer redist for the debug runtime (and in fact the software license forbids distributing it, so you'd be breaking the EULA even if you did get something put together). However, a "debug build" generally involves 4 separate options, and the other 3 don't affect distributing the app.... | <p>Read <a href="http://blogs.msdn.com/jigarme/archive/2008/05/08/vc-debug-c-runtime-files.aspx" rel="nofollow noreferrer">this blog post</a> on which files you need to be able to run debug flavor of your app and where to get them. You can't officially redistribute them to third parties however.</p>
<p>If you have an ... | 33,114 |
<p>Here is a quick test program:</p>
<pre><code> public static void main( String[] args )
{
Date date = Calendar.getInstance().getTime();
System.out.println("Months:");
printDate( "MMMM", "en", date );
printDate( "MMMM", "es", date );
printDate( "MMMM", "fr", date );
printDate( "MMMM", "de"... | <p>Not all languages share english capitalization rules. I guess you'd need to alter the data used by the API, but your non-english clients might not appreciate it...</p>
<p><a href="http://french.about.com/library/writing/bl-capitalization.htm" rel="noreferrer">about.com on french capitalization</a></p>
| <p>I'm having a problem now where a sentence begins with "dimanche 07 mars", which wouldn't matter if it were not at the beginning of a sentence. I guess this cannot be changed, unless I do manual string manipulation on the first character of the string.</p>
| 9,228 |
<p><em>Background</em></p>
<p>I want to be able to parse Javascript source in a Delphi Application. I need to be able to identify variables and functions within the source for the purpose of making changes to the code through later code. I understand that I probably need to use a lexer for this purpose but have not ha... | <p>For the lexer you can see <a href="http://synedit.sourceforge.net/" rel="nofollow noreferrer">Synedit's</a> source code for the Javascript highlighter. A highlighter in Synedit context is a lexer with special hooks to provide highlighting to the editor component. Trimming those hooks and getting a plain lexer is a t... | <p>I think you should use should look at GoldParser (<a href="http://www.devincook.com/goldparser" rel="nofollow noreferrer">http://www.devincook.com/goldparser</a>) for generating a complete JS parser in Delphi code. GoldParser is freeware though.</p>
| 46,191 |
<p>I am having an unusual problem. I have always been able to drag files and folder from my desktop or explorer to the solution explorer in visual studio and add the files to my project. No when I attempt to drag files I simply get the "stop" symbol. </p>
<p>I am using Visual Studio 2008 running on Vista Home Premium ... | <p>Windows will not let you drag from one window to another if only one of those windows is running as Administrator.</p>
<p>Are you running Visual Studio as Administrator?</p>
<p><strong>In short :</strong> Run Visual Studio as <strong>Non Administrator</strong>. </p>
| <p>I had the same issue and noticed I was pulling files from a folder that was compressed. I unzipped all the files and was able to drag and drop into the solutions explorer fine. Make sure your files are not in view mode in a compressed folder. </p>
| 33,529 |
<p>...if there is such a thing. Here's an image of two approachs for structuring DLLs/references in a .NET application: <a href="http://www.experts-exchange.com/images/t80668/compArch.png" rel="nofollow noreferrer">http://www.experts-exchange.com/images/t80668/compArch.png</a>. The app can be a website (it is in this... | <p>Having lots of references is usually bad because loading DLL's has a non-negligble cost. It's not as elegant perhaps, but having fewer modules improves your performance. As so often in our craft, you have to find the balance between elegance of total modularization and the harsh reality of performance. And as usual ... | <p>I think this is a really down to programmer preference.</p>
<p>It all boils down to dependencies really. More things in one DLL means it will naturally create many more depentdents on that DLL.</p>
<p>I personally tend to follow along similar lines to the MS structure, for these reasons:</p>
<ul>
<li>It makes it ... | 40,313 |
<p>I was unable to install <a href="http://cython.org/" rel="nofollow noreferrer">cython</a> due to <a href="http://epydoc.sourceforge.net/stdlib/distutils.version.StrictVersion-class.html" rel="nofollow noreferrer">strict version numbering class</a> of <a href="http://www.python.org/doc/2.5.2/dist/dist.html" rel="nofo... | <p>That's just another stupidness of distutils. I personally remove this annoying check in my distutils installation on every windows machine I have to use.</p>
<p>Installing another mingw version would work as long as it passes the version check - but really, the whole idea of checking version of the tools does not m... | <p>You could try <a href="http://www.develer.com/oss/GccWinBinaries" rel="nofollow noreferrer">this</a> unofficial MinGW distribution, it has a simple install process that sets up distutils to use it for compiling extensions.</p>
| 38,269 |
<p>I'm trying to pick a perforamnce analyzer to use. I'm a beginner developer and not sure what to look for in a performance analyzer. What are the most important features?</p>
| <p>If you use <code>valgrind</code>, I can highly recommend <a href="http://kcachegrind.sourceforge.net/html/Home.html" rel="nofollow noreferrer">KCacheGrind</a> to visualize performance bottlenecks.</p>
| <p>goldenmean has it right, I would add that line execution counts are sometimes handy as well.</p>
| 44,414 |
<p>I have the following string expression in a PowerShell script:</p>
<pre><code>"select count(*) cnt from ${schema}.${table} where ${col.column_name} is null"
</code></pre>
<p>The schema and table resolve to the values of $schema and $table, respectively. However, an empty string is supplied for ${col.column_name}. ... | <p>How about:</p>
<pre><code>"select count(*) cnt from $schema.$table where $($col.column_name) is null"
</code></pre>
| <p>One way would be:</p>
<pre><code>"select count(*) cnt from $schema.$table where $($col.column_name) is null"
</code></pre>
<p>Another option would be</p>
<pre><code>"select count(*) cnt from {0}.{1} where {2} is null" -f $schema, $table, $col.column_name
</code></pre>
| 29,169 |
<p>I have make a little test with 4 dots aligned with A tower, B and C tower. Distance W and S are the same in the stl but not in the print. I have tried diferent values of diagonal root but S always is smaller than W, and all S are equal (more or less 38.20mm) and all W are equal (more or less 40.80). I expect that W ... | <p>I bet your towers are not standing straight (vertical) or
your bed is not clearly horizontal</p>
<p>I've recreated your picture with some assumptions (for example that your SW calculates properly and your steppers and motors act well).</p>
<p>Take a look here:
<a href="https://i.stack.imgur.com/O4lKx.png" rel="nofol... | <p>Well, you have two main issues:</p>
<p><strong>1.-</strong> Your calculation for stepping is a little wrong, for example your firmware indicates 2315.84 when you need 2321.70 (REMEMBER this is an example and is not accurate), So you will see a diference about 2.0mm along your printing. If your printing is bigger mo... | 687 |
<p>In Ruby, <code>Dir.glob("**/*.rb")</code> (for instance) doesn't traverse symlinked directories. Is it possible to get the <code>**</code> to traverse symlinks?</p>
<p>I'm using two gems which find files this way, but I need them to see files within a symlinked directory.</p>
| <p>Jonathan's clever and cunning approach is great, capable of slashing through hordes of symlinks with but a mere flick of a few asterisks, muahaha. However, it has the unfortunate side-effect of not returning immediate-child matches. An improved version might be:</p>
<pre><code>Dir.glob("**{,/*/**}/*.rb")
</code></... | <p>Normally not with recursive search due to the risk of infinite loops.</p>
<p>But, <a href="http://groups.google.com/group/ruby-talk-google/browse_thread/thread/e319f62f55cdea31?pli=1" rel="noreferrer">this discussion may help</a>:</p>
<blockquote>
<p><code>Dir.glob("**/*/**/b")</code> will follow a symlink up to... | 46,650 |
<p>I've got a junk directory where I toss downloads, one-off projects, email drafts, and other various things that might be useful for a few days but don't need to be saved forever. To stop this directory from taking over my machine, I wrote a program that will delete all files older than a specified number of days an... | <p>According to <a href="http://msdn.microsoft.com/en-us/library/system.io.file.delete.aspx" rel="noreferrer">File.Delete's documentation,</a>, you'll have to strip the read-only attribute. You can set the file's attributes using <a href="http://msdn.microsoft.com/en-us/library/system.io.file.setattributes.aspx" rel="n... | <p>Hm, I think I'd rather put</p>
<pre><code>>del /F *
</code></pre>
<p>into a sheduled task. Maybe wrapped by a batch file for logging statistics.</p>
<p>Am I missing something?</p>
| 33,341 |
<p>I have a stored procedure that creates and opens some cursors. It closes them at the end, but if it hits an error those cursors are left open! Then subsequent runs fail when it tries to create cursors since a cursor with the name already exists.</p>
<p>Is there a way I can query which cursors exists and if they a... | <p>This seems to work for me:</p>
<pre><code>CREATE PROCEDURE dbo.p_cleanUpCursor @cursorName varchar(255) AS
BEGIN
DECLARE @cursorStatus int
SET @cursorStatus = (SELECT cursor_status('global',@cursorName))
DECLARE @sql varchar(255)
SET @sql = ''
IF @cursorStatus > 0
SET @sql = 'CLOS... | <blockquote>
<p>You can use the <strong>sp_cursor_list</strong> system stored procedure to get a list
of cursors visible to the current connection, and
<strong>sp_describe_cursor</strong>, <strong>sp_describe_cursor_columns</strong>, and
<strong>sp_describe_cursor_tables</strong> to determine the characteristic... | 33,299 |
<p>I'm developing an Eclipse plug-in, based on a bunch of core Eclipse plug-ins like SWT, JDT, GEF and others. </p>
<p>I need my plug-in to be compatible with Eclipse 3.3, since many potential customers are still using it. However, personally I like the new features in Eclipse 3.4 and would like to use it for my devel... | <p>You can change the 'Target platform' setting to point to the location of an existing set of eclipse 3.3 plugins. This will compile your code against the 3.3 plugins, making sure that they stay compatible no matter which version of eclipse you are using to develop the application. </p>
<p>The setting is under Window... | <p>And is it no way how to develop plugin for newer palfrom? Eg.: develop new plugin for 3.5 into 3.4...</p>
| 5,990 |
<p>Previously I have asked to strip text from a field and convert it to an int, this works successfully. But now, I would like to do an INNER JOIN on this new value.</p>
<p>So I have this:</p>
<pre><code>SELECT CONVERT(int, SUBSTRING(accountingTab.id, PATINDEX('%[0-9]%', accountingTab.id), 999))
AS 'memId', userDet... | <p>You can either repeat the whole expression or reverse your join:</p>
<pre><code>
SELECT *
FROM memDetTab
JOIN (SELECT CONVERT(int, SUBSTRING(accountingTab.id, PATINDEX('%[0-9]%', accountingTab.id), 999)) AS 'memId', userDetails.title, userDetails.lname
FROM accountingTab) subquery
ON subquery.memID = memDet... | <p>If you have to do this, you have design problems. If you're able, I would suggest you need to refactor your table or relationships.</p>
| 13,954 |
<p>In terms of performance and optimizations:</p>
<ul>
<li>When constructing a table in SQL Server, does it matter what order I put the columns in?</li>
<li>Does it matter if my primary key is the first column?</li>
<li>When constructing a multi-field index, does it matter if the columns are adjacent?</li>
<li>Using A... | <p>In SQL Server 2005, placement of nullable variable length columns has a space impact - placing nullable variable size columns at the end of the definition can result in less space consumption.</p>
<p>SQL Server 2008 adds the "SPARSE" column feature which negates this difference.</p>
<p>See <a href="https:/... | <p>For the first bullet:</p>
<p><strong>Yes</strong>, column order <em>does</em> matter, at least if you are using the deprecated BLOBs <code>image</code>, <code>text</code>, or <code>ntext</code>, and using SQL Server <= 2005.</p>
<p>In those cases, you should have those columns at the 'end' of the table, and the... | 5,520 |
<p>I have a method I want to unittest that has filesystem calls in it and am wondering how to go about it. I have looked at <a href="https://stackoverflow.com/questions/129036/unit-testing-code-with-a-file-system-dependency">Unit testing code with a file system dependency</a> but it does not answer my question.</p>
<p... | <p><strong>Edit</strong> I answered before you added C# to the question (or I missed it...) so my answer is a little java-esque, but the principles are the same...</p>
<hr>
<p>Your thought about a wrapper around file IO is a good one. This is one such example, but anything similar could do:</p>
<pre><code>interface ... | <p>I think you should create two files: one with zero length, and other with some data in it.
Then, you should have a test for each file. In the preparation phase, you should copy the given file to a test dir, run the test, and after it asserts if the file is there.</p>
| 48,470 |
<p>I'm hoping someone can clarify this behavior for me, and explain how ASP.NET is deciding when to treat something like a new Session.</p>
<p>A) In Internet Explorer I load the ASP.NET site in question. It starts a new Session.<br>
B) If I go to menu File - New Window... it stays within the same Session.<br>
C) If I ... | <p>Sessions in IIS/ASP.NET are based on cookies with a session scope, meaning that they get destroyed when the browser is closed, and apparently they are not shared within different processes of Internet Explorer.</p>
<p>When you open a new browser window with File > New Window the window will be handled by the same p... | <p>I'd wonder if the new IE instance would have the same cookies that happen in case B, where while it is a new window it is using the same process. It is usually in the cookie or in the querystring that there is a value used to map sessions to various clients.</p>
| 39,044 |
<p>I'm writing an app that contains the following tables: (1) employee_type, (2) employee and (3) employee_action.</p>
<p>Employee_action is foreign-keyed to employee, and contains a description of what happened and the date of the event, just as you might expect.</p>
<p>However, employees can change their type over ... | <p>Representing time data in SQL is tricky. There is a very good book on the subject, and it's even available for free online from the author: <a href="http://www.cs.arizona.edu/people/rts/tdbbook.pdf" rel="nofollow noreferrer">http://www.cs.arizona.edu/people/rts/tdbbook.pdf</a>.</p>
<p>The Amazon page is on <a href=... | <p>Have you considered introducing a transition (many-to-many) table linking the employee_type and the employee, and then linking the employee action to this transition table? The transition table could have an additional column for timestamping, that way allowing you to keep track of things chronologically.</p>
| 18,339 |
<p>I'm working on a web page where I'm making an AJAX call that returns a chunk of HTML like: </p>
<pre><code><div>
<!-- some html -->
<script type="text/javascript">
/** some javascript */
</script>
</div>
</code></pre>
<p>I'm inserting the whole thing into the DOM, but the Ja... | <p>Script added by setting the innerHTML property of an element doesn't get executed. Try creating a new div, setting its innerHTML, then adding this new div to the DOM. For example:</p>
<pre>
<html>
<head>
<script type='text/javascript'>
function addScript()
{
var str = "<script>ale... | <p>You can use one of the popular Ajax libraries that do this for you natively. I like <a href="http://www.prototypejs.org/" rel="nofollow noreferrer">Prototype</a>. You can just add evalScripts:true as part of your Ajax call and it happens automagically.</p>
| 10,159 |
<p>I have a function that gives me the following warning:</p>
<blockquote>
<p>[DCC Warning] filename.pas(6939): W1035 Return value of function 'function' might be undefined</p>
</blockquote>
<p>The function, however, is clean, small, and does have a known, expected, return value. The first statement in the function... | <p>Are you sure you have done everything to solve the warning? Maybe you could post the code for us to look at?</p>
<p>You can turn off the warning locally this way:</p>
<pre><code>{$WARN NO_RETVAL OFF}
function func(...): string;
begin
...
end;
{$WARN NO_RETVAL ON}
</code></pre>
| <p>There seems to be some sort of bug in Delphi. Read this post, the last comment links to other bug-reports that may be the one that you have got:</p>
<p><a href="http://qc.codegear.com/wc/qcmain.aspx?d=8144" rel="nofollow noreferrer">http://qc.codegear.com/wc/qcmain.aspx?d=8144</a></p>
| 8,664 |
<p>I need to pad numbers with leading zeros (total 8 digits) for display. I'm using oracle.</p>
<pre><code>select to_char(1011,'00000000') OPE_NO from dual;
select length(to_char(1011,'00000000')) OPE_NO from dual;
</code></pre>
<p>Instead of '00001011' I get ' 00001011'.
Why do I get an extra leading blank space? Wh... | <p>Use FM (Fill Mode), e.g. </p>
<p><code>select to_char(1011,'FM00000000') OPE_NO from dual;</code> </p>
| <p>From that same <a href="http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/sql_elements004.htm#SQLRF00211" rel="nofollow noreferrer">documentation</a> mentioned by <a href="https://stackoverflow.com/questions/156329/unwanted-leading-blank-space-on-oracle-number-format#156351">EddieAwad</a>:</p>
<blockqu... | 18,908 |
<p>I'd like to map a reference to an object instead of the object value with an HashTable</p>
<pre><code>configMapping.Add("HEADERS_PATH", Me.headers_path)
</code></pre>
<p>that way when I'm going to retrieve the value of "HEADERS_PATH" I'll be able to assign a value to Me.headers_path</p>
<p>something like the " &a... | <p>I am assuming that <em>Me.headers_path</em> is a System.String. Because <strong>System.String</strong> are immutable what you want cannot be achieved. But you can add an extra level of indirection to achieve a similar behavior.</p>
<blockquote>
<p>All problems in computer science can
be solved by another level ... | <p>make headers_path be a propriety (with set)</p>
| 19,952 |
<p>What's the best way to get a temp directory name in Windows? I see that I can use <code>GetTempPath</code> and <code>GetTempFileName</code> to create a temporary file, but is there any equivalent to the Linux / BSD <a href="http://linux.die.net/man/3/mkdtemp" rel="noreferrer"><code>mkdtemp</code></a> function for c... | <p>No, there is no equivalent to mkdtemp. The best option is to use a combination of <a href="https://learn.microsoft.com/en-us/dotnet/api/system.io.path.gettemppath" rel="noreferrer">GetTempPath</a> and <a href="https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getrandomfilename" rel="noreferrer">GetRandomFi... | <p><a href="http://msdn.microsoft.com/en-us/library/system.io.path.gettemppath.aspx" rel="nofollow noreferrer">GetTempPath</a> is the correct way of doing it; I'm not sure what your concern about this method is. You can then use <a href="http://msdn.microsoft.com/en-us/library/system.io.directory.createdirectory.aspx"... | 35,162 |
<p>I have about 150 000 rows of data written to a database everyday. These row represent outgoing articles for example. Now I need to <strong>show a graph using <a href="http://www.microsoft.com/technet/prodtechnol/sql/2005/2005ssrs.mspx" rel="nofollow noreferrer">SSRS</a> that show the average number of articles per d... | <p>The neat thing with SSAS is that you can get those indicators that you talk about quite easily either by creating calculated measures or by using KPIs.</p>
<p>I started with <a href="https://rads.stackoverflow.com/amzn/click/com/0072260904" rel="nofollow noreferrer" rel="nofollow noreferrer">Delivering Business Int... | <p>SSAS is an <a href="http://en.wikipedia.org/wiki/Extract,_transform,_load" rel="nofollow noreferrer">ETL</a> tool. Basically you get data from somewhere (your outgoing articles), do something to it (aggregate), and put it somewhere else (your aggregates table, data warehouse, etc). Check the link for details. </p>
... | 4,938 |
<pre><code>public static Logger getLogger() {
final Throwable t = new Throwable();
final StackTraceElement methodCaller = t.getStackTrace()[1];
final Logger logger = Logger.getLogger(methodCaller.getClassName());
logger.setLevel(ResourceManager.LOGLEVEL);
return logger;
}
</code></pre>
<p>This meth... | <p>I guess it adds a lot of overhead for every class. Every class has to be 'looked up'. You create new Throwable objects to do that... These throwables don't come for free.</p>
| <p>Why not?</p>
<pre><code>public static Logger getLogger(Object o) {
final Logger logger = Logger.getLogger(o.getClass());
logger.setLevel(ResourceManager.LOGLEVEL);
return logger;
}
</code></pre>
<p>And then when you need a logger for a class:</p>
<pre><code>getLogger(this).debug("Some log message")
</code><... | 10,622 |
<p>I have a SQL Server 2005 machine with a JDE DB2 set up as a linked server.</p>
<p>For some reason the performance of any queries from this box to the db2 box are horrible.</p>
<p>For example. The following takes 7 mins to run from Management Studio</p>
<pre><code>SELECT *
FROM F42119
WHERE SDUPMJ &... | <p>In certain searches SQL Server will decide to pull the entire table down to itself and sort and search the data within SQL Server instead of sending the query to the remote server. This is usually a problem with collation settings. </p>
<p>Make sure the provider has the following options set:
Data Access,
Collati... | <p>My first thought would go to the drivers. Years ago I had to link DB2 to SQL Server 2000 and it was extremely difficult to find the correct combination of drivers and setup parameters that would work... </p>
<p>So maybe I'm biased because of that, but I would try upgrading or downgrading the driver or changing the ... | 11,098 |
<p>I have a variable </p>
<pre><code>unsigned char* data = MyFunction();
</code></pre>
<p>how to find the length of data?</p>
| <p>Assuming its a <code>string</code></p>
<pre><code>length = strlen( char* );
</code></pre>
<p>but it doesn't seem to be...so there isn't a way <em>without</em> having the function return the length.</p>
| <pre><code>#include <stdio.h>
#include <limits.h>
int lengthOfU(unsigned char * str)
{
int i = 0;
while(*(str++)){
i++;
if(i == INT_MAX)
return -1;
}
return i;
}
</code></pre>
<p>HTH</p>
| 32,690 |
<p>Similar to the XP login screen, in Flex 3, how can I display a warning to the user in a textbox that the CAPS LOCK key is enabled?</p>
| <p>flash.ui.Keyboard.capsLock is not bindable so that code won't really work.</p>
<p>I would invoke a function in the "keyDown" event for the TextInput and then check flash.ui.Keyboard.capsLock in that function. You can then set visible/includeInLayout on that Text, pop up an Alert, etc...</p>
| <p>In actionScript:</p>
<pre>
<code>
if(flash.ui.Keyboard.capsLock){
// caps lock is on...
}
</code>
</pre>
<p>or MXML:</p>
<pre>
<code>
<mx:Box width="100%" id="capsbox"
visible="{flash.ui.Keyboard.capsLock}"
includeInLayout="{capsbox.visible}">
<... | 49,500 |
<p>We have a dotnet web service that a java using customer wants to connect to. What is the best technology for them to use? Axis or Metro, or something else?</p>
| <p>Theoretically you could do this with any standards compliant framework. In practice, the generated code (with the default settings) by some tools may not work for you. You may need for example to modify a namespace or add a SOAP header. You can do this for example with Axis2 and CXF, but some extra configuration is ... | <p>I haven't use Metro, but with Axis is very easy connect to .Net services </p>
| 38,612 |
<p>Currently, I am working on a new version control system as part of a final year project at University. The idea is to make it highly adaptable and pluggable.</p>
<p>We're using the OSGi framework (Equinox implementation) to manage our plug ins. My problem is that I can't find a simple & easy to use method for t... | <p>Spring Dynamic Modules has excellent support for <a href="http://static.springframework.org/osgi/docs/current/reference/html/testing.html" rel="noreferrer"> testing OSGi bundles</a>.</p>
| <p>How about bnd-testing-maven-plugin?</p>
<p>It allow running JUnit inside a running container like Felix or Equinox.
If you used the BNDTools for eclipse this is very similar but just maven withpout eclipse and without a UI.</p>
<p><a href="https://github.com/bndtools/bnd/tree/master/maven/bnd-testing-maven-plugin"... | 9,954 |
<p>We have some legacy code that needs to identify in the Page_Load which event caused the postback.
At the moment this is implemented by checking the Request data like this...</p>
<p>if (Request.Form["__EVENTTARGET"] != null<br>
&& (Request.Form["__EVENTTARGET"].IndexOf("BaseGrid") > -1 // BaseGrid event ( e.... | <p>This should get you the control that caused the postback:</p>
<pre><code>public static Control GetPostBackControl(Page page)
{
Control control = null;
string ctrlname = page.Request.Params.Get("__EVENTTARGET");
if (ctrlname != null && ctrlname != string.Empty)
{
control = page.FindC... | <p>In addition to the above code, if control is of type ImageButton then add the below code,</p>
<pre><code>if (control == null)
{ for (int i = 0; i < page.Request.Form.Count; i++)
{
if ((page.Request.Form.Keys[i].EndsWith(".x")) || (page.Request.Form.Keys[i].EndsWith(".y")))
{ control ... | 7,182 |
<p>I am trying to bind a hashtable to a detailsview in my ASP.NET web app. When I do this, the detailsview does not appear on the webpage when I do a debug. I have checked ALL the properties for the control and ensured that the visible and autogeneratecolumns (there is no autogeneraterows property) is set to true, and ... | <p>Take a look at the TFS API (<a href="http://msdn.microsoft.com/en-us/library/bb130146(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb130146(VS.80).aspx</a>). Access to the same code used by Microsoft to create the Visual Studio integration and their version control command line too... | <p>If you download <a href="http://msdn.microsoft.com/sv-se/tfs2008/bb980963(en-us).aspx" rel="nofollow noreferrer">tfs power tools</a> you can use "tfpt query" to your advantage.</p>
| 25,031 |
<p>This gets the value of whatever is selected in my dropdown menu.</p>
<pre><code>document.getElementById('newSkill').value
</code></pre>
<p>I cannot however find out what property to go after for the text that's currently displayed by the drop down menu. I tried "text" then looked at <a href="http://w3schools.com/"... | <p>Based on your example HTML code, here's one way to get the displayed text of the currently selected option:</p>
<pre><code>var skillsSelect = document.getElementById("newSkill");
var selectedText = skillsSelect.options[skillsSelect.selectedIndex].text;
</code></pre>
| <pre><code> var ele = document.getElementById('newSkill')
ele.onchange = function(){
var length = ele.children.length
for(var i=0; i<length;i++){
if(ele.children[i].selected){alert(ele.children[i].text)};
}
}
</code></pre>
| 2,779 |
<p>ABS is a very strong material, but it also has some downsides. One of them, which is the necessity of having a printer with enclosure, completely discouraged me from using it, as it would be a waste of money. This is quite sad, because I cannot make prints that will be able to withstand a large load of tension witho... | <p>There is no requirement for an enclosure when printing ABS. Like many things in FDM, there are improvements to be made, but there is a scale of what is possible.</p>
<p>A heated bed is much more necessary (for similar reasons, the thermal expansion is significant and without a heated bed you have very high risk of ... | <p>I print ABS in my basement in an unenclosed Prusa3D i3m3s, just as I print other filaments. Perhaps an enclosure would be helpful, but I don't have problems as it is. Your experience may vary.</p>
<p>Before that I printed ABS on a large home-brew delta machine. No problems related to lack of enclosure.</p>
<p>B... | 1,378 |
<p>In a tightly looped test application that prints out the value of <code>DateTime.UtcNow.Ticks</code>, I notice that the value will jump a remarkable amount once every hour or so. Look closely at the following sample data:</p>
<pre><code>1:52:14.312 PM - 633614215343125000
1:52:14.359 PM - 633614215343593750
1:52:1... | <p>Actually, just running some test with this loop:</p>
<pre><code>static DateTime past = DateTime.UtcNow;
static void PrintTime()
{
while (stopLoop == 0)
{
DateTime now = DateTime.UtcNow;
Console.WriteLine("{0} - {1} d: {2}", now, now.Ticks, now - past);
Pro... | <p>Can you post code to show how you generated this data? And provide details about the machine you are running this on?</p>
<p>Using the following, I'm not getting what you are getting.</p>
<pre><code> for (int i = 0; i < 10; i++)
{
Console.WriteLine(DateTime.Now.ToLongTimeString().To... | 32,950 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.