instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Are there any tools to transform SVG (XML) data to Canvas friendly input?</p>
| <p>No I don't think so. SVG is actually rather different to Canvas. SVG is a vector graphics description language, whereas Canvases are programmatically "drawn" by sets of instructions. Also, Canvas isn't actually vector based at all.</p>
<p>Take a look at the <a href="http://www.raphaeljs.com/" rel="nofollow noreferr... | <p>Take a look at XSLT.</p>
| 25,017 |
<p>I know this maybe a very basic question but I'm having a bit of a mind blank at the moment. Should I be unit testing this class.</p>
<pre><code>public class MapinfoWindowHandle : IWin32Window
{
IntPtr handle;
public MapinfoWindowHandle(IntPtr mapinfoHandle)
{
this.handle = ... | <p>The only thing that I can see is making sure you get out the handle that you put in via your constructor. I know that it's obvious that you implemented it this way, but a test would assure you that it stays this way. I would test this only because you are injecting it via the constructor. If it was just { get; se... | <p>The pragmatist in me says no, because the class does "nothing", so there is "nothing" to test.
But sure you could still test it, just for documentation purposes, and as a contract for future developers.</p>
| 45,809 |
<p>Which is the best way to store a 2D array in c# in order to optimize performance when performing lots of arithmetic on the elements in the array?</p>
<p>We have large (approx 1.5G) arrays, which for example we want to multiply with each other element by element. Performance is critical. The context in which this is... | <p>For best array performance, make sure you're using a single dimension array with lower index of 0.</p>
<p>To access the elements of the array as fast as possible, you can use unsafe pointers like so:</p>
<pre><code>int[] array = Enumerable.Range(0, 1000).ToArray();
int count = 0;
unsafe {
fixed (int* pArray =... | <p>Do you iterate the matrix by row or by colum or both? Do you always access nearby elements or do you do random accesses on the matrix.</p>
<p>If there is some locality in your accesses but you're not accessing it sequential (typical in matrix multiplication for example) then you can get a <em>huge</em> performance ... | 13,620 |
<p>I've searched for this a little but I have not gotten a particularly straight answer. In C (and I guess C++), how do you determine what comes after the % when using <code>printf</code>?. For example:</p>
<pre><code>double radius = 1.0;
double area = 0.0;
area = calculateArea( radius );
printf( "%10.1f %10.2\n",... | <p><a href="http://en.wikipedia.org/wiki/Printf#printf_format_placeholders" rel="noreferrer">http://en.wikipedia.org/wiki/Printf#printf_format_placeholders</a> is Wikipedia's reference for format placeholders in printf. <a href="http://www.cplusplus.com/reference/clibrary/cstdio/printf.html" rel="noreferrer">http://www... | <p>One issue that hasn't been raised by others is whether <strong>double</strong> is the same as a <strong>float</strong>. On some systems a different format specifier was needed for a double compared to a float. Not least because the parameters passed could be of different sizes.
<PRE>
%f - float
%lf - double
%g ... | 3,860 |
<p>MySQL offers many ways (on Windows) to connect to it, those are:</p>
<ul>
<li>Shared memory</li>
<li>Named pipes</li>
<li>TCP/IP</li>
</ul>
<p>My question is, if MySQL will be run on the same machine of the web server, then which method is best for security and performance?</p>
<p>P.S. This is a one web server sc... | <p>In terms of performance if both are running on the same machine then shared memory is the better option as it wont run into issues with firewall software that may be on the machine or installed at a later date.</p>
<p>However if in the future you need to seperate the web server and database due to upsizing, you wil... | <p>TCP/IP in all cases.</p>
| 34,206 |
<p>I am new to 3D printing but have been in CNC Machining for a few years. I have a part I am trying to print that is a cylinder 1.000 in. in diameter and has a .200 in overhang starting at 1.300 in. In other words I am printing a 1.300 in. cylinder that is 1.500 in. tall that at 1.300 in. its diameter increases by .20... | <p>The world of 3D Printers usually uses the metric system, especially in nozzle sizes. 0.2 inches are therefore better referred to as 5 mm, which is a considerable amount: that's 11 to 13 perimeters from a 0.4 mm nozzle, depending on extrusion width (0.46 and 0.4 mm respectively). Furthermore, the bore of the item isn... | <p>It appears that your part could be printable upside down. If possible, I'd highly recommend this, as it mostly avoids supports all together.</p>
| 1,483 |
<p>A requirement for an ASP.Net 2.0 project I'm working on limits a certain field to a max of 10 words (not characters). I'm currently using a CustomValidator control with the following ServerValidate method:</p>
<pre><code>Protected Sub TenWordsTextBoxValidator_ServerValidate(ByVal source As Object, ByVal args As Sys... | <p>You can use one of the builtin validators with a regex that counts the words.</p>
<p>I'm a little rusty with regex so go easy on me:</p>
<pre><code>(\b.*\b){0,10}
</code></pre>
| <p>I voted for mharen's answer, and commented on it as well, but since the comments are hidden by default let me explain it again:</p>
<p>The reason you would want to use the regex validator rather than the custom validator is that the regex validator will also automatically validate the regex client-side using javasc... | 7,583 |
<pre><code><div id="myDiv">
<a>...</a>
<a>...</a>
<a>...</a>
<a>...</a>
<a>...</a>
<a>...</a>
</div>
</code></pre>
<p>If you wanted to select the 2nd, 3rd and 4th <code>a</code> tags in the above example, ... | <p>jQuery <a href="http://docs.jquery.com/Traversing/slice" rel="noreferrer">slice()</a> function taking indexes of the first and the last needed elements selects a subset of the matched elements. Note what it doesn't include last element itself. </p>
<p>In your particular case you should use</p>
<pre><code>$("#myDiv... | <p>You should be able to do this by extracting a slice of the array thus. It's the line</p>
<pre><code>$("div[id='myDiv'] > a").slice(1,4).css("background","yellow");
</code></pre>
<p>that you're interested in. It will affect the 2nd, 3rd and 4th elements.</p>
<pre><code><html>
<head>
&l... | 22,497 |
<p>Should Singleton objects that don't use instance/reference counters be considered memory leaks in C++?</p>
<p>Without a counter that calls for explicit deletion of the singleton instance when the count is zero, how does the object get deleted? Is it cleaned up by the OS when the application is terminated? What if... | <p>You can rely on it being cleaned up by the operating system. </p>
<p>That said, if you are in a garbage collected language with finalizers rather than destructors you may want to have a graceful shutdown procedure that can cleanly shutdown your singletons directly so they can free any critical resources in case th... | <p>Any heap memory allocated by your process and not freed (deleted) will be reclaimed by the OS. If you're using the most common implementation of the singleton, which uses static variables, this would be cleaned up upon your application's termination as well.</p>
<p>*This does not mean that you should go around new-... | 34,489 |
<p>If I make two iPhone applications, how can/should I share custom data (not contacts and stuff like that) among them?</p>
<p>Thanks!</p>
| <p>There are two different ways you might go about this.</p>
<p>1) The data you need to share is non-persistent. In other words you need to launch one application with a piece of data that it can do something with. In this case you would register a special URL scheme per application.</p>
<p>You can find out more info... | <p>Dan Grisby's <a href="http://www.mobileorchard.com/podcast-warm-clothed-and-fed-developer-run-iphone-businesses/" rel="nofollow noreferrer">most recent mobile orchard podcast</a> hypothesizes that you might also use custom named clipboards to share information between apps. I realize this is an older post, but I tho... | 27,168 |
<p>I am trying to add the line</p>
<blockquote>
<p>G4 P4000 G1 F4000 E-50</p>
</blockquote>
<p>to pause and retract the print in order for the printed line to dry (printing in mid air vertically). Does the above code work or should i skip lines or does it not matter at all?</p>
<blockquote>
<p>G4 P4000<br>
G1 ... | <p>Yes, G-code is read line by line. G-code is a numerical control programming language. It basically instructs the machine sequentially line by line to do a specific task. The printer than executes the lines one by one until it reaches the end.</p>
<p>If you instruct the printer to wait (<code>G4</code> dwell), it wi... | <p>This needs to be on two lines like in your second example:</p>
<blockquote>
<p>G4 P4000<br>
G1 F4000 E-50</p>
</blockquote>
<p>See the RepRap Gcode Wiki for more info. <a href="https://reprap.org/wiki/G-code" rel="nofollow noreferrer">https://reprap.org/wiki/G-code</a></p>
<p>EDIT: if you actually want to ret... | 1,089 |
<p>When I do a file search on eclipse it includes the <code>.svn</code> directories by default. I tried excluding them from the build path but they still appear on file search results.</p>
| <p>Spaceman is right. With Helios, choose <code>Project -> Properties -> Resource -> Resource Filters</code> and then add an <code>exclude</code> filter for type "Folder" with name <code>.svn</code>.</p>
| <p>Click on the drop-down triangle in the top-right corner of the Navigator and choose "Filters..".</p>
<p>By default Eclipse only offers you "<em>.class" and ".</em>".</p>
<p>If you choose ".*" you'll hide .svn files. Obviously all other .something files will also be hidden.</p>
| 6,334 |
<p><strong>(Scroll down to bottom of post to find solution.)</strong></p>
<p>Got a asp.net page which contains a
Datalist. Inside this datalist, there
is a template containing a
dropdownlist and each time the
datalist is filled with an item, a
ItemCreatedCommand is called. The
itemCreatedCommand is responsible for
da... | <p>When the DataList is data-bound, the AutoPostBack has not been handled yet, i.e. the values in the ItemCreated event are still the original values.</p>
<p>You need to handle the SelectedIndexChange event of the dropdown control.</p>
| <p>Regarding your 2nd question:</p>
<p>I suggest you remove the AutoPostBack from the dropdown, add an "Update" button, and update the data in the button Click event.</p>
<p>The button can hold Command and CommandArgument values, so it's easy to associate with a database record.</p>
| 40,306 |
<p>(Note: I realize this is close to <a href="https://stackoverflow.com/questions/186392/how-do-you-document-your-database-structure">How do you document your database structure?</a> , but I don't think it's identical.)</p>
<p>I've started work at a place with a database with literally hundreds of tables and views, all... | <p>In my experience, ER (or UML) diagrams aren't the most useful artifact - with a large number of tables, diagrams (especially reverse engineered ones) are often a big convoluted mess that nobody learns anything from.</p>
<p>For my money, some good human-readable documentation (perhaps supplemented with diagrams of s... | <p>Well, a picture tells a thousand words so I would recommend creating ER diagrams where you can view the relationship between tables at a glance, something that is hard to do with a text-only description.</p>
<p>You don't have to do the whole database in one diagram, break it up into sections. We use Visual Paradigm... | 48,225 |
<p>I am new to RESTful stuff. But, I want to use it in my rails app. When I add this to my routes.rb <code>map.resources :notes</code> I get routes to these methods created:</p>
<ul>
<li>index</li>
<li>create</li>
<li>new</li>
<li>edit</li>
<li>show</li>
<li>update</li>
<li>destroy</li>
</ul>
<p>What I am wondering... | <p>When you use the scaffold generator in Rails 2 <code>create</code> is the action called when the form from the <code>new</code> action is submitted. Likewise, <code>update</code> is the action called when the form from the <code>edit</code> action is submitted.</p>
<p>As far as I know, you can blow that away and d... | <p>When you use the scaffold generator in Rails 2 <code>create</code> is the action called when the form from the <code>new</code> action is submitted. Likewise, <code>update</code> is the action called when the form from the <code>edit</code> action is submitted.</p>
<p>As far as I know, you can blow that away and d... | 37,021 |
<p>I am wrapping existing C++ code from a <strong>BSD</strong> project in our own custom wrapper and I want to integrate it to our code with as few changes as possible. This code uses <code>fprintf</code> to print to <strong>stderr</strong> in order to log / report errors.</p>
<p>I want to redirect this to an alternat... | <p>You can use a similar technique on Windows, you just need to use different words for the same concepts. :) This article: <a href="http://msdn.microsoft.com/en-us/library/ms682499.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms682499.aspx</a> uses a win32 pipe to handle I/O from another process, you... | <p>You mention that you don't want to use a named pipe for internal use; it's probably worth poining out that the documentation for <a href="http://msdn.microsoft.com/en-us/library/aa365152(VS.85).aspx" rel="nofollow noreferrer">CreatePipe()</a> states, <em>"Anonymous pipes are implemented using a named pipe with a uni... | 2,924 |
<p>I want to skeletize the surface mesh. For that I need to export .STL from Solidworks and then convert that into .OFF file to be able to use it in CGAL library for skeletonzation. How can I do this?</p>
| <p>One aspect of having this level of control with 3d printing of a model is the removal of the need for supports and the attendant post-processing. In the case of the model shown in the video, some effects are created by printing the continents in a conformal manner that would otherwise be impossible with conventional... | <p>Slicing prints for printing in 5 Axis is not going to be simple with the current software. If you look at the web site for the 5AxisMaker you can see they are using Algorithmic modeling software (Grasshopper). You would probably need to buy this as well and then spend a decent amount of time learning how to use this... | 429 |
<p>I am fairly comfortable with standalone Java app development, but will soon be working on a project using a Java EE application server.</p>
<p>Does anyone know of a straightforward how-to tutorial to getting a hello-world type application working in an application server? I'm (perhaps naievly) assuming that the ove... | <p>I would choose JBoss AS or GlassFish for a start. However I'm not sure what you mean by Java EE "Hello World". If you just want to deploy some JSP you could use this tutorial (for JBoss):</p>
<p><a href="http://www.centerkey.com/jboss/" rel="nofollow noreferrer">http://www.centerkey.com/jboss/</a></p>
<p>If you wa... | <p>As JeroenWyseur puts it, Java EE is a fairly big space. In addition to what he said, you should try to get more details of what exactly you'll be doing: servelts & co, EJB (entity, session, message beans?) and try to get familiar with that. </p>
<p>It should be clear for you that your code runs in a managed env... | 11,636 |
<p>how good to use 3 point technique for risk assessment.</p>
| <p>Is this what you mean? <a href="http://www.aof.mod.uk/aofcontent/tactical/risk/content/tpe.htm?zoom_highlight=simulation" rel="nofollow noreferrer">http://www.aof.mod.uk/aofcontent/tactical/risk/content/tpe.htm?zoom_highlight=simulation</a></p>
<p>If so, it looks like that site's a pretty good overview and analysis... | <p>Nice. Also, check out the ACM's <a href="http://www.acmqueue.com/figures/issue019/tiwana1.gif" rel="nofollow noreferrer">one minute risk assessment tool</a> which specifies 6 risk factors. Here is an <a href="http://www.dynamicalsoftware.com/cgi-bin/ViewBlogEntry.pl?id=9" rel="nofollow noreferrer">introduction</a> t... | 37,278 |
<p>Is there a way to restrict a specific SQL 2005 login on a Microsoft SQL Server 2005, standard version (sql is in mixed mode) to specific IP addresses, while other logins, Windows authenticated ones, are unaffected?</p>
| <p>Yes, you can do this. You'll need to write a logon trigger as described here:</p>
<p><a href="http://technet.microsoft.com/en-us/library/bb326598.aspx" rel="nofollow noreferrer">http://technet.microsoft.com/en-us/library/bb326598.aspx</a></p>
<p>I futzed around with it for the last fifteen minutes and had limited... | <p>Why do you need to restrict by IP address? If all your users are authenticated, just set up group permissions on SQL Server, and allow or deny the groups you want.</p>
<p>If the problem is various users using applications with the same SQL login (you mentioned you're using mixed-mode), then the question is why do ... | 33,816 |
<p>My VPS provider (Slicehost) doesn't provide an SMTP server. I use Google Apps to send and receive mail for my domains, but I want to be able to programmatically send e-mail.</p>
<p>I've been Googling this issue on and off for many months, and I just can't seem to get a clear picture of what I need to do. Do I jus... | <p>Have you looked <a href="http://articles.slicehost.com/search?q=email" rel="nofollow noreferrer">here</a>, seems to me that there is plenty of information to get started. I found <a href="http://articles.slicehost.com/2008/9/2/mail-server-slice-setup" rel="nofollow noreferrer">mail-server-slice-setup</a> to be quite... | <p>Just install something like postfix as "internet site" and you'll be able to send mails directly from your VPS</p>
<p>it should work with default settings but it would be recommended to also read a few docs/how-to's to secure it properly </p>
| 23,913 |
<p>This problem started technically just before a major move but I had hoped it was a "one off" issue... I started up my trusty Ender 3 today to find it may have actually gotten worse and I'm not entirely sure what the solution is. I was printing a replica of a weapon from a game and I noticed at one point th... | <p>Same G-code slice? The main cause of warping is temperature. If this is kept as a control variable and you have these results, it may be because of a different temperature the filament requires. Check the filament specs and adjust the bed/nozzle temperature to make the temperature difference smaller.</p>
<p>Edit: An... | <p>Problem was displaced by a factory reset of the 3D printer FlashForge Adventurer 3.</p>
<p><a href="https://i.stack.imgur.com/jxS9X.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jxS9X.jpg" alt="Photo of two versions" /></a></p>
<p>Right: white PLA only, left: transparent PLA bottom layers plus w... | 2,048 |
<p>I'm looking for an Access 2007 equivalent to SQL Server's COALESCE function.</p>
<p>In SQL Server you could do something like:</p>
<p><strong>Person</strong></p>
<pre><code>John
Steve
Richard
</code></pre>
<p><strong>SQL</strong></p>
<pre><code>DECLARE @PersonList nvarchar(1024)
SELECT @PersonList = COALESCE(@P... | <p>Here is a sample User Defined Function (UDF) and possible usage.</p>
<p>Function:</p>
<pre><code>Function Coalsce(strSQL As String, strDelim, ParamArray NameList() As Variant)
Dim db As Database
Dim rs As DAO.Recordset
Dim strList As String
Set db = CurrentDb
If strSQL <> "" Then
Set rs = d... | <p>I think Nz is what you're after, syntax is <code>Nz(variant, [if null value])</code>. Here's the documentation link: <a href="http://office.microsoft.com/en-us/access/HA012288901033.aspx" rel="nofollow noreferrer">Nz Function</a></p>
<pre><code>---Person---
John
Steve
Richard
DECLARE @PersonList nvarchar(1024)
SE... | 11,816 |
<p>What concerns, processes, and questions do you take into account when deciding when and how to cache. Is it always a no win situation?</p>
<p>This presupposes you are stuck with a code base that has been optimized. </p>
| <p>I have been working with DotNetNuke most recently for web applications and there are a number of things that I consider each time I implement caching solutions.</p>
<ul>
<li>Do all users need to see cached content?</li>
<li>How often does each bit of content change?</li>
<li>Can I cache the entire page?</li>
<li>Do... | <p>What language are you using? With ASP you have some very easy caching with only adding some property tag over the method and the value is cached depending of the time.</p>
<p>If you want more control over the cache, you can use some popular system like MemCached and have a control with time or by event.</p>
| 14,044 |
<p>How do you apply stroke (outline around text) to a textblock in xaml in WPF?</p>
| <p>Below is my more idiomatically WPF, full-featured take on this. It supports pretty much everything you'd expect, including:</p>
<ul>
<li>all font related properties including stretch and style</li>
<li>text alignment (left, right, center, justify)</li>
<li>text wrapping</li>
<li>text trimming</li>
<li>text decorati... | <p><TextBlock> has no decorative attributes itself. I would put it on a <Canvas> with a <Rectangle> and apply the stroke there.</p>
| 11,920 |
<p>I have installed CherryPy 3.1.0,. Here is what happens when I try to run tutorial 9:</p>
<pre><code>$ cd /Library/Python/2.5/site-packages/cherrypy/tutorial/
$ python tut09_files.py
Traceback (most recent call last):
File "tut09_files.py", line 48, in <module>
from cherrypy.lib import static
ImportError... | <p>I am a big fan of the proposed HTML 5 solution (<code>data-</code> prefixed attributes). Edit: I'd add that there are probably better examples for the use of custom attributes. For instance, data that a custom application will use that have no analogue in standard attributes (eg. customization for event handlers bas... | <p>My personal feeling in your example is that the span route is more appropriate, as it meets the standards of the XHTML specification. However, i can see an argment for custom attributes, but I think they add a level of confusion that isn't needed.</p>
| 25,703 |
<p>I have a class that I need to binary serialize. The class contains one field as below:</p>
<pre><code>private T[,] m_data;
</code></pre>
<p>These multi-dimensional arrays can be fairly large (hundreds of thousands of elements) and of any primitive type. When I tried standard .net serialization on an object the fil... | <p>Here's what I came up with. The code below makes an int[1000][10000] and writes it out using the BinaryFormatter to 2 files - one zipped and one not. </p>
<p>The zipped file is 1.19 MB (1,255,339 bytes)
Unzipped is 38.2 MB (40,150,034 bytes)</p>
<pre><code> int width = 1000;
int height = 10000;
... | <p>The best code length/output size ratio would be to encode your array using BitConverter, converting all elements into their compact binary format. It's manual, I know, but will save 80-90% space compared to .NET binary serialization.</p>
| 27,629 |
<p>I don't want to have the user install Google Gears so I can show him his guessed location. Is there a way to get the location without having to use Google Gears?</p>
<p>I have found <a href="http://www.wipmania.com/de/blog/google-geolocation-api/" rel="noreferrer">http://www.wipmania.com/de/blog/google-geolocation-... | <p>This is typically called IP Geolocation.</p>
<p>An example is <a href="http://www.geody.com/geoip.php" rel="noreferrer">here</a>.</p>
<p>The thing is, most sites (if you plan on calling this as a web service) will charge you for it. Otherwise, throw together a web service that grabs a geolocation page, parses it ... | <p>If your users are on mobile, <a href="http://xtify.com" rel="nofollow noreferrer">Xitfy</a> is also a free option. They have a small client that after the user agrees can be seamlessly installed on their handset. You can then call a REST based api to get their exact lat/lon sourced from gps / wifi or cell tower.</... | 40,466 |
<p>How do you find a memory leak in Java (using, for example, JHat)? I have tried to load the heap dump up in JHat to take a basic look. However, I do not understand how I am supposed to be able to find the root reference (<a href="https://stackoverflow.com/questions/104/anatomy-of-a-memory-leak">ref</a>) or whatever i... | <p>I use following approach to finding memory leaks in Java. I've used jProfiler with great success, but I believe that any specialized tool with graphing capabilities (diffs are easier to analyze in graphical form) will work.</p>
<ol>
<li>Start the application and wait until it get to "stable" state, when all the ini... | <p>You really need to use a memory profiler that tracks allocations. Take a look at <a href="http://www.ej-technologies.com/products/jprofiler/overview.html" rel="nofollow noreferrer">JProfiler</a> - their "heap walker" feature is great, and they have integration with all of the major Java IDEs. It's not free, but it i... | 6,132 |
<p>The CodePlex team has a <a href="https://rads.stackoverflow.com/amzn/click/com/0767907698" rel="noreferrer" rel="nofollow noreferrer">Slack</a> time policy, and it's worked out very well for them.</p>
<ul>
<li>Jim Newkirk and myself used it to work on the <a href="http://www.codeplex.com/xunit" rel="noreferrer">xUn... | <p>I just want to mention Google's policy on the subject.<br>
20% of the day should be used for private projects and research. </p>
<p>I think it is time for managers to face the fact that most good developers are a bit lazy. If they weren't, we wouldn't have concepts like code reuse.<br>
If this laziness can be focu... | <p>I've never worked anywhere that had a formalized policy, but practically every manager I've ever had has allowed me to spend some time on things that weren't directly related to the current project or fighting a fire.</p>
<p>I think the key is to talk about the things you'd like to try. Most managers want their te... | 3,434 |
<p>How to insert data into a particular cell in a Excel Work sheet in Asp.net</p>
| <p>I think you need to provide a little more information..</p>
<p>Off the top of my head, you could approach this a number of different ways :</p>
<p><em>1)</em> MS Office Automation - Using javascript you could open Excel, open the 'correct' document and then insert the particular data in the cell.</p>
<p><strong>... | <p>Does the worksheet already exist? If it does you can open the worksheet using the open-source component <a href="http://sourceforge.net/projects/koogra/" rel="nofollow noreferrer">Koogra</a> og the commercial component from <a href="http://infragistics.com/" rel="nofollow noreferrer">Infragistics</a> (there are othe... | 32,711 |
<p>I would be interested to learn about large scale development in Python and especially in how do you maintain a large code base?</p>
<ul>
<li><p>When you make incompatibility changes to the signature of a method, how do you find all the places where that method is being called. In C++/Java the compiler will find it ... | <h2>Don't use a screw driver as a hammer</h2>
<p>Python is not a statically typed language, so don't try to use it that way.</p>
<p>When you use a specific tool, you use it for what it has been built. For Python, it means:</p>
<ul>
<li><p><strong>Duck typing</strong> : no type checking. Only behavior matters. Theref... | <p>The usual answer to that is testing testing testing. You're supposed to have an extensive unit test suite and run it often, particularly before a new version goes online.</p>
<p>Proponents of dynamically typed languages make the case that you have to test anyway because even in a statically typed language conforman... | 29,259 |
<p>I would like display something more meaningful that animated gif while users upload file to my web application. What possibilities do I have? </p>
<p><em>Edit: I am using .Net but I don't mind if somebody shows me platform agnostic version.</em></p>
| <p>Here are a couple of versions of what you're looking for for some common JavaScript toolkits.</p>
<ul>
<li>Mootools - <a href="http://digitarald.de/project/fancyupload/" rel="noreferrer">http://digitarald.de/project/fancyupload/</a></li>
<li>Extjs - <a href="http://extjs.com/learn/Extension:UploadForm" rel="norefer... | <p>jQuery UI Progressbar - <a href="http://jqueryui.com/demos/progressbar/" rel="nofollow noreferrer">http://jqueryui.com/demos/progressbar/</a></p>
| 7,219 |
<p>What would be the best algorithm for finding a number that occurs only once in a list which has all other numbers occurring exactly twice.</p>
<p>So, in the list of integers (lets take it as an array) each integer repeats exactly twice, except one. To find that one, what is the best algorithm.</p>
| <p>The fastest (O(n)) and most memory efficient (O(1)) way is with the XOR operation.</p>
<p>In C:</p>
<pre><code>int arr[] = {3, 2, 5, 2, 1, 5, 3};
int num = 0, i;
for (i=0; i < 7; i++)
num ^= arr[i];
printf("%i\n", num);
</code></pre>
<p>This prints "1", which is the only one that occurs once.</p>
<p>Th... | <p>You could simply put the elements in the set into a hash until you find a collision. In ruby, this is a one-liner.</p>
<pre><code>def find_dupe(array)
h={}
array.detect { |e| h[e]||(h[e]=true; false) }
end
</code></pre>
<p>So, <code>find_dupe([1,2,3,4,5,1])</code> would return 1. </p>
<p>This is actually a c... | 5,561 |
<p>Just got a request from my boss for an application I'm working on. Basically we're getting an email address setup for an external client to submit excel files to. </p>
<p>What I need is a way to automatically pick up any email sent to this address, so I can take the attachment, process it and save it to a folder.</... | <p>Email -> mailserver ->[something] -> file-on-disk.</p>
<p>File on disk is pretty easy to parse, use <a href="http://java.sun.com/products/javamail/javadocs/javax/mail/package-summary.html" rel="noreferrer">JavaMail</a>.</p>
<p>The [something] could be:</p>
<ul>
<li>listener for smtp connections (overkill)!</li>
<... | <p>Lotus Notes/Domino stores mail in a Notes database. There are APIs available for getting documents (emails), reading field values (From, Subject), and detaching files.</p>
<p>APIs include</p>
<p>-LotusScript (VB variant, available within the Notes database)</p>
<p>-Java (from within or external to the database)<... | 8,078 |
<p>I'm quoting part of an answer which I received for <a href="https://stackoverflow.com/questions/83088/phpmysql-regular-recalcuation-of-benchmark-values-as-new-users-submit-their-data">another question of mine</a>:</p>
<blockquote>
<p>In the PHP/MySQL world I would say
stored procedures are no-go</p>
</blockquot... | <p>I develop and maintain a large PHP/MySQL application. Here is my experience with stored procedures.</p>
<p>Over time our application has grown very complex. And with all the logic on the php side, some operations would query the database with over 100 short queries.</p>
<p>MySQL is so quick that the performance ... | <p>I think that using stored procedures can offer some abstraction in certain applications, as in any where you would use the same SQL code chunk to update or add the same data, you could then create the one sproc save_user($attr.....) rather that repeating yourself all over the place. </p>
<p>Agreed the syntax is ha... | 10,908 |
<p>Trying to create several layers of folders at once C:\pie\applepie\recipies\
without using several different commands, is there an easy way similar to Directory.CreateDirectory()</p>
| <p>Here's some code I used in one of my projects. It requires a reference be added to the project for the file system object.</p>
<p>First, click Project -> References, scroll down to "Microsoft Scripting Runtime" and select it. Then you can use this function:</p>
<pre><code>Public Sub MakePath(ByVal Folder As Stri... | <p>As an alternative, here is a function I wrote that takes a complete path including a drive letter if needed as a parameter. It then walks the path and traps the VB error number 76 (path not found). When the error handler traps an error 76 it creates the folder that caused the error and resumes walking the path.</p>
... | 36,187 |
<p>The design for the website I am working on calls for a custom image on lists instead of a bullet. Using the image is fine, but I have been having difficulties ensuring that it is centered against the text of the list item across all browsers. Does anyone know of a standard solution for this?</p>
| <p>If you are referring to using a custom image bullet for your list this is the code you'll want to use, it will be vertically centered. I'm assuming here that the bullet image is 12px by 12px.</p>
<pre class="lang-css prettyprint-override"><code>ul li {
background: transparent url(/link/to/custom/bullet.gif) no-re... | <p>Have you tried adding the following code in your CSS file?</p>
<pre class="lang-css prettyprint-override"><code>li
{
background-image: URL('custom.png');
background-repeat: no-repeat;
background-position: center;
}
</code></pre>
| 8,985 |
<p>I hope it is correct term-wise to say that components in a GUI is like JButton, JPanel, JTextField, all that good stuff.</p>
<p>I want to create a text field that takes in an integer. Then a submit button can be pressed and based on the integer that was inputted, create that many textfields in a popup window or wha... | <p>Use an appropriate LayoutManager (e.g. GridLayout) to create and add your textfields.</p>
<pre><code>for (i = 0; i < numberOfTextFields; i++) {
JTextField textField = new JTextField();
container.add(textField);
/* also store textField somewhere else. */
}
</code></pre>
| <p>I would create a List to store the text fields, and then you can get them back by index. Then you can have as many fields as you need.</p>
<pre><code>List fields = new ArrayList();
// Create as many elements as you need
for (int i = 0; i < numberOfElements; i++){
JTextField field = new JTextField();
// Add... | 48,027 |
<p>I've been here for a little while. I am still a low-reputation of SE, with most of my involvement being here. I know that each SE has it's own personality, somewhat derived from the charter, somewhat from the written standards, and somewhat determined by the customary practices in the community.</p>
<p>I have foun... | <p>I struggled with the same question since I saw the edit, good that you brought this to Meta! Thanks!</p>
<p>As the community of regular and active members is limited, I think it is okay to welcome people in a comment or an answer. It would be a shame to scare people away after their first question, resulting in aban... | <p>I struggled with the same question since I saw the edit, good that you brought this to Meta! Thanks!</p>
<p>As the community of regular and active members is limited, I think it is okay to welcome people in a comment or an answer. It would be a shame to scare people away after their first question, resulting in aban... | 77 |
<p>Lists in C# have the <code>.ToArray()</code> method. I want the inverse, where an array is transformed into a list. I know how to create a list and loop through it but I would like a one liner to swap it back.</p>
<p>I am using the <code>String.Split</code> method in the .NET 2.0 environment, so LINQ, etc. is not a... | <pre><code>string s = ...
new List<string>(s.Split(....));
</code></pre>
| <p>If all you need is an object that implements the IList interface and you do not need to add new items you might also do it like this:</p>
<pre><code>IList<string> list = myString.Split(' ');
</code></pre>
| 31,388 |
<p>I'm looking for a simple, but cross-platform <em>negate</em>-process that negates the value a process returns. It should map 0 to some value != 0 and any value != 0 to 0, i.e. the following command should return "yes, nonexistingpath doesn't exist":</p>
<pre><code> ls nonexistingpath | negate && echo "yes, ... | <p><sup><em>Previously, the answer was presented with what's now the first section as the last section.</em></sup></p>
<h3>POSIX Shell includes a <code>!</code> operator</h3>
<p>Poking around the shell specification for other issues, I recently (September 2015) noticed that the POSIX shell supports a <code>!</code> ope... | <p>Note: sometimes you will see <code>!(command || other command)</code>.<br>
Here <code>! ls nonexistingpath && echo "yes, nonexistingpath doesn't exist."</code> is enough.<br>
No need for a sub-shell.</p>
<p>Git 2.22 (Q2 2019) illustrates that better form with:</p>
<p><a href="https://github.com/git/git/com... | 47,915 |
<p>svg is an xml based graphics and you can add JavaScripts to it. I have tried to access to the script functions defined in a svg. The script in my svg is something like this:</p>
<pre><code><svg ... onload="RunScript(evt);"...>
<script type="text/javascript">
...
function RunScript(loadEvent) {
// Get ... | <p>I think the clue might be in 'on another site'. There are strict rules about when JavaScript programs from different sites are allowed to communicate with teach other. The embedded SVG is being treated the same way a document inside an <code>iframe</code> would.</p>
| <p>From my experiense;
Your Code is true ,so that run exactly.
My PC Windows 7,IE9,installed Adobe Viewer.
Both unless SVG Viewer,IE9 SVG drawed,but can't run SVG TAG Animation,
only can run Javascript Animation.
So,under Windows XP,IE8,installed Adobe SVG Viewer, Same result(run exactly).</p>
<p>Firefox SVG can't run... | 30,754 |
<p>I'm wondering if there is a "best" choice for collation in MySQL for a general website where you aren't 100% sure of what will be entered? I understand that all the encodings should be the same, such as MySQL, Apache, the HTML and anything inside PHP.</p>
<p>In the past I have set PHP to output in "UTF-8", but whic... | <p>The main difference is sorting accuracy (when comparing characters in the language) and performance. The only special one is utf8_bin which is for comparing characters in binary format.</p>
<p><code>utf8_general_ci</code> is somewhat faster than <code>utf8_unicode_ci</code>, but less accurate (for sorting). The <em... | <p>In your database upload file, add the followin line before any line:</p>
<pre><code>SET NAMES utf8;
</code></pre>
<p>And your problem should be solved.</p>
| 47,993 |
<p>I am programming a website in which users will have a number of settings, such as their choice of colour scheme, etc. I'm happy to store these as plain text files, and security is not an issue.</p>
<p>The way I currently see it is: there is a dictionary, where all the keys are users and the values are dictionaries ... | <p>Using <a href="http://www.python.org/doc/2.5.2/lib/module-cPickle.html" rel="noreferrer">cPickle</a> on the dictionary would be my choice. Dictionaries are a natural fit for these kind of data, so given your requirements I see no reason not to use them. That, unless you are thinking about reading them from non-pytho... | <p>If you have a database, I might suggest storing the settings in the database. However, it sounds like ordinary files might suit your environment better.</p>
<p>You probably don't want to store <em>all</em> the users settings in the same file, because you might run into trouble with concurrent access to that one fil... | 24,477 |
<p>How do you convert decimal values to their hexadecimal equivalent in JavaScript?</p>
| <p>Convert a number to a hexadecimal string with:</p>
<pre><code>hexString = yourNumber.toString(16);
</code></pre>
<p>And reverse the process with:</p>
<pre><code>yourNumber = parseInt(hexString, 16);
</code></pre>
| <p>Here's my solution:</p>
<pre><code>hex = function(number) {
return '0x' + Math.abs(number).toString(16);
}
</code></pre>
<p>The question says: <em>"How to convert decimal to hexadecimal in JavaScript"</em>. While, the question does not specify that the hexadecimal string should begin with a 0x prefix, anybody wh... | 8,221 |
<p>Is there any way to change the entire width of the horizontal scroll bar on a scrolling div (including the nudge arrows and the handle).</p>
<p>EDIT: I only need an IE7 solution - it's for a scrolling DIV on a touch screen terminal</p>
<p>Thanks</p>
<p>Matt</p>
| <p>Actually, I revise my statement... <strong>in IE7</strong>, you <strong>CAN</strong> do some scaling.</p>
<pre><code><div style="zoom:5;font-size:20%;overflow-x:auto;">
Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World!
</div>... | <p>There is a way, but it's IMO not possible with JS or CSS.</p>
<p>If you have access to the terminal in question, you can set the theme property to have a larger scrollbar. It's at Control Panels -> Display -> tab Appearance -> Advanced -> item Scrollbar -> adjust size as desired
(<a href="http://i33.tinypic.com/idt... | 32,366 |
<p>I have a database table named call with columns call_time, location, emergency_type and there are three types of emergency: paramedics, police and firefighters. In the windows form I created CheckBoxes 'paramedics', 'police', 'firefighters' and I want to retrieve all table columns which meet user's selection.</p>
<... | <p>Well if you have to use emergency_type as a string then instead of passing in bools you could send in a List containing the text representation of the emergency type. For example to adjust the above code you could change the method signature to</p>
<pre><code>public static DataTable GetHistory(DateTime from, DateTi... | <p>This is a dirty way of doing this.</p>
<pre><code>string select = "SELECT call_time, location, emergency_type where call_time between @from AND @to AND (1=0";
if(paramedics) { select += " OR emergency_type = 'paramedics' "; }
if(police) { select += " OR emergency_type = 'police'"; }
if(xyz) { select += ... | 31,900 |
<p>Does anyone know of any methods to create a file upload progress bar in PHP? I have often heard that it's impossible.</p>
<p>I have one idea, but not sure if it would work: have a normal file upload, but instead submit to an iframe. When this is submitted, store the file information (size and temp location) in the ... | <p>You're pretty much figured out how to do it. The main problem is you usually don't have access to the size of the uploaded file until it's done uploading.</p>
<p>There are workarounds for this:
Enabling APC, you to access this information if you include a field called "APC_UPLOAD_PROGRESS" and use apc_fetch() for r... | <p>In pure PHP, you are correct: it's not possible.</p>
<p>If you AJAX-ify this, then you could do what you're describing. The only progress meters I've ever seen are in Javascript or Flash, though I imagine Silverlight could do it also.</p>
| 19,218 |
<p>We want to show a hint for a JList that the user can select multiple items with the platform dependent key for multiselect. </p>
<p>However I have not found any way to show the OS X COMMAND symbol in a JLabel, which means the symbol that's printed on the apple keyboard on the command key, also called apple key.</p>... | <p>The symbol in question is avaiable through Unicode, and the HTML character sets. All you need to do is make your JLabel display HTML by starting its text string with <html> and then include the character code.</p>
<pre><code>JLabel label = new JLabel( "<html>&#8984; is the Apple command symbol." );
... | <p>Your solution looks perfect. I assume you intend to factor out the hint code so you reuse it.</p>
<pre><code>add( new JLabel( MessageFormat.format(
"With {0} you can select multiple items",
getMetaKeyHint(),
BorderLayout.SOUTH );
public String getMetaKeyHint() {
return System.getProperty( "mrj.version" ... | 28,349 |
<p>Is there any way for a DBA to peek in on the execution plan of a long-running query in SQL Server 2000? I know how to get the SQL being run using fn_get_sql(). And yes, theoretically if open a new connection and set the environment flags the same, it should generate the same plan for the SQL. However, I'm in a da... | <p>I don't think you can do such a thing, it needs to be submitted to the server with the original query: </p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa178303(SQL.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa178303(SQL.80).aspx</a> . </p>
<p>You could load up the query ... | <p>Maybe...</p>
<p>Run profiler, and expand the "performance" events node.
Choose one of the SHOWPLAN options.</p>
<p>Hopefully, you will be able to trap the end of execution.
I know you can log query plans, but I don't know if it works in this case.</p>
<p>I don't have SQL 2k profiler, only 2k5, to test something o... | 46,504 |
<p>I want a list of hyperlinks on a basic html page, which point to files on our corporate intranet.</p>
<p>When a user clicks the link, I want the file to open.
They are excel spreadsheets, and this is an intranet environment, so I can count on everyone having Excel installed.</p>
<p>I've tried two things:</p>
<ol>... | <p>Try formatting the link like this (looks hellish, but it works in Firefox 3 under Vista for me) :</p>
<pre><code><a href="file://///SERVER/directory/file.ext">file.ext</a>
</code></pre>
| <p>Your first idea used to be the way but I've also noticed issues doing this using Firefox, try a straight http:// to the file - href='<a href="http://server/directory/file.xlsx" rel="nofollow noreferrer">http://server/directory/file.xlsx</a>'</p>
| 12,707 |
<p>I have a base URL :</p>
<pre><code>http://my.server.com/folder/directory/sample
</code></pre>
<p>And a relative one :</p>
<pre><code>../../other/path
</code></pre>
<p>How to get the absolute URL from this ? It's pretty straighforward using string manipulation, but I would like to do this in a secure way, using t... | <pre><code>var baseUri = new Uri("http://my.server.com/folder/directory/sample");
var absoluteUri = new Uri(baseUri,"../../other/path");
</code></pre>
<p>OR</p>
<pre><code>Uri uri;
if ( Uri.TryCreate("http://base/","../relative", out uri) ) doSomething(uri);
</code></pre>
| <p>Some might be looking for Javascript solution that would allow conversion of urls 'on the fly' when debugging </p>
<pre><code>var absoluteUrl = function(href) {
var link = document.createElement("a");
link.href = href;
return link.href;
}
</code></pre>
<p>use like: </p>
<p><code>absoluteUrl("http://g... | 15,683 |
<p>How do I segment a 2D image into blobs of similar values efficiently? The given input is a n array of integer, which includes hue for non-gray pixels and brightness of gray pixels.</p>
<p>I am writing a virtual mobile robot using Java, and I am using segmentation to analyze the map and also the image from the camer... | <p>I would downsample,in colourspace and in number of pixels, use a vision method(probably meanshift) and upscale the result.</p>
<p>This is good because downsampling also increases the robustness to noise, and makes it more likely that you get meaningful segments.</p>
<p>You could use floodfill to smooth edges after... | <p>What I have now:</p>
<ol>
<li>Make a buffer of the same size as the input image, initialized to <code>UNSEGMENTED</code>.</li>
<li><p>For each pixel in the image where the corresponding buffer value is not <code>UNSEGMENTED</code>, flood the buffer using the pixel value.</p>
<p>a. The border checking of the floodi... | 46,319 |
<p>The following snippet is supposed to take the value of PROJECT (defined in the Makefile)
and create an include file name. For example, if PROJECT=classifier, then it should at the end generate classifier_ir.h for PROJECTINCSTR</p>
<p>I find that this code works as long as I am not trying to use an underscore in the... | <pre><code>#define QMAKESTR(x) #x
#define MAKESTR(x) QMAKESTR(x)
#define SMASH(x,y) x##y
#define MAKEINC(x) SMASH(x,_ir.h)
#define PROJECTINC MAKEINC(PROJECT)
#define PROJECTINCSTR MAKESTR(PROJECTINC)</code></pre>
| <p>That barebone example works with gcc (v4.1.2) and tries to include "PROJECT_ir.h"</p>
| 17,152 |
<p>I'm in the process of moving one of our projects from VS6 to VS2008 and I've hit the following compile error with mshtml.h:</p>
<pre><code>1>c:\program files\microsoft sdks\windows\v6.0a\include\mshtml.h(5272) : error C2143: syntax error : missing '}' before 'constant'
1>c:\program files\microsoft sdks\window... | <p>There is probably a #define changing something. Try running just the preprocessor on your .cpp and generating a .i file. The setting is in the project property pages.</p>
<p>EDIT: Also, you can get the answer from that other expert site by scrolling to the bottom of the page. They have to do that or Google will ... | <p>What other incodes do ou have in the currently compiling file? It may be that <code>True</code> has been defined by a macro already as <code>1</code>. That would explain the error.</p>
| 14,456 |
<p>I'm making a simple 2 player game in XNA and started looking into saving the player's high scores.</p>
<p>I want the game to work on the XBox 360 as well as Windows, so I have to use the framework to save the data.</p>
<p>It seems that you save data to a particular user's gamer tag - so my question is, what to do ... | <p>You're right -- looks like Eclipse has acknowledged it as a <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=199499" rel="nofollow noreferrer">bug</a>. It's fixed in 3.5.</p>
| <p>I was initially thinking <kbd>Alt</kbd>-<kbd>←</kbd> and <kbd>Alt</kbd>-<kbd>→</kbd> might do what you want, but that's more for going forward and backwards in history of tabs you've viewed. Which might sort of get you what you want, but is probably just as confusing as <kbd>Alt</kbd>-<kbd>F6</kbd>.</p>
<p>I think i... | 8,698 |
<p>Before I upgraded to Firefox 3 I used to constantly use the <a href="https://addons.mozilla.org/en-US/firefox/addon/655" rel="nofollow noreferrer">View Source Chart Firefox Addon</a> which shows the source HTML in a very organized, graphical form. Unfortunately, this addon is only for Firefox 2 and the beta version ... | <p>Is <a href="https://addons.mozilla.org/en-US/firefox/addon/1843" rel="nofollow noreferrer">Firebug</a> not sufficient?</p>
| <p>You could always try Firefug. It sounds like it does a similar thing, plus more :)</p>
| 6,947 |
<p>What I'd like to accomplish is to present charts on webpages. For example aspx pages gridviews that present a two column table are able to be copied & placed into Excel then a chart created. The pages I currently use most are ASP.NET 3.0 or SharePoint team sites with stored procedures. People are very interested... | <p>The Google Chart API makes it easy to embed charts into web pages. No server-side install needed, at all.</p>
<p><a href="http://code.google.com/apis/chart/" rel="nofollow noreferrer">http://code.google.com/apis/chart/</a></p>
| <p>So you want to maybe export the GridView to MS Excel which should I can imagine contain a generated macro to generate the chart on the data. Something like that you mean. Or do you just want to get the data from the website into excel? i.e. CSV format is really simple to accomplish. For the Excel format, this is... | 26,601 |
<p>I've recently been working on a beginner's project in Scala, and have a beginner question about Scala's Lists.</p>
<p>Say I have a list of tuples ( <code>List[Tuple2[String, String]]</code>, for example). Is there a convenience method to return the first occurence of a specified tuple from the List, or is it necess... | <pre>
scala> val list = List(("A", "B", 1), ("C", "D", 1), ("E", "F", 1), ("C", "D", 2), ("G", "H", 1))
list: List[(java.lang.String, java.lang.String, Int)] = List((A,B,1), (C,D,1), (E,F,1), (C,D,2), (G,H,1))
scala> list find {e => e._1 == "C" && e._2 == "D"}
res0: Option[(java.lang.String, java.lang.String, Int)] = ... | <p>You could also do this, which doesn't require knowing the field names in the Tuple2 class--it uses pattern matching instead:</p>
<pre><code>list find { case (x,y,_) => x == "C" && y == "D" }
</code></pre>
<p>"find" is good when you know you only need one; if you want to find all matching elements you co... | 7,759 |
<p>I just wanna ask what would be better approach to supply these objects in my unit tests.</p>
<p>In my unit test I am testing CSLA object. CSLA object is internally using one property and one method of ApplicationUser object. ApplicationUser is inherited from IPrincipal.
The properties are:
1) ApplicationContext.Use... | <p>The reason you're getting a null reference error is because <code>IPrincipal.Identity</code> is null; it hasn't been set in your mocked <code>IPrincipal</code> yet. Calling <code>.Name</code> the null <code>Identity</code> results in your exception.</p>
<p>The answer, as Carlton pointed out, is to mock <code>IIdent... | <p>Here is the code I use to return a test user (using Stubs):</p>
<pre><code> [SetUp]
public void Setup()
{
var identity = MockRepository.GenerateStub<IIdentity>();
identity.Stub(p => p.Name).Return("TestUser").Repeat.Any();
var principal = MockRepository.GenerateStub<IP... | 19,652 |
<p>I have an XmlDocument that already exists and is read from a file. </p>
<p>I would like to add a chunk of Xml to a node in the document. Is there a good way to create and add all the nodes without cluttering my code with many .CreateNote and .AppendChild calls?</p>
<p>I would like some way of making a string or st... | <p>I suggest using <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.createdocumentfragment.aspx" rel="noreferrer">XmlDocument.CreateDocumentFragment</a> if you have the data in free form strings. You'll still have to use AppendChild to add the fragment to a node, but you have the freedom of build... | <p>All that I do is creating a new dataset object and open the xml file using ReadXML <code>myDataset.ReadXML(path and file name)</code>. </p>
<p>Then add or remove the rows that I need and save the document again using <code>myDataset.WriteXML(path and file name)</code>.</p>
<p>Bye.</p>
| 21,606 |
<p>Following on from a <a href="https://stackoverflow.com/questions/221417/how-do-i-programmatically-access-the-target-path-of-a-windows-symbolic-link">previous question</a>, I am creating a symbolic link on a Server 2008 from a Vista machine using UNC paths. I can create the link just fine. I can go to the Server 2008... | <p>To add to <a href="https://stackoverflow.com/a/230047/45375">@David Arno's helpful answer</a>, based on W7:</p>
<hr />
<p><code>fsutil.exe</code> can be made to show what arguments it takes by simply running:</p>
<pre><code>fsutil behavior set /?
</code></pre>
<p>To <strong>report the <em>current</em> configuration<... | <p>Remote junction points work by default. For files you still need symlinks.</p>
| 28,429 |
<p>I'm thinking that the reason I can't do this is because it might be a huge security hole, but here goes...</p>
<p>I want to have a bookmark on my browser (FF3, preferably) that is only a snippet of javascript code. It would merely construct a URL based on the current date and then do a window.location = on that UR... | <p>What you want is a <a href="http://en.wikipedia.org/wiki/Bookmarklet" rel="noreferrer">bookmarklet</a> they are easy to create and should work in most major browsers.</p>
<p>Edit: Stack overflow seems not to allow creating bookmarklets in the context of the site, basically you can create a new bookmark and type the... | <p>Well, I just created a bookmark in FF3, went back and updated it and added the following test:</p>
<pre><code>javascript:alert('Wacky%20test%20yo');
</code></pre>
<p>Low and behold, after I saved and loaded, I was able to get my alert.</p>
<p>I'm sure you can work up something similar for your needs.</p>
| 3,057 |
<p>From a HTML application (<code>.hta file</code>), you can drag any image and drop it into the desktop for example.</p>
<p>Does anybody know how to disable this capability?</p>
<p>I want the <code>.hta</code> files to have the same behavior as the <code>.html</code> files.</p>
| <p>Have a look at the <a href="http://pages.cs.wisc.edu/~bart/fuzz/" rel="nofollow noreferrer">Fuzz Testing of Application Reliability</a> website of the University of Wisconsin. They did a research study some years ago to test the reliability of desktop software and on that page you find a link to their FTP site provi... | <p>Here's a pseudocode (since you didn't mention the language you're using):</p>
<ul>
<li>Create an array that contains the alphabet from a-z, A-Z, 0-9 (depending on what keys you wish to send)</li>
<li>for i = 0 to NumberOfKeyStrokes</li>
<li>rand() % SizeOfArray</li>
<li>delay for rand() milliseconds (the lower the ... | 29,635 |
<p>I have an asp.net website that allows the user to download largish files - 30mb to about 60mb. Sometimes the download works fine but often it fails at some varying point before the download finishes with the message saying that the connection with the server was reset.</p>
<p>Originally I was simply using Server.T... | <p>Will</p>
<pre><code><configuration>
<system.web>
<httpRuntime executionTimeout="3600"/>
</system.web>
</configuration>
</code></pre>
<p>help anything?</p>
<p>The inner loop that writes the data seems a bit convoluted, I would at least change it to:</p>
<pre><code>int length;... | <p>What ended up working for me is doing a Response.End and also doing a using statement with the file stream. Here is the code that I have:</p>
<pre><code>public partial class ssl_Report_StreamReport : BaseReportPage
{
protected void Page_Load(object sender, EventArgs e)
{
//Get the parameters
... | 22,638 |
<p>I'm on a project doing an iPhone application. We had a Cocoa consultant come in for a few weeks. He showed me an interesting idiom of Cocoa, dealing with interfaces, but there was a difficult language barrier between us, and he wasn't really able to explain <em>why</em> this was done or where it was documented so I ... | <p>These are what's known in Objective-C as "categories". Categories make it possible to have multiple @interface and @implementation blocks for the same class. This works even to the extent that you can add methods on classes in the standard Apple frameworks, e.g. adding a category on NSString to add new methods to ... | <p>I don't know; those look a lot like informal protocols to me, largely for delegates. See pages 297 - 298 of <em>Cocoa Programming with Mac OS X, 3rd Edition</em>. The protocols are implemented via Categories ... And in all honesty, they appear to be heavily overused in your sample.</p>
| 48,600 |
<p>In our application we've run into an error numerous times where we get error CS0433, which complains about a name collison in two separate dlls. This is an ASP.NET app developed in C# using webforms. It always complained about A TimeLog page. Anyone have advice for resolving this error?</p>
| <p><a href="http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/aa9f90e8-534d-4e74-b656-99187eb3f281/" rel="nofollow noreferrer"> I found a link in the MSDN that describes this error.</a></p>
<p>To summarize, a naming conflict can happen between the file name of a page (TimeLogTab.aspx) and the class in the c... | <p>The error can happen intermittently: I'm using "Publish Web Site" for a VS 2005 Web Application Project with "Delete all existing files prior to publish" and then XCOPY-Deploy to the target IIS folder (which won't delete existing files there). Today I ran into that error for the first time (no new .ascx/.aspx files ... | 11,401 |
<p>I have uploaded some files to a directory under public and I try to access them using Dir.glob. But I get no results back. </p>
<p>The Dir.glob works fine on dev server (mongrel) and also works fine when using script/console on the site installed on site5</p>
<p>is there a way to get this working or a different wa... | <p>My guess is that executing a shell is prohibited by site5 or that you don't have access to /bin/sh. Globbing is generally implemented by running a shell... Try</p>
<pre><code>Dir.entries("public").each do |f|
puts(f)
end
</code></pre>
| <p>Turns out that glob is allowed, but on mongrel I need to prefix the path with public whereas on the site hosted by site5 I need to skip it.</p>
<p>valid in mongrel:</p>
<pre><code>Dir.glob('public/files/images/*.jpg')
</code></pre>
<p>valid in site5:</p>
<pre><code>Dir.glob('files/images/*.jpg')
</code></pre>
<... | 48,737 |
<p>I've been using htmldoc for a while, but I've run into some fairly serious limitations. I need the end solution to work on a Linux box. I'll be calling this library/utility/application from a Perl app, so any Perl interfaces would be a bonus.</p>
| <p>Sorry to unearth this old post, but it came out first in my search for the best HTML/PDF conversion tool.
On Linux <a href="http://wkhtmltopdf.org/" rel="noreferrer">wkhtmltopdf</a> is very good (takes into account CSS, among others) and GPL.</p>
| <p>You might want to check out 'Document Conversion Service' by Peernet (at <a href="http://www.peernet.com/conversion-software/batch-document-converter/" rel="nofollow">http://www.peernet.com/conversion-software/batch-document-converter/</a>). This runs as a service on a Windows Desktop or Windows Server machine. It... | 21,260 |
<p>Ok, I realize this situation is somewhat unusual, but I need to establish a TCP connection (the 3-way handshake) using only raw sockets (in C, in linux) -- i.e. I need to construct the IP headers and TCP headers myself. I'm writing a server (so I have to first respond to the incoming SYN packet), and for whatever r... | <p>You want to implement part of a TCP stack in userspace... this is ok, some other apps do this.</p>
<p>One problem you will come across is that the kernel will be sending out (generally negative, unhelpful) replies to incoming packets. This is going to screw up any communication you attempt to initiate.</p>
<p>One ... | <p>There are structures for IP and TCP headers declared in netinet/ip.h & netinet/tcp.h respectively. You may want to look at the other headers in this directory for extra macros & stuff that may be of use. </p>
<p>You send a packet with the SYN flag set and a random sequence number (x). You should receive a S... | 13,559 |
<p>I would like to manipulate the HTML inside an iframe using jQuery.</p>
<p>I thought I'd be able to do this by setting the context of the jQuery function to be the document of the iframe, something like:</p>
<pre><code>$(function(){ //document ready
$('some selector', frames['nameOfMyIframe'].document).doStuff(... | <p>I think what you are doing is subject to the <a href="http://en.wikipedia.org/wiki/Same_origin_policy" rel="noreferrer">same origin policy</a>. This should be the reason why you are getting <em>permission denied type</em> errors.</p>
| <p>For even more robustness:</p>
<pre><code>function getIframeWindow(iframe_object) {
var doc;
if (iframe_object.contentWindow) {
return iframe_object.contentWindow;
}
if (iframe_object.window) {
return iframe_object.window;
}
if (!doc && iframe_object.contentDocument) {
doc = ifram... | 47,639 |
<p>Suppose I have following string:</p>
<pre><code>String asd = "this is test ass this is test"
</code></pre>
<p>and I want to split the string using "ass" character sequence.</p>
<p>I used:</p>
<pre><code>asd.split("ass");
</code></pre>
<p>It doesn't work. What do I need to do?</p>
| <p>It seems to work fine for me:</p>
<pre><code>public class Test
{
public static void main(String[] args) {
String asd = "this is test ass this is test";
String[] bits = asd.split("ass");
for (String bit : bits) {
System.out.println("'" + bit + "'");
}
}
}
</code></... | <pre><code>public class Splitter {
public static void main(final String[] args) {
final String asd = "this is test ass this is test";
final String[] parts = asd.split("ass");
for (final String part : parts) {
System.out.println(part);
}
}
}
</code></pre>
<p>Prints:<... | 25,107 |
<p>What is the easiest way to check if a computer is alive and responding (say in ping/NetBios)?
I'd like a deterministic method that I can time-limit.</p>
<p>One solution is simple access the share (File.GetDirectories(@"\compname")) in a separate thread, and kill the thread if it takes too long.</p>
| <p>Easy! Use <code>System.Net.NetworkInformation</code> namespace's ping facility!</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping.aspx" rel="noreferrer">
<a href="http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping.aspx" rel="noreferrer">http://msdn.mi... | <p>As long as you want to check a computer within the own subnet you could check it using <a href="http://en.wikipedia.org/wiki/Address_Resolution_Protocol" rel="nofollow">ARP</a>. Here's an example:</p>
<pre><code> //for sending an arp request (see pinvoke.net)
[DllImport("iphlpapi.dll", ExactSpelling = true)]... | 45,233 |
<p>Is it possible to use WSE 2.0 SP2 under VS 2008?</p>
<p>I realise that the add-in (that generates the proxy classes/configuration) is not compatible but there are work-arounds to this (copying over the files from a VS 2003 solution). Our web services are relatively static so would not be making too many changes anw... | <p>You may want to use WSE 2.0 SP3 instead of SP2. Here is why: if you care about (or pay for) Microsoft support services for your application then <a href="http://www.microsoft.com/downloads/details.aspx?familyid=8070E1DE-22E1-4C78-AB9F-07A7FCF1B6AA&displaylang=en" rel="nofollow noreferrer" title="SP3 docs">SP3</a... | <p>I have been able to use WSE2 under VS2005/.NET 2.0 with no problems, but I dont know specifically about 2008. I needed Dime attachments (java web service - ugh.. what a headache) which are only in WSE2.</p>
<p>To get the functionality in VS, I actually installed WSE3 and then just changed the dll referenced in the ... | 33,308 |
<p>On 16 September 2020, Autodesk announced changes in the way that Fusion 360 can be used for non-commercial use with their Personal license. As a hobbyist, most of these changes will not affect me very much, since I do not use Fusion 360's advanced features. The most irksome will be only being allowed to have up to t... | <p>Most of my answer is based off of what Autodesk has said and <a href="https://www.youtube.com/watch?v=SlnEThQ4HR8" rel="nofollow noreferrer">this video</a> from Maker's Muse, which explains this topic in much more detail.</p>
<p>In summary, Autodesk is planning on restricting your ability to export any parametric fi... | <h1>If you use the private license: there was supposed to be a cutoff date.</h1>
<p>As long as you use the "private" license, you will get some restrictions. Originally, including the lock off of <code>.step</code> and similar files as well as limiting you to 10 active projects. This means, that you will need... | 1,745 |
<p>I have a Queue<T> object that I have initialised to a capacity of 2, but obviously that is just the capacity and it keeps expanding as I add items. Is there already an object that automatically dequeues an item when the limit is reached, or is the best solution to create my own inherited class?</p>
| <p>I've knocked up a basic version of what I'm looking for, it's not perfect but it'll do the job until something better comes along.</p>
<pre><code>public class LimitedQueue<T> : Queue<T>
{
public int Limit { get; set; }
public LimitedQueue(int limit) : base(limit)
{
Limit = limit;
... | <p>You can use a <a href="https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.linkedlist-1?view=netcore-3.1" rel="nofollow noreferrer"><code>LinkedList<T></code></a> and add thread safety:</p>
<pre><code>public class Buffer<T> : LinkedList<T>
{
private int capacity;
publi... | 2,368 |
<p>I use Visual Studio to do a lot of my coding. I find the open containing folder feature quite helpful. But I don't want the folder to be "opened" by the windows explorer, instead I want to "explore" the folder -- you know, get the nice little frame showing me all the other folders on the left hand side. Does anyone ... | <p>What I do when I want to export a Quicktime movie is something like the following:</p>
<pre><code>NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], QTMovieExport,
[exportSettings objectForKey: @"subtype"], QTMovieExportType,
[exportSettin... | <p>Those attributes are documented as things you can read but not write. However, you might be able to set them when you create the movie, with initWithAttributes:error:.</p>
| 24,679 |
<p>Working on a project where a sequential set of methods must be run every <code>x</code> seconds. Right now I have the methods contained within another "parent method", and just sequentially call them right after another.</p>
<pre><code>class DoTheseThings()
{
DoThis();
NowDoThat();
NowDoThis();
Mor... | <pre><code>Action[] work=new Action[]{new Action(DoThis), new Action(NowDoThat),
new Action(NowDoThis), new Action(MoreWork), new Action(AndImSpent)};
int current =0;
while(current!=work.Length)
{
try
{
work[current]();
current++;
}
catch(Exception ex)
{
// log the error... | <p>What would be the reason that an error was occuring?</p>
<p>If this were a resource issue, such as access to something like a connection or object, then you might want to look at using monitors, semaphores, or just locking. </p>
<pre><code>lock (resource)
{
Dosomething(resource);
}
</code></pre>
<p>This way ... | 29,340 |
<p>What's the best way to go about validating that a document follows some version of HTML (prefereably that I can specify)? I'd like to be able to know where the failures occur, as in a web-based validator, except in a native Python app.</p>
| <p>XHTML is easy, use <a href="http://lxml.de/validation.html" rel="noreferrer">lxml</a>.</p>
<pre><code>from lxml import etree
from StringIO import StringIO
etree.parse(StringIO(html), etree.HTMLParser(recover=False))
</code></pre>
<p>HTML is harder, since there's traditionally not been as much interest in validatio... | <p>I think that <a href="http://tidy.sourceforge.net/" rel="nofollow noreferrer">HTML tidy</a> will do what you want. There is a Python binding for it.</p>
| 5,606 |
<p>I need to use sendmail from Macs in an office. At the moment, I can get it to work on the two development Macs (which I think is due to MAMP being installed and working), but getting it to go on the others seems to be a problem...</p>
<p>I assume it's down to some config issue, and hope there's someway to fix it (w... | <p>Note that it's postfix that you have running on your mac, not sendmail.</p>
<p>The problem is that the machine mx01.xxx.uk[212.x.x.134] is configured to block mail relaying (accepting an email over SMTP and sending it on to the final mail server). The postfix configuration files are normally stored in /etc/postfix ... | <p>Ah ha! Thanks Denis - this looks like the beasty... </p>
<pre><code>### MAMP Postfix Configuration - Start ###
myorigin = example.com
myhostname = mailer.$myorigin
smtpd_sender_restrictions = permit_inet_interfaces
# smart host
relayhost = auth.example.co.uk
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = h... | 37,010 |
<p>I'm trying to determine what instances of sql server/sql express I have installed (either manually or programmatically) but all of the examples are telling me to run a SQL query to determine this which assumes I'm already connected to a particular instance.</p>
| <p>At a command line:</p>
<pre><code>SQLCMD -L
</code></pre>
<p>or </p>
<pre><code>OSQL -L
</code></pre>
<p>(Note: must be a capital L)</p>
<p>This will list all the sql servers installed on your network. There are configuration options you can set to prevent a SQL Server from showing in the list. To do this...<... | <p>If your within SSMS you might find it easier to use:</p>
<pre><code>SELECT @@Version
</code></pre>
| 17,049 |
<p>I have written a standalone app that controls a device through RS-232 port and some customers want to be able to use the device with LabVIEW. I have seen some threads describing where to start when learning to use LabVIEW, but I was wondering if anyone has experience with writing a plugin/driver (is that the right ... | <p>If you are prepared to invest a bit of time into learning how to program in LabVIEW, the relevant info on how to develop an instrument driver can be found <a href="http://www.ni.com/devzone/idnet/development.htm" rel="noreferrer">here</a> and <a href="http://zone.ni.com/devzone/cda/tut/p/id/3271" rel="noreferrer">he... | <p>Your customer wants to use your code with LabVIEW. This doesn't mean you have to write LabVIEW code. </p>
<p>LabVIEW can interact with DLLs. The trick here is to avoid the more complicated data structures. If you keep to pass by value of basic data types you will have no problem. LabVIEW can work with arrays to and... | 28,129 |
<p>I'm using reflection to loop through a <code>Type</code>'s properties and set certain types to their default. Now, I could do a switch on the type and set the <code>default(Type)</code> explicitly, but I'd rather do it in one line. Is there a programmatic equivalent of default?</p>
| <ul>
<li>In case of a value type use <a href="http://msdn.microsoft.com/en-us/library/system.activator.createinstance.aspx" rel="noreferrer">Activator.CreateInstance</a> and it should work fine.</li>
<li>When using reference type just return null</li>
</ul>
<pre><code>public static object GetDefault(Type type)
{
... | <pre><code> /// <summary>
/// returns the default value of a specified type
/// </summary>
/// <param name="type"></param>
public static object GetDefault(this Type type)
{
return type.IsValueType ? (!type.IsGenericType ? Activator.CreateInstance(type) : type.GenericT... | 42,141 |
<p>i have a Sharepoint feature that essentially extends Lists with a new feature, using a List receiver. For each list the feature is attached to, i need to store some configuration.</p>
<p>Now, the first thing that came into my mind is the obvious solution: Have a global list. That works of course, but I wonder if th... | <p>SPLists, unlike som other objects, do not have property bags, however all lists in a SharePoint site has a correlating SPFolder object stored in the RootFolder, and an SPFolder object has a property bag where you can store custom configuration data for the list.</p>
<p>Edit: I've written an article that shows <a hr... | <p>You should take a look at <a href="http://www.codeplex.com/SPConfigStore" rel="nofollow noreferrer">Sharepoint Config Store</a>. It's made by <a href="http://www.sharepointnutsandbolts.com/" rel="nofollow noreferrer">Chris O'Brien</a>.</p>
<p>With SPConfigStore you can retrieve config items this way </p>
<pre><cod... | 46,558 |
<p>Is there a website I can create an HTML final four bracket?</p>
<p>Or is there just HTML out there that will create it automatically and I can just fill in the specifics?</p>
| <p>Stumbled upon this HTML code, this did the trick. I will post it just in case anyone down the road has the same question.</p>
<pre><code>table.bracket {
border-collapse: collapse;
border: none;
}
.bracket td {
vertical-align: middle;
width: 40em;
margin: 0;
padding: 10px;
}
.bracket td p {... | <p>I don't really know what you need from the question but from the looks of it try out:</p>
<p><a href="http://www.bracketmaker.com/" rel="nofollow noreferrer">http://www.bracketmaker.com/</a></p>
| 32,776 |
<p>I'm trying to get crawl to work on two separate farms I have but can't get it to work on either one. They both have two WFE's with an additional WFE configured as an Index server. There is one more server dedicated for Query and two clustered SQL 2005 back end servers for the database. I have unsuccessfully tried... | <p>One thing to remember is that crawling SharePoint sites is different from crawling file shares or non-SharePoint websites.</p>
<p>A few other quick pointers:</p>
<ul>
<li>the sps3: protocol is for crawling user profiles for People Search. You can disregard anything the crawler says about it until you're ready for ... | <p>In the Services on Server section check the properties for the search crawl account to make sure it is set up, and that it has permissions to access those sites.</p>
| 12,658 |
<p>I just recently installed the MVC beta.
However, I assumed because the versioning numbers have changed and because it now uses the GAC instead of the bin folder that it wouldn't break existing applications.</p>
<p>However, it has.</p>
<p>What steps do I need to follow to ensure my existing preview 3 applications u... | <p>ASP.NET MVC beta is also bin-deployable, Move the following DLL's from GAC to the bin folder of your app</p>
<pre><code>* System.Web.Mvc
* System.Web.Routing
* System.Web.Abstractions
</code></pre>
<p><a href="http://haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx" rel="nofollow noreferrer">Check this art... | <p>You'll need to force uninstall (gacutil /u /f System.Web.Mvc) the Beta DLL from the GAC, and then use bin deployment for all versions (including the beta).</p>
| 33,580 |
<p>Which databases does Adobe Flash support, if any?</p>
| <p>None.</p>
<p>Instead, you would need to create some middleware (say, a webservice) that you talked to that did the database CRUD for you.</p>
| <p><a href="https://stackoverflow.com/questions/38674/does-adobe-flash-support-databases#38675">@SCdF</a> is correct. From <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14482&sliceId=2" rel="nofollow noreferrer">the horse's mouth</a>:</p>
<blockquote>
<p>A Macromedia Flash movie cannot
... | 5,962 |
<p>As per my understanding stateless session beans are used to code the business logic. They can not store data in their instance variables because their instance is shared by multiple requests. So they seem to be more like Singleton classes. However the difference is contain creates (or reuses from pool) the separate ... | <p>The SLSBs are single threaded because of the TX Context, Principal is associated with a bean instance when it is called. These beans are pooled and unless the max pool size is reached are processed in separate threads ( Vendor dependent).</p>
<p>If SLSBs were designed thread safe every call would have looked like a... | <p>The primary reason stateless session beans are single threaded is to make them highly scalable for the container. The container can make a lot of simplifying assumptions about the runtime environment. A second reason is to make life easier for the developer because the developer doesn't have to worry about any sync... | 4,948 |
<p>Are disabling and enabling foreign key constraints supported in SQL Server? Or is my only option to <strong><code>drop</code></strong> and then <strong>re-<code>create</code></strong> the constraints?</p>
| <p>If you want to disable all constraints in the database just run this code:</p>
<pre><code>-- disable all constraints
EXEC sp_MSforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
</code></pre>
<p>To switch them back on, run: (the print is optional of course and it is just listing the tables)</p>
<pre><code>-- ena... | <p>You can easily turn of CONSTRAINT using :
ALTER TABLE TableName NOCHECK CONSTRAINT ALL</p>
<p>After you finish the transaction do not forget to turn them on again using:
ALTER TABLE TableName CHECK CONSTRAINT ALL</p>
| 19,241 |
<p>Is there a query in SQL Server 2005 I can use to get the server's IP or name?</p>
| <pre><code>SELECT
CONNECTIONPROPERTY('net_transport') AS net_transport,
CONNECTIONPROPERTY('protocol_type') AS protocol_type,
CONNECTIONPROPERTY('auth_scheme') AS auth_scheme,
CONNECTIONPROPERTY('local_net_address') AS local_net_address,
CONNECTIONPROPERTY('local_tcp_port') AS local_tcp_port,
CONNEC... | <p>It is possible to use the host_name() function</p>
<pre><code>select HOST_NAME()
</code></pre>
| 17,184 |
<p>The .NET <code>System.Security.Cryptography</code> namespace has a rather bewildering collection of algorithms that I could use for encryption of credit card details. Which is the best?</p>
<p>It clearly needs to be secure for a relatively short string. </p>
<p>EDIT: I'm in the UK, where I understand we're OK stor... | <p>No offense, but the question is a little "misguided". There is no "silver bullet" solution. I would recommend to read up on cryptography in general and then do some threat modeling. Some questions (by no means a comprehensive list) you should ask yourself:</p>
<ul>
<li>Is the module doing the encryption the one whi... | <p>3des is pretty good, store the salt along side, and keep a standard key somewhere not in the database or a config file. That way if you get pwned, they can't decrypt it.</p>
| 6,252 |
<p>Suppose I have a stringbuilder in C# that does this:</p>
<pre><code>StringBuilder sb = new StringBuilder();
string cat = "cat";
sb.Append("the ").Append(cat).(" in the hat");
string s = sb.ToString();
</code></pre>
<p>would that be as efficient or any more efficient as having:</p>
<pre><code>string cat = "cat";
s... | <p><strong>NOTE:</strong> This answer was written when .NET 2.0 was the current version. This may no longer apply to later versions.</p>
<p><code>String.Format</code> uses a <code>StringBuilder</code> internally:</p>
<pre><code>public static string Format(IFormatProvider provider, string format, params object[] args)... | <p>I would suggest not, since String.Format was not designed for concatenation, it was design for formatting the output of various inputs such as a date.</p>
<pre><code>String s = String.Format("Today is {0:dd-MMM-yyyy}.", DateTime.Today);
</code></pre>
| 2,849 |
<p>Here's the quick and skinny of my issue:</p>
<pre>$("a").toggle(function() { /*function A*/ }, function() { /*function B*/ });</pre>
<p>Inside <code>function A</code> a form is displayed. If the user successfully completes the form, the form is hidden again (returning to it's original state).</p>
<p>Inside <code... | <p>jQuery has two <code>.toggle()</code> methods:</p>
<p><a href="http://api.jquery.com/toggle/" rel="nofollow noreferrer"><code>.toggle()</code></a></p>
<blockquote>
<p>Toggles each of the set of matched
elements. If they are shown, toggle
makes them hidden. If they are hidden,
toggle makes them shown.</p>
<... | <pre><code>$("#div_clicked").click(function() {
if ($("#toggle_div").is(":visible")) {
// do this
} else {
// do that
}
</code></pre>
<p>Replace hidden with visible</p>
| 30,304 |
<p>I am attempting to import mxml files that I developed with Emacs into a new project in FlexBuilder...I have created a project and manually added all my MXML and actionscript files into FlexBuilder. </p>
<p>I now can't figure out how to run the application. I believe the problem lies in the fact that FlexBuilder bel... | <p>I usually seem to have to go into the Project Properties, click 'Flex Applications' and add the MXMLs into that panel before I can run stuff.</p>
| <p>Make sure the MXML files are in the main source folder. You can't have a runnable application in a secondary source directory or subdirectory of the main source dir.</p>
| 27,084 |
<p>Can this be done w/ linqtosql?</p>
<pre><code>SELECT City, SUM(DATEDIFF(minute,StartDate,Completed)) AS Downtime
FROM Incidents
GROUP BY City
</code></pre>
| <p>It is in part to support scenarios (WebForms, WinForms, LINQ-to-SQL, etc) mixing generated code with programmer code.</p>
<p>There are more reasons to use it. For example, if you have big classes in large, unwieldy files, but the classes have groups of logically related methods, partial classes may be an option to ... | <p>Correction, as Matt pointed out, both sides of the partial need to be in the same assembly.
my bad.</p>
| 19,407 |
<p>I recently deploy one web application in one of my development servers. I'm using oracle, asp.net and c#. When I run the application in the server everything works fine, but when I try to run the application outside of the server (using my pc, for example) i get this error:</p>
<pre><code>ORA-12154: TNS:could not r... | <p>Have you tried this yet? (from <a href="http://ora-12154.ora-code.com/" rel="nofollow noreferrer">http://ora-12154.ora-code.com/</a>)</p>
<p>ORA-12154: TNS:could not resolve the connect identifier specified<br>
Cause: A connection to a database or other service was requested using a connect identifier, and the co... | <p>Is ORACLE_HOME set on server B?</p>
| 19,682 |
<p>I have a class that contains two methods like these:</p>
<pre><code>public String getFoo(Int32 a)
{
return getBar(a, "b", null);
}
public String getBar(Int32 a, String b, Int32 c)
{
//do something
return "";
}
</code></pre>
<p>However when I compile my class I get two errors:</p>
<ol>
<li>The best overload... | <p>In .NET, there is a distinct concept between reference types and value types.</p>
<p>A reference type is an object that is allocated on the heap (It will be a subclass of System.Object). All that is on the stack is a pointer to this object. Because of that, it is perfectly valid to store a null pointer.</p>
<p>A v... | <p>Int32 cannot be null. Make it a nullable type instead:</p>
<pre><code>public String getBar(Int32 a, String b, Int32? c)
{
if (c.HasValue)
{
...do something with c.Value...
}
return "";
}
</code></pre>
| 33,970 |
<p>Maybe this is an easy question, maybe not. I have a select box where I hardcode with width. Say 120px.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><select sty... | <p>If you have the option pre-existing in a fixed-with <code><select></code>, and you don't want to change the width programmatically, you could be out of luck unless you get a little creative.</p>
<ul>
<li>You could try and set the <code>title</code> attribute to each option. This is non-standard HTML (if you c... | <p>I improved the cychan's solution, to be like that:</p>
<pre><code><html>
<head>
<style>
.wrapper{
display: inline;
float: left;
width: 180px;
overflow: hidden;
}
.selectArrow{
display: inline;
float: left;
width: 17px;
... | 37,538 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.