instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I'm using a hosting service which allows me to backup my SQL 2008 database and download the BAK file via a web interface only--and I have access to the database via Management Studio. I can execute the backup command from Management Studio,but I don't have rights to the path where the backups are located. Is there a...
<p>If you have access via Management Studio, why don't you copy the hosted db on to your local machine (Tasks > Copy DB)? </p> <p>Once it's been restored to the local system, you can do whatever you want.</p>
<p>one way is to script the db structure and generate insert statements for the whole database with this SSMS addin <a href="http://www.ssmstoolspack.com/" rel="nofollow noreferrer">http://www.ssmstoolspack.com/</a></p>
45,366
<p>I use Safari Books Online as a reference library and to evaluate book before I decide to buy a paper copy, but it doesn't include any Apress books. Is there a better alternative you would recommend?</p> <p>Edit: Safari Books Online now includes Apress titles which makes it the most complete reference library on the...
<p>With my <a href="http://pd.acm.org/" rel="noreferrer">ACM membership</a>, I get access to both Safari and Books24x7 (this includes Apress).</p> <p>The selection is reduced from the total offering of those sites (600 in Safari only available to professional members and 500 in Books24x7 available to both student and ...
<p>Here in Santa Clara county, California, we can access the library e-resources, including Safari, from the library's website.</p>
21,638
<p>How can you you insert a newline from your batch file output?</p> <p>I want to do something like:</p> <pre class="lang-bat prettyprint-override"><code>echo hello\nworld </code></pre> <p>Which would output:</p> <pre class="lang-bat prettyprint-override"><code>hello world </code></pre>
<p><code>echo hello &amp; echo.world</code></p> <p>This means you could define <code>&amp; echo.</code> as a constant for a newline <code>\n</code>.</p>
<p>You can use <code>@echo</code> ( @echo + [space] + [insecable space] )</p> <p>Note: The insecable space can be obtained with Alt+0160</p> <p>Hope it helps :)</p> <p>[edit] Hmm you're right, I needed it in a Makefile, it works perfectly in there. I guess my answer is not adapted for batch files... My bad.</p>
16,094
<p>I am making a little GUI frontend for a app at the moment using wxPython.</p> <p>I am using <code>wx.StaticText()</code> to create a place to hold some text, code below:</p> <pre><code>content = wx.StaticText(panel, -1, "Text Here", style=wx.ALIGN_CENTRE) </code></pre> <p>I have a button when clicked retrieves da...
<p><code>wx.TextCtrl</code> has a style called <code>wx.TE_READONLY</code> . Use that to make it read-only.</p> <p>As a sidenode, you can use the <a href="http://docs.wxwidgets.org/stable/wx_contents.html" rel="noreferrer">C++ wxWidgets Manual</a> for wxPython aswell. Where special handling for wxPython or other ports...
<p><code>wx.TextCtrl</code> has a style called <code>wx.TE_READONLY</code> . Use that to make it read-only.</p> <p>As a sidenode, you can use the <a href="http://docs.wxwidgets.org/stable/wx_contents.html" rel="noreferrer">C++ wxWidgets Manual</a> for wxPython aswell. Where special handling for wxPython or other ports...
37,437
<p>I manage a high-school computer lab with ~40 machines, have old PCs with varying hardware. I need to roll out Windows XP + a standard set of apps and settings for new machines, and to re-format older machines. </p> <p>What tool is available to help with this? It doesn't have to be perfect, but if it minimizes the t...
<p>Remote Installation Services and/or Windows Deployment Services. One or the other comes "free" with Windows Server (RIS with Windows Server 2003 SP1 or earlier; WDS with Windows Server 2003 SP2 or later), and is pretty easy to set up and use. :-) Requires your computers to support PXE booting, however.</p>
<p><strong>Try <a href="http://www.net-runna.com/Products/net-runna_Enterprise/" rel="nofollow noreferrer">net-runna Enterprise</a>.</strong> </p> <p>It does so much more than just deploying operating systems. Typically in a lab environment you want to be able to return the desktops to a known good state. This prod...
9,351
<p>Is there a way to add some custom font on a website without using images, <a href="http://en.wikipedia.org/wiki/Adobe_Flash" rel="noreferrer">Flash</a> or some other graphics?</p> <p>For example, I was working on a wedding website, and I found a lot of nice fonts for that subject. But I can't find the right way to ...
<p>This could be done via CSS:</p> <pre><code>&lt;style type=&quot;text/css&quot;&gt; @font-face { font-family: &quot;My Custom Font&quot;; src: url(http://www.example.org/mycustomfont.ttf) format(&quot;truetype&quot;); } p.customfont { font-family: &quot;My Custom Font&quot;, Verdana, Tahoma; } &lt;/style...
<p>easy solution is to use @fontface in css</p> <pre><code>@font-face { font-family: myFirstFont; src: url(fileLocation);} div{ font-family: myfirstfont;} </code></pre>
13,331
<p>I'm building a .NET 3.5 application and have the need to evaluate JS code on the server - basically a user provided rule set that can work within a browser or on the server. Managed JS is not an option, because the JS code would be provided at runtime. Aptana's Jaxer is also not an option. So I was looking into usin...
<p><em>I realize that this may not be an exact answer to your question, but I figured I would put my 2 cents worth in as I doubt to many people have tried this.</em></p> <p>I got it to work by created a managed wrapper using mixed mode C++. There are other ways to do it, but I was going to attempt to make a full wrapp...
<p>From what I hear compiling it with IJW (Managed C++) should just work - but I may be really wrong, I have never touch MC++.</p>
46,548
<p>I'm not sure what this practice is actually called, so perhaps someone can edit the title to more accurately reflect my question.</p> <p>Let's say we have a site that stores objects of different types. Each type of object has its own database (a database of books and assorted information with its tables, a database...
<p>Is there a reason to have separate databases for each type of object? You would be better off using multiple tables, and joining them. For example, you may have a table <code>GENERIC_OBJECT</code> which holds things that are common across all types, and then a table called <code>BOOK_OBJECT</code> where <code>BOOK_O...
<p>If the decision about whether to use one database or two is yours, I recommend going with just one database. The data in the two tables appears closely related, judging from your question. The size and complexity doesn't seem to merit splitting into two databases.</p> <p>What's your DBMS? If it's Oracle, DB2, S...
38,291
<p>Why in this millennium should Python <a href="http://www.python.org/dev/peps/pep-0008/" rel="noreferrer">PEP-8</a> specify a <a href="https://www.python.org/dev/peps/pep-0008/#maximum-line-length" rel="noreferrer">maximum line length</a> of 79 characters?</p> <p>Pretty much every code editor under the sun can handle...
<p>Much of the value of PEP-8 is to stop people arguing about inconsequential formatting rules, and get on with writing good, consistently formatted code. Sure, no one really thinks that 79 is optimal, but there's no obvious gain in changing it to 99 or 119 or whatever your preferred line length is. I think the choices...
<p>because if you push it beyond the 80th column it means that either you are writing a very long and complex line of code that does too much (and so you should refactor), or that you indented too much (and so you should refactor).</p>
11,459
<p>What's the most efficient way to read a stream into another stream? In this case, I'm trying to read data in a Filestream into a generic stream. I know I could do the following:<br> 1. read line by line and write the data to the stream<br> 2. read chunks of bytes and write to the stream<br> 3. etc</p> <p>I'm just...
<p>Stephen Toub discusses a stream pipeline in his MSDN .NET matters column <a href="http://msdn.microsoft.com/en-us/magazine/cc163290.aspx" rel="noreferrer">here</a>. In the article he describes a CopyStream() method that copies from one input stream to another stream. This sounds quite similar to what you're trying ...
<p>I assume by generic stream, you mean any other kind of stream, like a Memory Stream, etc.</p> <p>If so, the most efficient way is to read chunks of bytes and write them to the recipient stream. The chunk size can be something like 512 bytes.</p>
15,705
<p>Getting this <strong>error</strong>:</p> <pre><code>NativeError = 258 Error = [Microsoft][SQL Native Client]Shared Memory Provider: Timeout error [258]. SQLState = HYT00, NativeError = 0 Error = [Microsoft][SQL Native Client]Login timeout expired SQLState = 08001, NativeError = 258 Error = [Microsoft][SQL Native C...
<p>Try setting the SqlCommand.CommandTimeout property to 0. For more info, there is a MSDN article <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx" rel="nofollow noreferrer"> here</a>.</p>
<p>Restart your SQL server or try increasing the pool size in your connection string.</p>
43,256
<p>We are using a custom FTP application (which encrypts the files) for secure transfers. We send the application to end users and they use it to send us confidential data. We also use it to send information back to the end users.</p> <p>The application is in need of an update - some things are no longer working con...
<p>I've had good results using <a href="http://www.freesshd.com/" rel="nofollow noreferrer">Free SSHd</a> on windows machines; it runs on the standard SSH port (22), supports SFTP, and is encrypted end to end. It also lets you set up authorization systems in parallel with your windows permissions, so you can exercise p...
<p>First, FTP is a plaintext protocol, so it's already not secure. Your updated description is helpful on this count :)</p> <p>Running SFTP is pretty easy - by deafult it's running when OpenSSH is installed and running. (Yes, they need a login, but that's simple enough to handle - especially with an LDAP tie-in.)</p> ...
32,839
<p>Has anyone found a good compression format for MS Sqlserver databases? If so, what do you use and are you pleased with how it performs? </p> <p>My company frequently will compress a database snapshot from one of our clients and download it so we have a local copy for testing and dev purposes. We tried zip in the pa...
<p>In sql 2008 you have native compression, if you have to do this a lot and don't have SQL server 2008 then take a look at something like <a href="http://www.quest.com/litespeed-for-sql-server/" rel="nofollow noreferrer">Quest LiteSpeed</a> which compreeses the backup automatically</p>
<p>In the no-cost category, newer versions of <a href="http://www.gzip.org/#faq10" rel="nofollow noreferrer">gzip</a> and <a href="http://www.bzip.org/" rel="nofollow noreferrer">bzip2</a> are supposed to include large file support (someone on the internet tells me that bzip2 1.0.1 and beyond is large file compatible t...
4,334
<p>I'm creating a Q&amp;A application in CakePHP, and I want to exclude my associations in some cases. Imagine the following:</p> <p>I'm listing all questions on the first page using $this->Question->findAll();. Since I have the following association in my model:</p> <pre><code>public $hasMany = array('Answer' =&gt; ...
<p>I quick look at the <a href="http://api.cakephp.org" rel="noreferrer">CakePHP API</a> reveals that you've got an <a href="http://api.cakephp.org/class_model.html#0b969d5264205cd3a425980dd53e9658" rel="noreferrer">unbindModel</a> method on the Model. So in you example you can do this:</p> <pre><code>$this-&gt;Questi...
<p>If you are using CakePHP 1.2 you should think about Containable Behaviour. See <a href="http://cakebaker.42dh.com/2008/05/18/new-core-behavior-containable/" rel="nofollow noreferrer">http://cakebaker.42dh.com/2008/05/18/new-core-behavior-containable/</a> for details</p>
49,496
<p>I'm comparing it Java where you can start your application server in debug mode, then attach your IDE to the server. And you can change your code "on the fly" without restarting the server. As long as your changes don't affect any method signatures or fields you can just hit recompile for a class and the application...
<p>From <a href="http://blog.mattsmith.co.nz/Lists/Posts/Post.aspx?ID=45" rel="noreferrer">Matt Smiths</a> blog on how to get F5 debugging with sharepoint. A very cool trick.</p> <ol> <li>Create a web application project in Visual Studio (File -> New -> Project -> ASP.Net Web Application, not File -> New -> Web Site)....
<blockquote> <p>And you can change your code "on the fly" without restarting the server</p> </blockquote> <p>You can accomplish this with ASP.net if you make a Web Site project (as opposed to a Web Application Project). Using a Web Site project, you can post changes to code-behinds without having to refresh anything...
5,187
<p>In the situation of having a project initiated by a marketing or sales team, how can we capture the not so obvious requirements that the project be marketable, or even better, self marketing? </p> <p>In many cases the marketing/sales team can hardly enumerate the functional specs of what the project should do, let ...
<p>Prototype early, prototype often, and make sure to get customers to look at your early versions. </p> <p>If you're working on an existing system, one part of the solution is to record and trend customer complaints and requests for support. Many times, these are really enhancement requests, or they can pinpoint to p...
<p>One thing that pops to mind is to send a technical, <strong>not-socially-inept</strong>, person with the sales crew at least <em>part</em> of the time to take notes.</p> <p>He can even be working on bug fixes while he's onsite, so it's not lost time.</p> <p>Also, make sure you're keeping in touch with the customer...
34,015
<p>After being through numerous forums available on the net for last 5 days, I am still not able to completely track down the browser close event. My requirement is to generate a popup message, when user tries to close the browser.</p> <p>I have called my javascript function on body 'onbeforeunload' event. And I have h...
<p>The question isn't an unusual one. Yet after 5 days searching the internet you still haven't found a satisfactory answer. That in itself should be a fairly plain indicator.</p> <p>What I've found on the web is there is a serious aversion to the 'no can do' answer. When something can't be done the normal response...
<blockquote> <blockquote> <p>"Thanks buddy, but I have already gone through that and didn't find much help there too. My seniors are not happy with that solution as putting a flag on evry link of my application is a complicated job and they fear of breaking the application. Any other suggestions wou...
21,863
<p>The reason I am asking this is that I had accidentally done a <code>git commit -a</code> that included a file I did not yet want to commit. My solution was to do the following:</p> <pre><code>git reset --soft HEAD^ git reset -- file/with/changes_not_to_committed git commit -C HEAD@{1} </code></pre> <p>Here, I’ve r...
<p>Right. When you want to move revisions from HEAD or another revision to the index, you use 'git reset REVISION -- file' - then, you'd use 'git commit --amend' to revise the commit. As it happens I'm currently working on a review aimed towards making it more obvious how files can be moved from A to B like that.</p>...
<p>It looks like you can do something like this using <a href="http://kernel.org/pub/software/scm/git-core/docs/git-update-index.html" rel="nofollow noreferrer"><code>git update-index</code></a>:</p> <pre><code>git update-index --cacheinfo 100644 5be7e154c284fb8de8ddca0bb18b72a73089df9b filename </code></pre> <p>You ...
32,074
<p>As you can see the left side of the edge came out jagged. The right side came out just fine. What happened to the left side?</p> <p>I am using Ender 3 + BLTouch using Sunlu PLA+ with 200 °C hotend.</p> <p><a href="https://i.imgur.com/Ki7ZzQ4.jpg" rel="nofollow noreferrer" title="Left side"><img src="https://i.imgur....
<p>This may be due to uneven cooling. The part cooling fan only comes from one direction on the Ender 3 series of printers. You may be able to solve the issue by printing the walls from the outside in. If not, I recommend printing a fan shroud that has part cooling ducts on both sides; there are plenty of them on thing...
<p>This may be due to uneven cooling. The part cooling fan only comes from one direction on the Ender 3 series of printers. You may be able to solve the issue by printing the walls from the outside in. If not, I recommend printing a fan shroud that has part cooling ducts on both sides; there are plenty of them on thing...
1,980
<p>I'm starting a new project which involves developing an interface for a machine that measures wedge and roundness of lenses and stores the information in a database and reports on it. There's a decent chance we're going to be putting a touch screen on this machine so that it doesn't need to have a mouse or keyboard....
<p>A few things to consider:</p> <ul> <li><p>You need to account for parallax error when touching controls. Basically, the user may touch the screen above or below your actual control and therefore miss the control. This is a combination of the size of the control (eg you can have the active area larger than visual co...
<p>If you've not already done so, have a look at some of the documentation available for developers on mobile platforms, eg <a href="http://msdn.microsoft.com/en-gb/windowsmobile/bb250568.aspx" rel="nofollow noreferrer">Windows Mobile</a>, <a href="http://developer.apple.com/iphone/" rel="nofollow noreferrer">iPhone</a...
17,454
<p>Is there any way to catch all syscalls on Linux? The only solution I know of is using LD_PRELOAD à la <a href="http://packages.qa.debian.org/f/fakeroot.html" rel="nofollow noreferrer">fakeroot</a>, but that only works for dynamically linked applications. Furthermore, this approach requires enumerating all syscalls w...
<p>I think you are looking for <a href="http://www.linuxjournal.com/article/6100" rel="nofollow noreferrer"><code>ptrace(2)</code></a>.</p>
<p>You can trace a program. Think about how <code>strace</code> works. Hint: it doesn't use <code>LD_PRELOAD</code> tricks.</p>
33,710
<p>I'm working on a piece of library code around <code>IDisposable</code>. The managed path (via <code>using</code>) is easily testable. I'm wondering about the finalizer though: Is calling <a href="http://msdn.microsoft.com/en-us/library/xe0c2357.aspx" rel="noreferrer"><code>System.GC.Collect()</code></a> sufficient t...
<p>No, the GC.Collect() call is asynchronous, you would also need to call this:</p> <pre><code>System.GC.WaitForPendingFinalizers(); </code></pre>
<p>Could you mock out an <code>IDisposable</code> interface and expect a call to <code>Dispose</code>? That would at least let you see when the object is actually disposed.</p>
30,576
<p>I have a simple page that has some iframe sections (to display RSS links). How can I apply the same CSS format from the main page to the page displayed in the iframe?</p>
<p><strong>Edit:</strong> This does not work cross domain unless the appropriate <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS" rel="noreferrer">CORS header</a> is set.</p> <p>There are two different things here: the style of the iframe block and the style of the page embedded in the i...
<p>Well, I have followed these steps:</p> <ol> <li>Div with a class to hold <code>iframe</code></li> <li>Add <code>iframe</code> to the <code>div</code>.</li> <li>In CSS file, </li> </ol> <pre class="lang-css prettyprint-override"><code>divClass { width: 500px; height: 500px; } divClass iframe { width: 100%; height: ...
26,764
<p>I have several forms in a .net windows app that have a common set of textboxes and other user input controls,each form has the same look and feel, but each form needs to load and save to different database tables. </p> <p>Would it be better to place the controls on a base form, and inherit from it or to create a u...
<p>I usually prefer UserControls as they are more flexible - you can use them in the context of a form, or in any other visual context to display or modify data. I've had several cases where I had to change my UI design from a separate dialog to edit something to an inline control inside the main form or something like...
<p>It depends. Composite model (using User Control) is cleaner, but the control cannot be aware of the calling form, so you have to pass the logic in as events. That sometimes can lead to duplicate logic.</p> <p>With inheritance, you can implement common code at the base class with some override at the subclass form a...
23,793
<p>Now I'm sure we're all well aware of the relative merits of Linux vs Windows Desktop. However I've heard much less about the world of embedded development. I'm mainly interested in solutions for industry and am therefore uninterested about the IPhone or Android and more interested in these two OSes.</p> <p>What are...
<p>I worked for several years at a company that provided both CE and Linux for all of their hardware, so I'm fairly familiar with both sides of this equation.</p> <ul> <li><strong>Tools:</strong> Windows CE tools certainly are better than those provided by Linux, though the linux tools are certainly getting better.</l...
<p>Android is a good option for some embedded systems.(it's linux based)</p> <ul> <li><p>You have many experts that are able to develop on this system.</p></li> <li><p>You have access to many libraries in java or C.</p></li> </ul> <p>but it uses lot of memory and energy.</p> <p>What we often forget with paid / licen...
42,312
<p>Is there any way in IIS to map requests to a particular URL with no extension to a given application.</p> <p>For example, in trying to port something from a Java servlet, you might have a URL like this...</p> <p><a href="http://[server]/MyApp/HomePage?some=parameter" rel="nofollow noreferrer">http://[server]/MyApp...
<p>With AIR on Linux, it is easy to write to stdout, since the process can see its own file descriptors as files in /dev.</p> <p>For stdout, open <code>/dev/fd/1</code> or <code>/dev/stdout</code> as a <code>FileStream</code>, then write to that.</p> <p>Example:</p> <pre><code>var stdout : FileStream = new FileStrea...
<p>If you are using a debug Flash Player, you can have the Flash Player log trace messages to a file on your system.</p> <p>If you want real time messages, then you could tail the file.</p> <p>More info:</p> <p><a href="http://blog.flexexamples.com/2007/08/26/debugging-flex-applications-with-mmcfg-and-flashlogtxt/" ...
5,959
<p>I have some code on my PHP powered site that creates a random hash (using <code>sha1()</code>) and I use it to match records in the database.</p> <p>What are the chances of a collision? Should I generate the hash, then check first if it's in the database (I'd rather avoid an extra query) or automatically insert it,...
<p>If you assume that SHA-1 does a good job, you can conclude that there's a 1 in 2^160 chance that two given messages have the same hash (since SHA-1 produces a 160-bit hash).</p> <p>2^160 is a ridiculously large number. It's roughly 10^48. Even if you have a million entries in your database, that's still a 1 in 10^4...
<p>The other comments have covered you on the probabilities, however if you look at this pragmatically then you can get a definite answer for yourself.</p> <p>You said yourself that you are going to be hashing your sequential IDs. It would be easy to code up a test case. Iterate through ~100,000,000 ids and check for ...
38,131
<p>I'm using a few (2 or 3) master pages in my ASP.NET MVC application and they must each display bits of information from the database. Such as a list of sponsors, current fundings status etc.</p> <p>So my question was, where should I put these master-page database calling code?</p> <p>Normally, these should goes in...
<p>One way to do this is to put in the masterpage view the hook for the ViewData and then you define a BaseController : Controller (or multiple base classes) where you do all the db calls you need.</p> <p>What you wanna do is quite the same thing described in <a href="http://weblogs.asp.net/stephenwalther/archive/2008...
<p>If you don't mind strongly typed view data, you can put all the master page data in a common base class for viewData. You can set this data in the base class's constructor. All your views requiring additional data will then need strongly typed viewdata that inherits from this base class.</p> <p>To allow a call to V...
8,541
<p>I have several listboxes that get each of their data from a separate stored procedure. </p> <p>If the user selects an option in 1 listbox, it should filter the other listboxes. </p> <p>I have done this before by adding logic to the stored procedure, but sometimes it seems to get very long. </p> <p>Does anyone ...
<p>You can try changing the code so that instead of having the Listbox bind directly to an ADO.Net datatable, it binds to a DataView. DataViews can be sorted and filtered independently from the underlying DataTable they are based on... </p> <p>Assume LBStates is state ListBox, and lbCities is City ListBox, and dtCiti...
<p>Listboxes are often used to display "lookup" data, which doesn't change often. Like a list of states or types of entities. So one thing to look into when trying to improve efficiency is caching. There's no reason for a round trip to the database every time you want to get a list of states.</p> <p>Additionally, i...
49,994
<p>Because Canvas3D doesn't have the ability to resize dynamically with the parent frame, I would like to be able to track when a user resizes a window and then resize it manually myself. (If this ends up crashing Canvas3D, as some docs suggest, I will simply destroy and recreate it when the user resizes their window)....
<p>To determine the size of a component you have to either:</p> <ul> <li>have set it manually at some point</li> <li>run the layout manager responsible for layouting the component</li> </ul> <p>Generally, you get the exact size of a component via the getSize() method, which returns a Dimension object containing width...
<p>I found out that if you extend by JFrame, this code can be used also to save time, effort and space.</p> <pre><code>int windowWidth = getWidth(); int windowHeight = getHeight(); </code></pre> <p>I know you already got an answer but if you ever need an alternative, here it is.</p>
25,920
<p>Is there any windows simulator availabe through which I can test (only testing) my iPhone application on Windows XP?</p> <p>Thanks &amp; regards,</p> <p>Khushi</p>
<p>No. The iPhone Simulator is available as part of the iPhone SDK, which is only available for Mac OS X Leopard on Intel-based Macs.</p>
<p>If you have a physical iOS device, you can test your app on Windows with <a href="http://experitest.com/automation/" rel="nofollow">SeeTest</a>.</p> <p>You connect your device to your Windows machine and then you can perform Web/Native tests, record it and play it again.</p>
40,094
<p>PHP's explode function returns an array of strings split on some provided substring. It will return empty strings when there are leading, trailing, or consecutive delimiters, like this:</p> <pre><code>var_dump(explode('/', '1/2//3/')); array(5) { [0]=&gt; string(1) &quot;1&quot; [1]=&gt; string(1) &quot;2&qu...
<p>Try <a href="http://php.net/preg_split" rel="nofollow noreferrer">preg_split</a>.</p> <p><code>$exploded = preg_split('@/@', '1/2//3/', -1, PREG_SPLIT_NO_EMPTY);</code></p>
<p>I usually wrap it in a call to <a href="http://uk.php.net/manual/en/function.array-filter.php" rel="nofollow noreferrer">array_filter</a>, e.g.</p> <pre><code>var_dump(array_filter(explode('/', '1/2//3/')) =&gt; array(3) { [0]=&gt; string(1) "1" [1]=&gt; string(1) "2" [3]=&gt; string(1) "3" } </code></p...
9,013
<p><a href="http://api.rubyonrails.com/classes/ActiveSupport/CoreExtensions/Time/Conversions.html" rel="noreferrer">Rails' ActiveSupport module extends the builtin ruby Time class with a number of methods.</a></p> <p>Notably, there is the <code>to_formatted_s</code> method, which lets you write <code>Time.now.to_forma...
<p>It looks like ActiveSupport does provide the parsing methods you are looking for (and I was looking for too), after all! &mdash; at least if the string you are trying to parse is a standard, ISO-8601-formatted (<code>:db</code> format) date.</p> <p>If the date you're trying to parse is already in your local time zo...
<pre><code>&gt;&gt; "2009-09-24".to_date =&gt; Thu, 24 Sep 2009 &gt;&gt; "9/24/2009".to_date =&gt; Thu, 24 Sep 2009 </code></pre> <p>Works great unless your date is in some weird format.</p>
46,203
<p>We have a customer requesting data in XML format. Normally this is not required as we usually just hand off an Access database or csv files and that is sufficient. However in this case I need to automate the exporting of proper XML from a dozen tables.</p> <p>If I can do it out of SQL Server 2005, that would be pre...
<p>Look into using FOR XML AUTO. Depending on your requirements, you might need to use EXPLICIT.</p> <p>As a quick example:</p> <pre><code>SELECT * FROM Customers INNER JOIN Orders ON Orders.CustID = Customers.CustID FOR XML AUTO </code></pre> <p>This will generate a nested XML document with the orders insid...
<p>There's an outline <a href="http://www.microsoft.com/technet/scriptcenter/resources/officetips/oct05/tips1020.mspx" rel="nofollow noreferrer">here</a> of a macro used to export data from an access db to an xml file, which may be of some use to you.</p> <pre><code>Const acExportTable = 0 Set objAccess = CreateObjec...
14,997
<p>I am trying to call a setTimeout from within a setInterval callback:</p> <pre><code>function callback() { //assign myVar var myVar = document.getElementById("givenID"); //... //now wait 2 secs then call some code that uses myVAr setTimeout("myVar.innerHTML = 'TEST'", 2000); } setInterval("callback()...
<p>This is a perfect candidate for closures:</p> <pre><code>setInterval( function () { var myVar = document.getElementById("givenID"); setTimeout( function() { // myVar is available because the inner closure // gets the outer closures scope ...
<p>Run it in Firefox and check Tools | Error Console. if setTimeout fails it may tell you why there.</p> <p>Also, try replacing <code>"someFunction();"</code> with <code>"alert('hi')"</code> (no semicolon) and see if that works. If so, the problem is narrowed down significantly.</p>
29,377
<pre><code>&quot;foo&quot; instanceof String //=&gt; false &quot;foo&quot; instanceof Object //=&gt; false true instanceof Boolean //=&gt; false true instanceof Object //=&gt; false false instanceof Boolean //=&gt; false false instanceof Object //=&gt; false 12.21 instanceof Number //=&gt; false /foo/ instanceof RegE...
<p>Primitives are a different kind of type than objects created from within Javascript. From the <a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/instanceof_Operator" rel="noreferrer">Mozilla API docs</a>:</p> <pre><code>var color1 = new String("green"); color1 instanc...
<p>Or you can just make your own function like so:</p> <pre><code>function isInstanceOf(obj, clazz){ return (obj instanceof eval("("+clazz+")")) || (typeof obj == clazz.toLowerCase()); }; </code></pre> <p>usage:</p> <pre><code>isInstanceOf('','String'); isInstanceOf(new String(), 'String'); </code></pre> <p>These...
24,925
<p>I have a 3D printer and I have printed some models with castable resin. When I burn one of these models in the oven and then do the metal casting, the surface of the metal piece is not smooth.</p> <p>I did a test with a pan. I put a model of wax and a model of castable resin to heat in a pan, and the wax model melt...
<p>Factually, the correct process is to heat up the mold hot enough to evaporate the positive. </p> <p>In <a href="https://en.wikipedia.org/wiki/Investment_casting" rel="nofollow noreferrer">investment casting</a> the process to remove the wax or plastic positive is called the <code>"Dewax"</code> and <code>"Burnout p...
<h2>Traditional lost molds.</h2> <p>The reason many jewelers use wax for making the molds for lost mold casting is, that it has (compared to plastic molding materials) a very low melting and boiling point, allowing to create molds with much lower temperature equipment.</p> <p>A variant of green sand casting is done wit...
1,264
<p>I'm in the process of converting a varchar(8000) field to an xml field in MSSQL 2005. Many of the XML docs have small issues (example: degree symbol not encoded). Is there a better way to validate the XML than a Try/Catch process?</p> <p>Maybe I could write a .NET Stored Procedure. What is the proper method to vali...
<p>You could write a Stored Procedure in managed code. Here are some samples <a href="http://www.yukonxml.com/articles/sqlclr/" rel="nofollow noreferrer">http://www.yukonxml.com/articles/sqlclr/</a></p>
<p>So far I think it is more simple (but brute) to use the Try/Catch method. The team I am working on hasn't really started using Managed Stored Procs yet.</p>
35,572
<p>I'm trying to test a simple WebForms (asp.net) based UI, and follow the MVP pattern to allow my UI to be more testable. </p> <p>As I follow the TDD methodology for backend algorithms, I find that there are some unit test refactorings that happen in the spirit of the DRY principle (Don't Repeat Yourself). As I try t...
<p>I would not refactor tests like standard code. Tests start to become more obscure as you refactor things into common base classes, helper methods, etc. Tests should be sufficiently clear on their own. </p> <p>DRY is not a test concern.</p> <p>That said, there are many plumbing things that are commonly done, and th...
<p>I use MVP, and on my tests I try to apply most of the refactoring I would in standard code. It normally doesn't work quite as well on the tests, due to the slight variations needed to test different scenarios, but within parts there can be commonality, and when possible I do consolidate. This does ease the needed ch...
8,463
<p>I have a windows forms (.net 3.0) project that won't run on my customer's vista computer due to a DEP error. It runs on my vista machine, and in a clean version of vista sp1 in a virtual machine. I am having trouble tracking down ways to make my program DEP, Data Execution Prevention compatible. I really can't do an...
<p>DEP runs in one of two modes:</p> <ol> <li><p>Hardware DEP is for CPUs that can mark memory pages as non-executable. This helps to prevent certain exploits such as buffer overflows.</p> </li> <li><p>Software DEP is for CPUs that do not have hardware DEP support. It doesn't prevent execution of code in data pages, bu...
<p>Start by trying to figure out where and how your program is failing. Can you replicate the issue on your system? With enabling DEP for the application on your system? When you can replicate the issue and get the error (access violation), you can look to fixing your program.</p> <p>See the <a href="http://msdn.mi...
45,690
<p>I would like to create events for certain resources that are used across various processes and access these events by name. The problem seems to be that the names of the events must be known to all applications referring to them.</p> <p>Is there maybe a way to get a list of names events in the system?</p> <p>I am ...
<p>No, there is not any facility to enumerate named events. You could enumerate all objects in the respective object manager directory using ZwOpenDirectoryObject and then filter for events. But this routine is undocumented and therefore should not be used without good reason.</p> <p>Why not use a separate mechanism t...
<p><a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" rel="nofollow noreferrer">ProcessExplorer</a> is able to enumerate all the named events held by some specific process. You could go over the entire process list and do something similar although I have now clue as to what API is used to get the ...
5,631
<p>We are discussing development of an improved management infrastructure for our distributed system. We use COM, web services and .NET components. Since we're based on Microsoft Windows Server XP/2003, I guess, we basically have two options:</p> <ol> <li>Powershell cmdlets <li>WMI classes using System.Management and ...
<p>I would choose PowerShell over WMI for the following reasons:</p> <ol> <li>Writing a cmdlet is only adding a .NET Class.</li> <li>The PowerShell runtime provides command line parsing built in.</li> <li>Writing your management interface in PowerShell allows administrators the ability to integrate management of your ...
<p>Not sure that this can be answered with the information that you have provided so far. My gut feeling would be that you should use powershell since it sounds like you may already have some .Net code. But it really does just depend on exactly what you are trying to do.</p>
32,346
<p>I'm looking for a complete solution to a automated "building" and testing of PHP application. I came across PhpUnderControl, a solution for running automated application builds created around Cruise Control.</p> <p>Unfortunately PhpUC is still in it's early stages of development and I can't get it to work on window...
<blockquote> <p>I'm wondering if Cruise Control is able to merge logs created by PHPUnit (in XML format) into project log or is it working for Java's JUnit files only.</p> </blockquote> <p>CC will merge any xml file you point it at. When you say merging the files isn't working are you getting an error mergi...
<p>I have found that CruiseControl only merge the logs containing test results when a test fails. </p> <p>When I broke a test on purpose, the results got merged into the log, and where shown on the CruiseControl dashboard.</p> <p>Could that be your problem?</p>
42,819
<p><a href="https://i.stack.imgur.com/rtG5C.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rtG5C.jpg" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/i1oaO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i1oaO.jpg" alt="enter image description here"></a>...
<p>In Ultimaker Cura you can select only one of the the build plate adhesion options skirt, brim or raft. You cannot select multiple options. </p> <p>There is no option available in Ultimaker Cura to increase the outline count of the raft bed adhesion structure. Basically the raft exists of a line support structure as...
<p>It's not necessarily the case that the apparent underextrusion of a small portion of your raft is the root cause. ABS is notorious for shrinkage and peeling. As a start, you should have a full enclosure so as to maintain a warm environment while printing. </p> <p>It's also quite possible that your bed is slight...
1,084
<p>Im running a ASP.NET Site where I have problems to find some JavaScript Errors just with manual testing.</p> <p>Is there a possibility to catch all JavaScript Errors on the Clientside and log them on the Server i.e. in the EventLog (via Webservice or something like that)?</p>
<p>You could try setting up your own handler for the <a href="http://developer.mozilla.org/En/DOM:window.onerror" rel="noreferrer">onerror event</a> and use XMLHttpRequest to tell the server what went wrong, however since it's not part of any specification, <a href="http://www.quirksmode.org/dom/events/error.html" rel=...
<p>You could potentially make an Ajax call to the server from a try/catch, but that's probably about the best you can do.</p> <p>May I suggest JavaScript unit testing instead? Possibly with <a href="https://github.com/pivotal/jsunit" rel="nofollow noreferrer">JSUnit</a>?</p>
14,526
<p>Is there a good way to exclude certain pages from using a HTTP module?</p> <p>I have an application that uses a custom HTTP module to validate a session. The HTTPModule is set up like this in web config:</p> <pre><code>&lt;system.web&gt; &lt;!-- ... --&gt; &lt;httpModules&gt; &lt;add name="SessionValidatio...
<p>You could use an HTTPHandler instead of an HTTPModule. Handlers let you specify a path when you declare them in Web.Config. </p> <pre><code>&lt;add verb="*" path="/validate/*.aspx" type="Handler,Assembly"/&gt; </code></pre> <p>If you must use an HTTPModule, you could just check the path of the request and if it'...
<p>Here is some simple example how to filter requests by extension... the example below exclude from the processing files with the specific extensions. Filtering by file name will look almost the same with some small changes...</p> <pre><code>public class AuthenticationModule : IHttpModule { private static readonl...
9,639
<p>I'm looking for a method that computes the line number of a given text position in a JTextPane with wrapping enabled.</p> <p>Example:</p> <blockquote> <p>This a very very very very very very very very very very very very very very very very very very very very very very long line.<br> This is another very very...
<p>Try this</p> <pre><code> /** * Return an int containing the wrapped line index at the given position * @param component JTextPane * @param int pos * @return int */ public int getLineNumber(JTextPane component, int pos) { int posLine; int y = 0; try { Rectangle caretCoords ...
<p>you could try this:</p> <pre><code>public int getLineNumberAt(JTextPane pane, int pos) { return pane.getDocument().getDefaultRootElement().getElementIndex(pos); } </code></pre> <p>Keep in mind that line numbers always start at 0.</p>
12,771
<p>I have a web service API. Some calls return objects containing text fields with information provided by the user. From both a design and a security standpoint, what are the downsides to returning null in those fields when no information has been provided? Is there a clear advantage to always returning an empty strin...
<p>It all depends on whether you treat a null string value as semantically different from an empty string.</p> <p>If null and empty string both mean that there's no data for that field then I see no reason not to make life simpler for the client by not having to check and return empty string.</p>
<p>I don't think there's a security issue involved with returning null vs. returning an empty string.</p> <p>There's not any real downside to returning null for those fields for which there is no information - that's kind of what nulls are meant to indicate.</p> <p>You can simplify your client code by using</p> <pre...
18,253
<p>We have developed a number of custom dll's which are called by third-party Windows applications. These dlls are loaded / unloaded as required.</p> <p>Most of the dlls call web services and these need to have urls, timeouts, etc configured.</p> <p>Because the dll is not permanently in memory, it has to read the con...
<p>Use the registry to store your configuration information, it's definitely fast enough.</p>
<p>Why don't you let the calling application fill out a data-structure with the stuff you need? Can be done as part of an init-call or so.</p>
16,566
<p><strong>Has anyone had success automating testing directly on embedded hardware?</strong></p> <p>Specifically, I am thinking of automating a battery of unit tests for hardware layer modules. We need to have greater confidence in our hardware layer code. A lot of our projects use interrupt driven timers, ADCs, seria...
<p>Sure. In the automotive industry we use $100,000 custom built testers for each new product to verify the hardware and software are operating correctly.</p> <p>The developers, however, also build a cheaper (sub $1,000) tester that includes a bunch of USB I/O, A/D, PWM in/out, etc and either use scripting on the wor...
<p>Unit testing embedded projects is quite diffucult, as it usually requires a external stimulus and external measurment.</p> <p>We have been successful in developing a external serial protocol (either rs232 or udp or tcpip messages) with basic commands for exercising the hw with debug logging in the low level drivers...
14,040
<p>I would like to ask for some simple examples showing the uses of <code>&lt;div&gt;</code> and <code>&lt;span&gt;</code>. I've seen them both used to mark a section of a page with an <code>id</code> or <code>class</code>, but I'm interested in knowing if there are times when one is preferred over the other.</p>
<ul> <li><code>div</code> is a <a href="https://en.wikipedia.org/wiki/HTML_element#Block_elements" rel="noreferrer">block element</a></li> <li><code>span</code> is an <a href="https://en.wikipedia.org/wiki/HTML_element#Inline_elements" rel="noreferrer">inline element</a>.</li> </ul> <p>This means that to use them sema...
<p>In HTML there are tags that add structure or semantics to content. For example the <code>&lt;p&gt;</code> tag is used to identify a paragraph. Another example is the <code>&lt;ol&gt;</code> tag for an ordered list.</p> <p>When there is no suitable tag available in HTML as shown above, the <code>&lt;div&gt;</code> a...
22,194
<p>I'm writing a utility in Python that will attach changed files in Subversion to an email and send it when a subset of folders that are under source control in SVN have been changed. I am using the pysvn library to access the repository.</p> <p>I have a copy of the files on my local file system and I do an update t...
<p>Stay with the slice operator, but do not change the loop variable inside the loop. for fun, try the generator expression (or keep the listcomp).</p> <pre><code>baselen = len(self.basePath) return (path[baselen:].replace("/", "\\") for path in paths) </code></pre> <p>Edit: `lstrip()' is not relevant here. From the ...
<p>Hm... That would do it:</p> <pre><code>baselen = len(self.basePath) for path in paths: path = path[baselen:].replace("/", "\\") newPaths.append(path) return newPaths </code></pre> <p>If you like, you can do it like this:</p> <pre><code>baselen = len(self.basePath) return (path[baselen:].replace("/", "\\")...
30,995
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/9/how-do-i-calculate-someones-age-in-c">How do I calculate someone&#39;s age in C#?</a> </p> </blockquote> <p>Maybe this could be silly but and I don't have issues with my age but sometimes it is good to calcul...
<blockquote> <p>Maybe this could be silly but and I don't have issues with my age but sometimes it is good to calculate the exact age of someone, I have introduced my birthdate in my profile (01/12/1975) "dd/mm/yyyy" and it calculated 33 and I'm 32 actually still, doesn't it better to calculate the exact age? </p> <...
<p>Actually, because of leap years, your code would be off. Since the timespan object has no TotalYears property the best way to get it would be this</p> <p>Pardon the VB.Net</p> <pre><code>Dim myAge AS Integer = DateTime.Now.year - BirthDate.year If Birthdate.month &lt; DateTime.Now.Month _ OrElse BirthDate.Month =...
3,911
<p>In VB.NET I often <code>Catch…When</code>:</p> <pre><code>Try … Catch e As ArgumentNullException When e.ParamName.ToUpper() = "SAMPLES" … End Try </code></pre> <p>Is there a C# equivalent to <code>Catch…When</code>?</p> <p>I don't want to resort to using an <code>if</code> statement inside a <code>catch</...
<p>This functionality was announced for C# 6. It is now possible to write</p> <pre><code>try { … } catch (MyException e) when (myfilter(e)) { … } </code></pre> <p>You can download the preview of <a href="http://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs.aspx" rel="noreferrer">Visual Stud...
<p>There's no equivalent to <code>Catch…When</code> in C#. You will really have to resort to an <code>if</code> statement inside your <code>catch</code>, then rethrow if your condition isn't fulfilled:</p> <pre><code>try { … } catch (ArgumentNullException e) { if ("SAMPLES" == e.ParamName.ToUpper()) { ...
21,862
<p>I have been enjoying learning the basics of python, but before I started reading things I tried to install various python versions and modules clumsily. Now that I have some ideas of what I want to do and how to do it I'm finding that various aspects are broken. For instance, 2.6 IDLE won't launch, and when I try to...
<p>I had this problem so much when I first got my Mac. The best solution I found was to delete everything I'd installed and just go with the <a href="http://pythonmac.org" rel="nofollow noreferrer">pythonmac.org</a> version of Python (2.6). I then installed setuptools from the same site, and then used easy_install to i...
<p>Macports should be easy to get rid of; just delete /opt/local/. I think that Fink does something similar.</p> <p>You can do <code>which python</code> to see what python is the default one. The system python should be in /System/Library/Frameworks/Python.framework/Versions/2.5/bin/python</p> <p>The MacPython you ma...
29,964
<p>Is there anyway to have a sort of virtual static member in C++?</p> <p>For example:</p> <pre><code>class BaseClass { public: BaseClass(const string&amp; name) : _name(name) {} string GetName() const { return _name; } virtual void UseClass() = 0; private: const string _name; ...
<p>Here is one solution: </p> <pre><code>struct BaseData { const string my_word; const int my_number; }; class Base { public: Base(const BaseData* apBaseData) { mpBaseData = apBaseData; } const string getMyWord() { return mpBaseData-&gt;my_word; } int getMyNumber() ...
<p>It sounds as if you're trying to avoid having to duplicate the code at the leaf classes, so why not just derive an intermediate base class from the base class. this intermediate class can hold the static data, and have all your leaf classes derive from the intermediate base class. This presupposes that one static pi...
5,476
<p>Howdy. Consider the following:</p> <pre><code>SQL&gt; DECLARE 2 b1 BOOLEAN; 3 b2 BOOLEAN; 4 FUNCTION checkit RETURN BOOLEAN IS 5 BEGIN 6 dbms_output.put_line('inside checkit'); 7 RETURN TRUE; 8 END checkit; 9 10 PROCEDURE outp(n VARCHAR2, p BOOLEAN) IS 1...
<p>Yes. PL/SQL performs <a href="http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/fundamentals.htm#sthref481" rel="noreferrer">short circuit evaluation</a> of logical expressions from left to right.</p>
<p>This is called "short-circuit evaluation", and it is the norm in most languages, <a href="http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/fundamentals.htm#CIHGJBFD" rel="nofollow noreferrer">including PL/SQL</a>.</p>
22,795
<p>I have a GridView control on my page that I have defined a number of BoundFields for. Each row of the databound GridView has a CommandField (Select), for which I want to send the PostBack to a new page.</p> <p>Of course I could easily send the NewSelectedIndex in a QueryString, but I'd rather keep that information...
<p>Leppie is right. The GridView has no PostbackUrl property. However, you can do what you want by using a standard control, which has a PostbackUrl property.</p> <pre><code>&lt;asp:TemplateField AccessibleHeaderText="Edit"&gt; &lt;ItemTemplate&gt; &lt;asp:Button runat="server" ID="btnEdit" PostBackUrl="~...
<p>Use a HyperLinkField column in your GridView:</p> <pre><code>&lt;asp:HyperLinkField AccessibleHeaderText="Edit" DataNavigateUrlFields="ActivityId" DataNavigateUrlFormatString="AcitivtyEdit.aspx?id={0}" Text="Edit Activity" /&gt; </code></pre> <p>Of course, as you said, this option shows the id in the url. To hide ...
43,226
<p>When one thinks of Ada, one usually thinks of avionics.</p> <p>What I'm interested in are some other applications of Ada? Where is it used? Are there any shipped applications written in Ada?</p> <p>For example, are there CRUD apps written in it? Or games? Etc.</p>
<p>Michael Feldman actively maintains a "<a href="http://www.seas.gwu.edu/~mfeldman/ada-project-summary.html" rel="noreferrer">Who's Using Ada/Real-World Projects</a>" list that lists all types of military and commercial projects. And because he maintains contributor confidentiality, projects will show up there that wo...
<p>Ada is still popular in colossal, legacy, government-targeted programs. It's also a basis for <a href="https://stackoverflow.com/questions/tagged/vhdl">VHDL</a>.</p>
47,804
<p>What's the best way to "see what is happening" in an algorithm/data structure? If it's something like a binary search I just imagine a bunch of boxes in a row, and throwing half of them out each time. Is there something more powerful that will let us grok something as abstract as an algorithm/data structure?</p> <p...
<p>In general, <b>animations</b> are excellent for visualizing processes that occur over time, such as the execution of algorithms.</p> <p>For example, check out these animations: <a href="http://www.inf.ethz.ch/personal/staerk/algorithms/SortAnimation.html" rel="nofollow noreferrer">Animated Sort Algorthms</a></p> <...
<p>Describing something in terms of another thing is called analogy. You just did it with the binary search being a bunch of boxes. Just play with the student's prior knowledge.</p> <p>For instance, trees can be thought of linked-lists, with multiple "next" nodes, or they could be explained to the uninitiated as somet...
44,998
<p>I know how to change the schema of a table in SQL server 2005:</p> <pre><code>ALTER SCHEMA NewSchama TRANSFER dbo.Table1 </code></pre> <p>But how can i check and/or alter stored procedures that use the old schema name?</p> <p>Sorry: I mean: There are stored procedures that have the old schema name of the table in...
<p>Get a list of dependent objects by right-clicking on the table before you change the schema and then look at what is dependent on the table, make a list and then change those. There is, however, always a possibility that you'll miss something because it is possible to break the dependencies SQL server tracks.</p> <...
<p>DECLARE @SearchObject VARCHAR(100)</p> <p>SET @SearchObject = 'searchable_table_name' -- change 'searchable_table_name' to the table name what you want to search</p> <p>SELECT sc.name [Search Object], so.name [Container Object],<br> CASE so.xtype WHEN 'U' THEN 'Table' WHEN 'P' THEN 'Stored Procedure' WHEN 'F' THE...
12,695
<p>I have pushed my .htaccess files to the production severs, but they don't work. Would a restart be the next step, or should I check something else.</p>
<p>A restart is <strong>not</strong> required for changes to .htaccess. Something else is wrong.</p> <p>Make sure your .htaccess includes the statement</p> <blockquote> <p>RewriteEngine on</p> </blockquote> <p>which is required even if it's also present in httpd.conf. Also check that .htaccess is readable by the htt...
<p>What's in your .htaccess? RewriteRules? Check that mod_rewrite is installed and enabled.</p> <p>Other stuff? Try setting AllowOverride to 'all' on that directory.</p>
17,230
<p>I'm starting a Wordpress Blog that will have adult content on it, so I'll need a first-time-only splash page in Wordpress. The first-time-only issue, I can fix with a cookie (although I am aware that not everyone has cookies enabled) </p> <p>What I could do is, create a script that loads another page if a cookie is...
<p>I would just create the CSS for it, get it all ready to go, then stick it into the header with your condition. This way, you know that everypage will display it, and you can;t be "caught with your pants down" if you get linked to.</p> <p>My only concern would be to make sure that the lightbox effect covers anything...
<p>Use Colorbox and call it onload</p> <p><a href="http://jacklmoore.com/colorbox/example1/" rel="nofollow">http://jacklmoore.com/colorbox/example1/</a></p> <p>I'm using this to create a popup on load. It sets a cookie to expire every 30 days. Create a div called <code>#inline_content</code> with all your content in ...
28,880
<p>I'm working on a menu-generating HtmlHelper extension method. This method will need to know which Action is being executed. So if Home/Index is executing, the extension method would show all links to other actions that're "coordinated." In a sense, all I need to know during the execution of the Home controller's Ind...
<p>Try this</p> <pre><code>var action = HtmlHelper.ViewContext.RouteData.Values["action"]; var controller = HtmlHelper.ViewContext.RouteData.Values["controller"]; </code></pre>
<p>I do something similar with a filter attribute. You can get the action name like this:</p> <pre><code>filterContext.RouteData.Values["action"].ToString(); </code></pre> <p>I use this to disable the menu item that represents the current context.</p>
43,007
<p>Lets say I have a loop in Bash:</p> <pre><code>for foo in `some-command` do do-something $foo done </code></pre> <p><code>do-something</code> is cpu bound and I have a nice shiny 4 core processor. I'd like to be able to run up to 4 <code>do-something</code>'s at once.</p> <p>The naive approach seems to be:</p>...
<p>Depending on what you want to do xargs also can help (here: converting documents with pdf2ps):</p> <pre><code>cpus=$( ls -d /sys/devices/system/cpu/cpu[[:digit:]]* | wc -w ) find . -name \*.pdf | xargs --max-args=1 --max-procs=$cpus pdf2ps </code></pre> <p>From the docs:</p> <pre><code>--max-procs=max-procs -P ...
<p>$DOMAINS = "list of some domain in commands" for foo in <code>some-command</code> do</p> <pre><code>eval `some-command for $DOMAINS` &amp; job[$i]=$! i=$(( i + 1)) </code></pre> <p>done</p> <p>Ndomains=<code>echo $DOMAINS |wc -w</code></p> <p>for i in $(seq 1 1 $Ndomains) do echo "wait for ${job[$i]}...
5,906
<p>I'm loading an html snippet using </p> <pre><code>$("#TemplateDump").load("Themes/default.template", function() { processTemplate() }) </code></pre> <p>The html i am loading contains</p> <pre><code>&lt;div&gt; `hello ##name##, your age is ##age##. your page is &lt;a href="##website##"&gt;here&lt;/a&gt; &lt;/div&...
<p>See <a href="http://www.hibernate.org/hib_docs/v3/reference/en-US/html/tutorial-associations.html#tutorial-associations-bidirectional" rel="nofollow noreferrer">Working bi-directional links</a> in the Hibernate documentation.</p> <blockquote> <p>Many developers program defensively and create link management met...
<p>you could make it static</p> <pre><code>public class Foo { List&lt;Bar&gt; Bars = new List&lt;Bar&gt;(); public void AddBar(Bar bar) { Bars.Add(bar); Bar.AddFoo(bar,this); } } public class Bar { List&lt;Foo&gt; Foos = new List&lt;Foo&gt;(); // This shouldn't exist. pub...
40,160
<p>I have developed a couple of extensions for Firefox, and am annoyed that it is so hard to get the extension signed. When an extension isn't signed, it says "Author not verified" when it is installed, and to me that just looks wrong.</p> <p>I have a simple build script that builds my .xpi file from sources, and I h...
<p>I've used the comodo certificate to sign XPIs. It was the cheapest option at the time. </p> <p><strike>I've written a few posts on the <a href="http://o-regan.org/2007/04/11/firefox-xpi-internal-structure/" rel="nofollow noreferrer">XPI Forma</a>t and a howto for <a href="http://o-regan.org/2007/04/23/extension-sig...
<p>Yes, XPI signing is unfortunately quite untrivial. I would advise searching/posting to the mozilla newsgroups (dev-extensions, project owners @ mozdev, irc.mozilla.org) and also trying to get in touch with the people who got it to work.</p>
15,780
<p>I'm trying to write a regex function that will identify and replace a single instance of a match within a string without affecting the other instances. For example, I have this string:</p> <pre><code>12||34||56 </code></pre> <p>I want to replace the second set of pipes with ampersands to get this string:</p> <pr...
<p>here's something that works:</p> <pre><code>"23||45||45||56||67".replace(/^((?:[0-9]+\|\|){n})([0-9]+)\|\|/,"$1$2&amp;&amp;") </code></pre> <p>where n is the one less than the nth pipe, (of course you don't need that first subexpression if n = 0)</p> <p>And if you'd like a function to do this:</p> <pre><code>fun...
<p>Thanks Binda, I have modified the code for generic uses:</p> <pre><code>private replaceNthMatch(original, pattern, n, replace) { let m = -1; return original.replaceAll(pattern, x =&gt; { m++; if ( n == m ) { return replace; } else { return x; } }); ...
5,687
<p>Have you ever worked on a (full-time) project where using Agile methodologies actually allowed you to accomplish a 40-hour work-week? If so, what were the most valuable agile practices?</p>
<p>Yes, I'm on a 40 hour (actually it's 37.5 hours or so, that's what my contract says) on a project that was run with SCRUM from the beginning. That was about 2 years ago and the first time we implemented SCRUM. It's the project with the least amount of overtime for me personally, and it's also a PC game we're develop...
<p>Certainly. </p> <p>For the me the most important things that helped (in order of importance):</p> <ol> <li>Cross-functional team - having programmers, testers, technical writers and sales/services people in the same team and talking to each other daily (daily call) was great.</li> <li>Regular builds and continuous...
32,898
<p>I fill a collection one single time when my J2EE webapp starts. Then, several thread may access it at same time but only to read it.</p> <p>I know using a synchronized collection is mandatory for parallels write but do I still need it for parallels read ?</p>
<p>Normally no because you are not changing the internal state of the collection in this case. When you iterate over the collection a new instance of the iterator is created and the state of the iteration is per iterator instance.</p> <hr> <p><strong>Aside note:</strong> Remember that by keeping a read-only collectio...
<p>The collection itself does not, but keep in mind that if what it holds is not immutable also, those seperate classes need their own synchronization.</p>
18,382
<p>I have a site, which contains several ashx handlers, on a couple of the handlers I want to reject non-SSL requests. Is there a way that I can do this in code?</p>
<p>If you must do it programmatically, a way I've done it in the past is to inspect the url and look for "https" in it. Redirect if you don't see that. Request.IsSecureConnection should be the preferred method, however. You may have to add additional logic to handle a loopback address.</p>
<p>I think the proper way is to check the Request.IsSecureConnection property and redirect or throw if it's false</p>
8,345
<p>What would be the best hashing algorithm if we had the following priorities (in that order):</p> <ol> <li>Minimal hash collisions</li> <li>Performance</li> </ol> <p>It doesn't have to be secure. Basically I'm trying to create an index based on a combination of properties of some objects. <strong>All the properties...
<p>Forget about the term "best". No matter which hash algorithm anyone might come up with, unless you have a very limited set of data that needs to be hashed, every algorithm that performs very well on average can become completely useless if only being fed with the right (or from your perspective "wrong") data.</p> <...
<p>Here is the <a href="http://en.wikipedia.org/wiki/Cuckoo_hashing" rel="nofollow noreferrer">Cuckoo Hash</a>.</p> <blockquote> <p>Lookup requires inspection of just two locations in the hash table, which takes constant time in the worst case (see Big O notation). This is in contrast to many other hash table algorithm...
31,297
<p>I'm trying to determine how to modify SAP R/3 package code of an installed system. Can anyone suggest the module/tool for that?</p>
<p>SAP has provided various customer plug-ins in order to enable customers to modify and adapt standard code:</p> <ul> <li><p>User exits (Transactions SMOD, CMOD and SE81). <a href="https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/208811b0-00b2-2910-c5ac-dd2c7c50c8e8" rel="noreferrer">This article</...
<p>I've always done it through the SE80 transaction, where I can browse the existing non-Z code, copied it to a Z package, and modifiy it there.</p>
16,543
<p>I am working on a project that requires the manipulation of enormous matrices, specifically pyramidal summation for a copula calculation. </p> <p>In short, I need to keep track of a relatively small number of values (usually a value of 1, and in rare cases more than 1) in a sea of zeros in the matrix (multidimensi...
<p>For C++, a map works well. Several million objects won't be a problem. 10 million items took about 4.4 seconds and about 57 meg on my computer.</p> <p>My test application is as follows:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;map&gt; class triple { public: int x; i...
<p>Since only values with [a][b][c]...[w][x][y][z] are of consequence, we only store the indice themselves, not the value 1 which is just about everywhere - always the same + no way to hash it. Noting that the curse of dimensionality is present, suggest go with some established tool NIST or Boost, at least read the sou...
2,632
<p>In Silverlight, I have a Vertical ListBox that has a Horizontal ListBox for each item. I want the items in the HorizontalListbox to space evenly across the width of the parent (Vertical) ListBox. How can I do this?</p> <pre><code> &lt;ListBox x:Name="MachineListBox" Background="Green"&gt; &lt;ListBox.It...
<p>Instead of forking there are two other approaches to handle concurrent connections. Either you use threads or a polling approach.</p> <p>In the thread approach for each connection a new thread is created that handles the I/O of a socket. A thread runs in the same virtual memory of the creating process and can acces...
<p>Instead of forking there are two other approaches to handle concurrent connections. Either you use threads or a polling approach.</p> <p>In the thread approach for each connection a new thread is created that handles the I/O of a socket. A thread runs in the same virtual memory of the creating process and can acces...
46,832
<p>Is there a PDF library that one can use to automate creating PDFs from URLs? The current approach I use is to "Print" a page and select a PDF plugin like PrimoPDF to generate the PDF document but I was wanting to automate that. </p>
<p><a href="http://www.websupergoo.com" rel="nofollow noreferrer">ABCPDF </a>can do it </p>
<p>Depends on what platform you are on</p> <p>Windows - Websupergoo's ABC PDF</p> <p><a href="http://www.websupergoo.com/" rel="nofollow noreferrer">http://www.websupergoo.com/</a></p> <p>*nix - Prince XML <a href="http://www.princexml.com/overview/" rel="nofollow noreferrer">http://www.princexml.com/overview/</a></...
5,332
<p>In the following code, both <code>amp_swap()</code> and <code>star_swap()</code> seems to be doing the same thing. So why will someone prefer to use one over the other? Which one is the preferred notation and why? Or is it just a matter of taste?</p> <pre><code>#include &lt;iostream&gt; using namespace std; void ...
<p>One is using a reference, one is using a pointer.</p> <p>I would use the one with references, because you can't pass a NULL reference (whereas you can pass a NULL pointer).</p> <p>So if you do:</p> <pre><code>star_swap(NULL, NULL); </code></pre> <p>Your application will crash. Whereas if you try:</p> <pre><code...
<p>They are the exact same thing to the computer. However, one is a reference (&amp;) and the other is a pointer (*)</p> <p><a href="http://www.google.com/search?hl=en&amp;q=pointers+vs+references&amp;btnG=Google+Search&amp;aq=1&amp;oq=pointers+vs" rel="nofollow noreferrer">http://www.google.com/search?hl=en&amp;q=poi...
23,125
<p>I'm using Drupal 5 and have a multitude of views that I want to alter the output of. Using the views wizard, I can create a different template for each instance, but I'm wanting to do the same changes across all my views and having 30 files in the themes directory seams like a hell of a lot of maintenance and code....
<p>I <em>think</em> just creating a file named "views-list.tpl.php" will apply to all List-style views (unless a more specific .tpl.php file is present).</p> <p>Otherwise, there may be a way to get what you want using theme functions.</p>
<p>I believe that each template will have to be updated independently, if you're talking about something that goes on inside the view's template. I don't know of a way to update just one small part of n views.</p> <p>If you have a header that you're putting above the template for each view you might be able to do tha...
38,826
<p>Does anyone know if there is a c# Console app, similar to the Python or Ruby console? I know the whole "Compiled versus Interpreted" difference, but with C#'s reflection power I think it could be done.</p> <p><strong>UPDATE</strong> Well, it only took about 200 lines, but I wrote a simple one...It works a lot like ...
<p>Given your mention of "C#'s reflection power", I am unsure whether you're looking for an interactive C# console for small code snippets of your own (à la Ruby's <code>irb</code>), or a means of interacting with an existing, compiled application currently running as a process.</p> <p>In the former case:</p> <ul> <l...
<p>Google reveals a few efforts at this. One in particular illustrates why this is less straightforward than it might seem. <a href="http://www.codeproject.com/KB/cs/csi.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/cs/csi.aspx</a> has a basic interpreter using .NET's built in ability to compile c# co...
6,982
<p>I am trying to figure out the best way to use Ant to precompile JSPs that will be deployed to an Oracle application server. Even though I am deploying to an Oracle app server I would like to avoid using Oracle's version of Ant.</p>
<p>Oracle's JSP compiler is available in your oc4j install at ORACLE_HOME/j2ee/home/jsp/bin/ojspc</p> <p>Assuming your classpath is correct at the compand line you would run:</p> <p>ojspc your.war</p> <p>The war will get updated and place a jar in the WEB-INF/lib containing the pre-compiled JSPs. Note that if your ...
<p>I'm not sure what you mean by Oracle's version of Ant but as I understand it you will need the oracle's ant task to do this job. <a href="http://download-west.oracle.com/docs/cd/B32110_01/web.1013/b28961/ojspc.htm" rel="nofollow noreferrer">This</a> page explains how to do it. You will be using the apache ant that y...
28,475
<p>I need a RegExp which matches a word or multiple words in quotes.</p> <p>[\w]* matches a word</p> <p>"[\w\W&amp;&amp;[^"]]*" matches multiple words in quotes.</p> <p>(btw, not sure why \w\W works, but not a simple . (which should match all characters)</p> <p>So how do i combine these two regexp?</p>
<p>Does <code>"[^"]+"</code> do what you want? (Match a double-quote, match one or more chars that are not double quotes, then match a second double-quote.)</p>
<p>I would prefer:</p> <pre><code>"\s*((?:\w(?!\s+")+|\s(?!\s*"))+\w)\s*" </code></pre> <p>rather than <code>"[^"]+"</code> because <code>^"</code> matches everything, no just <code>\w</code> (<strong>alphanumerical</strong>) char <code>[a-zA-Z_0-9]</code></p> <p>That way, you match only <code>\w</code> chars within...
42,186
<p>I'm not sure how to look for this online... I think they might be called something different in C++</p> <p>I want to have a simple event system, somthing like</p> <pre><code>event myCustomEvent; myCustomEvent.subscribe( void myHandler(string) ); myCustomEvent.fire("a custom argument"); // myHandler prints out the ...
<p>I use <a href="http://sigslot.sourceforge.net/" rel="noreferrer">sigslot</a> for exactly this purpose.</p>
<p>I use <a href="http://libsigc.sourceforge.net/" rel="nofollow noreferrer">libsigc++</a>. It's native for gtkmm.</p> <p>A simple example losely adapted from the <a href="https://developer.gnome.org/libsigc++-tutorial/stable/" rel="nofollow noreferrer">tutorial</a>:</p> <pre><code>#include &lt;iostream&gt; #include ...
29,532
<p>I'm interested in 3d printed reaction chambers, but can't find any good information on chemical resistances of PLA, just vague claims that it "might not be" "because it's biodegradable" or that it depends on additives (likely true, but it would be nice to know if there's hope of finding PLA without problematic addit...
<p>The paper <a href="https://www.researchgate.net/publication/326697946_Chemical_Compatibility_of_Fused_Filament_Fabrication-based_3-D_Printed_Components_with_Solutions_Commonly_Used_in_Semiconductor_Wet_Processing" rel="nofollow noreferrer">Chemical Compatibility of Fused Filament Fabrication-based 3-D Printed Compon...
<p>As @T. M. notes in his comment, there are many good charts of chemical compatibility with various agents. Very few (I found none) include information about PLA. By all means, use search engines to find some information.</p> <p>But, no data source is as true to your specific needs as is testing your candidate mate...
1,273
<p>I cannot seem to programmatcally scroll in WPF in a normal Windows Form I would use the code below but that property does not exist in WPF.</p> <pre><code>HtmlDocument doc = this.webBrowser1.Document; doc.Body.ScrollTop = 800; return; </code></pre> <p>Is there an alternative to doing this? </p>
<p>Not exaclty sure what to look for in that code, but I basically have a WebControl that shows a Webpage that has several articles. I would like to jump to an article by it's title. I know I can get the index of the article name, but jumping to it is the issue.</p>
<p>How about this?</p> <pre><code>if (wb.Document is mshtml.HTMLDocument htmlDoc) { htmlDoc.parentWindow.scrollTo(0, 0); } </code></pre>
29,541
<p>I'd like to play sound file which loaded from internet, so I tried to start from iPhone SDK SpeakHere sample. I recorded the sound, then saved and uploaded to the internet, I could download that file and play without problem from sound tools. But when I tried to play that URL from SpeakHere, I am getting error <code...
<p>Yes, you need to use <a href="http://developer.apple.com/iphone/library/documentation/MusicAudio/Reference/AudioStreamReference/Reference/reference.html" rel="nofollow noreferrer">Audio File Stream Services</a> to play directly from the internet.</p> <p>I found the "AudioFileStreamExample" example useful, which sho...
<p>I figured out a workaround. That is copy the content from internet to a local file, then play sound from that local file. And appears solve the problem.</p> <p>Not perfect, but just works. If anyone has real solution, please let me know.</p> <p>Here is the code to copy from internet to local file.</p> <pre><code...
37,522
<p>I just upgraded to Eclipse 3.4 for the second time and I think its for good now. The first time (right when it was released) was too buggy for me to stomach (mainly the PDT 2.0 plug-in); but now it seems to be all worked out.</p> <p>My problem is the Javascript validator. If I define a class in one JS file in my pr...
<p>Looks like this problem is due to the default browser for Eclipse not having the required libraries.</p> <p>Try below steps to add the required library: Project -> Properties -> JavaScript -> JavaScript Libraries -> Libraries(tab) -> Add Runtime Library -> select 'Internet Explorer Library'</p> <p>This should reso...
<p>After hours of looking around I have found how to definetly remove JS validation.</p> <p>This means editing your .project file, so back it up before just in case.</p> <ul> <li>Close Eclipse</li> <li>Open your .project file</li> <li>look for the following line : &lt;nature&gt;org.eclipse.wst.jsdt.core.jsNature&lt;/...
32,632
<p>I'm printing 6 separate parts in one go, after 4 hours of printing one part failed, but the other 5 are printing nicely.</p> <p>Is there a way to prevent the print from printing the failed part and continue printing the other 5 parts.</p> <p>I'm using Cura and an Ender 3 printer.</p>
<p>If you use the <a href="https://octoprint.org/" rel="noreferrer">OctoPrint</a> print manager, you can exclude regions to be printed using the <a href="https://plugins.octoprint.org/plugins/excluderegion/" rel="noreferrer">Exclude Region</a> plugin. The description states that it can be used to rescue partially-faile...
<p>No, once you sliced the 6 parts on the build plate in your slicer, the G-code is fixed and the printer will print as the sliced instructions. During printing it cannot skip the code of a part that failed along the way; there is no way to interfere with the printing other than stopping the print. For that reason, man...
1,708
<p>I have been using Castle MonoRail for the last two years, but in a new job I am going to be the one to bring in ASP.NET MVC with me. <br /></p> <p>I understand the basics of views, actions and the like. <br />I just need a good sample for someone with MVC experience. <br /> Any good links besides Scott's Northwind ...
<p><a href="http://code.google.com/p/codecampserver/" rel="noreferrer">CodeCampServer</a> - Built with ASP.NET MVC, pretty light and small project. No cruft at all.</p> <p>@lomaxx - Just FYI, most of what Troy Goode wrote is now part of <a href="http://weblogs.asp.net/scottgu/archive/2008/07/14/asp-net-mvc-preview-4-...
<p>Check out some of these:</p> <ul> <li><a href="http://www.codeplex.com/mvcpress" rel="nofollow noreferrer">MVCPress/Blog</a></li> <li><a href="http://www.codeplex.com/CarTrackr/Release/ProjectReleases.aspx?ReleaseId=18356" rel="nofollow noreferrer">CarTrackr</a></li> <li><a href="http://haacked.com/archive/2008/11/...
5,133
<p>Greetings!</p> <p>If I have XML such as this:</p> <pre><code>&lt;Root&gt; &lt;AlphaSection&gt; . . . &lt;/AlphaSection&gt; &lt;BetaSection&gt; &lt;Choices&gt; &lt;SetA&gt; &lt;Choice id="choice1"&gt;Choice One&lt;/Choice&gt; &lt;Choice i...
<p>You don't need the where clause at all - you just need to change the Elements call to be Descendants:</p> <pre><code>var choiceList = myXDoc.Root .Element("BetaSection") .Descendants("Choice") .Select(element =&gt; new ...
<p>I'd write this instead. I prefer the SQL syntax instead of method syntax but is a matter of taste...</p> <pre><code>class Program { static void Main(string[] args) { String xml = @"&lt;Root&gt; &lt;AlphaSection&gt;&lt;/AlphaSection&gt; ...
42,032
<p>Is there a way to use XMLHttpRequest in combination with other domains?</p> <p>I would like to parse some xml from Google without having to use a server so it is minimalistically complex to run.</p> <pre><code>var req = getXmlHttpRequestObject(); ... req.open('GET', 'http://www.google.de/ig/api?weather=Braunschwei...
<p>Nope, not right now. I believe I read that plans/design's are in the works by standards groups for the future, so we can securely do this. </p> <p>Cross site scripting vulnerabilities would be rampant other wise. </p> <p><a href="http://www.west-wind.com/Weblog/posts/107136.aspx" rel="noreferrer">JSONP</a> is a po...
<p>You can try to do something on the serverside. So on your application you make the request to the remote site getting the result and returning it to your client. The AJAX call is then only calling your own server and works.</p>
42,049
<p>I know next to nothing when it comes to the how and why of https connections. Obviously, when I'm transmitting secure data like passwords or especially credit card information, https is a critical tool. What do I need to know about it, though? What are the most common mistakes you see developers making when they ...
<p>An HTTPS, or Secure Sockets Layer (SSL) certificate is served for a site, and is typically signed by a Certificate Authority (CA), which is effectively a trusted 3rd party that verifies some basic details about your site, and certifies it for use in browsers. If your browser trusts the CA, then it trusts any certifi...
<p>I would suggest any time <em>any</em> user data is stored in a database and communicated, use https. Consider this requirement even if the user data is mundane, because even many of these mundane details are used by that user to identify themselves on other websites. Consider all the random security questions your b...
9,021
<p>As a follow up to this question: <a href="https://stackoverflow.com/questions/46873/developing-a-online-exam-application-how-do-i-prevent-cheaters">Developing a online exam application, how do I prevent cheaters?</a></p> <p>Can I detect when Flex application looses its focus? that is if a user has clicked onto anot...
<p>The key part of the code at that link is the </p> <pre><code>systemManager.stage.addEventListener(Event.DEACTIVATE,deactivate); </code></pre> <p>The Flash player send outs activate and deactivate events when the focus enters and leaves the player. All you need to do is create a listenr for them and react appropria...
<p>This will work to detect when the Flex windows loses focus, but to detect when the window regains focus without having to actually click on the flex app requires an update in the HTML wrapper, correct? Something like:</p> <pre><code>&lt;script language="JavaScript" type="text/javascript"&gt; &lt;!-- // ------------...
6,909
<p>I need to create an application that when a user copies a file into an specific folder, my application will be activated and the file will be changed, also, when the user reads back any file in the folder, changes will also be made to the file.</p> <p>Is it possible?</p> <p>I'll use .net for this.</p> <p>I think ...
<p>Well, I'm sure you could write an explorer extension that would do that, but the more typical method that I know of is to write a windows service that monitors the directory in question using the FileSystemWatcher class to monitor events. The service can then perform the requested actions (or spawn an executable to ...
<p>You can monitor for changes with <a href="http://msdn.microsoft.com/en-us/library/ch2s8yd7.aspx" rel="nofollow noreferrer">FileSystemWatcher</a>.</p> <blockquote> <p>You can configure the component to watch either an entire directory and its contents or a specific file or set of files within a given directo...
42,270
<p>I need to know the application's ProductCode in the Installer.OnCommitted callback. There doesn't seem to be an obvious way of determining this.</p>
<p>You can avoid hardcoding your product code, using /productCode=[ProductCode] in your CustomActionData property.</p>
<p>The MSI function MsiGetProperty can be used to get the name of the ProductCode property. I don't know if that would work in this case, since I've never created a .NET installer.</p>
8,615
<pre><code>&lt;document.write("&lt;SCR"+"IPT TYPE='text/javascript' SRC='"+"http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+gDomain+"/"+gDcsId+"/wtid.js"+"'&gt;&lt;\/SCR"+"IPT&gt;"); </code></pre> <p>I need to escape the string above in order to add the whole thing to a StringBuilder but so far I mu...
<p>You should try something like this :</p> <pre><code>@"&lt;document.write(""&lt;SCR""+""IPT TYPE='text/javascript' SRC='""+""http""+(window.location.protocol.indexOf('https:')==0?'s':'')+""://""+gDomain+""/""+gDcsId+""/wtid.js""+""'&gt;&lt;\/SCR""+""IPT&gt;"");" </code></pre> <p>When prefixing a string literal with...
<p>I think you are mixing up what is <code>JavaScript</code> and what is <code>C#</code>. Can you please tell us the string you are string you are trying to achieve...</p> <p>for instance</p> <p><code>window.location.protocol.indexOf('https:')</code> is <code>JavaScript</code></p> <p>but presumably</p> <p><code>gDo...
44,175
<p>Let's say I have <strong>a <code>List</code> object</strong> and <strong>an iterator</strong> for that list.</p> <p>Now I sort the list with <code>java.util.Collections.sort()</code></p> <ul> <li>What happens to the iterator? </li> <li>Is its behavior still defined and can it still be used? </li> <li>If not, can I...
<p>Most of the collections in <code>java.util</code> are "fail-fast" and <strong>may</strong> throw a <a href="http://java.sun.com/javase/6/docs/api/java/util/ConcurrentModificationException.html" rel="noreferrer"><code>ConcurrentModificationException</code></a> if the underlying collection is changed. It should be poi...
<p>Generally, any kind of mutation on a collection will invalidate its iterators. A mutation done through an iterator will not invalidate that iterator. There are some exceptional collection implementations, such as <code>CopyOnWriteArrayList</code>. </p> <p>The general solution would be to sort a copy of the collecti...
38,309
<p>I've tried with Postsharp, but their current implementation targets 2.0, and it's getting painful to make it work. Should I roll out my own AoP implementation (I'm thinking of a very VERY basic and utilitarian implementation here)</p> <p>Or there is an alternative I'm not aware of?</p>
<p>You may wish to take a look at <a href="http://www.bodden.de/tools/aop-dot-net/" rel="nofollow noreferrer">Eric Bodden's list</a> which was taken from <a href="https://stackoverflow.com/questions/133950/what-are-the-bestmost-popular-ways-to-do-aspect-oriented-programming-aop-in-cnet">a very similar stackoverflow qu...
<p>oOo an "out of the box" AOP on CF? You may be a little disappointed.</p> <p>The best answer is <a href="http://www.postsharp.org/download/1.5/" rel="nofollow noreferrer">PostSharp</a>. :D The issue here though is that the download link says this:</p> <blockquote> <p>"It is not stable, however. Download it if y...
46,852
<p>My Anet A8 suddenly had issues with being unable to heat the bed. After ruling out software issues, I disconnected the connector and found this (sorry for the terrible quality):</p> <p><a href="https://i.stack.imgur.com/7WYfE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7WYfE.jpg" alt="Faulty ...
<p>Owning an Anet A8 I confirm that the connectors are not rated for the amount of current that pass through them. <strong>You do not need a new bed unless the heat element has burned through</strong> (but that is pretty uncommon, it usually is the connector). This burning of the bed connectors is a very well known pro...
<h1>New Bed (Connection)</h1> <p>You will at least need a new female connector, but as the connector burnt, you have some underlying problem that made the connector burn in the first place: either the board is sending bad signals to the bed, or the bed is not rated for the board or you <em>just</em> had a faulty connec...
1,147
<p><code>IntToStr()</code> function returns string which is Unicode now. I want to convert to <code>AnsiString</code>. Can I use <code>AnsiString(IntToStr(I))</code> safely?</p>
<p>Sure. Or you can use <code>IntToAnsiString</code> (written by <a href="http://www.bobswart.nl/Weblog/Blog.aspx?RootId=5:2984" rel="nofollow noreferrer" title="Unicode tip #8 - Integer and Float To AnsiString">Dr. Bob</a>):</p> <pre><code>function IntToAnsiStr(X: Integer; Width: Integer = 0): AnsiString; begin St...
<p>Yes, you can safely convert the <code>UnicodeString</code> returned by <code>IntToStr</code> to an <code>AnsiString</code>. The reason it's safe is that the string it returns will only contain the digit characters <code>'0'</code> through <code>'9'</code>, not any fancy Unicode digits, so the conversion to <code>Ans...
44,622
<p>I'm developing an application with two windows:</p> <ul> <li>Window 1: Renders direct draw surfaces</li> <li>Window 2: I'd <em>like</em> to have it do pure OpenGL calls</li> </ul> <p>I don't want to mix OpenGL and DirectDraw in the same window.</p> <p>I see from the Open GL FAQ (<a href="http://www.opengl.org/res...
<p>There should be no problems running both in the same process, barring of course bugs in the ICD video driver.</p> <p>Probably the quickest way to tell is commenting out OpenGL code and check if the application still crashes. </p> <p>Or, force your OpenGL code to use Microsoft implementation - it's software based o...
<p>Worst-case: have your main program spawn do one type of rendering (DirectDraw, let's say). Have it spawn a process which does the other type (OpenGL). Communicate between the two using pipes. This will require you to have two processes, and it might be a bit of a workaround, but it will at least work.</p>
35,750