instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I have a LINQ to SQL generated class with a readonly property:</p>
<pre><code><Column(Name:="totalLogins", Storage:="_TotalLogins", DbType:="Int", UpdateCheck:=UpdateCheck.Never)> _
Public ReadOnly Property TotalLogins() As System.Nullable(Of Integer)
Get
Return Me._TotalLogins
End Get
End Pr... | <p>Set the existing TotalLogins property as either private or protected and remove the readonly attribute. You may also want to rename it e.g. InternalTotalLogins.</p>
<p>Then create a new property by hand in the partial class that exposes it publically as a read-only property:</p>
<pre><code>Public ReadOnly Property... | <pre><code>Make a second property that is protected or internal(?)
<Column(Name:="totalLogins", Storage:="_TotalLogins", DbType:="Int", UpdateCheck:=UpdateCheck.Never)> _
protected Property TotalLogins2() As System.Nullable(Of Integer)
Get
Return Me._TotalLogins
End Get
Set(byval value as S... | 12,095 |
<p>I have a .NET Framework 2.0 app and would like to use the Windows Imaging Component. Since my application is a WinForms app and will be redistributed to users via an MSI installer I'm trying to figure out the best way to do this.</p>
<p>I see a couple of options:
1) Skip .NET 2.0 and build on .NET 3.0 which include... | <p>WIC is built into Windows Vista so you don't need to distribute it for Vista machines. For XP it is available as download from Microsoft <a href="http://www.microsoft.com/downloads/details.aspx?familyid=8E011506-6307-445B-B950-215DEF45DDD8&displaylang=en" rel="nofollow noreferrer">here</a>.</p>
| <p>I'm not familiar with WIC but can you just set the Copy Local property on the reference to true? I would assume that the needed assembly would then be available to you when you create your MSI.</p>
<p>My solution would probably just be to build on the newer framework. I believe MSI can be setup to install it if n... | 29,326 |
<p>When you subscribe to an event on an object from within a form, you are essentially handing over control of your callback method to the event source. You have no idea whether that event source will choose to trigger the event on a different thread.</p>
<p>The problem is that when the callback is invoked, you cannot... | <p>To simplify Simon's code a bit, you could use the built in generic Action delegate. It saves peppering your code with a bunch of delegate types you don't really need. Also, in .NET 3.5 they added a params parameter to the Invoke method so you don't have to define a temporary array.</p>
<pre><code>void SomethingHa... | <p>In many simple cases, you can use the MethodInvoker delegate and avoid the need to create your own delegate type.</p>
| 2,799 |
<p>I'm working with a team that's building an engine for a variety of 2D and eventually 3D mini-games. The problem we're facing is a solid, cross-platform, sound API. Obviously, DirectX is out of the question due to our needs for cross-platform capabilities. SDL is nice, and works great, but let's face it SDL_Mixer is ... | <p><em>(note: I have experience with FMOD, BASS, OpenAL and DirectSound; and while I list other libraries below, I haven't used them).</em></p>
<p><a href="http://www.un4seen.com/" rel="noreferrer">BASS</a> and <a href="http://www.fmod.org/" rel="noreferrer">FMOD</a> are both good (and actually I liked FMOD's document... | <p>I can vouch for FMOD as well, it's used quite a extensively in game development due to the tools and excellent multi-platform support. It's designers are really a bliss to work with. Thing is though, it requires an expensive license for commercial development.</p>
| 11,585 |
<p>When compiling the following simpleType with the XJC compile (from the JAXB package)...</p>
<pre><code><xs:simpleType name="test">
<xs:annotation>
<xs:appinfo>
<jaxb:typesafeEnumClass/>
</xs:appinfo>
</xs:annotation>
<xs:restriction base... | <p>There's nothing in the JAXB spec that seems to allow this change. I think the only way to do this would be to write a JAXB Plugin.</p>
| <p>you could create a small variant of the generated class that only differs from the generated one for the name of this method. then at runtime, you have to make sure your variant is loaded instead of the generated one, playing the classloader game.</p>
<p>Of course, this can only work is the original XSD doesn't cha... | 26,825 |
<p>I have an MS Access database, how can I determine which encoding characters are used in the database?</p>
| <p>ACCESS databases all use UTF-8 encoding since (at least) version 2000</p>
| <p>ACCESS databases all use UTF-8 encoding since (at least) version 2000</p>
| 10,671 |
<p>I cannot understand the Oracle documentation. :-(</p>
<p>Does anybody know how to fetch multiple rows of simple data from Oracle via OCI?</p>
<p>I currently use <code>OCIDefineByPos</code> to define single variables (I only need to do this for simple integers -- <code>SQLT_INT</code>/4-byte ints) and then fetch a ... | <p>Unless you're using <code>LPSTR_TEXTCALLBACK</code>, the tree-view control is responsible for allocating the memory, not your code, so you shouldn't change the value of the <code>pszText</code> pointer.</p>
<p>To change the item's text in your <code>TVN_ENDLABELEDIT</code> handler, you can use <code>TreeView_SetIte... | <p>You don't want to directly edit the text in the TVITEM struct, the results are undefined. Instead, use the TVM_SETITEM message, or equivalently, use the TreeView_SetItem() macro defined in windowsx.h.</p>
| 12,639 |
<p>Over the years, I have tried many times to find a good, easy to use, cross platform tool for some basic software system diagramming. The UML tools I have tried seemed to get in my way more than help. So far, the solution I keep returning to is Visio, which is both Windows-only and expensive. Although its far from... | <p>You could try DIA, though it is a bit basic it will keep out of your way when doing pure diagrams.</p>
<p><a href="http://www.gnome.org/projects/dia/" rel="noreferrer">http://www.gnome.org/projects/dia/</a></p>
| <p><a href="http://www.magicdraw.com/" rel="nofollow noreferrer">MagicDraw</a> is quite good IMHO.</p>
| 15,660 |
<p>I need to get the number of digits containing the number 1. I know in java I can take the input as a <code>String</code> and use <code>charAt</code>, but I understand there is no implicit String function in C. How can I accomplish this?</p>
| <p>Division and modulus are your friends.</p>
<pre><code>#include "stdio.h"
int main(){
int digits[] = {0,0,0,0,0,0,0,0,0,0};
int i = 11031;
while(i > 0){
digits[i % 10]++;
i = i / 10;
}
printf("There are %d ones.\n", digits[1]);
}
</code></pre>
| <p>Something along the lines of:</p>
<pre><code>int val=11031;
int count=0;
int i=0;
char buf[100];
sprint(buf, "%d", val);
for(i=0; (i < sizeof(buf)) && (buf[i]); i++) {
if(buf[i] == '1')
count++;
}
</code></pre>
| 9,177 |
<p>Is anyone successfully using the CJ web services? I just keep getting <code>java.lang.NullPointerException</code>s even though my app is .net (clearly their errors). CJ support doesn't even know what a web service is. I googled and found many people getting this or other errors. Question is: is it a temporary proble... | <p>I have successfully used CJ's API with PHP, though not this particular WSDL. I am seriously troubled by the lack of documentation and even cannot find any serious programmer using it (all amateurs basically trying to copy-paste). If you have some more experience we may be able to help each other out. </p>
| <p>I can make a user interface for you to lift your curse !!!</p>
<p>To use Daily Publisher Commission Report Service !!</p>
<p>Let me know here if you still need help.</p>
| 17,681 |
<p>How can you join between a table with a sparse number of dates and another table with an exhaustive number of dates such that the gaps between the sparse dates take the values of the previous sparse date?</p>
<p>Illustrative example:</p>
<pre><code>PRICE table (sparse dates):
date itemid price
2008-12-04 ... | <p>This isn't as simple as a single LEFT OUTER JOIN to the sparse table, because you want the NULLs left by the outer join to be filled with the most recent price.</p>
<pre><code>EXPLAIN SELECT v.`date`, v.volume_amt, p1.item_id, p1.price
FROM Volume v JOIN Price p1
ON (v.`date` >= p1.`date` AND v.item_id = p1.it... | <pre><code> SELECT Volume.date, volume.itemid, price.price, volume.volume_amt
FROM Volume
LEFT OUTER JOIN Price
ON Volume.date = Price.date
</code></pre>
<p>Probably. My SQL-fu is weak</p>
| 49,584 |
<p>I have just started authoring web pages for use on "smart phones". I need to target Blackberry, WinCE, iPhone, etc. What resources or books would you recommend for someone with ample web and software development experience but no experience developing UI for these devices? What emulation kits would you recommend,... | <p>Check out <a href="http://wurfl.sourceforge.net/index.php" rel="nofollow noreferrer"><strong>WURFL - the Wireless Universal Resource File</strong></a></p>
<blockquote>
<p>The WURFL is an XML configuration file
which contains information about
capabilities and features of many
mobile devices.</p>
<p>The... | <p>Telling us the language you are using/know would be very helpful.</p>
<p>From an emulator standpoint, there are good ones out there, but honestly NOTHING beats having the actual device, yes it is expensive, but the user experience on a mobile device is much different than any emulator can illustrate. if you are se... | 18,740 |
<p>Upon a click on an IMG, I would like to get to the next subsequent DIV so that the DIVs content can either be displayed or hidden depending on its current display state.</p>
<p>This is an HTML snippet:</p>
<pre><code><div>
<span class="expand"><img src="images/plus.gif"></span>
<span... | <p>Here's a working example:</p>
<pre><code><script type="text/javascript" src="../jquery-1.2.6.min.js"></script>
<div>
<span class="expand"><img src="x.jpg"></span>
<span>Subject Heading</span>
</div>
<div class="record hidden">Display or Hide this text... | <p>You have several options:</p>
<pre><code>$('.expand').click(function () {
$(".record").toggle();
});
</code></pre>
<p>or</p>
<pre><code>$('.expand').click(function () {
$(".record").slideToggle("slow");
});
</code></pre>
<p>Though if you're going to be targeting the next div based on it's relevance to the cl... | 33,876 |
<p>I am developing an ASP.NET mobile website using .NET 3.5 and mobile controls that come with the framework. I have a login form where the system will authenticate the user so he/she can access certain restricted pages. </p>
<p>In a standard ASP.NET website, I can use a session to store some flag after a user had log... | <p>Session variables are stored in the server so you can forget the device browser capabilities.</p>
<p>I've not practice developing for mobile device, but 4 years ago I was using a service that used cookie authentication and the phone was not top-notch so... I think you can take for granted the cookie availability. F... | <p><p>You can indeed support cookie authentication but the only guaranteed way for it to work is to attach the cookie ID as part of the URL i.e. cookieless sessions. Yes, this is bad practice as it's ugly and very insecure and all modern phones support cookies.</p> <p>But some devices have cookie limitations and, what'... | 10,714 |
<p>I'm using hibernate 3 and want to stop it from dumping all the startup messages to the console. I tried commenting out the stdout lines in log4j.properties but no luck. I've pasted my log file below. Also I'm using eclipse with the standard project structure and have a copy of log4j.properties in both the root of th... | <p>Try to set more reasonable logging level. Setting logging level to <code>info</code> means that only log event at <code>info</code> or higher level (<code>warn</code>, <code>error</code> and <code>fatal</code>) are logged, that is <code>debug</code> logging events are ignored.</p>
<pre><code>log4j.logger.org.hibern... | <p>Replace slf4j-jdk14-xxx.jar with slf4j-log4j12-xxx.jar. If you have both, delete slf4j-jdk14-xxx.jar. Found this solution at <a href="https://forum.hibernate.org/viewtopic.php?f=1&t=999623" rel="nofollow">https://forum.hibernate.org/viewtopic.php?f=1&t=999623</a></p>
| 40,130 |
<p>From browsing on this site and elsewhere, I've learned that serving websites as XHTML at present <a href="http://hixie.ch/advocacy/xhtml" rel="nofollow noreferrer">is considered harmful</a>.</p>
<p>Delivering XHTML and serving it as <code>application/xhtml+xml</code> isn't supported by the majority of people browsi... | <p>In HTML you won't be able to insert SVG directly. </p>
<p>You can embed SVG files with <code><object></code>/<code><embed></code> and in cutting-edge browsers (Opera, Safari) also <code><img></code> and CSS <code>background-image</code>.</p>
<p>You can put SVG in <code>data:</code> URI to avoid u... | <p>You may (read I haven't tried this myself) to use an embedded object and type it accordingly.</p>
| 11,253 |
<p>I am trying to guarantee the integrity of a file after download. I store the MD5 of the file in database and compare that MD5 to the file after it is downloaded. However, I always get different MD5 results when I hash the file after it is downloaded. I am wondering if the byte array that is being hashed contains the... | <p>The MD5 hash is calculated on the file contents, and is not affected by document metadata. It is a deterministic process that will always produce the same result, if you start with the same content (although, there are ways to fake an MD5 signature due to collision).</p>
<p>How are you creating the MD5 hash for th... | <p>If im not totally wrong here the md5 hash is only working on the actual data not the timestamps and other metadata. Maybe you are transfering text-files with ftp, in that case the ftpclient might rewrite the newline characters to fit your system and then the hash will be diffrent</p>
| 36,715 |
<p>Just about every piece of example code everywhere omits error handling (because it "confuses the issue" that the example code is addressing). My programming knowledge comes primarily from books and web sites, and you seldom see any error handling in use at all there, let alone good stuff.</p>
<p>Where are some plac... | <p>Herb Sutter's and Andrei Alexandrescu's book <a href="http://www.gotw.ca/publications/c++cs.htm" rel="noreferrer">C++ Coding Standards</a> comes with a whole chapter on <em>Error Handling and Exceptions</em> including</p>
<ul>
<li>Assert liberally to document internal assumptions and invariants</li>
<li>Establish a... | <p>With C++, you should end up with less visible error handling code anyway, because you can leave a lot of the heavy lifting to Exceptions.</p>
<p>In my opinion the most basic rule with exceptions (and one most commonly broken) is this.
<strong><em>Don't try to catch exceptions unless you have a specific plan to hand... | 28,608 |
<p>Trying to make a pure css dropdown list that works well, and can't find any good resources.</p>
| <p><a href="http://www.alistapart.com" rel="noreferrer">A List Apart</a> is a great resource, here's their take: <a href="http://www.alistapart.com/articles/horizdropdowns/" rel="noreferrer">Drop-Down Menus, Horizontal Style</a></p>
| <ul>
<li><a href="http://pixelspread.com/blog/289/css-drop-down-menu" rel="nofollow noreferrer">pixelspread: CSS Drop Down Menu</a></li>
</ul>
| 49,291 |
<p>For testing purposes I need to get my Outlook 2003 addin (vb.net) disabled so that it can only be reactivated through the help menu or by deleting the resilency key from within the registry.</p>
<p>I tried to achieve this by creating an unhandled invalid cast exception during the startup eventhandler but this does ... | <p>I found a simple way by myself:</p>
<ul>
<li>Set a breakpoint within the startup eventhandler of the addin. </li>
<li>Start the addin from within the visual studio in debug mode. </li>
<li>As the breakpoint is reached open the Taskmanager.</li>
<li>Kill the Outlook process.</li>
<li>Start Outlook normaly (not from ... | <p>Another operation can be during startup call something like</p>
<p><code>System.Threading.Thread.Sleep(10000)</code></p>
<p>during this kill outlook from the task manager.</p>
<p>When you start outlook next time, it will ask you if you want to disable the addin.</p>
| 44,786 |
<p>Is it possible to turn off all HTML formatting in Visual Studio 2008? It just totally messes everything up. For example, I'll add a grid with columns, styles, etc. with them all indented and on separate lines. I'll switch to design view or split view and all the work I just did is on one line! It is so frustrating.<... | <p>There are some formatting options under <em>Tools-->Options-->Text Editor-->HTML-->Format</em>
while there doesn't seem to be an option to turn it off, there may be something there to define how you want it to format.</p>
<p>To reformat the document hit (<kbd>CTRL</kbd>+<kbd>K</kbd>,<kbd>CTRL</kbd>+<kbd>... | <p>Don't use design view. A good asp.net developer doesn't need it. It only brings with it more headaches than benefits.</p>
| 33,261 |
<p>Using the following query:</p>
<pre><code> SELECT pe.prodtree_element_name_l, MAX(rs.resource_value) AS resource_value
FROM prodtree_element pe
LEFT JOIN resource_shortstrings rs
ON pe.prodtree_element_name_l_rk = rs.resource_key
WHERE rs.language_id = '5'
AND pe.prodtree_element_name... | <p>This will get the first random entry</p>
<pre><code>SELECT DISTINCT
pe.prodtree_element_name_l,
(SELECT TOP 1 rs2.resource_value
FROM resource_shortstrings rs2
WHERE rs2.language_id = '5'
AND rs2.resource_key = pe.prodtree_element_name_l_rk) AS "resource_value"
FROM prodtree_element pe
LEFT... | <pre><code> SELECT pe.prodtree_element_name_l, MAX(CAST(rs.resource_value AS NVARCHAR(MAX))) AS resource_value
FROM prodtree_element pe
LEFT JOIN resource_shortstrings rs
ON pe.prodtree_element_name_l_rk = rs.resource_key
WHERE rs.language_id = '5'
AND pe.prodtree_element_name_l <> ''... | 25,726 |
<p>This is rather the inverse of <a href="https://stackoverflow.com/questions/102535/what-can-you-use-python-generator-functions-for">What can you use Python generator functions for?</a>: python generators, generator expressions, and the <code>itertools</code> module are some of my favorite features of python these day... | <p><strong>Use a list instead of a generator when:</strong></p>
<p>1) You need to access the data <strong>multiple</strong> times (i.e. cache the results instead of recomputing them):</p>
<pre><code>for i in outer: # used once, okay to be a generator or return a list
for j in inner: # used multipl... | <p>A generator builds and enumerable list of values. enumerables are useful when iterative process can use the values on demand. It takes time to build your generator, so if the list is millions of records in size, it may be more useful to use sql server to process the data in sql.</p>
| 30,493 |
<p>When <strong>Eclipse</strong> creates a new file (<strong>.c</strong> or <strong>.h</strong> file) in a C project the editor always auto creates a <code>#define</code> at the top of the file like this: If the file is named 'myCFile.c' there will be a <code>#define</code> at the start of the file like this</p>
<pre>... | <p>It's to guard against <a href="http://www.fredosaurus.com/notes-cpp/preprocessor/ifdef.html" rel="nofollow noreferrer">multiple definitions</a>.</p>
| <p>I think it's a throwback of C include issues, where multiple copies of the source would get included - unless you are meticulous with include chains (One file includes n others).
Checking if a symbol is defined and including only if the symbol is defined - was a way out of this.</p>
| 5,845 |
<p>What's the best way of implementing a multiple choice option in Windows Forms? I want to enforce a single selection from a list, starting with a default value.</p>
<p>It seems like a ComboBox would be a good choice, but is there a way to specify a non-blank default value?<br>
I could just set it in the code at some... | <p>If you only want one answer from the group, then a RadioButton control would be your best fit or you could use the ComboBox if you will have a lot of options. To set a default value, just add the item to the ComboBox's collection and set the SelectedIndex or SelectedItem to that item.</p>
<p>Depending on how many ... | <p>If you are giving the user a small list of choices then stick with the radio buttons. However, if you will want want to use the combo box for dynamic or long lists. Set the style to DropDownList.</p>
<pre><code>private sub populateList( items as List(of UserChoices))
dim choices as UserChoices
dim defaultChoi... | 3,543 |
<p>I am making an HTTP connection to an IIS web server and sending a POST request with the data encoded using Transfer-Encoding: chunked. When I do this, IIS simply closes the connection, with no error message or status code. According to the <a href="https://www.rfc-editor.org/rfc/rfc2616#section-3.6.1" rel="nofollow ... | <p>My understanding is that chunked encoding can only be used in a HTTP response. A chunked request body would have the property of being incompatible with a 1.0 server, and in any case, there would be no way of a user-agent knowing that the server was a 1.0 server until it had already sent the request.</p>
<p>But I a... | <p>My only guess is they did not implement it out of concerns for security. In a naive solution it would be easy to set up a DOS attack by starting multiple chunked transfers that never end. And a complex solution which could account for the DOS attack is probably not worth the effort. </p>
<p>Of course I cannot speak... | 43,961 |
<p>I'm building an install using VS 2003. The install has an Excel workbook and two Access databases. I need to force the Access files to load regardless of the create/mod date of the existing databases on the user's computer. I currently use ORCA to force in a Version number on the two files, but would like to find a ... | <p>@LanceSc</p>
<p>I don't think MsiFileHash table will help here. See this <a href="http://blogs.msdn.com/astebner/archive/2005/08/30/458295.aspx" rel="nofollow noreferrer" title="How Windows Installer handles file replacement logic for versioned and unversioned files">excellent post</a> by Aaron Stebner. Most likely... | <p>Since it sounds like you don't have properly versioned resources, have you tried changing the REINSTALLMODE property?</p>
<p>IIRC, in the default value of 'omus', it's the 'o' flag that's only allowing you to install if you have an older version. You may try changing this from 'o' to 'e'. Be warned that this will... | 12,789 |
<p>I have got a simple contacts database but I'm having problems with users entering in duplicate data. I have implemented a simple data comparison but unfortunately the duplicated data that is being entered is not exactly the same. For example, names are incorrectly spelled or one person will put in 'Bill Smith' and a... | <p>You can compare the names with the <a href="http://en.wikipedia.org/wiki/Levenshtein_distance" rel="noreferrer">Levenshtein distance</a>. If the names are the same, the distance is 0, else it is given by the minimum number of operations needed to transform one string into the other.</p>
| <p>You might also want to look into probabilistic matching. </p>
| 5,143 |
<p>Is there a simple way to drop a group of interrelated tables in SQL Server? Ideally I'd like to avoid having to worry about what order they're being dropped in since I know the entire group will be gone by the end of the process.</p>
| <p>At the risk of sounding stupid, I don't believe SQL Server supports the delete / cascade syntax. I think you can configure a delete rule to do cascading deletes (<a href="http://msdn.microsoft.com/en-us/library/ms152507.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms152507.aspx</a>), but a... | <p>I don't have access to SQL Server to test this, but how about:</p>
<pre><code>DROP TABLE IF EXISTS table1, table2, table3 CASCADE;
</code></pre>
| 2,905 |
<p>What memory leak detectors have people had a good experience with?</p>
<p>Here is a summary of the answers so far:</p>
<p><a href="http://valgrind.org/" rel="noreferrer">Valgrind</a> - Instrumentation framework for building dynamic analysis tools.</p>
<p><a href="http://directory.fsf.org/project/ElectricFence/" r... | <p>second the <a href="http://valgrind.org/" rel="noreferrer">valgrind</a>... and I'll add <a href="http://directory.fsf.org/project/ElectricFence/" rel="noreferrer">electric fence</a>.</p>
| <p>I'll second the valgrind as an external tool for memory leaks.<br>
But, for most of the problems I've had to solve I've always used internally built tools. Sometimes the external tools have too much overhead or are too complicated to set up.</p>
<p>Why use already written code when you can write your own :)</p>
<... | 7,686 |
<p>Following are the PHP code lines which I am using to open a PDF file:</p>
<pre><code>$pdf_generartor = new PDFlib();
$doc = $pdf_generartor -> open_pdi_document("Report.pdf", "") or die ("ERROR: " . $pdf_generartor -> get_errmsg());
</code></pre>
<p>Though the file is at required location, every time I rece... | <p>I know it's a bit overdue, but I ran into this problem myself and managed to "fix" it. Apparently the PDF lib doesn't understand relative paths very well, so you'll have to use realpath().</p>
<p>When you take a look at the samples, you can do this in two ways. You can either use realpath() with the actual file pat... | <p>Try to give a file from a different path, even mentioning the directory:</p>
<pre><code> $doc = $pdf_generartor->open_pdi_document("D:\\Report.pdf", "") or die ("ERROR:")
</code></pre>
| 46,820 |
<p>My boss is bidding on a project to convert a desktop application into one that runs online as a client-server application. The original app has a little more than a quarter of a million lines of C++ (MFC) code that's not cleanly divided between engine and front-end.</p>
<p>I need to come up with estimates of how lo... | <p>I would take a very long time, as most likely, you would have to change languages. It would basically be a complete rewrite. You may even just be better off defining what the old system did, and rewrite it from scratch, only referring to the old code when you need to duplicate business logic.</p>
| <p>Without a clear division between the engine and the front-end, it's a bad idea. Giving over the code to a contractor or such would require a large amount of training just to understand the code, including parts that are meant to be rewritten as web apps.</p>
<p>You would first need to estimate how long it would tak... | 29,861 |
<p>Let's say I have the following <code>class X</code> where I want to return access to an internal member:</p>
<pre><code>class Z
{
// details
};
class X
{
std::vector<Z> vecZ;
public:
Z& Z(size_t index)
{
// massive amounts of code for validating index
Z& ret = vecZ[i... | <p>For a detailed explanation, please see the heading "Avoid Duplication in <code>const</code> and Non-<code>const</code> Member Function," on p. 23, in Item 3 "Use <code>const</code> whenever possible," in <a href="https://www.aristeia.com/books.html" rel="noreferrer"><em>Effective C++</em>, 3d ed<... | <p><a href="http://www.ddj.com/cpp/184401331" rel="nofollow noreferrer">This DDJ article</a> shows a way using template specialization that doesn't require you to use const_cast. For such a simple function it really isn't needed though.</p>
<p>boost::any_cast (at one point, it doesn't any more) uses a const_cast from ... | 15,050 |
<p>I would need to create a temp table for paging purposes. I would be selecting all records into a temp table and then do further processing with it.</p>
<p>I am wondering which of the following is a better approach:</p>
<p>1) Select all the columns of my Primary Table into the Temp Table and then being able to sele... | <p>If you have a non-trivial amount of rows (more than 100) than a table variable's performance is generally going to be worse than a temp table equivalent. But test it to make sure.</p>
<p>Option 2 would use less resources, because there is less data duplication.</p>
<p>Tony's points about this being a dirty read are ... | <p>This is exactly the approach I use for Paging on the server,</p>
<p>Create a Table Variable (why incur the overhead of transaction logging ?) With just the key values. (Create the table with an autonum Identity column Primary Key - this will be RowNum. )</p>
<p>Insert keys into the table based on users sort/filt... | 45,978 |
<p>I have an onclick handler for an <a> element (actually, it's a jQuery-created handler, but that's not important). It looks like this:</p>
<pre><code>function handleOnClick() {
if(confirm("Are you sure?")) {
return handleOnClickConfirmed();
}
return false;
}
</code></pre>
<p>From this fun... | <p>The following ought to do it:</p>
<pre><code>function handleOnClick() {
if( confirm( "Sure?" ) ) {
return handleOnClickConfirmed.call( this );
}
return false;
}
</code></pre>
<p>The <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function/call" rel="norefe... | <p>Rob's answer is the best answer for your problem, but I wanted to address something that you wrote in your original question:</p>
<blockquote>
<p>I know I can pass this as an argument to handleOnClickConfirmed, but some of my code already uses handleOnClickConfirmed and I don't want to have to rewrite those calls... | 42,080 |
<p>I need to make a random list of permutations. The elements can be anything but assume that they are the integers 0 through x-1. I want to make y lists, each containing z elements. The rules are that no list may contain the same element twice and that over all the lists, the number of times each elements is used i... | <p>This could be improved, but it seems to do the job (Python):</p>
<pre><code>import math, random
def get_pool(items, y, z):
slots = y*z
use_each_times = slots/len(items)
exceptions = slots - use_each_times*len(items)
if (use_each_times > y or
exceptions > 0 and use_each_times+1 >... | <p>Ok, one way to approximate that:</p>
<p>1 - shuffle your list</p>
<p>2 - take the y first elements to form the next row</p>
<p>4 - repeat (2) as long as you have numbers in the list</p>
<p>5 - if you don't have enough numbers to finish the list, reshuffle the original list and take the missing elements, making s... | 11,886 |
<p>I want to be able to run my SqlDataProvider against an oracle stored procedure. I can use Microsoft's Oracle Provider but that wouldn't allow me to call a stored procedure. has anyone been able to get this to work? I particularly want to be able to use declarative data binding. I have been able to programatically cr... | <p>SqlDataProvider, SqlConnection and other classes prefixed Sql from the System.Data namespaces almost universally refer to SQL-Server specific implementations. It is, however, possible to invoke a Stored Procedure using the System.Data.oracleClient library Microsoft have released.</p>
<p>Please ensure that when cons... | <p>Here are the steps to return a table-like select statement::</p>
<p>1) You should return a cursor for the select, then add in the parameters io_cursor IN OUT CURSOR</p>
<p>2) When you Consume it add ANOTHER parameter </p>
<pre><code><asp:Parameter Name="io_cursor" Direction="Output" />
</code></pre>
<p... | 46,145 |
<p>I read that you could call JavaScript code from a Java Applet by calling</p>
<pre><code>JApplet.getAppletContext().showDocument( "javascript:alert('Hello World');" );
</code></pre>
<p>However, when I do this i get the following error:</p>
<pre><code>java.net.MalformedURLException: unknown protocol: javascript
</c... | <p>I get the same exception as you do because of that the URL class does not accept javascript: as a valid protocol.</p>
<p>There is a workaround though; supply an URLStreamHandler to the URL constructor.</p>
<p>Example:</p>
<pre><code>final URLStreamHandler streamHandler = new URLStreamHandler() {
@Override
... | <pre><code> try {
this.getAppletContext().showDocument(new URL("javascript:alert('hello world');"));
}catch(Exception e) {
e.printStackTrace();
}
</code></pre>
<p>Works !! </p>
<p>Maybe the browser does not have javascript enabled.. just a guess</p>
| 20,916 |
<p>I use [Dllimport("DllName.dll")]
where I'm sure a path to my dll exists in the process PATH environment variable, and still
I get "DllName.dll could not be found"</p>
| <p>"DllName.dll could not be found" could also mean that DllImport has not found one of DllName.dll dependencies.</p>
<p>Grab <a href="http://www.dependencywalker.com/" rel="noreferrer">Dependecy Walker</a> to check which dependecy you are missing.</p>
| <p>I'd suggest you to use FileMon (sysinternals.com) to check if your assumptions about the library location are right.</p>
| 37,540 |
<p>I'm using MSVE, and I have my own tiles I'm displaying in layers on top. Problem is, there's a ton of them, and they're on a network server. In certain directories, there are something on the order of 30,000+ files. Initially I called Directory.GetFiles, but once I started testing in a pseudo-real environment, it ti... | <p>I've worked on a SAN system in the past with telephony audio recordings which had issues with numbers of files in a single folder - that system became unusable somewhere near 5,000 (on Windows 2000 Advanced Server with an application in C#.Net 1.1)- the only sensible solution that we came up with was to change the f... | <p>None. .NET relies on underlying Windows API calls that really, really hate that amount of files themselves.</p>
<p>As Ronnie says: split them up.</p>
| 2,562 |
<p>Edit: This code is fine. I found a logic bug somewhere that doesn't exist in my pseudo code. I was blaming it on my lack of Java experience.</p>
<p>In the <strong>pseudo code</strong> below, I'm trying to parse the XML shown. A silly example maybe but my code was too large/specific for anyone to get any real val... | <p>The code looks fine to me. I say set breakpoints at the start of each function and watch it in the debugger or add some print statements. My gut tells me that either <code>characters()</code> is not being called or <code>setColor()</code> and <code>setAge()</code> don't work correctly, but that's just a guess.</p>... | <p>I have to say that I'm not a big fan of this design.
However, are you sure that your characters is ever called ? (maybe a few system.outs would help). If it's never called, you would end up with an uninitialized cow.</p>
<p>Also, I would not try to implement an XML parser myself like this since you need to be more ... | 29,399 |
<p>I just tried FxCop. It does detect unused private methods, but not unused public. Is there a custom rule that I can download, plug-in that will detect public methods that aren't called from within the same assembly?</p>
| <p>Corey, my answer of using FxCop had assumed you were interested in removing unused private members, however to solve the problem with other cases you can try using <a href="http://www.ndepend.com/" rel="nofollow noreferrer">NDepend</a>. Here is some CQL to detect unused public members (adapted from an article listed... | <p>How would it know that the public methods are unused?</p>
<p>By marking a method as public it can be accessed by any application which references your library.</p>
| 9,703 |
<p>At the moment, I am doing a number of searches which include "html" in them, for example "html rearrange". Unfortunately, I get a lot of hits from sites that include "rearrange" on a .html page but have no mention of html in the page itself.</p>
<p>Is there a way to prevent search terms from matching urls?</p>
| <p>try something like</p>
<p>"html rearrange -inurl:html"</p>
<p>the inurl means "match the following pattern in the URL", the - means to exclude those pages</p>
| <p>-inurl:(htm|html) "search term"</p>
<p>Good luck!</p>
| 12,693 |
<p>I have a window which overrides a <code>RadioButton</code>'s <code>ControlTemplate</code> to show a custom control inside of it. Inside the custom control, I have a button's visibility tied to <code>IsMouseOver</code>, which works correctly in showing the button only when the mouse is hovering over the control. Howe... | <p>I seemed to have fixed the problem by setting a trigger in the control template, which binds to the RadioButton's IsMouseOver, and sets a custom DependencyProperty on the UserControl. </p>
<p>Something like: </p>
<pre><code><ControlTemplate TargetType="{x:Type RadioButton}">
<WPFTest:TestUC x:Name="UC... | <p>Very interesting problem. I myself would like to know more of why the UserControl IsMouseOver changes to false when the TextBlock(s) in its visuals are mouse downed upon.</p>
<p>However, here is another way to solve it ... maybe you will like this approach better.</p>
<p><strong>Instead of using RadioButton (since... | 32,318 |
<p>I am building a Flex Application that calls a .aspx page on the same webserver which builds a PDF report using SQL Reporting Services. When the report is built it prompts the user to open or save the PDF.</p>
<p>We are trying to find a way to display a Progress Bar to let the user know that the report they requeste... | <p>There are 2 options:</p>
<ol>
<li>Use the <code>FileReference</code> class in Flex to programmatically invoke your aspx file. You will be able to track the progress of the call from within Flex by listening to its events. But the users can only save the PDF, not open it.</li>
<li>Have an intermediate HTML page that... | <p>If you don't have control over the page to be able to put JavaScript on it to hit a URL (or call back to the parent/opener), then you might consider whipping up an aspx page of your own to host a ReportViewer control, and display the report inside of that. This would require you to create a .NET website with a page... | 29,100 |
<p>How do I check if the directory into which a file is going to be written does exist, and if it does not, create the directory using Python?</p>
| <p>On Python ≥ 3.5, use <a href="https://docs.python.org/library/pathlib.html#pathlib.Path.mkdir" rel="noreferrer"><code>pathlib.Path.mkdir</code></a>:</p>
<pre><code>from pathlib import Path
Path("/my/directory").mkdir(parents=True, exist_ok=True)
</code></pre>
<p>For older versions of Python, I see two answers with... | <p>This may not exactly answer the question. But I guess your real intention is to create a file and its parent directories, given its content all in 1 command.</p>
<p>You can do that with <code>fastcore</code> extension to pathlib: <code>path.mk_write(data)</code></p>
<pre class="lang-py prettyprint-override"><code>fr... | 34,408 |
<p>Should be simple and quick: I want a C# equivalent to the following Java code:</p>
<pre><code>orig: for(String a : foo) {
for (String b : bar) {
if (b.equals("buzz")) {
continue orig;
}
}
// other code comes here...
}
</code></pre>
<hr>
<p><strong><em>Edit</em></strong>:
OK it seems there is n... | <p>I don't believe there's an equivalent, I'm afraid. You'll have to either use a boolean, or just "goto" the end of the inside of the outer loop. It's even messier than it sounds, as a label has to be applied to a statement - but we don't want to do anything here. However, I think this does what you want it to:</p>
<... | <p>I think you're looking for the simple "continue" keyword... However, not being a Java guy I don't really get what the code snippet is trying to achieve.</p>
<p>Consider the following, though.</p>
<pre><code>foreach(int i in new int[] {1,2,3,5,6,7})
{
if(i % 2 == 0)
continue;
else
Console.W... | 46,886 |
<p>I am trying to get a header that will work with Apache, IIS 6, and IIS 7. I won't go into the reason for that here. Let's just say that it's not as easy as I thought it would be :-)</p>
<p>Anyway, the problem has something to do with NPH. In our code (originally written for IIS 6) we have</p>
<pre><code>use CGI... | <p>I'd just create a subroutine that does the right thing depending on the server. You know what you have to do in each case, so just do that in that case.</p>
<p>The other option is to patch CGI.pm to set its $CGI::NPH variable correctly by looking at the server type. CGI.pm already has the basics there. Once you fix... | <p>I'd just create a subroutine that does the right thing depending on the server. You know what you have to do in each case, so just do that in that case.</p>
<p>The other option is to patch CGI.pm to set its $CGI::NPH variable correctly by looking at the server type. CGI.pm already has the basics there. Once you fix... | 43,132 |
<pre><code>class MyBase
{
protected object PropertyOfBase { get; set; }
}
class MyType : MyBase
{
void MyMethod(MyBase parameter)
{
// I am looking for:
object p = parameter.PropertyOfBase; // error CS1540: Cannot access protected member 'MyBase.PropertyOfBase' via a qualifier of type 'MyB... | <p>No, you can't do this.</p>
<p>You're only allowed to access protected members of objects of the accessing type (or derived from it). Here, we don't know whether the parameter is of type MyType or SomeOtherCompletelyDifferentType.</p>
<p>EDIT: The relevant bit of the C# 3.0 spec is section 3.5.3:</p>
<blockquote>
... | <p>As you are inheriting from MyBase, you can access all fields/properties/methods from it marked as "protected" using the "base" keyword.</p>
<pre><code>public class MyBase
{
protected object PropertyOfBase { get; set; }
}
public class MyType : MyBase
{
void MyMethod()
{
object p = base.Property... | 44,811 |
<p>I have a table called ApprovalTasks... Approvals has a status column</p>
<p>I also have a view called ApprovalsView</p>
<p>When I try a straight update :</p>
<pre><code>update ApprovalTasks set Status = 2 where ApprovalTaskID = 48
</code></pre>
<p>I'm getting this error message: </p>
<pre><code>Msg 2601, Level ... | <p>look at the definition of the index IX_ApprovalTaskID
Is it possible there is a unique key constraint on ApprovalTaskID, StatusID which would mean there is another row in the table with Status = 2 & ApprovalTaskID = 48 </p>
<p>I agree with user Learning, it looks like there's a FOR UPDATE trigger on ApprovalTa... | <p>It looks like a view has been created which is either of, or includes, the table you are updating and that the error occurs when the view is being updated with the changes.</p>
<p>Perhaps the view contains data from different tables which is incompatible, or has stricter constraints set?</p>
| 46,804 |
<p>Anybody found yet a good web site architecture using linq to sql? Any help will be very helpful!</p>
| <p>We just finished up an internal IT project banking heavily on Linq2Sql and it paid off. I was a bit skeptical at first, but I think it worked out great in the end. Just remember, the fundamentals don't change.</p>
<ol>
<li>try to stay as stateless as possible</li>
<li>keep clean lines between your services and da... | <p>Remember Linq is a technology that sits atop the typical data access structures. Therefore all rules that have applied thus far still hold. Just because you can get to data a little easier in the client app doesnt mean you throw out the architecture best practices for data access. </p>
| 12,180 |
<p>How can I find any unused functions in a PHP project?</p>
<p>Are there features or APIs built into PHP that will allow me to analyse my codebase - for example <a href="http://ie.php.net/manual/en/language.oop5.reflection.php" rel="noreferrer">Reflection</a>, <a href="http://php.net/manual/en/function.token-get-all.... | <p>Thanks Greg and Dave for the feedback. Wasn't quite what I was looking for, but I decided to put a bit of time into researching it and came up with this quick and dirty solution:</p>
<pre><code><?php
$functions = array();
$path = "/path/to/my/php/project";
define_dir($path, $functions);
reference... | <p>afaik there is no way. To know which functions "are belonging to whom" you would need to execute the system (runtime late binding function lookup). </p>
<p>But Refactoring tools are based on static code analysis. I really like dynamic typed languages, but in my view they are difficult to scale. The lack of safe re... | 3,263 |
<p>I'm doing some research into databases and I'm looking at some limitations of relational DBs. </p>
<p>I'm getting that joins of large tables is very expensive, but I'm not completely sure why. What does the DBMS need to do to execute a join operation, where is the bottleneck?<br>
How can denormalization help to ove... | <p>Denormalising to improve performance? It sounds convincing, but it doesn't hold water.</p>
<p>Chris Date, who in company with Dr Ted Codd was the original proponent of the relational data model, ran out of patience with misinformed arguments against normalisation and systematically demolished them using scientific ... | <p>Elaborating what others have said,</p>
<p>Joins are just cartesian products with some lipgloss. {1,2,3,4}X{1,2,3} would give us 12 combinations (nXn=n^2). This computed set acts as a reference on which conditions are applied. The DBMS applies the conditions (like where both left and right are 2 or 3) to give us the... | 20,932 |
<p>Is it possible for a client to pass an RMI object as an argument to an EJB so that the
EJB may callback the client? </p>
| <p>You'd need to pass the connection details in the call to the EJB and have the EJB make a connection to the client-side RMI server.</p>
<p>My advise would be to use messaging and a temporary queue for the asynchronous behaviour it sounds like you're trying to achieve...</p>
| <p>No. Remote objects cannot be serialized and moved to other locations, since the connection to the remote object itself is transient in nature. </p>
<p>It may be possible to use some kind wrapper object that can be serialized and will reestablish the RMI connection once sent to the EJB.</p>
| 45,497 |
<p>For a project we're currently working on, we need a library of spoken words in many different languages. </p>
<p>Two options seem possible: text-to-speech or "real" recordings by native speakers. As the quality is important to us, we're thinking about going the latter path. </p>
<p>In order to create a prototype f... | <p>A co-worker just found this community based library, which is nice, but rather small in size:</p>
<p><a href="http://www.forvo.com/" rel="nofollow noreferrer">Forvo.com</a></p>
| <p>One I use to use a lot: <a href="http://shtooka.net/index.php" rel="nofollow noreferrer">http://shtooka.net/index.php</a>
Easy access to the recordings.</p>
| 17,321 |
<p>Does any one know how can I convert a BSTR to an int in VC++ 2008</p>
<p>Thanks in advance.</p>
| <p>You can <a href="https://stackoverflow.com/questions/71980/how-do-you-efficiently-copy-bstr-to-wchart">pass a BSTR safely</a> to any function expecting a <code>wchar_t *</code>. So you can use <a href="http://msdn.microsoft.com/en-us/library/yd5xkb5c(VS.80).aspx" rel="nofollow noreferrer">_wtoi</a>().</p>
| <p>You should use <a href="http://msdn.microsoft.com/en-us/library/ms221194.aspx" rel="nofollow noreferrer">VarI4FromStr</a> like others pointed out. <code>BSTR</code> is not <code>wchar_t*</code> because of differences in their <a href="http://blogs.msdn.com/ericlippert/archive/2003/09/12/52976.aspx" rel="nofollow nor... | 20,291 |
<p>In Eclipse, its easy to specify buttons for your toolbar using the ActionSets extension point. However, when I need to specify some items programmatically, I can't get the same look. I don't believe that the framework is using native buttons for these, but so far, I can't find the right recipe to match the Eclipse... | <p>It's difficult to tell from your question, but it sounds like you may be attempting to add a ControlContribution to the toolbar and returning a Button. This would make the button on the toolbar appear like a native button like you seem to be describing. This would look something like this:</p>
<pre><code>IToolBarMa... | <p>Could you perhaps put in an extract of the code you have for adding actions programmatically to the toolbar? I assume you do this in an <strong>ApplicationActionBarAdvisor</strong> class? Their should be no difference in the look of buttons you add declaratively vs those you add programatically. </p>
| 19,258 |
<p>Is it possible is asp to detect from the MobileCapabilities object if the device support arabic or not</p>
| <p>Yes, you can check the Accept-Language HTTP header for "ar" for arabic.</p>
<p>For example this real sample:</p>
<pre><code>Accept-Language: en;q=1.0,fr;q=0.5,ar;q=0.5
</code></pre>
<p>Says, <strong>en</strong> (English) is accepted with a 100% quality, but you can give <strong>fr</strong> (French, France) too wi... | <p>You can use the Accept-Language header. It works for at least some phones. My Nokia bought from an Israli operator sends out:</p>
<pre><code>Accept-Language: he-IL
</code></pre>
<p>You can access it from Request.Headers.</p>
<p>Hope this helps,<br />
Asaf</p>
| 49,487 |
<p>I need to draw gridlines on the background of a canvas that will have other controls placed on it. </p>
<p>I tried creating a StreamGeometry, using that to draw lines, and getting that assigned to a DrawingBrush. However I find that if the StreamGeometry has too many lines, the program becomes sluggish after the Dr... | <p>My advice would be to keep the primitive count down. You're making WPF spend CPU cycles and bandwidth creating and sending that massive grid to the render thread and GPU.</p>
<p>DrawingBrush is a <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.tilebrush.aspx" rel="noreferrer">TileBrush</a>.</p... | <p>One solution is to override OnRender(DrawingContext dc) method on the panel and draw the lines in there. </p>
<p>Another option is to have a lightweight visual element that draws the lines. This element should be added to the visual tree of the panel. The standard WPF Grid control uses a similar approach to draw li... | 40,260 |
<p>Does updating statistics cause tables to be inaccessible? In other words, can you run this procedure without downtime? </p>
<p>Specifically for SQL Server 2005</p>
| <p>No (it doesn't make them inaccessible), and Yes (you can run it without downtime).</p>
<p>sp_updatestats can be run against a live database without downtime.</p>
| <p>In SQL Server 2000, you can run this procedure without causing downtime. I doubt that has changed in later versions. </p>
| 38,987 |
<p>How do I register a custom protocol with Windows so that when clicking a link in an email or on a web page my application is opened and the parameters from the URL are passed to it?</p>
| <ol>
<li><p>Go to <code>Start</code> then in <code>Find</code> type <code>regedit</code> -> it should open Registry editor</p>
</li>
<li><p>Click <kbd>Right Mouse</kbd> on <code>HKEY_CLASSES_ROOT</code> then <code>New</code> -> <code>Key</code></p>
</li>
</ol>
<p><a href="https://i.stack.imgur.com/9boI6.png" rel=... | <p>There is an npm module for this purpose.</p>
<p>link :<a href="https://www.npmjs.com/package/protocol-registry" rel="nofollow noreferrer">https://www.npmjs.com/package/protocol-registry</a></p>
<p>So to do this in nodejs you just need to run the code below:</p>
<p>First Install it</p>
<pre><code>npm i protocol-regis... | 10,614 |
<p>I'm using ADO.NET dataservices in a Silverlight application and since the silverlight libraries don't support the ToList() call on the IQueryable I thought it might be possible to create an extension method around this called SilverlightToList(). So in this method I'm calling the BeginExecute method on my context as... | <p>I've since found <a href="http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3981405&SiteID=1" rel="nofollow noreferrer">this post</a> on the MSDN forum which says that any managed->UnManaged->Managed marshalling happens on the UI thread which explains why the WaitOne method call is hanging...</p>
| <p>Silverlight probably isn't going to like synchronous anything, because it's intended to run in the browser, and it only can have one thread to play with - and it has to share that. And the only thread available for the host is the one provided by the browser.</p>
| 45,788 |
<p>I am looking into an image processing problem for semi-real time detection of certain scenarios. My goal is to have the live video arrive as Motion JPEG frames in my Java code <em>somehow</em>. </p>
<p>I am familiar with the <a href="http://java.sun.com/javase/technologies/desktop/media/jmf/" rel="noreferrer">Jav... | <p>This JavaCV implementation works fine.</p>
<p><strong>CODE:</strong></p>
<pre><code>import com.googlecode.javacv.OpenCVFrameGrabber;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
public class CaptureImage {
private static void captureFrame() ... | <p>Have you ever looked at <a href="http://processing.org/" rel="nofollow noreferrer">Processing.org</a>? It's basically a simplified application framework for developing "artsy" applications and physical computing platforms, but it's based on Java and you can dig down to the "real" Java underneath.</p>
<p>The reason ... | 14,119 |
<p>Does anyone know if it is possible to display a prompt to a user/administrator when activating or installing a sharepoint feature? </p>
<p>I am writing a custom webpart and it is connecting to a separate database, I would like to allow the administrator to select or type in a connection string when installing the ... | <p>Unfortunately there is no way to swap to a screen where you can get user via the feature activation process. Couple of comments for you:</p>
<ol>
<li>I'm assuming the connection string is going to be different for every installation, so there is no way you can include it directly in the Solution. </li>
<li>I'm assu... | <p>Sounds good. I will look at these possible solutions.</p>
<p>I do not think #1 will work since I am deploying multiple webparts inside a single solution which all use the same connectionString.</p>
<p>#3 sounds like a very clean solution. I see the config items are cached so it looks like if I need to store a co... | 3,033 |
<p>After a brownout a print failed and it got the whole hotend covered in PLA. I am now in the process of replacing some parts on the hotend (one of the thermistor legs broke of) and also wanted to take the heater cartridge out. The problem is that the bolt that locks the heater cartridge is stuck and I am now afraid t... | <h1>Don't Panic!</h1>
<p>First of all, a printhead caked in PLA is usually not a death sentence, it is often a temporary setback. Let's start in steps!</p>
<h2>Step 1: remove the extruder</h2>
<p>We want to work on the hotend, so we remove the extruder feed first. For direct drive, we unload it, then remove it dependin... | <p>If you use a brass heating block (which is a bit heavier than aluminum), you can first use a heat gun to soften the residues to remove the cartridge/sensor.</p>
<p>After removing all electronics, you can use a gas torch and burn the residues off. However, the far best option would be to use a heat block made of sta... | 1,174 |
<p>I'm trying to create some skinned forms (just the border and caption) with a different approach than you usually see but I'm having some issues with form flickering while I resize the form.</p>
<p>I don't know how else to explain the problem, so here's a video I created to demonstrate the problem:
<a href="http://w... | <p>(This is a Vista-specific solution; it only works when desktop compositing is enabled.)</p>
<p>It looks like Windows initializes the contents of resized forms by copying the pixels on the form's original border over to the new areas. In your case, the new areas are initialized black likely because the form origina... | <p>Tried enabling DoubleBuffering ?</p>
| 41,154 |
<p>I've been reading up on Linux's "swappiness" tuneable, which controls how aggressive the kernel is about swapping applications' memory to disk when they're not being used. If you Google the term, you get a lot of pages like <a href="http://www.debian.co.nz/Tweak+your+swappiness.html" rel="nofollow noreferr... | <blockquote>
<p>If I have an inactive application that's using a ton of memory, why doesn't the kernel page its memory to disk AND leave another copy of that data in-memory?</p>
</blockquote>
<p>Lets say we did it. We wrote the page to disk, but left it in memory. A while later another process needs memory, so we wa... | <p>The first thing the VM does is clean pages and move them to the clean list.<br>
When cleaning anonymous memory (things which do not have an actual file backing store, you can see the segments in /proc//maps which are anonymous and have no filesystem vnode storage behind them), the first thing the VM is going to do i... | 17,711 |
<p>I have a mysql database which has grown to over 200 tables in it. I know this isn't a performance problem, but most admin tools I have aren't organized well enough to manage this number of tables easily, and I am thinking of putting some (new) tables into a 2nd database just for my own sanity.</p>
<p>Has anyone els... | <p>Personally, as along as all the tables in the database are for the same application, I would recommend keeping them in the same database. If you run into performance problems, you should get more hardware. The most important reason not to split them up, is that no matter how much you think there is a partition in t... | <p>If you want to start moving some things out to a second database make sure to do it with purpose. I do this when I realize some of the data will be reference data for several projects I'm working on. It becomes my "reference" database.</p>
<p>Then my database list would look something like the following:<br>
proje... | 36,811 |
<p>Say I've got a generic vertical market application and I want to package it as two separate programs aaa.exe and bbb.exe. Is there any way to use the Delphi linker to create an EXE/DLL file that doesn't have the same name as the DPR? </p>
<p><b>I can't just rename the file</b> because I get this error </p>
<pre>
... | <p>Delphi 2007 and Delphi 2009 both use MSbuild. You can use post-build events in MSbuild to do almost anything you want. You could, for example, use the Copy task to copy the EXE into a new filename.</p>
| <p>Or you could have the program examine it's own exe name when you run it. If it is not aaa.exe or bbb.exe then have it copy itself into those two names and terminate (or launch them!) </p>
| 47,114 |
<p>I have a HTML report, which needs to be printed landscape because of the many columns. It there a way to do this, without the user having to change the document settings?</p>
<p>And what are the options amongst browsers.</p>
| <p>In your CSS you can set the @page property as shown below. </p>
<pre><code>@media print{@page {size: landscape}}
</code></pre>
<p>The @page is part of <a href="http://www.w3.org/TR/CSS21/page.html#page-box" rel="noreferrer">CSS 2.1 specification</a> however this <code>size</code> is not as highlighted by the answe... | <p>You can try the following:</p>
<pre class="lang-css prettyprint-override"><code>@page {
size: auto
}
</code></pre>
| 16,760 |
<p>I have a database table (sql server 2008) that I want to view data for, what is the quickest way of displaying this data?</p>
<p>(if it could have paging that would be perfect).</p>
<p>Would it be a gridview or ?</p>
<p>query: select * from testData</p>
| <p>if you're using .NET 3.5 you could use ASP.NET Dynamic Data:</p>
<p><a href="http://www.asp.net/dynamicdata/" rel="nofollow noreferrer">http://www.asp.net/dynamicdata/</a></p>
<p>Hope this helps!</p>
| <p>Use LinqToSql and bind the results to a grid view.</p>
| 36,199 |
<p>I have a form with a progress bar and a cancel button which is displayed as a process runs. The buttons "Cancel" property is set to true so pressing escape, cancels the process.</p>
<p>But, as the button is the only control on the form capable of taking the focus, should the user inadvertently press enter (or space... | <p>In my opinion, the Enter key <strong>should activate</strong> the cancel button. Or are you requiring the user to reach out for the mouse? why?</p>
<p>I suggest adding just a confirmation dialog after the user cancels the operation, so if anyone accidentally presses the Enter key have the chance to resume saying 'n... | <p>In my opinion, the Enter key <strong>should activate</strong> the cancel button. Or are you requiring the user to reach out for the mouse? why?</p>
<p>I suggest adding just a confirmation dialog after the user cancels the operation, so if anyone accidentally presses the Enter key have the chance to resume saying 'n... | 19,469 |
<p>I know this will be a really obvious question to some people, but I have bricked about 3 boards doing this so I want to be certain before I brick a fourth. I don't have a lot of experience working with AC voltage, especially crimping / hacking it like what's going on here. Trust me it was my last resort to ask this.... | <p>In effect, the ground (from mains) does not need to be connected to the relay, the relay interrupts the "hot" or "neutral" (preferably the "hot", but that is not possible for all plugs, e.g. some European plugs can be inserted 180° turned into the sockets). You connect one of the interrupted wires to the <code>C... | <p>Let's look at the notes on the relay first, as these tell us what to connect the terminals to.</p>
<h2>Powered side</h2>
<ul>
<li><code>NO</code>/<code>NC</code> - Normally Open/Normally Closed lead. Which you use determines the switching behavior: open line on signal (NC) or closed line on signal (NO). Connect th... | 1,500 |
<p>I'm using the following logon trigger on an Oracle 10.2 database:</p>
<pre><code>CREATE OR REPLACE TRIGGER AlterSession_trg
AFTER LOGON ON DATABASE
BEGIN
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_COMP=LINGUISTIC';
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_SORT=BINARY_AI';
END AlterSession_trg;
</code></pre>
<p>T... | <p>Oracle SQL Developer is changing the NLS parameters based on the preferences. (Tools -> Preferences... -> Database -> NLS Parameters)</p>
<p>Probably your .NET application is also changing the NLS parameters, overwriting your trigger settings.</p>
<p>Have you tried setting <code>NLS_COMP</code> and <code>NLS_SORT<... | <p>Just as an FYI, you'll need to be careful about manipulating session variables in order to handle case-insensitive search.</p>
<p>If you issue queries across a db-link to a database instance that is Oracle version 9.2 or earlier with these session variables, you'll get ORA-00600 errors because the session variable ... | 38,801 |
<p>What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if <code>http://somedomain/foo/</code> will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without havin... | <p><strong>edit</strong>: This answer works, but nowadays you should just use the <a href="http://docs.python-requests.org/en/latest/index.html" rel="noreferrer">requests</a> library as mentioned by other answers below.</p>
<hr>
<p>Use <a href="https://docs.python.org/2/library/httplib.html" rel="noreferrer">httplib<... | <p>Probably easier: use urllib or urllib2.</p>
<pre><code>>>> import urllib
>>> f = urllib.urlopen('http://google.com')
>>> f.info().gettype()
'text/html'
</code></pre>
<p>f.info() is a dictionary-like object, so you can do f.info()['content-type'], etc.</p>
<p><a href="http://docs.python.... | 13,289 |
<p>This is more of an generic XML Schema question, but if and how do you specify
field dependencies in an XML Schema. For example, how would I say fieldB is
required, if fieldA is provided ???</p>
| <p>You can download <a href="http://downloads.channel.aol.com/browser" rel="noreferrer">AOL Explorer</a> by itself.</p>
| <p>I found the accepted answer linked through to the generic downloads location, you can go directly to the product here: <a href="http://info.aol.co.uk/browser/" rel="nofollow">http://info.aol.co.uk/browser/</a></p>
| 35,639 |
<p>I'm working with a client to plan the topology for a public facing SharePoint internet site. </p>
<p>The SharePoint installation will live in the client's DMZ and the plan is to use an existing SQL Server machine to host the SharePoint databases. </p>
<p>The problem is that there is no domain in the DMZ - and the ... | <p><a href="http://blogs.msdn.com/fooshen/archive/2007/02/01/installing-moss-without-ad.aspx" rel="nofollow noreferrer">No. Mostly.</a></p>
| <p>It is possible because it works this way here in the company I work.</p>
<p>We basically have an user account with the same name on the 2 servers (web front end server and SQL database server). This account has access to the database.</p>
| 47,852 |
<p>Is there a way to specify a one dimensional array in a ini file. </p>
<p>so in my ini I would like to do</p>
<p>someproperty = [array of something]</p>
<p>I am using <code>Zend_Config_Ini</code> config adapter (I prefer ini for base configuration). </p>
| <pre><code>someproperty[] = a
someproperty[] = b
someproperty[] = c
someproperty[] = d
someproperty[] = e
</code></pre>
<p>see: <a href="http://us.php.net/manual/en/function.parse-ini-file.php#75983" rel="noreferrer">http://us.php.net/manual/en/function.parse-ini-file.php#75983</a></p>
| <p>You can use separators to make further sub-sections, and they are presented as either another level of objects ($config->some->a) or with $config->toArray(), they can be turned into a multi-level array.</p>
<p>Combining both the above techniques to make arrays, and the separators like so:</p>
<pre><code>some.a[] =... | 43,947 |
<p>Delphi 2009 has changed its string type to use 2 bytes to represent a character, which allows support for unicode char sets. Now when you get sizeof(string) you get length(String) * sizeof(char) . Sizeof(char) currently being 2. </p>
<p>What I am interested in is whether anyone knows of a way which on a characte... | <p>You could check the value of the character:</p>
<pre><code>if ord(c) < 128 then
// is an ascii character
</code></pre>
| <p>An ASCII character always fits in one byte. You can't say the same for a unicode character since that depends how it is encoded. You can't see from a single byte if it is an ASCII or unicode character or if it is a character at all for that matter. So what is your question again? And why do you need to know? My gues... | 23,133 |
<p>I have a long running function in MATLAB that I tried to speed up by adding caching and wound up slowing down my performance significantly. My code is basically searching for continuous "horizontal" lines in an edge detected image and the original code looks something like this:</p>
<pre><code>function lineLength ... | <p>I'm pretty sure the global is not the problem, but as a matter of style, you should use a <code>persistent</code>, which maintains it's value from call to call, but is local to the function. </p>
<p>Anytime you have performance problems, profile. Call <code>profile on</code>, then your function, then <code>profil... | <p>My guess is that you're caching the wrong part of your code. The recursion in the elseif part seems to be the real bottleneck. The whole algorithm looks a bit strange to me, perhaps you should better try something like this (although I don't know for sure if this is what you want):</p>
<pre><code>for every pixel p ... | 48,088 |
<p>I have some SQL Server DTS packages that import data from a FoxPro database. This was working fine until recently. Now the script that imports data from one of the FoxPro tables bombs out about 470,000 records into the import. I'm just pulling the data into a table with nullable varchar fields so I'm thinking it ... | <p><a href="http://www.cmstory.com/_cm/CMrepair.zip" rel="nofollow noreferrer">Cmrepair</a> is an excellent freeware utility to repair corrupted .DBF files.</p>
| <p>@Lance:</p>
<p>if you have access to Visual FoxPro command line window, type:</p>
<pre><code>SET TABLEVALIDATE 11
USE "YourTable" EXCLUSIVE && If the table is damaged VFP must display an error here
PACK && To reindex the table and deleted "marked" records
PACK MEMO && If you have m... | 3,151 |
<p>Does anybody recommend a design pattern for taking a binary data file, parsing parts of it into objects and storing the resultant data into a database? </p>
<p>I think a similar pattern could be used for taking an XML or tab-delimited file and parse it into their representative objects.</p>
<p>A common data struc... | <ol>
<li>Just write your file parser, using whatever techniques come to mind</li>
<li>Write lots of unit tests for it to make sure all your edge cases are covered</li>
</ol>
<p>Once you've done this, you will actually have a reasonable idea of the problem/solution.</p>
<p>Right now you just have theories floating aro... | <p>The Strategy pattern is maybe one you want to look at. The strategy being the file parsing algorithm.</p>
<p>Then you want a separate strategy for database insertion.</p>
| 3,276 |
<p>I want to load one or more DLLs dynamically so that they run with a different security or basepath than my main application. How do I load these DLLs into a separate AppDomain and instantiate objects from them?</p>
| <p>More specifically</p>
<pre><code>AppDomain domain = AppDomain.CreateDomain("New domain name");
//Do other things to the domain like set the security policy
string pathToDll = @"C:\myDll.dll"; //Full path to dll you want to load
Type t = typeof(TypeIWantToLoad);
TypeIWantToLoad myObject = (TypeIWantToLoad)domain.Cr... | <p>Create a new Appdomain with AppDomain.Create( ... ).
After creating the AppDomain load the DLLs into that AppDomain.</p>
<p>Look into all the methods that Appdomain has with Create*. There are certain things like CreateInstanceAndUnwrap, etc.</p>
| 11,438 |
<p>I have a Coupon table. A Coupon can be applicable to certain items only or to a whole category of items.</p>
<p>For example: a 5$ coupon for a Pizza 12" <strong>AND</strong> (1L Pepsi <strong>OR</strong> French fries)</p>
<p>The best I could come up with is to make a CouponMenuItems table containing a coupon_id an... | <p>Often, you can simplify this kind of thing by using <a href="http://mathworld.wolfram.com/DisjunctiveNormalForm.html" rel="nofollow noreferrer">Disjunctive Normal Form</a>.</p>
<p>You normalize your logic into a series disjunctions -- "or clauses". Each disjunct is set of "and clauses". </p>
<p>So your rules bec... | <p>You could treat individual items as their own group (1 member) and just implement pure logic to map coupons to groups.</p>
| 27,948 |
<p>I am writing a C# control that wraps DirectX 9 and provides a simplified interface to perform 2D pixel level drawing. .NET requires that I wrap this code in an unsafe code block and compile with the allow unsafe code option.</p>
<p>I'm locking the entire surface which then returns a pointer to the locked area of me... | <p>Using unsafe pointers is the fastest way to do direct memory manipulation in C# (definitely faster than using the Marshal wrapper functions).</p>
<p>Just out of curiosity, what sort of 2D drawing operations are you trying to perform?</p>
<p>I ask because locking a DirectX surface to do pixel level manipulations wi... | <p>I recently was tasked with creating a simple histogram control for one of our thin client apps (C#). The images that I was analyzing were about 1200x1200 and I had to go the same route. I could make the thing draw itself once with no problem, but the control needed to be re-sizable. I tried to avoid it, but I had... | 7,982 |
<p>I am looking for something to integrate to my CI workflow.<br>
I've heard of <a href="http://dbdeploy.com" rel="noreferrer">dbdeploy</a> but I'm looking for something else. The reason I don't like dbdeploy is I don't want to install java on my server.</p>
<p>I would prefer of course that the solution doesn't involv... | <p><a href="http://flywaydb.org"><strong>Here</strong></a> is a <strong>feature comparison</strong> between</p>
<ul>
<li>Flyway</li>
<li>Liquibase</li>
<li>c5-db-migration</li>
<li>dbdeploy</li>
<li>mybatis</li>
<li>MIGRATEdb</li>
<li>migrate4j</li>
<li>dbmaintain</li>
<li>AutoPatch</li>
</ul>
| <p>Visual Studio Team system (database edition) does some refactoring.</p>
<p>I read the Refactoring databases book. I think it's helpful.</p>
<p>But in software dev, you build tests so that you are safe refactoring. They don't touch on tests in the Refactoring Databases book, which was my big disappointment with i... | 4,730 |
<p>Does anyone know of such a library that performs mathematical optimization (linear programming, convex optimization, or more general types of problems)? I'm looking for something like MATLAB, but with the ability to handle larger problems. Do I have to write my own implementations, or buy one of those commercial pro... | <p>A good answer is dependent on what you mean by "convex" and "more general" If you are trying to solve large or challenging linear or convex-quadratic optimization problems (especially with a discrete component to them), then it's hard to beat the main commercial solvers, <a href="http://www.gurobi.com" rel="nofollo... | <p>Look into <a href="http://www.AMPL.com" rel="nofollow noreferrer" title="A Mathematical Programming Language">AMPL</a>. The basic edition is free, but it costs money for larger problems. You don't pay for the language; you pay for solvers. It is also possible to upload your code and have it run on their servers.<... | 17,276 |
<p>How do I save a Tlistviews layout in Delphi 2007?</p>
<p>I have been asked to write some code to allow users to re-order columns in a TListview (well all TListviews in our application), I have the code working (by manipulating the columns index and setting width to zero to hide columns not needed) but now I need a ... | <p>If you only want to save and load a certain part of the data you can store it n an ini or xml file.
General data can be written to the file. Columns is another problem. You need to find an unique identification for each column. The ini could be something like:</p>
<pre><code>[Settings]
[Col_1]
position=1
width=50... | <p>I suggest you inherit from Tlistview (or is there a TCustomListView) to create your own component, class helpers are nice but unofficial.</p>
| 34,161 |
<p><a href="http://en.wikipedia.org/wiki/Tcl" rel="noreferrer">Tcl/Tk</a> is a simple way to script small GUIs.</p>
<p>Can anyone give a nice example with a <em>button</em> and a <em>text</em> widget. When the button is pressed should a shell command be executed and the output piped to the <em>text</em> widget.</p>
<... | <p>Here's a more complete example using fileevents. This will auto-scroll all the time. For usability purposes you probably only want to auto-scroll if the bottom of the text is visible (ie: if the user hasn't moved the scrollbar) but I'll leave that as an exercise for the reader to keep this already long example from ... | <p>I can give a start...please suggest improvements. I.e I'd like it to scroll as the command is outputting</p>
<pre><code>#!/usr/bin/wish
proc push_button {} {
put_text
.main see end
}
proc put_text {} {
set f [ open "| date" r]
while {[gets $f x] >= 0} {
.main insert end "$x\n"
}
catch {... | 20,076 |
<p>I am putting together an Java application that needs to display some basic lab instrument components. For example, I'd like to display: a strip chart, oscilloscope-style trace, and a panel meter (galvanometer needle). Rendering requirements are open (as long as the engine is free and generally available). Any sug... | <p>It can be done by using a mobile phone connected to your computer, but a more robust way would be to use an SMS aggregator - well known ones are <a href="http://www.mblox.com/" rel="nofollow noreferrer">Mblox</a> or <a href="http://www.hslsms.com/" rel="nofollow noreferrer">Hay</a>, but a google search will show man... | <p>The short answer is that you have 4 options: </p>
<ul>
<li>Having your own SMS server </li>
</ul>
<p>OR</p>
<ul>
<li>Having to use the webportal for each provider you want to sent the message</li>
</ul>
<p>OR</p>
<ul>
<li>Some provider let you send SMS with email to SMS</li>
</ul>
<p>OR</p>
<ul>
<li>Use some ... | 42,275 |
<p>I've opened an old workspace that is a libray and its test harness. It used to work fine but now doesn't and older versions of the code don't work either with the same errors. I've tried recreating the project and that causes the same errors too. Nothing seems out of order in project settings and the code generated ... | <p>One possibility lies with Win32 ANSI/Unicode "name-mangling", which turns the symbol <code>GetMessage</code> into either <code>GetMessageA</code> or <code>GetMessageW</code>. There are three possibilities:</p>
<ol>
<li><p>Windows.h hasn't been loaded, so <code>GetMessage</code> stays <code>GetMessage</code></p></li... | <p>windows.h is declared at the top of IOCompletionPort.h as an include - I was sick of seeing 7 lines just to include 1 file so I have wrapped it its own file and includes that itself. This also contains some additional #defines (i.e. ULONG_PTR) as our main app won't compile with the Platform SDK installed:-(</p>
<ol>... | 2,775 |
<p>How does a virtual machine generate native machine code on the fly and execute it?</p>
<p>Assuming you can figure out what are the native machine op-codes you want to emit, how do you go about actually running it?</p>
<p>Is it something as hacky as mapping the mnemonic instructions to binary codes, stuffing it int... | <p>You can just make the <a href="http://en.wikipedia.org/wiki/Program_counter" rel="noreferrer">program counter</a> point to the code you want to execute. Remember that data can be data or code. On x86 the program counter is the EIP register. The IP part of EIP stands for instruction pointer. The JMP instruction is ca... | <p>As far as i know it compiles everything in memory because it has to run some heuristics to to optimize the code (i.e.: inlining over time) but you can have a look at the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=8c09fd61-3f26-4555-ae17-3121b4f51d4d&displaylang=en" rel="nofollow norefer... | 6,728 |
<p>Is it possible for a web server to know which <em>type</em> of device request has been received from?</p>
<p>For example, can a create a website which shows different contents if request came from a computer (Firefox) and something different if it came from iPhone?</p>
| <p>The way is the User Agent header, as has been said. You best use a list like <a href="http://www.zytrax.com/tech/web/mobile_ids.html" rel="nofollow noreferrer">this one</a> to find out which mobile is it. </p>
<p>When I had to do something like it I stored the unknown received User Agents in a table to find out lat... | <p>Check the <code>User-Agent</code> in the Request Header</p>
<p>For full details on HTTP headers, see the specifications at <a href="http://www.w3.org/Protocols/" rel="nofollow noreferrer">http://www.w3.org/Protocols/</a>. </p>
| 18,288 |
<p>We are connecting to a WCF web service which has Anonomous Access turned off, Windows Authentication turned on. The web.config file has a local user account for allow users and deny users="?". </p>
<p>I can download and generate the service proxy fine (being prompted for creds), however from my windows form proje... | <p>Looks like your service is asking for <em>basic</em> authentication; not windows integrated authentication. </p>
<p>In that case, I think you need to specify the credentials on the client proxy using in the ClientCredentials.UserName property and not ClientCredentials.Windows.</p>
| <p>No change. The virtual directory is asking for Windows Auth and passing in a local user. It works fine in the browser but the service keeps erroring out.</p>
| 23,411 |
<p>This is my problem:</p>
<p>I'm assembling a 3D printer with the RAMPS 1.4 board and Arduino Mega. I have assembled the structure and the electronics (set drivers, placed the jumpers, connected stepper motors...) and have uploaded Marlin firmware (configuring: thermistor, endstops...) on the Arduino Mega.</p>
<p>I've... | <p>The demo files are gcode files generated for use with the sample PLA that comes with the printer. If you want to print it with ABS select the file and set the temperature manually afterwards. </p>
| <p>If you want to use the demo files, you can probably pause the print as soon as it starts, and manually set the extruder temperatures before resuming the print. Easier to generate new g-code though.</p>
| 466 |
<blockquote>
<p>"To help protect your security,
Explorer has restricted this webpage
from running scripts or ActiveX
controls that could access your
computer"</p>
</blockquote>
<p>Whenever I add Flash movies or javascript code this message will show. It also shows for somebody else, so how do I get rid of th... | <p>If you're loading an HTML file directly (as opposed to through a web server) you can quite often get this message. If that's the case, set up a local web server (Apache or IIS for example) and develop on that.</p>
<p>If you're already going through a web server, then it's probably your IE security settings are a b... | <p>This article explains one way to bypass this for localfiles
<a href="http://msdn.microsoft.com/en-us/library/ms537628(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms537628(VS.85).aspx</a></p>
<p>The problem is that locally loaded files run with permissions that ones loaded from a r... | 24,967 |
<p>I'm using the ListView control (ASP.NET 2008) to show a bunch of lines of data, and at the bottom I want some totals. I was initially going to define the header and footer in the LayoutTemplate and get the totals with some local function, i.e. <%#GetTheSum()%>, but it appears that the LayoutTemplate does not proc... | <p>It turns out that FindControl does work: </p>
<pre><code>CType(MyListView.FindControl("litTotal"), Literal).Text = GetTheSum()
</code></pre>
<p>I'd still like to know if there might be a better way though.</p>
| <p>You can't reference the control in the code-behind because it's in the LayoutTemplate. Maybe with FindControl, but I haven't tried that yet.</p>
| 26,060 |
<p>In ASP.NET what's the best way to do the following:</p>
<ol>
<li>Show certain controls based on your rights?</li>
<li>For a gridview control, how do you show certain columns based on your role?</li>
</ol>
<p>I'm thinking for number 2, have the data come from a role specific view on the database.</p>
| <p>Instead of actually using roles to hide/show certain controls, I would suggest having another layer of permissions for each role and show/hide based on those instead.</p>
<p>That way you can redefine what permissions a role has and won't have to change your code.</p>
<p>Also, this allows you to make new roles in t... | <p>If you're going the role-based route, ASP.NET (since version 2.0) has had a variety of membership controls available which might help in this scenario. Assuming (and this could well be a faulty assumption) that you're using the in-box membership provider, you can actually use the <code>LoginView</code> control to ge... | 25,783 |
<p>I've found an issue with ASP.NET that I know at least has stumped one other person out there. We were trying to use an HttpModule to handle wildcard
requests to a web application. The generated url is dynamic and could
potentially be several hundred characters long. Unfortunately there
appears to be a limitati... | <p>This is a known issue with aspnet_isapi.dll and there is currently no workaround. The reason you don't see this issue when running your site in the built-in Visual Studio Webserver (aka Cassini) is because it's all managed code and doesn't rely on aspnet_isapi.dll.</p>
<p>This will get addressed in a future version... | <p>You could use an URL-rewriting ISAPI such as <a href="http://cheeso.members.winisp.net/IIRF.aspx" rel="nofollow noreferrer">IIRF</a> to rewrite the URL into something the aspnet_isapi can process.</p>
| 33,240 |
<p>I am wondering what security concerns there are to implementing a <code>PHP evaluator</code> like this:</p>
<pre><code><?php eval($_POST['codeInput']); %>
</code></pre>
<p>This is in the context of making a <code>PHP sandbox</code> so sanitising against <code>DB input</code> etc. isn't a massive issue.</p>
... | <p>don't do that.</p>
<p>they basically have access to anything you can do in PHP (look around the file system, get/set any sort of variables, open connections to other machines to insert code to run, etc...)</p>
| <p>As already answered, you need to sanitize your inputs. I guess you could use some regex-filtring of some kind to remove unwanted commands such as "exec" and basically every malicious command PHP has got to offer (or which could be exploited), and that's a lot.</p>
| 15,999 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.