instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Short of using a profiler, is there any way inside a running program to detect first chance exceptions? Ideally, I would like to record more detailed state information that is not available once the catch block has taken over the final exception.</p>
| <p>I was googling FirstChanceException, and I can't resist answering this more than two years later...</p>
<p>Now, in .net 4.0, you can catch the <a href="https://msdn.microsoft.com/en-us/library/system.appdomain.firstchanceexception(VS.100).aspx" rel="nofollow noreferrer">FirstChanceException event</a> of the AppDoma... | <p>Use <a href="http://support.microsoft.com/default.aspx/kb/286350" rel="nofollow noreferrer">Adplus</a>.
It will attach a debugger to the proccess, and generate (by default) a small minidump when first chance excpetion are raised. Adplus generated log file will also contain exception info. Just make sure you have PDB... | 32,014 |
<p>My father has found a Russian language keyboard mapping that he really likes <a href="http://translit.ru/" rel="nofollow noreferrer">here</a>. However, it is non-standard and therefore is not one that appears in the Languages (<em>Control Panel->Regional and Language Options->Languages->Details->Text Services And I... | <p>There's <a href="http://www.microsoft.com/globaldev/tools/msklc.mspx" rel="noreferrer">this utility from Microsoft</a></p>
<blockquote>
<p>The Microsoft Keyboard Layout Creator
(MSKLC) extends the international
functionality of Windows 2000, Windows
XP, Windows Server 2003,and Windows
Vistas systems by al... | <p>Try AutoHotKey (<a href="http://www.autohotkey.com/" rel="nofollow noreferrer">http://www.autohotkey.com/</a>) i use it to get emacs keybindings in normal text editors, i'm sure it could tackle this too.</p>
<p>edit: the bit you're looking for is in the quickstart here: <a href="http://www.autohotkey.com/docs/Tutor... | 42,269 |
<p>After reading <a href="http://www.onlamp.com/pub/a/apache/2005/02/10/database_logs.html" rel="noreferrer">an article about the subject from O'Reilly</a>, I wanted to ask Stack Overflow for their thoughts on the matter.</p>
| <p>Write locally to disk, then batch insert to the database periodically (e.g. at log rollover time). Do that in a separate, low-priority process. More efficient and more robust...</p>
<p>(Make sure that your database log table contains a column for "which machine the log event came from" by the way - very handy!)</p>... | <p>It probably isn't a bad idea if you want the logs in a database but I would say not to follow the article's advice if you have a lot of log file entries. The main issue is that I've seen file systems have issues keeping up with logs coming from a busy site let alone a database. If you really want to do this I would ... | 36,998 |
<p>We've just started using LINQ to SQL at work for our DAL & we haven't really come up with a standard for out caching model. Previously we had being using a base 'DAL' class that implemented a cache manager property that all our DAL classes inherited from, but now we don't have that. I'm wondering if anyone has... | <p>My <a href="http://petemontgomery.wordpress.com/2008/08/07/caching-the-results-of-linq-queries/" rel="noreferrer">LINQ query result cache</a> is probably just what you're looking for.</p>
<pre><code>var q = from c in context.Customers
where c.City == "London"
select new { c.Name, c.Phone };
var res... | <p>See the 'GetReferenceData' method in the 'ReferenceData' class in <a href="http://blog.huagati.com/res/index.php/2008/06/23/application-architecture-part-2-data-access-layer-dynamic-linq/" rel="nofollow noreferrer">this article</a>:
<a href="http://blog.huagati.com/res/index.php/2008/06/23/application-architecture-p... | 5,802 |
<p>Let's say I have a <strong>Base</strong> class and several <strong>Derived</strong> classes. Is there any way to cast an object to one of the derived classes without the need to write something like this :</p>
<pre><code>
string typename = typeid(*object).name();
if(typename == "Derived1") {
Derived1 *d1 = stati... | <p>Don't. </p>
<p>Read up on polymorphism. Almost every "dynamic cast" situation is an example of polymorphism struggling to be implemented.</p>
<p>Whatever decision you're making in the dynamic cast has already been made. Just delegate the real work to the subclasses. </p>
<p>You left out the most important par... | <p>Your example won't port, because the exact format of name() isn't specified. You could try a succession of <code>dynamic_cast</code>s. <code>Dynamic_cast</code> returns a null pointer if you cast to the wrong type. However, if you're doing a typeswitch like this one, there's something wrong with your design.</p>
| 30,108 |
<p>I have many small files containing code fragments, pseudo-code algorithms, classes, templates, SQL-samples, etc., and I obviously cannot put all these into libraries. I need a practical method to index all of them, and to be able to make this index available to others.</p>
<ol>
<li>What must such an index contain t... | <p>If you're working with .NET / Visual Studio, you could look at adding them as <a href="http://msdn.microsoft.com/en-us/vs2005/aa718338.aspx" rel="nofollow noreferrer">code snippets</a></p>
<p><a href="http://www.codekeep.net/" rel="nofollow noreferrer">Code Keep</a> is a pretty good online repo for CodeSnippets and... | <p>I find the only way to manage source code is in the source control repository. This includes templates and pseudo code algorithms.
How it's different from the rest of your code ?
I'm familiar with <a href="http://ximbiot.com/cvs/wiki/" rel="nofollow noreferrer">cvs</a> that can be hosted for example <a href="https... | 29,434 |
<p>Although I played with it before, I'm finally starting to use <a href="http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard" rel="noreferrer">Dvorak (Simplified)</a> regularly. I've been in a steady relationship with Vim for several years now, and I'm trying to figure out the best way to remap the key bindings to... | <p>I use one of the more <a href="http://vim.wikia.com/wiki/Change_cursor_movement_keys_for_Dvorak_layout" rel="noreferrer">common recommended keybindings</a>:</p>
<pre><code>Dvorak it!
no d h
no h j
no t k
no n l
no s :
no S :
no j d
no l n
no L N
Added benefits
no - $
no _ ^
no N <C-w><C-w>
no T <C-w&... | <p>You can use this to <a href="https://stackoverflow.com/questions/14025247/make-vim-use-dvorak-keybindings-only-in-insert-mode">have Vim use Dvorak only in insert mode:</a></p>
<pre><code>:set keymap=dvorak
</code></pre>
<p>This way all of the commands are still in QWERTY, but everything you type will be in Dvorak.... | 19,969 |
<p>I am just starting to play with Django/Python and am trying to shift into the MTV mode of programming that Django asks for (insists on). Deciding on what functions should be methods of a model vs simple being a function in a view has so far been confusing. Does anyone know of a book, website, blog, slideshow, what... | <p>My basic rule in Django is: if you could conceivably need the functionality from somewhere other than the view itself, it doesn't belong in the view function. </p>
<p>I'd also recommend downloading some of the plethora of apps on <a href="http://djangoplugables.com/" rel="nofollow noreferrer">Django Pluggables</a> ... | <p>If you aren't absolutely set on diving into Django and don't mind trying something else as a start, you might want to give <a href="http://www.python.org/dev/peps/pep-0333/" rel="nofollow noreferrer">WSGI</a> a shot, which allows you to template your application your own way using a <a href="http://pypi.python.org/p... | 4,220 |
<p>I have some data that has a detail table. I want the data to be presented in a ListView. I want the detail data to appear as a nested ListView when you select an item in the original list. I can't seem to figure out how to get the data binding to work.</p>
<p>Here's what I have so far, (the problem is the <code>{Bi... | <p>If I understand your question correctly you need to bind to the SelectedItem of the original list:</p>
<pre><code><ListView ItemsSource="{Binding ElementName=lstHistory, Path=SelectedItem}">
</code></pre>
<p>And then set the datatemplate/view as needed. If you don't want to use ElementName for the binding yo... | <p>You need to change your problem line to the following:</p>
<pre><code><ListView ItemsSource="{Binding FK_History_HistoryItems}">
</code></pre>
<p>With that change, the control works beautifully. I have been working on something similar to no avail. I really like your work on this.</p>
| 46,070 |
<p>Repetier-host has a setting to specify the "print area". That's roughly the size of the bed.</p>
<p>Note that the printer head can go out of those bounds, in my case my bed is very undersized compared to the printer frame, but this would also be an issue if you had clips or some obstacles in the bed.</p>
<... | <p>The print area settings would be in the Preferences > Printers. Select the particular printer on the left side pane, then click the "Machine Settings" button.</p>
<p><a href="https://i.stack.imgur.com/86dAH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/86dAH.jpg" alt="enter image de... | <p>I am not sure this is the "official" solution for this, but I was able to define the "disallowed areas" in a custom printer definition.</p>
<p>I created a json file under C:\Program Files\Ultimaker Cura 4.8.0\resources\definitions for the printer, and added the machine_disallowed_areas section to... | 1,859 |
<p>Is there a built-in/custom script available?</p>
| <p>In fact not really programming related. Anyway, from my experience, <a href="http://opencsw.wikidot.com/munin-package" rel="nofollow noreferrer">munin</a> can generate very nice graphs, powered by rrdtool. You can also host a munin master on a different machine and collect data from many munin nodes.</p>
| <p>Although its maybe not really programing related you could try <a href="http://www.orcaware.com/orca/" rel="nofollow noreferrer">Orca</a>.</p>
| 26,194 |
<p>Or does it?</p>
<p>Should an object-oriented design use a language construct that exposes member data by default, if there is an equally useful construct that properly hides data members?</p>
<p>EDIT: One of the responders mentioned that if there's no invariant one can use a struct. That's an interesting observati... | <p>In C++, <strong>struct</strong>s and <strong>class</strong>es are identical except for the default public/privateness of their members. (This default is easily, and usually, overridden.)</p>
<p>However, most programmers think of a struct as a "data object" and a class as an "interactive object". That's not a bad th... | <p>Structs are fine as long as they're kept small. As you probably know, they are allocated on the stack (not the heap) so you need to watch the size. They can come in handy for small data structures like Point, Size, etc. A class is usually the better choice though, being a reference type and all.</p>
| 31,382 |
<p>The structures of my Git repositories look like this:</p>
<pre><code>A-B-C-D-E-F # master branch in separate repo1
A-B-C-D-E-G-H # master branch in separate repo2
</code></pre>
<p>A-H are simple commits. As you can see the repositories are related (repo2 is a fork of repo1). I'm trying to combine these two repos... | <p>You can treat another git repository on the same filesystem as a remote repo.</p>
<p>In the first, do the following:</p>
<pre><code>git remote add <name> /path/to/other/repo/.git
git fetch <name>
git branch <name> <name>/master #optional
</code></pre>
<p>Now they're both branches in a sing... | <p>I think Jim is right. Also bear in mind that if two commits do exactly the same patch/diff against the code, they will have exactly the same SHA1 hash. So A through E should have the same SHA1 in both repos, so it shouldn't be a problem to merge from one to the other, and keep the merged repo as the sole repo to m... | 30,345 |
<p>i have a basic ruby class:</p>
<pre><code>class LogEntry
end
</code></pre>
<p>and what i would like to do is be able to define a hash with a few values like so:</p>
<pre><code>EntryType = { :error => 0, :warning => 1, :info => 2 }
</code></pre>
<p>so that i can access the values like this (or something... | <p>You can do this:</p>
<pre><code>class LogEntry
EntryType = { :error => 0, :warning => 1, :info => 2 }
end
</code></pre>
<p>But you want to reference it as</p>
<pre><code>LogEntry::EntryType[:error]
</code></pre>
| <p>Why do you need a hash?</p>
<p>Can you not just declare the entry types on the LogEntry class?</p>
<pre><code>class LogEntry
@@ErrorType = 0
End
LogEntry.ErrorType
</code></pre>
| 41,238 |
<p>I create a new Button object but did not specify the <code>command</code> option upon creation. Is there a way in Tkinter to change the command (onclick) function after the object has been created?</p>
| <p>Though <a href="https://stackoverflow.com/questions/68327/change-command-method-for-tkinter-button-in-python#68455">Eli Courtwright's</a> program will work fine¹, what you really seem to want though is just a way to reconfigure after instantiation any attribute which you could have set when you instantiated². How y... | <p>Sure; just use the <code>bind</code> method to specify the callback after the button has been created. I've just written and tested the example below. You can find a nice tutorial on doing this at <a href="http://www.pythonware.com/library/tkinter/introduction/events-and-bindings.htm" rel="nofollow noreferrer">htt... | 9,383 |
<p>Sorting has been studied for decades, so surely the sorting algorithms provide by any programming platform (java, .NET, etc.) must be good by now, right? Is there any reason to override something like System.Collections.SortedList?</p>
| <p>There are absolutely times where your intimate understanding of your data can result in much, much more efficient sorting algorithms than any general purpose algorithm available. I shared an example of such a situation in another post at SO, but I'll share it hear just to provide a case-in-point:</p>
<p>Back in th... | <p>A few months ago the Coding Horror blog reported on some platform with an atrociously bad sorting algorithm. If you have to use that platform then you sure do want to implement your own instead.</p>
| 29,566 |
<p>Just wondering if it's possible to screen grab a page you are viewing with a PHP script or javascript? For example, load up a page in an iframe and then save that view as a JPEG?</p>
<p>I'm sure it's possible somehow, but are there any known implementations/libraries that help out?</p>
| <p>Nope, sorry, it is impossible with Javascript and definitely impossible with a server-side language like PHP. (<strong>Edit:</strong> I mean it's impossible to take a screenshot of the user's view of the page.)</p>
<p>It depends on what you want to do this for, but you might want to find a script or program that ru... | <p>Thanks for the help guys. I did find this interesting resource:</p>
<p><a href="http://www.zubrag.com/scripts/website-thumbnail-generator.php" rel="nofollow noreferrer">http://www.zubrag.com/scripts/website-thumbnail-generator.php</a></p>
<p>It's not PHP specific by any means, just an example of running an EXE sc... | 23,490 |
<p>I am developping a (relatively small) website in ASP.Net 2.0. I am also using nAnt to perform some easy tweaking on my project before delivering executables. In its current state, the website is "precompiled" using </p>
<blockquote>
<p><code>aspnet_compiler.exe -nologo -v ${Appname} -u ${target}</code></p>
</bloc... | <p>Make sure that:</p>
<ol>
<li>You are using a Web Application project rather than a Web Site project, this will result in a precompiled binary for your code behind</li>
<li>You have turned off debug code generation in the web.config file - I guess if this is different to when you used aspnet_compiler the code may be... | <p>@Simon:</p>
<ul>
<li>The project is a Web Application. Websites are then slower to startup (I had no idea it had an incidence, beside the different code organization)?</li>
<li>I checked, and while I edit the web.config after aspnet_compiler is called, I don't touch the debug value (I will however check the website... | 8,027 |
<p>After you start tracking the source of a bunch of open source software, how do you keep your code in sync? Run <code>svn update</code> every time you want to look at or play with the code?</p>
<p>It strikes me that it would be better to essentially start mirroring the code with (say) a <code>cron</code> job every n... | <p>The general workflow recommended by <a href="http://svnbook.red-bean.com/en/1.5/svn.tour.cycle.html#svn.tour.cycle.update" rel="nofollow noreferrer">the Subversion book</a> is to update your working copy often; at the start of every work-day is a good time. But you don't have to. Just update whenever you feel like s... | <p>If your repository sends you an email every time someone checks in, why not have a program that checks for those emails and then updates the working copy at that time? This way you're always up to date. Caveats include needlessly burning bandwidth and the possibility of getting odd conflicts when a file you're worki... | 14,032 |
<p>I've used some very large scale systems and never seen a required order, but came across it recently. Does the STL or STD library or even Boost have any cases where certain includes must come in a certain order?</p>
| <blockquote>
<p>Does the STL or STD library or even Boost have any cases where certain includes must come in a certain order?</p>
</blockquote>
<p>For the standard, the answer is emphatically, <strong>no</strong>. I imagine the same is true for Boost, though I haven't looked it up.</p>
<p>From the C standard:</p>
... | <p>Not to my knowledge. It's pretty bad practice. I've run into it recently with a Windows header and some weird interface in my code, though. </p>
| 49,163 |
<p>How can I vary the infill percentage for different layer heights of my model?</p>
<p>Context: The bottom part of my model needs about 20% infill. The geometry of the top part of the model (mostly cones of various sizes) prints well with 0% infill and is of course a lot faster to print if I can specify this.</p>
| <p><em>Your question is very similar to <a href="https://3dprinting.stackexchange.com/questions/6522/different-infill-in-the-same-part">Different infill in the same part</a> and <a href="https://3dprinting.stackexchange.com/questions/7019/using-multiple-infill-types-within-one-model">Using multiple infill types within ... | <p>Let's assume the model is 75mm high; the bottom portion (which needs 20% infill) is 40mm, and the top portion (which needs 0% infill) is 35mm.</p>
<ul>
<li>Load your model into Slic3r.</li>
<li>Be sure your default fill is 20%.</li>
<li>Right click on the model, and select Settings.</li>
<li>Click "Load Generic".</... | 1,051 |
<p>Has any one done this before? It would seem to me that there should be a webservice but i can't find one. I am writing an application for personal use that would just show basic info from IMDB.</p>
| <p>There is no webservice available.</p>
<p>But there are enough html scrapers written in every language to suit your needs!</p>
<p>I've used the <a href="http://www.codeplex.com/imdb" rel="noreferrer">.NET 3.5 Imdb Services opensource project</a> in a few personal projects. </p>
<p>1 minute google results:</p>
<ul... | <p>There is at least one unofficial IMDb API called IMDb8. It has about 31 endpoints including</p>
<ol>
<li>actors/list-born-today</li>
<li>actors/get-awards-summary</li>
<li>title/get-plots</li>
<li>title/get-top-crew</li>
</ol>
<p>etc. Like any other API it is very straightforward to use. I used this API for building... | 12,555 |
<p>Is there some way to catch exceptions which are otherwise unhandled (including those thrown outside the catch block)?</p>
<p>I'm not really concerned about all the normal cleanup stuff done with exceptions, just that I can catch it, write it to log/notify the user and exit the program, since the exceptions in these... | <p>This can be used to catch unexpected exceptions.</p>
<pre><code>catch (...)
{
std::cout << "OMG! an unexpected exception has been caught" << std::endl;
}
</code></pre>
<p>Without a try catch block, I don't think you can catch exceptions, so structure your program so the exception thowing code is un... | <p>Use catch (...) in all of your exception barriers (not just the main thread). I suggest that you always rethrow (...) and redirect standard output/error to the log file, as you can't do meaningful RTTI on (...). OTOH, compiler like GCC will output a fairly detailed description about the unhandled exception: the type... | 34,810 |
<p>So after installing NUnit, the assemblies (<code>nunit.framework</code>, etc.) now appear in the <code>References > Add Reference</code> dialog, but they're not in the <code>%WINDIR%\Microsoft.NET\Framework\v2.0.50727</code> dir and there is no <code>NUnit</code> registry entry for the Assembly Path <code>(i.e. H... | <p>I dug deeper into this at the weekend. Reproduced verbatim from my <a href="http://www.differentpla.net/content/2008/10/why-nunit-not-gac-or-why-does-assembly-x-not-appear-visual-studios-add-reference-dialog" rel="nofollow noreferrer">blog</a>:</p>
<h2>Why is NUnit not in the GAC? (or Why does [assembly X] not appe... | <p>Strange, [HKEY_CURRENT_USER\SOFTWARE\Microsoft.NETFramework\AssemblyFolders] should be the only thing driving this.</p>
<p>Perhaps this snippet from <a href="http://support.microsoft.com/kb/306149" rel="nofollow noreferrer">this page</a> is relevant?</p>
<p>If you install the .NET Framework 3.0 Service Pack 1 (SP1... | 27,123 |
<p>How can I extract information from a website (<a href="http://tv.yahoo.com/listings" rel="nofollow noreferrer">http://tv.yahoo.com/listings</a>) and then create an XML file out of it? I want to save it so to parse later and display information using JavaScript?</p>
<p>I am quite new to Perl and I have no idea abo... | <p>Of course. The easiest way would be the <strong><a href="http://p3rl.org/Web::Scraper" rel="nofollow noreferrer">Web::Scraper</a></strong> module. What it does is it lets you define scraper objects that consist of</p>
<ol>
<li>hash key names,</li>
<li>XPath expressions that locate elements of interest,</li>
<li>and... | <p>If you want to pass the information to Javascript, use Javascript Object Notation (JSON) instead of XML. There are plenty of Perl libraries, such as <a href="http://search.cpan.org/dist/JSON-Any" rel="nofollow noreferrer">JSON::Any</a>, that can handle that for you.</p>
| 27,238 |
<p>Can anyone tell me what is the difference between XSDObjectGen.exe & XSD.exe?</p>
<p>Is there any way to make XSDObjectGen.exe work in dot net 2.0?</p>
| <p>As an alternative, there's <a href="http://xsd2code.codeplex.com/" rel="noreferrer">Xsd2Code</a>. Some features:</p>
<ul>
<li>Generate partial class. </li>
<li>Support generic and custom collection (List, ObservableCollection, MyCustomCollection). </li>
<li>Support automatic properties when no special get or set is... | <p>At a purely technical level: </p>
<p>XSD.exe uses <code>Arrays</code><br>
XSDObjectGen takes a tiny step ahead and uses <code>ArrayLists</code>.<br>
XSD2Code <strong><em>leaps ahead</em></strong> with usage of <code>Generics</code>.</p>
<p>If you're using .NET 2.0 and above using XSD2Code is most preferred.<... | 36,842 |
<p>We have a typical business web app that allows our users to send e-mails with offerings to their clients. We set user e-mail in FROM field so the client can reply directly to the user. The problem is that because of SMTP protocol, undelivered e-mail notification is returned to our e-mail address(the address of the a... | <p>First, it's important to understand the difference between the "From:" header (which the recipient sees in their email client) and the sender address (which is also called the envelope return path, or the argument to the SMTP "MAIL FROM" command). The sender address is where bounce messages go when the email can't ... | <p>Exactly which routine are you using to send the Email?
We send emails via raw SMTP using HTTP put_lines and the replies bounce back to the address we nominate in the FROM: field.</p>
<p>See if your SMTP API wrapper has a Reply To: field</p>
<p>Some APIs might not provide that functionality because it increases the... | 15,124 |
<p>There are two schools of thought on how to best extend, enhance, and reuse code in an object-oriented system:</p>
<ol>
<li><p>Inheritance: extend the functionality of a class by creating a subclass. Override superclass members in the subclasses to provide new functionality. Make methods abstract/virtual to force su... | <p>It's not a matter of which is the best, but of when to use what.</p>
<p>In the 'normal' cases a simple question is enough to find out if we need inheritance or aggregation.</p>
<ul>
<li>If The new class <strong>is</strong> more or less as the original class. Use inheritance. The new class is now a subclass of the ... | <p>Both approaches are used to solve different problems. You don't always need to aggregate over two or more classes when inheriting from one class.</p>
<p>Sometimes you do have to aggregate a single class because that class is sealed or has otherwise non-virtual members you need to intercept so you create a proxy la... | 33,854 |
<p>I have the following situation: I built an Access form with a subform (which records are linked to the records of main form via certain key). When I try to delete any record in the subform, I get the following message: “Access has suspended the action because you and another user tried to change the data” (approxima... | <p>If you are currently 'editing' the current form then it will not allow the action. Editing a record can sometimes be triggered by simply clicking inside a field, or other simple actions you wouldn't normally consider 'editing'.</p>
<p>This is usually avoided in Access by using the RunCommand method to undo any edit... | <p>Also check the "row locking mechanism" that you have. I haven't used Access in a while but I remember that you could use set that in the table properties. You can access those properties clicking in the famous "dot" in the upper left corner of the table to bring up its properties. Well if you're using Access, you kn... | 5,435 |
<p>According to <a href="http://en.wikipedia.org/wiki/Rounding" rel="noreferrer">Wikipedia</a> when rounding a negative number, you round the absolute number. So by that reasoning, -3.5 would be rounded to -4. But when I use java.lang.Math.round(-3.5) returns -3. Can someone please explain this?</p>
| <p>According to the <a href="http://java.sun.com/javase/6/docs/api/java/lang/Math.html#round(double)" rel="noreferrer">javadoc</a></p>
<blockquote>
<p>Returns the closest long to the
argument. The result is rounded to an
integer by adding 1/2, taking the
floor of the result, and casting the
result to type lo... | <p>Turns out the convention is to round up. I guess Wikipedia is fallible. Turns out Microsoft got it wrong, though, as they round it to -4 as well, which is not convention (I checked with someone who has a PhD in math).</p>
| 33,888 |
<p>In Visual Studio, How do I show all classes inherited from a base class? </p>
<p><strong>For example</strong>, in ASP.NET MVC there are several '<a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.actionresult.aspx" rel="noreferrer">ActionResult</a>' types -- and they all inherit from / implement the b... | <p>Sure, <a href="http://www.jetbrains.com/resharper/" rel="noreferrer">Resharper</a> can do this. And much more.</p>
<p>Just right click on type name in any place and choose "Go To Inheritor" in context menu.
"Go To Inheritor" can be also applied to method for navigating to overrides and an interface method's impleme... | <p>A very simple way to do this, is to search for <code>: Classname</code> in the "Find and Replace Window" (CTRL + F) and use the "Find Options/Match whole word" Option.
You will find only the inherited classes.</p>
| 35,758 |
<p>I am writing code that checks for the permission to write to and delete from certain directories. The first is fairly easy. To whit:</p>
<pre><code>FileIOPermission writePermit = new FileIOPermission(FileIOPermissionAccess.Write, _ArchiveHome);
writePermit.Demand();
</code></pre>
<p>But, how do I do the same for p... | <p>The Write property mutually means you can delete
<a href="http://msdn.microsoft.com/en-us/library/system.security.permissions.fileiopermissionaccess(VS.85).aspx" rel="nofollow noreferrer">msdn link</a></p>
| <p>The write permit allows you to modify files as in, deleting, modifying, creating, adding.</p>
| 49,691 |
<p>How can I create this file in a directory in windows 2003 SP2:</p>
<pre><code>.hgignore
</code></pre>
<p>I get error: You must type a file name.</p>
| <p>That's a "feature" of Windows Explorer. Try to create your files from a command line (or from a batch/program you wrote) and it should work fine. Try this from a dos prompt:</p>
<pre><code>echo Hello there! > .hgignore
</code></pre>
| <p>By the way Raymond Chen had a blog post about this topic a while back:</p>
<p><a href="https://devblogs.microsoft.com/oldnewthing/20080414-00/?p=22763" rel="nofollow noreferrer">Why doesn't Explorer let you create a file whose name begins with a dot?</a> (archive.org link with comments: <a href="https://web.archive.... | 3,989 |
<p>This is for my DB class. I am new to OO, been a procedural lad for some time, so I'm still a bit murky.</p>
<p>My first idea was using a bunch of setter functions/methods.. but after writing a whole bunch, I thought about using PHP's define function, like so.</p>
<pre><code>define('MYSQL_USERNAME', 'jimbo');
</cod... | <p>I use <code>const</code> only for creating mnemonic names for immutable constants in the class. The <code>define()</code> function does not create constants as part of the class, it creates constants in the global space.</p>
<pre><code>class MyClass
{
const CONFIG_FILE = 'myapp.ini';
</code></pre>
<p>Class conf... | <p>I've had good success at doing this in two ways:</p>
<ol>
<li><p>as @Owen recommends, using class constants</p>
<pre><code>class Config {
const PASSWORD_LENGTH = 12;
const SEND_PASSWORD_EMAILS = true;
// ...
}
</code></pre></li>
<li><p>For simple config variables (i.e. no arrays etc) the package <a hre... | 43,109 |
<p>I would like to compare the contents of a couple of collections in my Equals method. I have a Dictionary and an IList. Is there a built-in method to do this?</p>
<p>Edited:
I want to compare two Dictionaries and two ILists, so I think what equality means is clear - if the two dictionaries contain the same keys ma... | <p><a href="http://msdn.microsoft.com/en-us/library/bb342073.aspx" rel="noreferrer"><code>Enumerable.SequenceEqual</code></a></p>
<blockquote>
<p>Determines whether two sequences are equal by comparing their elements by using a specified IEqualityComparer(T).</p>
</blockquote>
<p>You can't directly compare the list... | <p>No, because the framework doesn't know how to compare the contents of your lists.</p>
<p>Have a look at this:</p>
<p><a href="http://blogs.msdn.com/abhinaba/archive/2005/10/11/479537.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/abhinaba/archive/2005/10/11/479537.aspx</a></p>
| 6,507 |
<p>I'm searching for a document (not printed) that explains in details, but still simply, the subject of character encoding.</p>
| <p>A great overview from the Programmer's perspective is:</p>
<p>The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)<br>
By Joel Spolsky</p>
<p><a href="http://www.joelonsoftware.com/articles/Unicode.html" rel="nofollow noreferrer">http://www.j... | <p>There is a French book about this called <em>Fontes et codages</em> by Yannis Haralambous, an O'Reilly book, I'm pretty sure it is or will be translated. Indeed, it is:
<a href="http://oreilly.com/catalog/9780596102425/index.html" rel="nofollow noreferrer">Fonts and Encodings</a>.</p>
| 45,945 |
<p>Every time I have to estimate time for a project (or review someone else's estimate), time is allotted for testing/bug fixing that will be done between the alpha and production releases. I know very well that estimating so far into the future regarding a problem-set of unknown size is not a good recipe for a success... | <p>It really depends on a lot of factors. To mention but a few: the development methodology you are using, the amount of testing resource you have, the number of developers available at this stage in the project (many project managers will move people onto something new at the end).</p>
<p>As Rob Rolnick says 1:1 is a... | <p>Use a language with Design-by-Contract or "Code-contracts" (preconditions, check assertions, post-conditions, class-invariants, etc) to get "testing" as close to your classes and class features (methods and properties) as possible. Then use TDD to test your code with its contracts.</p>
<p>Use as much self-built cod... | 7,086 |
<p>What's the difference between <code><b></code> and <code><strong></code>, <code><i></code> and <code><em></code> in HTML/XHTML? When should you use each?</p>
| <p>They have the <strong>same effect on normal web browser rendering engines</strong>, but there is a <strong>fundamental difference</strong> between them.</p>
<p>As the author writes in <a href="https://web.archive.org/web/20091124170143/http://lists.evolt.org/archive/Week-of-Mon-20010521/032901.html" rel="noreferrer... | <p>We use the <code><strong></code> tag for text which has high priority for SEO purposes like product name, company name etc, while <code><b></code> simple makes it bold.</p>
<p>Similarly, we use <code><em></code> for text which has high priority for SEO, while <code><i></code> to make the tex... | 34,189 |
<p>Using eclipse 3.3.2 with MyEclipse installed. For some reason if a file isn't called build.xml then it isnt' recognised as an ant file. The file association for *.xml includes ant and says "locked by 'Ant Buildfile' content type.</p>
<p>The run-as menu is broken. Even if the editor association works run-as doesn't.... | <p>The environment inspects the file contents to determine if it is an Ant file (if it isn't called "build.xml"). Add the following to the XML file:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<project name="myproject" default="t1">
<target name="t1"></target>
</project>
</... | <p>If you open the "File Associations" page (Window -> Preferences -> General -> Editors -> File Associations) you should see a list of all file types which Eclipse recognises. Scroll down to the "*.xml" entry, highlight "Ant Editor" in the "Associated Editors" pane and hit the "Default" button on the right-hand side. ... | 11,632 |
<p>In other words, can <code>fn()</code> know that it is being used as <code>$var = fn();</code> rather than as <code>fn();</code>?</p>
<p>A use case would be to <code>echo</code> the return value in the latter case but to <code>return</code> it in the former.</p>
<p>Can this be done without passing a parameter to th... | <p>Many PHP functions do this by passing a boolean value called $return which returns the value if $return is true, or prints the value if $return is false. A couple of examples are <a href="http://php.net/print_r" rel="nofollow noreferrer">print_r()</a> and <a href="http://php.net/highlight_file" rel="nofollow norefer... | <p>No, there is no way to find it out. The unique thing you could do, is to grab the call stack (<a href="http://it2.php.net/debug_backtrace" rel="nofollow noreferrer">http://it2.php.net/debug_backtrace</a>) and inspect it. </p>
| 32,081 |
<p>Because Linux (and its variants) have a completely different set of fonts than Windows and Mac OS X, is there anyone with any experience of creating cross-platform font families - ideally finding equivalents to the common fonts found on the aforementioned operating systems?</p>
<p>If so, what is the best route to t... | <p>Here are some good up-to-date listings of the most-installed fonts for PC, Mac, and Linux:</p>
<p><a href="http://www.codestyle.org/css/font-family/sampler-SansSerif.shtml" rel="nofollow noreferrer">Sans serif font sampler and survey results</a></p>
<p><a href="http://www.codestyle.org/css/font-family/sampler-Seri... | <p>TrueType Fonts (TTF) will generally work on Windows, Mac, and Linux platforms.</p>
<p><a href="http://en.wikipedia.org/wiki/TrueType" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/TrueType</a></p>
| 5,924 |
<p>What is the best way to display <code>Flash</code> content in a <strong>C#</strong> WinForms application? I would like to create a user control (similar to the current <code>PictureBox</code>) that will be able to display images and flash content.</p>
<p>It would be great to be able to load the flash content from a... | <p>While I haven't used a flash object inside a windows form application myself, I do know that it's possible.
In Visual studio on your toolbox, choose to add a new component.
Then in the new window that appears choose the <strong>"COM Components"</strong> tab to get a list in which you can find the <strong>"Shockwave ... | <p><a href="https://stackoverflow.com/users/46/sven">Sven</a>, you reached the same conclusion as I did: I found the Shockwave Flash Object, all be it from a slightly different route, but was stumped on how to load the files from somewhere other than file on disk/URL. The <a href="https://www.f-in-box.com/dotnet/" rel=... | 2,344 |
<p>An older application using System.Web.Mail is throwing an exception on emails coming from <em>hr@domain.com</em>. Other addresses appear to be working correctly. We changed our mail server to Exchange 2007 when the errors started, so I assume that is where the problem is. Does anyone know what is happening?</p>
<p>... | <p>Same as string insertion.</p>
<pre><code>if goo =~ /#{Regexp.quote(foo)}/
#...
</code></pre>
| <pre><code>foo = "0.0.0.0"
goo = "here is some other stuff 0.0.0.0"
puts "success!" if goo =~ /#{foo}/
</code></pre>
| 18,088 |
<p>I'm looking for a desktop/embedded database. The two candidates I'm looking at are
Microsoft SQL Server CE and Oracle Lite. If anyone's used both of these products, it'd be great if you could compare them. I haven't been able to find any comparisons online.</p>
<p>The backend DB is Oracle10g.</p>
<p><strong>Update... | <p>If the backend database is Oracle 10g it will probably be easier for you to use Oracle Lite - that way you don't have to use two completely different SQL dialects in the same project.</p>
<p>BTW, In my product I use SQLite as the desktop database </p>
| <p>You might want to look at Oracle XE. I cannot remember all of the differences, but O-Lite didn't fit my project needs. Oracle XE is a very good database for local development.</p>
<p>Brad</p>
| 7,093 |
<p>The <code>printf</code> function takes an argument type, such as <code>%d</code> or <code>%i</code> for a <code>signed int</code>. However, I don't see anything for a <code>long</code> value.</p>
| <p>Put an <code>l</code> (lowercased letter L) directly before the specifier. </p>
<pre><code>unsigned long n;
long m;
printf("%lu %ld", n, m);
</code></pre>
| <p>I think to answer this question definitively would require knowing the compiler name and version that you are using and the platform (CPU type, OS etc.) that it is compiling for.</p>
| 5,944 |
<p>I was watching Rob Connerys webcasts on the MVCStoreFront App, and I noticed he was unit testing even the most mundane things, things like:</p>
<pre><code>public Decimal DiscountPrice
{
get
{
return this.Price - this.Discount;
}
}
</code></pre>
<p>Would have a test like:</p>
<pre><code>[TestMethod... | <p>First, testing is like security -- you can never be 100% sure you've got it, but each layer adds more confidence and a framework for more easily fixing the problems that remain.</p>
<p>Second, you can break tests into subroutines which themselves can then be tested. When you have 20 similar tests, making a (tested... | <p>Even if you do not test your code, it will surely be tested in production by your users. Users are very creative in trying to crash your soft and finding even non-critical errors.</p>
<p>Fixing bugs in production is much more costly than resolving issues in development phase.
As a side-effect, you will lose income ... | 30,298 |
<p>Working with a traditional listener callback model. I have several listeners that collect various stuff. Each listener's collected stuff is inside the listener in internal structures.</p>
<p>The problem is that I want some of the listeners to be aware of some of the "stuff" in the other listeners.</p>
<p>I enforce... | <p>You've describing a lot of coupling here. Best would be to eliminate all this back-channel dependency, but failing that maybe you could have those with dependencies listening not on the initial listener list, but on whatever they are dependent on. Or you could have them wait till they have all the signals.</p>
<p>Y... | <p>"How would we change this so that Listener B is Listener A aware? Or not even aware, just somehow coupled?"</p>
<p>You don't often want to couple two "peer" objects like this. You want two peers to depend on something common.</p>
<p>The deeper question is what does Listener A or Listener B do with all the informa... | 34,718 |
<p>Code lines per file, methods per class, cyclomatic complexity and so on. Developers resist and workaround most if not all of them! There is a good <a href="http://www.joelonsoftware.com/items/2006/08/09.html" rel="noreferrer">Joel article</a> on it (no time to find it now).</p>
<p>What code metric(s) you recommend ... | <p>No metrics regarding coding-style are part of such a warning.</p>
<p>For me it is about <strong>static analysis of the code</strong>, which can truly be 'on' all the time:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/105852">cyclomatic complexity</a> (detected by checkstyle)</li>
<li><a href="https://... | <p>This hilarious blog post on <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=215899" rel="nofollow noreferrer">The Code C.R.A.P Metric</a> could be useful.</p>
| 22,683 |
<p>I would like to know the procedure to adopt to parse and obtain text content from Microsoft word (.doc and .docx) documents . programming language used should be plain "C" (should be gcc).</p>
<p>Are there any libraries that already do this job,</p>
<p>extension : can i use the same procedure to parse text from Mi... | <p>You should have a look at C preprocessors that exists traditionaly with databases (<a href="http://www.postgresql.org/docs/8.3/interactive/ecpg.html" rel="nofollow noreferrer">ecpg</a> for postgres, <a href="http://www.cs.umbc.edu/help/oracle8/server.815/a68022/toc.htm" rel="nofollow noreferrer">Pro*C</a> for oracle... | <p>Use SQLAPI++ - it's cross platform and supports MS SQL Server, Oracle, Postgres and others. Very easy to use.</p>
<p><a href="http://www.sqlapi.com/" rel="nofollow noreferrer">http://www.sqlapi.com/</a></p>
| 38,615 |
<p>I just realized that in some place in my code I have the return statement inside the lock and sometime outside. Which one is the best?</p>
<p>1)</p>
<pre><code>void example()
{
lock (mutex)
{
//...
}
return myData;
}
</code></pre>
<p>2)</p>
<pre><code>void example()
{
lock (mutex)
{
... | <p>Essentially, which-ever makes the code simpler. Single point of exit is a nice ideal, but I wouldn't bend the code out of shape just to achieve it... And if the alternative is declaring a local variable (outside the lock), initializing it (inside the lock) and then returning it (outside the lock), then I'd say that ... | <p><sup>Note: I believe this answer to be factually correct and I hope that it is helpful too, but I'm always happy to improve it based on concrete feedback.
</sup></p>
<p>To summarize and complement the existing answers:</p>
<ul>
<li><p>The <a href="https://stackoverflow.com/a/266718/45375">accepted answer</a> shows t... | 33,432 |
<p>A z-axis homing issue is giving me an ulcer. I'm hoping someone can help with this.</p>
<p>As per usual, after the Z endstop is triggered on my TEVO Tarantula the gantry raises a bit then slowly lowers back down to the z=0 point established by the trigger. However, the gantry is now lowering well past the point tri... | <p>The soldering in the Tevo components is very low quality as I replaced/resoldered most of the end-stops.</p>
<p>As the gantry goes down - please ensure that the cable is not pulled over (no contact) and there is contact on the edge of the acrylic and the end-stop, also the small acrylic switch holder could bend/sli... | <p>I'm not familiar with your particular model, so this may not be directly applicable.</p>
<p>For many printer models, a swing thru thingiverse.com will find you a replacement z-stop switch mount that uses a threaded screw to set the z-height at which the microswitch fires. It may well be that you simply need to off... | 1,064 |
<p>When I start Tomcat (6.0.18) from Eclipse (3.4), I receive this message (first in the log):</p>
<blockquote>
<p>WARNING:
[SetPropertiesRule]{Server/Service/Engine/Host/Context}
Setting property 'source' to
'org.eclipse.jst.jee.server: (project name)'
did not find a matching property.</p>
</blockquote>
<p... | <p>The solution to this problem is very simple. Double click on your tomcat server. It will open the server configuration. Under server options check ‘Publish module contents to separate XML files’ checkbox. Restart your server. This time your page will come without any issues.</p>
| <p>I'm finding that Tomcat can't seem to find classes defined in other projects, maybe even in the main project. It's failing on the filter definition which is the first definition in web.xml. If I add the project and its dependencies to the server's launch configuration then I just move on to a new error, all of which... | 13,044 |
<p>I switched my Anet A8 over to a Bowden and it's printing great. Moving that weight off has enabled me to almost double the speed and resonance problems have vanished. </p>
<p>My question is regarding after the print is done should I add a retraction code and back the filament out of the v6 or is it okay to leave it... | <p>It's okay to leave the filament in the hot end, as long as you let it cool down with the hot end cooling fan running.</p>
<hr>
<p><em>From comment:</em></p>
<blockquote>
<p>That's not an issue, you can simply leave it in the hot end. The only "end of print" clogs usually occur when leaving the hot end hot for a... | <p>I agree with towe's answer. I would leave it, retracting at most a mm or two just to avoid a mess. If you retract much at end of print, initial state for the second or later print is different from after just loading new filament, and this leads to different priming/skirt outcomes for the two cases, which can be pro... | 1,518 |
<p>Is it possible to convert UTF8 string in a std::string to std::wstring and vice versa in a platform independent manner? In a Windows application I would use MultiByteToWideChar and WideCharToMultiByte. However, the code is compiled for multiple OSes and I'm limited to standard C++ library.</p>
| <p>I've asked this question 5 years ago. This thread was very helpful for me back then, I came to a conclusion, then I moved on with my project. It is funny that I needed something similar recently, totally unrelated to that project from the past. As I was researching for possible solutions, I stumbled upon my own ques... | <p>I don't think there's a portable way of doing this. C++ doesn't know the encoding of its multibyte characters.<br></p>
<p>As Chris suggested, your best bet is to play with codecvt.</p>
| 17,883 |
<p>For PHP</p>
<p>I have a date I want line wrapped.</p>
<p>I have $date = '2008-09-28 9:19 pm';
I need the first space replaced with a br
to become </p>
<pre><code>2008-09-28<br>9:19 pm
</code></pre>
<p>If it wasn't for that second space before PM, I would just str_replace() it. </p>
| <p>I'd suggest aggregation rather than inheritance here for the relationship between account and profile, but have an Account base class that is inherited into multiple account types.</p>
<p>The account contains a profile object, which can be set in the constructor of each polymorphic account type. </p>
<p>You could ... | <p>thanks for the examples; you may be trying to make this harder than it is. Would the following work?</p>
<pre><code>User <<--> Account
Account <<--> AccountType
Account <--> Profile
Profile <<--> ProfileType
</code></pre>
<p>I question the account-profile 1:1 relationship, it seems... | 23,241 |
<p>When you use Visual Studio's code analysic (FxCop), and want to suppress a message there are 3 options.</p>
<ol>
<li>Suppress a violation in code.</li>
<li>Suppress a violation in a GlobalSupression.cs file.</li>
<li>Disable the violation check in the project file (via Project -> Properties -> Code Analysic).</li>
... | <p>Suppressing multiple violations with a single <strong>SuppressMessage</strong> attribute is officially not supported. Apparently, this is by design.</p>
<p>I agree, it might be annoying at times, but I can't say I disagree with the decision, since the attribute is their way to force you to say, "Yes, I know what I ... | <p>I think things have changed since this question was posted and answered. For Visual Studio 2010 and 2012 you can create a custom "rule set" file where you can specify which code analysis rules you want to suppress. </p>
<p><a href="http://msdn.microsoft.com/en-us/library/dd380660.aspx" rel="nofollow">http://msdn.mi... | 9,844 |
<p>I am creating an RSS reader as a hobby project, and at the point where the user is adding his own URL's.</p>
<p>I was thinking of two things.</p>
<ul>
<li>A plaintext file where each url is a single line</li>
<li>SQLite where i can have unique ID's and descriptions following the URL</li>
</ul>
<p>Is the SQLite id... | <p>What about as an <a href="http://en.wikipedia.org/wiki/Opml" rel="nofollow noreferrer">OPML</a> file? It's XML, so if you needed to store more data then the OPML specification supplies, you can always add your own namespace.</p>
<p>Additionally, importing and exporting from other RSS readers is all done via OPML. ... | <p>If it's a single user application that only has one instance, SQLite might be overkill. </p>
<p>You've got a few options as I see it:</p>
<ol>
<li>SQLite / Database layer. Increases the dependencies your code needs to run. But allows concurrent access </li>
<li>Roll your own text parser. Complexity increases as yo... | 19,684 |
<p>I want to set the <code>include_path</code> variable in my <em>php.ini</em> file (<code>C:\Windows\php.ini</code>).</p>
<p>But, I want different <code>include_path</code> values for different sites hosted on the same Windows server. How can I do this?</p>
| <p><a href="http://php.net/manual/en/configuration.file.php" rel="nofollow noreferrer">http://php.net/manual/en/configuration.file.php</a> says:</p>
<blockquote>
<p>php.ini is searched for in these locations (in order):</p>
<p>. . .</p>
</blockquote>
<p>You can review this list and see if one of the techniques... | <p>Unfortunately, I don't think you can. However, some webservers can change PHP settings on an individual basis... Apache using mod_php has the php_value setting that you can set on various virtual hosts, IIS might have something similar, but I'm not sure.</p>
<p><a href="http://us2.php.net/manual/en/function.set-i... | 45,675 |
<p>I'm working now together with others in a grails project. I have to write some Java-classes. But I need access to an searchable object created with groovy. It seems, that this object has to be placed in the default-package. </p>
<p>My question is: <strong>Is there a way to access this object in the default-package ... | <p><a href="http://mindprod.com/jgloss/import.html" rel="noreferrer">You can’t use</a> classes in the default package from a named package.<br />
(<em>Technically</em> you can, as shown in Sharique Abdullah's <a href="https://stackoverflow.com/a/561183/6309">answer</a> through reflection API, <em>but</em> classes from ... | <p><em>just to complete the idea:</em></p>
<p><strong>From inside</strong> default-package you can access objects resided in named packages.</p>
| 35,995 |
<p>I am trying to accomplish the following in MySQL (see <code>pseudo</code> code)</p>
<pre><code>SELECT DISTINCT gid
FROM `gd`
WHERE COUNT(*) > 10
ORDER BY lastupdated DESC
</code></pre>
<p>Is there a way to do this without using a (SELECT...) in the WHERE clause because that would seem like a waste of resources.... | <p>try this;</p>
<pre><code>select gid
from `gd`
group by gid
having count(*) > 10
order by lastupdated desc
</code></pre>
| <p>i think you can not add <code>count()</code> with <code>where</code>. now see why ....</p>
<p><code>where</code> is not same as <code>having</code> , <code>having</code> means you are working or dealing with group and same work of count , it is also dealing with the whole group , </p>
<p>now how count it is workin... | 38,737 |
<p>So I'm using an IDataReader to hydrate some business objects, but I don't know at runtime exactly what fields will be in the reader. Any fields that aren't in the reader would be left null on the resulting object. How do you test if a reader contains a specific field without just wrapping it in a try/catch?</p>
| <p>This should do the trick:</p>
<pre><code> Public Shared Function ReaderContainsColumn(ByVal reader As IDataReader, ByVal name As String) As Boolean
For i As Integer = 0 To reader.FieldCount - 1
If reader.GetName(i).Equals(name, StringComparison.CurrentCultureIgnoreCase) Then Return True
... | <p>You can't just test reader["field"] for null or DBNull because a IndexOutOfRangeException is thrown if the column isn't in the reader.</p>
<p>The code I use in my mapping layer for creating domain objects and the stored procedures that use the mapping layer might have different column names is below; you could modi... | 7,630 |
<p>Our team has been experiencing a recurring problem with velocity templates. Upon rendering, some throw a RuntimeException with the message "Template.merge() failure - Unable to render Velocity Template, '/template.vm'". We have not been able to reproduce the problem and the documentation on the web is pretty insuffi... | <p>What version of Velocity are you using? There were some race conditions in old versions that caused this. Most were squashed in the Velocity 1.5 release. Though i would personally recommend using Velocity 1.6-beta1. It has vastly improved performance (memory and speed) and a lot of minor bug fixes that didn't ma... | <p>Since the comments in the source already state this shouldn't happen, I think it's a bug in the Template software. Submit a bug report to whoever wrote it.</p>
| 10,043 |
<p>My organization is working on building RESTful webservices on JBoss appserver. The QA team is used to testing SOAP webservices so far using SoapUI. SoapUI has a new version that has REST capabilities. We're considering using that.</p>
<ol>
<li>Are there any publicly available RESTful services available on the net f... | <p><a href="http://www.soapui.org" rel="noreferrer">soapUI</a> will do the job as well, check out <a href="http://www.eviware.com/blogs/oleblog/?p=11" rel="noreferrer">this blog post</a> to get started.</p>
| <p><a href="http://www.oniontest.org" rel="nofollow">OnionTest</a> still beta , but quite useful</p>
| 24,900 |
<p>What options do I have to read the roles of the current user from my JSP pages? I'm aware of the <code>visibleOnUserRole="myRole"</code> attribute on Tomahawk components, but I need roles for a bit more complicated things than simple visibility.</p>
| <p>The <a href="http://docs.oracle.com/javaee/6/api/javax/faces/context/ExternalContext.html" rel="nofollow noreferrer">ExternalContext</a> exposes user and role information.</p>
<pre><code>public class RolesAccess implements Serializable {
public String getUserPrincipalName() {
FacesContext context = Fac... | <p>In Java EE 6 (which wasn't available when this question was asked/answered), you can test roles directly from the <code>request</code> variable in your Facelets code. This is super-convenient.</p>
<p>E.g.</p>
<pre><code><h:outputText value="hi, admin!" rendered="#{request.isUserInRole('Admin')}" />
</code></... | 36,449 |
<p>I have an UPDATE sql command that modifies a Date/Time field in a particular table. This table has two keys, ProductionCode and TestTime, which is what is being modified. The Production Code never changes for a particular record, but often a user will find that they entered the wrong test time and need to change it.... | <p>Add a new column "id" that holds a unique number that can identify each row. If your users need to modify the primary key you have probably not chosen a good primary key?</p>
| <p>I don't know which language you're using, but the way you mention "datagrid" makes me think a .NET language.</p>
<p>Datagrids (and gridviews, etc.) have properties that allow you to set the key to refer back to. Create an autonumber index for your primary key, and use that to refer back to the right record to upda... | 22,649 |
<p>In Python you can use <a href="https://docs.python.org/library/struct.html" rel="noreferrer">StringIO</a> for a file-like buffer for character data. <a href="https://docs.python.org/library/mmap.html" rel="noreferrer">Memory-mapped file</a> basically does similar thing for binary data, but it requires a file that is... | <p>You are probably looking for <a href="http://docs.python.org/release/3.1.3/library/io.html#binary-i-o">io.BytesIO</a> class. It works exactly like StringIO except that it supports binary data:</p>
<pre><code>from io import BytesIO
bio = BytesIO(b"some initial binary data: \x00\x01")
</code></pre>
<p>StringIO will ... | <p>Look at the struct package: <a href="https://docs.python.org/library/struct.html" rel="nofollow noreferrer">https://docs.python.org/library/struct.html</a>, it allows you to interpret strings as packed binary data.</p>
<p>Not sure if this will completely answer your question but you can use struct.unpack() to conve... | 4,472 |
<p>What is the best way to abstract the episerver infrastructure for easier testing?</p>
| <p>I have written a post about <a href="http://marekblotny.blogspot.com/2009/03/tdd-with-episerver.html" rel="noreferrer">TDD with EPiServer</a> recently. </p>
<p>Basically the idea is to use Model-View-Presenter design pattern to isolate as much logic as you can from asp.net runtime. </p>
| <p>Perhaps this post will help: <a href="http://labs.episerver.com/en/Blogs/Cristian-Libardo/Dates/2008/10/R2-and-unit-testing/" rel="noreferrer">EPiServer CMS 5 R2 and unit testing</a></p>
| 40,311 |
<p>Delegates look like such a powerful language feature, but I've yet to find an opportunity to use them in anger (apart from in DALs I must say).</p>
<p>How often do you use them, and under what circumstances do you find them most useful? </p>
| <p>I use C# Delegate the most of time with Event.</p>
<pre><code>public delegate void MyDelegate(object sender, EventArgs e, string otherParameterIWant);
//...Inside the class
public event MyDelegate myEvent;
//...Inside a method
if (myEvent != null)
myEvent(this, new EventArgs(), "Test for SO");
</code></pre>
| <p>I use them the most for callbacks. Instead of objects for callback methods (using interfaces), I can wrap a method in a delegate and pass that on.</p>
| 39,409 |
<p>I want to create a route in my rails application along the lines of</p>
<pre><code>/panda/blog
/tiger/blog
/dog/blog
</code></pre>
<p>where panda, tiger, and dog are all permalinks (for an animal class)</p>
<p>The normal way of doing this</p>
<pre><code>map.resources :animals do |animal|
animal.resource :blog
e... | <p>In rails 3.x, you can add <code>path => ""</code> to any <code>resource</code> or <code>resources</code> call to remove the first segment from the generated path.</p>
<pre><code>resources :animals, :path => ""
</code></pre>
<hr>
<pre><code>$ rake routes
animals GET / {:action=>"... | <p>You can use this plugin:</p>
<p><a href="http://github.com/caring/default_routing/tree/master" rel="nofollow noreferrer">http://github.com/caring/default_routing/tree/master</a></p>
| 21,996 |
<p>I come from a CVS background. I'm currently investigating using SVN for a project. The code that I work on tends to be in the following directory structure.</p>
<blockquote>
<p>project\libs\lib1</p>
<p>project\libs\lib1\test</p>
<p>project\libs\lib1\mock</p>
<p>project\libs\lib2</p>
</blockquote>
... | <p>I don't know if this is the "correct" answer, but I can think of two options.</p>
<p>A. Tag and delete:</p>
<ol>
<li>Tag your /project/libs directory as project-release-1;</li>
<li>Delete "test" and "mock" directories from project-release-1.
Alternatively, first create a project-release-1-with-tests tag with every... | <p>A tag is just a copy like any other copy. So you could create an empty directory in tags, to mark that release, then create two directories inside that--one for the release with tests, and the other for the release without the tests.</p>
| 39,222 |
<p>I have a site map of a few thoasand pages where the only different content on them is the title attribute and the content plotted out in a google map?</p>
<p>Will google punish me for this as spam?</p>
| <p>Google has a specific standard for indexing geo-spatial content which they call a "<a href="http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=94554" rel="nofollow noreferrer">Geo sitemap</a>". It's just an extension of the <a href="http://sitemaps.org/protocol.php" rel="nofollow noreferrer">si... | <p>The common wisdom says 'yes'. Your page rank is a direct representation of the worth of your contribution to the internet. If you're trying to appear like you have more content by creating duplicate, or near duplicate pages, expect to be chastised appropriately. </p>
| 11,811 |
<p>Okay, so this probably sounds terribly nefarious, but I need such capabilities for my senior project. Essentially I'm tasked with writing something that will cut down outbound spam on a zombified pc through a system of packet interception and evaluation. We have a number of algorithms we'll use on the captured messa... | <p>Sounds like you need to write a <a href="http://en.wikipedia.org/wiki/Layered_Service_Provider" rel="nofollow noreferrer">Winsock LSP</a>.</p>
<blockquote>
<p>Once in the stack, a Layered Service Provider can intercept and modify inbound and outbound Internet traffic. It allows processing all the TCP/IP traffic t... | <p>One would think <a href="http://www.wireshark.org/" rel="nofollow noreferrer">Wireshark</a> would solve your problem -- no hassle install and pretty easy to use.</p>
<p>Edit: Ah, I see now the interception requirement vs. just sniffing.. in this case Wireshark alone won't cut it. Probably whatever's the equivalent ... | 10,581 |
<p>When I build a site I tend to do a bit of graphic design (developer style) in Paint.NET, but how do I know the colors will all display properly on all browsers on different machines? What color depth to you generally code for? 16bit 256 colors etc.</p>
| <p>I don't worry about whether the colors will display perfectly everywhere, as even the most basic of cell phones support 16-bit color.</p>
<p>In my opinion, the days of <strong>having</strong> to worry about 'web-safe' colors is mostly over.</p>
<p>As long as you're not using colors incredibly similar to each other... | <p>According to <a href="http://www.w3schools.com/browsers/browsers_display.asp" rel="nofollow noreferrer">w3schools</a> only 2% of visitors still have 256-color displays. If you don't use web colors, they'll just see somewhat different colors from what you intended, so there's not really any reason to stick to <a href... | 24,340 |
<p>To create a playlist for all of the music in a folder, I am using the following command in bash:</p>
<pre><code>ls > list.txt
</code></pre>
<p>I would like to use the result of the <code>pwd</code> command for the name of the playlist.</p>
<p>Something like:</p>
<pre><code>ls > ${pwd}.txt
</code></pre>
<p... | <p>The best way to do this is with <code>"$(command substitution)"</code> (thanks, <a href="https://stackoverflow.com/a/58233/1899640">Landon</a>):</p>
<pre><code>ls > "$(pwd).txt"
</code></pre>
<p>You will sometimes also see people use the older backtick notation, but this has <a href="https://stackoverflow.com/q... | <p>to strip all but the directory name</p>
<pre><code>ls >/playlistdir/${PWD##/*}.txt
</code></pre>
<p>this is probably not what you want because then you don't know where the files are (unless you change the ls command)</p>
<p>to replace "/" with "_"</p>
<pre><code>ls >/playlistdir/${PWD//\//_}.txt
</code></... | 8,260 |
<p>Do you think ASP.NET MVC will ever have a significant share of the Microsoft web development market? Or will it be more like 10-15% of the market?</p>
| <p>Oh yes. It's going to blow web forms out of the water - we've already seen how valuable a true MVC framework can be in the Java world. In the MS world - it's really been a void that has needed to be filled.</p>
<p>As a former Java/Struts dude - I find it pretty frustrating doing current work in web forms - becaus... | <p>I think developers who like that development model will adopt it, but I prefer webforms because the lifecycle provides a great way to create re-usable controls.</p>
<p>And you can also maintain an MVC development style with webforms and be able to create unit tests of all your code, so being testable isn't really a... | 11,444 |
<p>Is there an easy way of programmatically checking if a serial COM port is already open/being used?</p>
<p>Normally I would use:</p>
<pre><code>try
{
// open port
}
catch (Exception ex)
{
// handle the exception
}
</code></pre>
<p>However, I would like to programatically check so I can attempt to use anoth... | <p>I needed something similar some time ago, to search for a device.</p>
<p>I obtained a list of available COM ports and then simply iterated over them, if it didn't throw an exception i tried to communicate with the device. A bit rough but working.</p>
<pre><code>var portNames = SerialPort.GetPortNames();
foreach(v... | <p>You can try folloing code to check whether a port already open or not. I'm assumming you dont know specificaly which port you want to check.</p>
<pre><code>foreach (var portName in Serial.GetPortNames()
{
SerialPort port = new SerialPort(portName);
if (port.IsOpen){
/** do something **/
}
else {
/**... | 23,748 |
<p>I've been doing a massive code review and one pattern I notice all over the place is this:</p>
<pre><code>public bool MethodName()
{
bool returnValue = false;
if (expression)
{
// do something
returnValue = MethodCall();
}
else
{
// do something else
returnVal... | <p>I would have used ternary, to reduce control structures...</p>
<pre>
<code>
return expression ? MethodCall() : Expression;
</code>
</pre>
| <p>They both accomplish the same task. Some say that a method should only have one entry and one exit point. </p>
| 16,902 |
<p>Is there a built in function in .NET 2.0 that will take two arrays and merge them into one array?</p>
<p>The arrays are both of the same type. I'm getting these arrays from a widely used function within my code base and can't modify the function to return the data in a different format.</p>
<p>I'm looking to avoid... | <p>In C# 3.0 you can use LINQ's <a href="https://msdn.microsoft.com/en-us/library/vstudio/bb302894%28v=vs.100%29.aspx" rel="noreferrer">Concat</a> method to accomplish this easily:</p>
<pre><code>int[] front = { 1, 2, 3, 4 };
int[] back = { 5, 6, 7, 8 };
int[] combined = front.Concat(back).ToArray();
</code></pre>
<p... | <p>Try this:</p>
<pre><code>ArrayLIst al = new ArrayList();
al.AddRange(array_1);
al.AddRange(array_2);
al.AddRange(array_3);
array_4 = al.ToArray();
</code></pre>
| 8,376 |
<p>There are a lot of new features that came with the .Net Framework 3.5. Most of the posts and info on the subject list stuff about new 3.5 features and C# 3 changes at the same time. But C# 3 can be used without .Net 3.5. Does anyone know of a good post describing the changes to the language? (Besides the boring, exp... | <p>Update: I can certainly understand.
Eric Lippert has some more indepth posts..<a href="http://blogs.msdn.com/ericlippert/archive/tags/C_2300_/Lambda+Expressions/default.aspx" rel="nofollow noreferrer">Check them out</a>.</p>
<hr>
<p>I liked the series of posts by <a href="http://weblogs.asp.net/scottgu/archive/20... | <p>That's one thing that I would concretely like to know myself. The one thing that I can tell you is that a lot of the new features in C# 3.0 will actually work in a purely 2.0 application if you do multi targeting in VS 2008. I know that extension methods are one such thing.</p>
| 16,652 |
<p>My RubyOnRails app is set up with the usual pack of mongrels behind Apache configuration. We've noticed that our Mongrel web server memory usage can grow quite large on certain operations and we'd really like to be able to dynamically do a graceful restart of selected Mongrel processes at any time.</p>
<p>However, ... | <p>I've done a little more investigation into the Mongrel source and it turns out that Mongrel installs a signal handler to catch an standard process kill (TERM) and do a graceful shutdown, so I don't need a special procedure after all.</p>
<p>You can see this working from the log output you get when killing a Mongrel... | <p>Try using:</p>
<pre><code>mongrel_cluster_ctl stop
</code></pre>
<p>You can also use:</p>
<pre><code>mongrel_cluster_ctl restart
</code></pre>
| 4,740 |
<pre><code>SqlConnection connection = new SqlConnection(FROM_CONFIGURATION)
SqlCommand command = new SqlCommand("SomeSQL", connection);
connection.Open();
command.ExecuteNonQuery();
command.Dispose();
connection.Dispose();
</code></pre>
<p>It is recommended that the code above should include try/catch (or using) ... | <p>As other people here said the GC is non-deterministic, so you don't know when your object will be collected. What I want to clarify is that this is not a problem with the memory, but with the system resources (opened files, database connections) which are expensive and should be released asap. Dispose lets you do th... | <p>GC does take care of disposing objects, but the disposal may not happen right away. Manually disposing the objects will free up memory faster.</p>
| 27,549 |
<p>I am writing unit tests for a class, which has a static final variable.
However, since the state of the static final var is modified in each test, I need some way to reinitialize it.</p>
<p>
How would this be possible? Would i need to use some sort of a custom classloader? </p>
<p>
The variable is initialized as -... | <p>Of course you can hack around it with reflection or class loading, but "if I were you, I wouldn't be starting form here." Mutable statics are really evil (even those called singletons). So, design you code better by "parameterisation from above" - pass object into those that need them, rather than doing something ha... | <p>The only way I can think that a "final" variable is getting modified, through unit tests or otherwise, would be through byte code manipulation.</p>
| 36,901 |
<p>I have my winform application gathering data using databinding. Everything looks fine except that I have to link the <strong>property</strong> with the <strong>textedit</strong> using a string:</p>
<blockquote>
<p>Me.TextEdit4.DataBindings.Add(New System.Windows.Forms.Binding("EditValue", Me.MyClassBindingSource,... | <p>Here is an example of what I'm talking about:</p>
<pre><code>[AttributeUsage(AttributeTargets.Property)]
class TextProperyAttribute: Attribute
{}
class MyTextBox
{
[TextPropery]
public string Text { get; set;}
public int Foo { get; set;}
public double Bar { get; set;}
}
static string GetTextPrope... | <p>You'll have the same problem using reflection because in order to find the right property in all the type's properties, you'll have to know its name, right?</p>
| 18,366 |
<p>Questions like:</p>
<blockquote>
<p><em>x</em> 3d printer is good?</p>
</blockquote>
<p>or</p>
<blockquote>
<p>if it is my first printer, which model would you recommend</p>
</blockquote>
<p>or</p>
<blockquote>
<p>What printer model to buy?</p>
</blockquote>
<p>are on-topic?</p>
<p>I think if you ask</p... | <p>These are shopping questions, plain and simple. They are such obvious <a href="https://en.wikipedia.org/wiki/Broken_windows_theory" rel="nofollow noreferrer">broken windows</a> that it is important that they are closed as quickly as possible.</p>
<p>On <em>Robotics</em> I have the following <a href="https://robotic... | <p>I don't think any of these types of questions should be on-topic. They're all heavily opinion-based. I think even the last one ("What 3D printer can do X?") isn't a good question, because possibly very many printers might be able to do it, and then the answers quickly devolve into subjective recommendations.</p>
<p... | 17 |
<p>I have an incoming project and the only 3D printer available to me is the TronXY X1. </p>
<p>So the question is: Can it handle at least four days of continuous load or should I search for an alternate solution? </p>
<p><em>I don't want to damage (my only) 3D printer for this project.</em></p>
| <p>I have the same Printer - a TronXY X1, and I feel confident that with a little upgrade here and there, it can handle long prints without problems.</p>
<p>The most needed upgrade is a quality power brick. Mine died after some month. For replacement I have chosen a 12 V/10 A output one of a reputable suppli... | <p>I know that this is a bit <em>wishy-washy</em> but some can, some can't.</p>
<p>The TronXY has a bit of an issue with the power supply to start with. The <em>power brick</em> is a (<em>reportedly</em>) bit suspect, for long jobs, see <a href="https://3dprinting.stackexchange.com/questions/5798/ramps-1-4-with-a-powe... | 949 |
<p>I am working on turbo C on windows where char takes one byte.Now my problem is with the below union.</p>
<pre><code>union a
{
unsigned char c:2;
}b;
void main()
{
printf("%d",sizeof(b)); \\or even sizeof(union a)
}
</code></pre>
<p><p>This program is printing output as 2 where as union should be taking only 1 by... | <p>Compilers are allowed to add padding to structs and unions and while, I admit, that it's a little surprising that yours does round up the union to a two byte size when you are able to get a one byte struct it is perfectly allowed.</p>
<p>In answer to your second question: no it's not avoidable. Bit fields are a str... | <p>In addition to the fact that there "there may also be unnamed padding at the end of a structure or union", the compiler is permitted to place a bitfield in "any addressable storage unit large enough to hold a bit-field". (both quotes are from the C90 standard - there is similar, but different, wording tin the C99 s... | 36,936 |
<p>I want to write a default structure, N times, to a file, using fwrite.</p>
<pre><code>typedef struct foo_s {
uint32 A;
uint32 B;
char desc[100];
}foo_t;
void init_file(FILE *fp, int N)
{
foo_t foo_struct = {0};
foo_struct.A = -1;
foo_struct.B = 1;
fwrite(&foo_struct, sizeof(foo_struct), N, f... | <p>You can't with a single fwrite(). You'd have to use a loop:</p>
<pre><code>int i;
for (i = 0; i < N; ++i)
fwrite(&foo_struct, sizeof(foo_struct), 1, fp);
</code></pre>
<p>The third parameter of fwrite() is the number of objects to write, not the number of times to write a single object.</p>
| <p>The only way to do this with a single fwrite is to replicate the foo_struct N times in RAM, then do a single fwrite of all that RAM.</p>
<p>I doubt that doing a malloc, N copies, and then an fwrite would be quicker than just doing N fwrites (this is the only reason I can think of for wanting to do this!), but if yo... | 28,601 |
<p>I want to filter two list with any fastest method in python script. I have used the built-in <code>filter()</code> method for this purpose. but it is quite slow and taking too much time because I have very big list, I think more than 5 million item in each list or may be more.
I do not know how I will make it. Plea... | <p>Maybe your lists are too large and do not fit in memory, and you experience <a href="http://en.wikipedia.org/wiki/Thrash_(computer_science)" rel="nofollow noreferrer">thrashing</a>.
If the sources are in files, you do not need the whole list in memory all at once. Try using <em><a href="https://docs.python.org/2/lib... | <p>I guess filter() is as fast as you can possibly get without having to code the filtering function in C (and in that case, you better code the whole filtering process in C).</p>
<p>Why don't you paste the function you are filtering on? That might lead to easier optimizations.</p>
<p>Read <a href="http://www.python.... | 24,438 |
<pre><code>$fp_src=fopen('file','r');
$filter = stream_filter_prepend($fp_src, 'convert.iconv.ISO-8859-1/UTF-8');
while(fread($fp_src,4096)){
++$count;
if($count%1000==0) print ftell($fp_src)."\n";
}
</code></pre>
<p>When I run this the script ends up consuming ~ 200 MB of RAM after going through just 35MB ... | <p>You only need to register custom filters. iconv is built in. It's not the particular operation, using a stream filter for rot13 exhibits similar behavior.</p>
| <p>From what I'm reading <a href="http://us3.php.net/manual/en/function.stream-filter-register.php" rel="nofollow noreferrer">here</a>, you are not implementing <code>stream_filter_prepend()</code> correctly, although there could be something I misunderstand about the process.</p>
<p>Als, I'm not totally sure, but I'm... | 29,916 |
<p>How would I upload a file to a webserver using c++ and MFC. We are not using .Net. Would I need to open a socket and do everything myself? If so, where is a good reference to follow?</p>
| <p>You don't want to use direct socket calls. It's hard to get HTTP right this way.</p>
<p>The easier way is to the WinINet APIs. Check out the docs for InternetOpen, this will likely be the first call you make. Functions you will likely need:</p>
<ul>
<li>InternetOpen</li>
<li>InternetConnect</li>
<li>HttpOpenReques... | <p>You could use BITS:</p>
<p><a href="http://www.codeproject.com/KB/IP/bitsman.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/IP/bitsman.aspx</a></p>
| 19,224 |
<p>There are lots of PHP articles about the subject so is this a PHP only problem.
I am sending emails using System.Net.Mail after some regular expression checks of course.
Similar to <a href="http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx" rel="noreferrer">http://weblogs.asp.net/scottgu/archive/2005/12/... | <p>the PHP email injection attack works because of a weakness in the PHP Mail() function. As a .net developer you need not worry.</p>
| <p>I've never heard of that issue in ASP.NET. However, you should trust user input about as much as you'd trust a hooker with your wallet.</p>
| 7,856 |
<p>I used code like this to find the remote user name:</p>
<pre><code>banner_label.Text = "Welcome, <B>" + User.Identity.Name + "</B>!"
</code></pre>
<p>I'd also like to find the remote host name.
My production environment will be a corporate intranet with active directory.</p>
| <p>You're on an Intranet, so Request.UserHostName should work well for you. If you have a complex network, some of the routers may not let that info through, but...</p>
<p>Here's something similar I did in an app at a previous job, to record the IP and host name:</p>
<pre><code>// NAT'ed addresses are sometimes still... | <p>maybe this would work for you</p>
<pre><code>Request.UserHostName
</code></pre>
<p>edit:</p>
<p>i think what you're trying to do will not working over the internet, what you're trying to get is the name of the computer, which will not be transmitted with the request to the server.</p>
| 35,651 |
<p>I'm looking for a .NET Add-in that reads in the contents of the Current Document window, lists the header declaration of all Regions, Subs, Functions, and Module Level Variables, and provides a simple Move Up/Move Down buttons to rearrange their order.</p>
| <p>I find that the "File Structure Window" provided by the <a href="http://www.jetbrains.com/resharper/" rel="nofollow noreferrer">Resharper</a> add-in provides most of the features you are looking for. However, it is part of a comprehensive refactoring add-in and this may not suit you.</p>
| <p>Here is an automatic member organisation plugin that will work with <a href="http://www.devexpress.com/Downloads/Visual_Studio_Add-in/DXCore/" rel="nofollow noreferrer">DXCore</a>. You can also see Mark Miller developing this plugin in dnrTV.</p>
<p><a href="http://dnrtv.com/default.aspx?showID=5" rel="nofollow nor... | 24,627 |
<p>Every indication I have, based on my experience in embedded computing is that doing something like this would require expensive equipment to get access to the platform (ICE debuggers, JTAG probes, I2C programmers, etc, etc), but I've always wondered if some ambitious hacker out there has found a way to load native c... | <p>I've seen this question pop up in a number of different forums over time. The original Blackberries were programmable in C++ but I think that RIM ran up against the problems of trying to implement a secure platform in the C/C++ compile to native paradigm. </p>
<p>The devices do have JTAG ports, but unless one could... | <p>Unfortunately the official <a href="http://na.blackberry.com/eng/developers/" rel="nofollow noreferrer">SDK website</a> only seems to mention Java. According to <a href="http://en.wikipedia.org/wiki/BlackBerry#CPU" rel="nofollow noreferrer">wikipedia</a>, different versions of the BlackBerry use different processor... | 16,270 |
<p>How do I download a file from the internet in a Flex based AIR application. </p>
<p>I tried using a file with url set to the address, but I got a file does not exist error when I tried to save it. And it is really hard to google for help on this issue.</p>
| <p>You want to choose from 2 api combos to accomplish this.</p>
<p>Version 1 is URLLoader and FileStream</p>
<p>Using this combination of class, you would load the file from your server in to air via the URLLoader object. This will download the file in to memory and then notify you when the download is complete. Make... | <p>Check out the <code>flash.net.URLRequest</code> class which will help you to download the file.</p>
| 44,592 |
<p>I have a .NET 3.5 Web application on VS 2008 SP1 running on Vista Ultimate 32 SP1. I created an Application under the Default Web Site. So the url to the app is "<a href="http://localhost/mysite" rel="noreferrer">http://localhost/mysite</a>". The application folder is pointing to the solution folder and it is outsid... | <p>For those encountering this with <strong>Visual-Studio 2012 or 2013</strong> and/or <strong>Windows 8 or 10</strong> do the following.</p>
<p>You have to add .Net 3.5 (or 4.5) to your <strong>Turn Windows Features on or off</strong> window. You get to it via:</p>
<blockquote>
<p>Control Panel -> Programs -> Tur... | <p>Have you tried:</p>
<ul>
<li>Turn of UAT</li>
<li>Add the user the website is running under (and/or yourself) to the Debuggers or Administrators group (temporarily)</li>
<li>Turn on IIS logging</li>
</ul>
| 36,633 |
<p>In c (embedded) a plugin can be implemented by defining a function pointer table and an address range that the module can be loaded into.</p>
<p>This requires linker directive to allocate the space and define the location of the function table.</p>
<p>Is there a similar mechanism in HDL / VHDL or Verilog.</p>
<p>... | <p>If you are using Xilinx FPGA's, this can be supported in some of their chips.</p>
<p>See:
<a href="http://www.xilinx.com/publications/xcellonline/xcell_55/xc_reconfig55.htm" rel="noreferrer">Benefits of Partial Reconfiguration with Xilinx</a></p>
<p>--jeffk++</p>
| <p>The feature you're looking for is orthogonal to the domain of VHDL. VHDL allows modules (entities, implemented by architectures), so in theory, yes, this can work. But in practice, it really depends on your running system.</p>
<p>What do you expect to gain by this? Save reconfiguration time?</p>
<p>If you have a s... | 49,946 |
<p>Is there a command or an existing script that will let me view all of a *NIX system's scheduled cron jobs at once? I'd like it to include all of the user crontabs, as well as <code>/etc/crontab</code>, and whatever's in <code>/etc/cron.d</code>. It would also be nice to see the specific commands run by <code>run-par... | <p>You would have to run this as root, but:</p>
<pre><code>for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done
</code></pre>
<p>will loop over each user name listing out their crontab. The crontabs are owned by the respective users so you won't be able to see another user's crontab w/o being them or... | <p>This script outputs the Crontab to a file and also lists all users confirming those which have no crontab entry:</p>
<pre><code>for user in $(cut -f1 -d: /etc/passwd); do
echo $user >> crontab.bak
echo "" >> crontab.bak
crontab -u $user -l >> crontab.bak 2>> > crontab.bak
done
</co... | 16,339 |
<p>The <a href="http://www.cplusplus.com/doc/tutorial/inheritance/" rel="noreferrer">C++ friend keyword</a> allows a <code>class A</code> to designate <code>class B</code> as its friend. This allows <code>Class B</code> to access the <code>private</code>/<code>protected</code> members of <code>class A</code>.</p>
<p>... | <p>Having friends in programming is more-or-less considered "dirty" and easy to abuse. It breaks the relationships between classes and undermines some fundamental attributes of an OO language.</p>
<p>That being said, it is a nice feature and I've used it plenty of times myself in C++; and would like to use it in C# to... | <p>If you are working with C++ and you find your self using friend keyword, it is a very strong indication, that you have a design issue, because why the heck a class needs to access the private members of other class??</p>
| 24,912 |
<p>Having worked with Classic ASP for about 2 years now by creating a few 100 simple web forms I can't see a good reason for switching to .net; however, I'm not that versed in .net so I'm sure I could be missing a few things.</p>
<p>Some points that I often hear around work can be found here: <a href="http://www.packt... | <p>You're missing more than a few things! ASP.NET is orders of magnitudes more productive, robust, and maintainable than old-school ASP ever thought about being. Server side controls, third-party controls, master pages, forms authentication, forms validation, an OO model than encourages appropriate application partitio... | <h2><a href="http://weblogs.asp.net/dwahlin/archive/2009/04/06/5-reasons-you-should-take-a-closer-look-at-asp-net-mvc.aspx" rel="nofollow noreferrer">5 Reasons You Should Take a Closer Look at ASP.NET MVC</a></h2>
| 6,700 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.