instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>ok, ive a class and i pass an object as property.</p> <p>the object that i pass is a <code>List&lt;X&gt;</code></p> <p>in my class im trying to access the Object index by reflection BUT I CAN'T!!! </p> <p>Example:</p> <p>this class works i just wrote down the part i want to show you and i need help.</p> <pre><c...
<p>If you are using reflection (and hence lots of <code>object</code>), why not just cast as an <code>IList</code> (non-generic) instead?</p> <p>i.e.</p> <pre><code>IList list = (IList)actualList; object foo = list[17]; </code></pre> <p>Also - for your original code with <code>Count</code>, you don't mean <code>int....
<p>Just cast your object to a list first, you don't need reflection here. </p>
44,465
<p>I'm writing a library which is to be dynamically loaded in C++. </p> <p>I'd like to read argc and argv (for debugging reasons) from within my code, however I do not have access to the main function. Is there any way to retrieve the command line (both Windows and Linux solution would be nice).</p> <p>Thanks, Dan</p...
<p>There is the GetCommandLine() function in the Win32 API. On other platforms, you would have to save argc/argv somewhere (external variable?).</p>
<p>Use getpid() and ps command.</p> <p>int pid;</p> <p>int fd;</p> <p>char cmd[80];</p> <p>pid = getpid();</p> <p>sprintf(cmd, "ps %d", pid);</p> <p>fd = popen(cmd, "r");</p> <p>.... lines should be like</p> <p>.... 1358 ./a.out abc def</p>
19,384
<p>I'm trying to use a link to open an overlay instead of in a separate popup window. This overlay should consist of a semi-transparent div layer that blocks the whole screen from being clicked on. I also aim to disable scrolling at this point. Not matter where you are on the main page, when the link is clicked, the ov...
<p>You might want to check out an old JS lib I wrote, called <a href="http://code.google.com/p/submodal/" rel="nofollow noreferrer">SubModal</a>.</p> <p>Easy to understand and modify. Go to town ;)</p> <p>Once you've modded it, use <a href="http://code.google.com/p/minify/" rel="nofollow noreferrer">Minify</a> in com...
<p>Grab the javascript <a href="http://extjs.com/" rel="nofollow noreferrer">ext</a> library. It has functionality for overlays that are modal.</p>
12,484
<p>This question may require migration to Meta.SE, as it could be a site-wide "bug", but I thought that I would test the waters here, to see if there is an obvious explanation.</p> <p>I noticed that a question of mine had been modified, on April 16, by "Song Khmer" <strike>in the <a href="https://3dprinting.stackexcha...
<p>Regarding the "invisible modification", there is technically a modification made multiple times by the user <strong>Song Khmer</strong> (now destroyed). This user was posting nonsense to your question by copying text from your question and posting it as an answer.</p> <p>The reason you probably did not see this in ...
<p>The Stack Exchange network is undergoing a transition to HTTPS for its sites, including 3D Printing SE.</p> <p>This edit (from Community, it looks like), was probably scripted from SE Staff in attempt to fix content on Questions and Answers. Ultimately, I don't think this is worth migrating the SE Meta.</p>
40
<p>I installed a ASP.Net website on a Windows 2008 server, which is by default using IIS7. The website seems to work fine, but the post backs on my forms do not work. After a few hours of debugging, I realized that when I manually try to hit the WebResource.axd file in my browser (e.g. I type <a href="http://www.doma...
<p>If you are using plesk panel or Web Application Firewall (ModSecurity) is active, disable &quot;OWASP_CRS / LEAKAGE / ERRORS_IIS&quot; and &quot;OWASP_CRS / POLICY / EXT_RESTRICTED&quot; security rules.</p>
<p>Check your IIS logs - they should give a status code that has more detailed information about the error. Also, what is the nature of the error on the postback?</p>
15,034
<p>Puzzled by the Lua 5.0 documentation references to things like <code>_LOADED</code>, <code>LUA_PATH</code>, <code>_ALERT</code> and so on (that I could not use in Lua 5.1), I discovered all of those have been removed and the functionality put elsewhere. Am I right in thinking that the only one global variable left i...
<p>I'm not familiar with regexes, so forgive me if this answer's off-base. I've been assuming that $3, $2, and $1 are strings. Here's what I did in IRB to replicate the problem:</p> <pre><code>irb(main):003:0&gt; Integer("04") =&gt; 4 irb(main):004:0&gt; Integer("09") ArgumentError: invalid value for Integer: "09" ...
<p>Instead of checking any integer with leading 0 directly. Eg:</p> <p><code>Integer(&quot;08016&quot;) #=&gt; ArgumentError: invalid value for Integer(): &quot;08016&quot;</code></p> <p>Create a method to check and rescue for leading 0:</p> <pre><code>def is_numeric(data) _is_numeric = true if Integer(data) rescue f...
17,659
<p>Phantom References serve for post-mortem operations. The Java specification states that a <strong>phantom referenced object</strong> will not be deallocated until the phantom-reference itself is cleaned.</p> <p>My question is: What purpose does this feature (object not deallocated) serve?</p> <p>(The only idea i c...
<p>Edit, since I've misunderstand the question first:</p> <p>Quoted from here <a href="http://www.memorymanagement.org/glossary/p.html" rel="nofollow noreferrer">http://www.memorymanagement.org/glossary/p.html</a>:</p> <blockquote> <p>The Java specification says that the phantom reference is not cleared when th...
<p>It can allow you two have phantom caches which are very efficient in memory management. Simply put, if you have huge objects that are expensive to create but seldom used, you can use a phantom cache to reference them and be sure they do not take up memory that is more valuable. If you use regular references you hav...
10,620
<p>I'm about to create a web application that requires a lot of different web forms where the user needs to be able to input a lot of different types of information. What I mean is that one of those forms may require some text input fields, some integer input fields, some decimal input fields, some date input fields, s...
<p>I would be tempted to look at Ext JS for this. </p> <p><a href="http://extjs.com/products/extjs/" rel="nofollow noreferrer">Ext JS</a></p>
<p>have you had a look at <a href="http://javascript.neyric.com/inputex/" rel="nofollow noreferrer">InputEx</a></p>
6,548
<p>OK, I know what you're thinking, &quot;why write a method you do not want people to use?&quot; Right?</p> <p>Well, in short, I have a class that needs to be serialized to XML. In order for the <a href="https://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28v=vs.110%29.aspx" rel="noreferrer...
<p>If a class is <a href="https://msdn.microsoft.com/en-us/library/system.serializableattribute%28v=vs.110%29.aspx" rel="noreferrer"><code>[Serialisable]</code></a> (i.e. it can be copied around the place as needed) the param-less constructor is needed to deserialise.</p> <p>I'm guessing that you want to force your co...
<p><a href="http://msdn.microsoft.com/en-us/library/system.obsoleteattribute.aspx" rel="nofollow noreferrer"><code>ObsoleteAttribute</code></a> will probably work in your situation - you can even cause the build to break if that method is used. </p> <p>Since obsolete warnings occur at compile time, and since the refle...
4,743
<p>Being used to (and potentially spoiled by) <code>MSSQL</code>, I'm wondering how I can get at tables size in <code>Oracle</code> 10g. I have googled it so I'm now aware that I may not have as easy an option as <code>sp_spaceused</code>. Still the potential answers I got are most of the time outdated or don't work. P...
<p>You might be interested in this query. It tells you how much space is allocated for each table taking into account the indexes and any LOBs on the table. Often you are interested to know "How much spaces the the Purchase Order table take, including any indexes" rather than just the table itself. You can always de...
<p>I have the same variant as the last ones which calculates segments of table data, table indexes and blob-fields:</p> <pre><code>CREATE OR REPLACE FUNCTION SYS.RAZMER_TABLICY_RAW(pNazvanie in varchar, pOwner in varchar2) return number is val number(16); sz number(16); begin sz := 0; --Calculate size of ta...
33,192
<p>Wikipedia provides <a href="http://en.wikipedia.org/wiki/Citation#Sciences" rel="nofollow noreferrer">a number of citations used in the sciences</a>, however does one stand out in computer science and software engineering related documents? My initial guess is to the <a href="http://www.computer.org/portal/site/ieee...
<p>I think I used both APA and MLA styles at different points. Unlike journalism or psychology, there isn't a defined standard, so it will probably depend the most on the school/professors that you have.</p>
<p>I think I am little late on this thread. But I am just gonna share some resource in case someone stumbles here. They do have a standardized citation format. In fact, the format may vary from institute to institute. In case your institute has a different format, you can always go for <a href="http://www.researchomati...
29,680
<p>I have two third-party libraries occasionally having the same symbol name exported. When the executable is loaded, <em>ld</em> usually picks the wrong one and I getting crash as a result. I cannot do too much about the content of these libraries, so may be there is a way to instruct <em>ld</em> how to find the prope...
<p>If you don't need to link in both shared libraries at compile time (which isn't clear from your question), you can use <code>-Bdirect</code> for the shared library. This will record for all symbols from the shared library where they had been found; if then at run-time a second definition of the symbol appears (from ...
<p>One solution is to set the <code>LD_PRELOAD</code> environment variable to the library whose symbols should take precedence. (If that library has shared library dependencies of its own, you may need to preload all of its dependencies; just set <code>LD_PRELOAD</code> to the list of dependent libraries, separated by...
43,462
<p>We're looking to automate our deployment of Web Applications, particularly when going from local development to a remote server.</p> <p>Our current stack is LAMP remotely, MAMP locally, but I'm interested in general what people are using for this task regardless of their environment?</p> <p>I'm not just talking ab...
<p>We use "svn export" when it needs to go live. Keeps our code under revision control, and lets us actively develop it on test boxes or our local computer.</p>
<p>rsync->great tool</p> <p>But, the answer depends on your enviro. What do you use for source control? What do you use for a build system? Etc.</p> <p>Deployment for a web server is nothing more than a "cp" command depending on which files changed. You need to build a process that tracks the files that change, pu...
15,172
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/16660/internationalization-in-ssrs">Internationalization in SSRS</a> </p> </blockquote> <p>We use SQL Server Reporting Services for our web reports. At the moment, our clients are all in the UK, so for each rep...
<p>Please check out this thread. It might help you here.</p> <p><a href="https://stackoverflow.com/questions/16660/internationalization-in-ssrs"><strong>Internationalization in SSRS</strong></a></p>
<p>The report will be rendered with the web browsers language in regard to formatting of dates, currencies and so on if the report's language has not been set. See <a href="http://msdn.microsoft.com/en-us/library/aa178910(SQL.80).aspx" rel="nofollow noreferrer">MSDN documentation</a>:</p> <blockquote> <p>If the lang...
21,139
<p>Hi I was looking into Ruby to actionscript 3 bytecode compilers and found a mention of a project called Red Sun but can find very little information on it. </p> <p>So my Question is ... what tools are available to convert Ruby source into AS3 bytecode</p>
<p>I am the lead developer on the Red Sun project. There is very little information because it is really not ready to be used yet. I worked on the original prototype and presented it to a handful of people at 360|Flex San Jose. This generated further interest and encouraged me to propose it for <a href="http://rubyconf...
<p>As an aside, I'm pretty sure there are things you can do in Ruby that you can't do in AS3, so any converter would probably only be able to convert a subset of Ruby code. </p>
16,160
<p>I have an Ant script with a junit target where I want it to start up the VM with a different working directory than the basedir. How would I do this?</p> <p>Here's a pseudo version of my target.</p> <pre><code>&lt;target name="buildWithClassFiles"&gt; &lt;mkdir dir="${basedir}/UnitTest/junit-reports"/&gt; ...
<p>Have you tried:</p> <pre><code> &lt;junit fork="true" printsummary="yes" dir="workingdir"&gt; </code></pre>
<p>I think the other answers might be overlooking the fact that you want the working directory to be specified, not just that you want to run junit on a particular directory. In other words, you want to make sure that if a test creates a file with no path information, it is from the base directory you are specifying.</...
31,183
<p>Currently at my job, we are distributing installers for our windows base software via an apache web server on a Ubuntu server using apache authentication. When we initially started doing this we only had 3 projects to distribute and as such, 3 htpasswd files to manage. Since then, we have grown and are now distrib...
<p>Se up apache to use LDAP for authentication. Then you can use a pre-existing LDAP frontend, or roll your own, to manage access rights and account expiration.</p> <p>With LDAP, you could have a group for each project, so that users can have access to several projects by being in several groups.</p> <p>Some info on ...
<p>I might consider <a href="http://plone.org" rel="nofollow noreferrer">Plone</a> with the LDAP plugin.</p> <p>As a side note, I'd also suggest updating to the more recent LTS release of Ubuntu, but it's not mandatory :)</p>
47,573
<p>Can a WinForms app compiled for "Any CPU" be configured to run as "x86" on a 64-bit server without recompiling the app? Specifically, I'm looking for an app.config setting or Control Panel applet to accomplish this end. All the customer's clients are x86, but the server is x64, and we like to install the WinForms ap...
<p>From <a href="http://www.request-response.com/blog/PermaLink,guid,34966ef8-3142-46b2-84e0-372b5c36ddcc.aspx" rel="nofollow noreferrer">http://www.request-response.com/blog/PermaLink,guid,34966ef8-3142-46b2-84e0-372b5c36ddcc.aspx</a></p> <blockquote> <p>You can, however, control and override this default behavi...
<p>No configuration ought to be needed if you wrote your managed code correctly. As long as the 64-bit machine has the proper frameworks installed, the JIT process will take care of any of the differences between 32 and 64 bit requirements.</p> <p>The only thing you need to be concerned about in your own code is if y...
22,732
<p>Since <a href="http://www.iboxprinters.com/" rel="nofollow noreferrer">iBox Nano</a> is the smallest public-production-available 3d Resin printer (and the cheapest so far), I assume it has a huge size limitation. So far I've only seen pictures of its outputs that are <a href="http://www.iboxprinters.com/ibox-nano-1/...
<p>On their <a href="http://www.iboxprinters.com/ibox-nano-1/" rel="nofollow noreferrer">website</a>, I found the following picture, which states a build area of 40 mm x 20 mm x 90 mm (1.57" x 0,79" x 3.54").</p> <p><a href="https://i.stack.imgur.com/TYxa8.jpg" rel="nofollow noreferrer" title="iBox Nano 3D printer spe...
<p>From their website I found a <a href="http://www.iboxprinters.com/pages.php?pageid=17" rel="nofollow">comparison between 300 microns down to 50 microns print quality</a>. My answer would be somewhere around this range.</p>
318
<p>I'm working on an application for a charitable student organization. The application will track participation and fund-raising for (primarily) student participants in an event. One of the things we'd like to do is collect some demographic information about students who register for the event from our enterprise di...
<p>Here are my thoughts:</p> <ul> <li>You shouldn't tie in demographics with registration. It doesn't make sense logically and this can always lead to practical issues. You can instead create a demographics history table, e.g. StudentID, StartDate, EndDate, xxxDemographics, yyyDemographics...)</li> <li>Different acade...
<p>If you write your code in such a way that adding columns won't break it (or will be easy to update), for example being careful with SELECT * and specifying columns in INSERT, then from your description it doesn't sound like you need the ultra-flexibility of attribute-value, so I'd stick with option 1.</p>
20,779
<p>I am trying to add enhancements to a 4 year old VC++ 6.0 program. The debug build runs from the command line but not in the debugger: it crashes with an access violation inside printf(). If I skip the printf, then it crashes in malloc() (called from within fopen()) and I can't skip over that.</p> <p>This means I ca...
<p>You can use <a href="http://msdn.microsoft.com/en-us/library/5at7yxcs(VS.71).aspx" rel="nofollow noreferrer"><code>_CrtSetDbgFlag()</code></a> to enable a bunch of useful heap debugging techniques. There's a host of other <a href="http://msdn.microsoft.com/en-us/library/1666sb98(VS.71).aspx" rel="nofollow noreferre...
<p>I have a suspicion that there is a DLL compiled with a different version of the C++ runtime than the rest of the application. This will often result in "memory at address XXX could not be 'read'/'written'" violations.</p>
49,012
<p>By default when viewing an account in edit mode you have access to Opportunities, Invoices, and Quotes which contain the products being shopped by the account and/or the sales department.</p> <p>I'm trying to determine where to store, display, and use the products that an account has a subscription too. </p> <p>I ...
<p>I suspect this is a compiler error, actually.</p> <p>Here's a short but complete program to show why I think that:</p> <pre><code>using System; class Test { static void Main() { decimal constant = decimal.MaxValue / 10m; decimal calculated = decimal.MaxValue; calculated /= 10m; ...
<p>I'd guess because you are overstepping the max precision value when you are dividing by 10. <a href="http://en.wikipedia.org/wiki/Arithmetic_precision" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Arithmetic_precision</a></p>
44,433
<p>For an <code>std::map&lt;std::string, std::string&gt; variables</code>, I'd like to do this:</p> <pre><code>BOOST_CHECK_EQUAL(variables["a"], "b"); </code></pre> <p>The only problem is, in this context <code>variables</code> is <code>const</code>, so <code>operator[]</code> won't work :(</p> <p>Now, there are sev...
<pre><code>template &lt;typename K, typename V&gt; V get(std::map&lt;K, V&gt; const&amp; map, K const&amp; key) { std::map&lt;K, V&gt;::const_iterator iter(map.find(key)); return iter != map.end() ? iter-&gt;second : V(); } </code></pre> <p>Improved implementation based on comments:</p> <pre><code>template &l...
<pre><code>std::map&lt;std::string, std::string&gt;::const_iterator it( m.find("a") ); BOOST_CHECK_EQUAL( ( it == m.end() ? std::string("") : it-&gt;second ), "b" ); </code></pre> <p>That doesn't look too bad to me... I probably wouldn't write a function fo...
18,417
<p>I am starting a new ASP.NET MVC project to learn with, and am wondering what's the optimal way to set up the project(s) to connect to a SQL server for the data. For example lets pretend we have a Product table and a product object I want to use to populate data in my view.</p> <p>I know somewhere in here I should ...
<p>It really depends on which data access technology you're using. If you're using Linq To Sql, you might want to abstract away the data access behind some sort of "repository" interface, such as an IProductRepository. The main appeal for this is that you can change out the specific data access implementation at any ti...
<p>For our application I plan on using LINQ to Entities, but as it's new to me there is the possiblity that I will want to replace this in the future if it doesn't perform as I would like and use something else like LINQ to SQL or NHibernate, so I'll be abstracting the data access objects into an abstract factory so th...
14,228
<p>I have a form with a "Clear" button.</p> <p>When the user clicks "Clear", I want to clear the value of all the visible elements on the form. In the case of date controls, I want to reset them to the current date.</p> <p>All of my controls are contained on a Panel.</p> <p>Right now, I'm doing this with the below ...
<p>You can skip the GetType and CType dance with <a href="http://msdn.microsoft.com/en-us/library/zyy863x8(VS.80).aspx" rel="noreferrer">TryCast</a>:</p> <pre><code>Dim dtp as DateTimePicker = TryCast(ctrl, DateTimePicker) If dtp IsNot Nothing then dtp.Value = Now() </code></pre> <p>That'll save you about 10 lines.</...
<p>I present you my <code>ControlIterator</code> Class</p> <p>Source: <a href="http://pastebin.com/dubt4nPG" rel="nofollow">http://pastebin.com/dubt4nPG</a></p> <p>Some usage examples:</p> <pre><code> ControlIterator.Disable(CheckBox1) ControlIterator.Enable({CheckBox1, CheckBox2}) ControlIterator.Check(Of Check...
24,319
<p>I'm quite confident that globally declared variables get allocated (and initialized, if applicable) at program start time.</p> <pre><code>int globalgarbage; unsigned int anumber = 42; </code></pre> <p>But what about static ones defined within a function?</p> <pre><code>void doSomething() { static bool globalish...
<p>I was curious about this so I wrote the following test program and compiled it with g++ version 4.1.2.</p> <pre><code>include &lt;iostream&gt; #include &lt;string&gt; using namespace std; class test { public: test(const char *name) : _name(name) { cout &lt;&lt; _nam...
<p>In the following code it prints Initial = 4 which is the value of static_x as it is implemented in the compiling time.</p> <pre><code> int func(int x) { static int static_x = 4; static_x = x; printf (&quot;Address = 0x%x&quot;,&amp;static_x ); // prints 0x40a010 return static_x;...
7,931
<p>When manually generating a JSON object or array, it's often easier to leave a trailing comma on the last item in the object or array. For example, code to output from an array of strings might look like (in a C++ like pseudocode):</p> <pre><code>s.append("["); for (i = 0; i &lt; 5; ++i) { s.appendF("\"%d\",", ...
<p>Unfortunately <a href="http://www.json.org/" rel="noreferrer">the JSON specification</a> does not allow a trailing comma. There are a few browsers that will allow it, but generally you need to worry about all browsers.</p> <p>In general I try turn the problem around, and add the comma before the actual value, so yo...
<p>I usually loop over the array and attach a comma after every entry in the string. After the loop I delete the last comma again.</p> <p>Maybe not the best way, but less expensive than checking every time if it's the last object in the loop I guess.</p>
24,649
<p>I have some linq entities that inherit something like this:</p> <pre><code>public abstract class EntityBase { public int Identifier { get; } } public interface IDeviceEntity { int DeviceId { get; set; } } public abstract class DeviceEntityBase : EntityBase, IDeviceEntity { public abstract int DeviceId { get; se...
<p>LINQ-to-SQL has <em>some</em> support for inheritance via a discriminator (<a href="http://www.davidhayden.com/blog/dave/archive/2007/10/28/LINQToSQLEnumSupportExampleDiscriminatorColumnInheritanceMapping.aspx" rel="nofollow noreferrer">here</a>, <a href="http://weblogs.asp.net/zeeshanhirani/archive/2008/06/25/inher...
<p>Try <code>.OfType&lt;&gt;()</code> as posted here <a href="https://stackoverflow.com/a/17734469/3936440">https://stackoverflow.com/a/17734469/3936440</a>, it works for me having the exact same issue.</p>
18,886
<p>The description of DTDs in the XML 1.1 specification is very terse, and it is difficult to gain an appreciation of what features are available. For example, from looking at the <a href="http://www.w3.org/TR/XHTMLplusMathMLplusSVG/#driver" rel="nofollow noreferrer">unflattened XHTML+MathML+SVG DTD</a>, I know it is p...
<p>I would recommend <em>Elliotte-Rusty Harold</em>'s <strong><a href="https://rads.stackoverflow.com/amzn/click/com/0764549863" rel="nofollow noreferrer" rel="nofollow noreferrer">book</a> "<a href="https://rads.stackoverflow.com/amzn/click/com/0764549863" rel="nofollow noreferrer" rel="nofollow noreferrer">XML Bible<...
<p>I just kind of winged it using auto completion from <a href="http://www.liquid-technologies.com/Product_XmlStudio.aspx" rel="nofollow noreferrer">Liquid Technologies XML Studio</a> ; they even had a tool that let me give a sample of the XML I was writing a XSD for and it would try to infer the definition. Of course ...
37,828
<p>I have been looking for a logging framework for .net (c#) and decided to give log4net a go after reading up on a few question/answer threads here on stackoverflow. I see people mentioning over and over that they use a wrapper class for log4net and I am wonder what that would look like.</p> <p>I have my code split u...
<p>Essentially you create an interface and then a concrete implementation of that interface that wraps the classes and methods of Log4net directly. Additional logging systems can be wrapped by creating more concrete classes which wrap other classes and methods of those systems. Finally use a factory to create instanc...
<p>I know this answer is late, but it may help someone in the future.</p> <p>It sounds like you want a programmatic API that XQuiSoft Logging gives you. You don't have to specify which logger you want with XQuiSoft. it is as simple as this:</p> <p>Log.Write(Level.Verbose, "source", "category", "your message here");...
20,104
<p>In my simple OpenGL program I get the following error about exit redefinition:</p> <pre><code>1&gt;c:\program files\microsoft visual studio 8\vc\include\stdlib.h(406) : error C2381: 'exit' : redefinition; __declspec(noreturn) differs 1&gt; c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\...
<p><strong>Cause:</strong></p> <p>The <strong>stdlib.h</strong> which ships with the recent versions of Visual Studio has a different (and conflicting) definition of the <strong>exit()</strong> function. It clashes with the definition in <strong>glut.h</strong>.</p> <p><strong>Solution:</strong></p> <p>Override the ...
<p>or this... To fix the error, right click on the project name in the Solution Explorer tab and select Properties -> C/C++ -> Preprocessor -> Preprocessor definitions and append GLUT_BUILDING_LIB to the existing definitions, seperated by semicolons. </p>
3,521
<p>When creating a class library in C++, you can choose between dynamic (<code>.dll</code>, <code>.so</code>) and static (<code>.lib</code>, <code>.a</code>) libraries. What is the difference between them and when is it appropriate to use which?</p>
<p>Static libraries increase the size of the code in your binary. They're always loaded and whatever version of the code you compiled with is the version of the code that will run.</p> <p>Dynamic libraries are stored and versioned separately. It's possible for a version of the dynamic library to be loaded that wasn't ...
<p>Apart from all the points that have been mentioned by others, I use static libraries in a specific use-case to:</p> <blockquote> <p>Not allow my end users to get access to some general-purpose libraries that I have developed in my code.</p> </blockquote> <p>In other words, suppose that I have two libraries in my pro...
16,949
<p>I have a VPS host running 3 sites using Ubuntu Hardy. I've spent much time setting it up. That includes all the installation + configuration and stuff. What ways are there to do backup + restore for VPS? </p>
<p>Backups alone aren't enough. You should be keeping a detailed system log of all configuration changes you make to the system so that you can reproduce your configuration elsewhere. Ideally, perform the changes on a local VM, then write a script to perform those changes automatically, then run those scripts on the ...
<p>It'll depend a lot on what your host offers. MediaTemple and Slicehost both offer snapshot backups for a nominal fee. Contact your host and ask if they offer such a solution.</p> <p>If your host doesn't offer anything, you could always backup the critical stuff regularly to something like Amazon's S3 storage servi...
9,846
<p>The .NET web system I'm working on allows the end user to input HTML formatted text in some situations. In some of those places, we want to leave all the tags, but strip off any trailing break tags (but leave any breaks inside the body of the text.)</p> <p>What's the best way to do this? (I can think of ways to d...
<p>As @<a href="https://stackoverflow.com/questions/135151#135161">Mitch</a> said, </p> <pre><code>// using System.Text.RegularExpressions; /// &lt;summary&gt; /// Regular expression built for C# on: Thu, Sep 25, 2008, 02:01:36 PM /// Using Expresso Version: 2.1.2150, http://www.ultrapico.com /// /// A descrip...
<p>you can use RegEx or check if the trailing string is a break and remove it</p>
16,371
<p>First of all (in case this is important) I'm using ActiveState's Perl (v5.8.7 built for MSWin32-x86-multi-thread).</p> <p>I've just emerged from a three hour long debugging session, trying to find the source of an error. I found there was simply no error, but for some reason ADO's connection object was getting the ...
<p>This is to be expected as it's what ADO does and the Win32::ADO is quite a thin layer above it.</p> <p>ref: knowledge base <a href="http://support.microsoft.com/kb/194792" rel="nofollow noreferrer">note that the RAISERROR and PRINT statements are returned through the ADO errors collection</a></p>
<p>OK, after a <strong>lot</strong> of testing and reading, I came to found it explained in the BOLs' article "Using PRINT" (my emphasis):</p> <blockquote> <p>The PRINT statement is used to return messages to applications. PRINT takes either a character or Unicode string expression as a parameter and returns the str...
27,612
<p>I'm currently trying to improve the design of a legacy db and I have the following situation</p> <p>Currently I have a table SalesLead in which we store the the LeadSource.</p> <pre><code>Create Table SalesLead( .... LeadSource varchar(20) .... ) </code></pre> <p>The Lead Sources are helpfully stored ...
<p>If you want to de-normalize the table, simply add the LeadSource (Varchar) column to your SalesLead table, instead of using a FK or an ID.</p> <p>On the other hand, if your language has support for ENUM structures, the "magic numbers" should be safely stored in an enum, so you could: </p> <pre><code>SELECT * FROM ...
<p>I really don't see your problem behind the join. </p> <p>Naturally, asking directly by the FK_LeadSourceID is wrong, but using the JOIN seems to be the right way to go as I masks changing IDs perfectly fine. If, for example, "foo" becomes 3 at one day (and you update the foreign key field), the last query you've di...
10,723
<p>How do I dictate the destination folder of a clickOnce application?</p>
<p>This is not possible with ClickOnce. ClickOnce applications are always installed in the <code>Apps</code> subdirectory of local application data.</p>
<p>One Click application directly installs into the user profile directory. There is no way you can install it to your Programme files. To customize the your application use Installaware Admin <a href="http://www.installaware.com/studio-admin-features.htm" rel="nofollow">http://www.installaware.com/studio-admin-feature...
17,533
<p>I've been given a job of 'translating' one language into another. The source is too flexible (complex) for a simple line by line approach with regex. Where can I go to learn more about lexical analysis and parsers?</p>
<p>If you want to get "emotional" about the subject, pick up a copy of "<a href="http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools" rel="noreferrer">The Dragon Book</a>." It is <em>usually</em> the text in a compiler design course. It will definitely meet your need "learn more about lexical an...
<p>If you prefer Java based tools, the Java Compiler Compiler, JavaCC, is a nice parser/scanner. It's config file driven, and will generate java code that you can include in your program. I haven't used it a couple years though, so I'm not sure how the current version is. You can find out more here: <a href="https:/...
5,424
<p>This question is to seek out good examples of Hungarian Notation, so we can bring together a collection of these. </p> <p><strong>Edit:</strong> I agree that Hungarian for types isn't that necessary, I'm hoping for more specific examples where it increases readability and maintainability, like Joel gives in his ar...
<p>The now classic article, as mentioned in other Hungarian posts, is the one from Joel's site:</p> <p><a href="http://www.joelonsoftware.com/articles/Wrong.html" rel="noreferrer">http://www.joelonsoftware.com/articles/Wrong.html</a></p>
<p>There's no such thing as a good example of hungarian notation. Just don't use it. Not even if you are using a weakly typed language. You'll live happier.</p> <p>But if you really need some reason not to use it, this is my favourite one, extracted from <a href="http://mindprod.com/jgloss/unmain.html" rel="nofollow ...
24,698
<p>I need to highlight, case insensitively, given keywords in a JavaScript string.</p> <p>For example:</p> <ul> <li><code>highlight("foobar Foo bar FOO", "foo")</code> should return <code>"&lt;b&gt;foo&lt;/b&gt;bar &lt;b&gt;Foo&lt;/b&gt; bar &lt;b&gt;FOO&lt;/b&gt;"</code></li> </ul> <p>I need the code to work for an...
<p>You <em>can</em> use regular expressions if you prepare the search string. In PHP e.g. there is a function preg_quote, which replaces all regex-chars in a string with their escaped versions.</p> <p>Here is such a function for javascript (<a href="https://locutus.io/php/pcre/preg_quote/" rel="nofollow noreferrer">so...
<p>Why not just create a new regex on each call to your function? You can use:</p> <pre><code>new Regex([pat], [flags]) </code></pre> <p>where [pat] is a string for the pattern, and [flags] are the flags.</p>
35,515
<p>What are the pros/cons of doing either way. Is there One Right Way(tm) ?</p>
<p>If you want to use exceptions instead of errors for your entire application, you can do it with <a href="http://php.net/ErrorException" rel="noreferrer">ErrorException</a> and a custom error handler (see the ErrorException page for a sample error handler). The only downside to this method is that non-fatal errors wi...
<p><em><strong>Using exceptions are not a good idea in the era of 3rd party application integration</em></strong>. </p> <p>Because, the moment you try to integrate your app with something else, or someone else's app with yours, your entire application will come to a halt the moment a class in some 3rd party plugin thr...
8,552
<p>When a previous Vim session crashed, you are greeted with the "Swap file ... already exists!" for each and every file that was open in the previous session.</p> <p>Can you make this Vim recovery prompt smarter? (Without switching off recovery!) Specifically, I'm thinking of:</p> <ul> <li>If the swapped version doe...
<p>I have vim store my swap files in a single local directory, by having this in my .vimrc:</p> <pre><code>set directory=~/.vim/swap,. </code></pre> <p>Among other benefits, this makes the swap files easy to find all at once. Now when my laptop loses power or whatever and I start back up with a bunch of swap files la...
<p>I prefer to not set my VIM working directory in the .vimrc. Here's a modification of chouser's script that copies the swap files to the swap path on demand checking for duplicates and then reconciles them. This was written rushed, make sure to evaluate it before putting it to practical use.</p> <pre><code>#!/bin/ba...
8,864
<p>Are there any good webservices out there that provide good lookup information for Countries and States/Provinces?</p> <p>If so what ones do you use?</p>
<p>If you only need US information, the US Postal Service provides a set of web services it calls WebTools for this exact thing. <a href="https://www.usps.com/business/web-tools-apis/welcome.htm" rel="nofollow noreferrer">https://www.usps.com/business/web-tools-apis/welcome.htm</a>. You will need to register to be ab...
<p>A good source of geographic data, including lookups and mapping data for the USA is the US Census Bureau's <a href="http://www.census.gov/geo/www/tiger/" rel="nofollow noreferrer">TIGER Data set</a>. They no longer actively track Zip code data, but they do have a <a href="http://www.2010census.biz/geo/www/tiger/zip...
14,731
<p>We are in the process of converting our main build process from ant to maven. We use TeamCity for our Continuous Integration server (CI).</p> <p>We'd like to use the CI server to kick off (nightly) builds whose version contain a build number, as in 1.0.0.build#. These builds would be installed in our local maven re...
<p>Sounds like you want to build SNAPSHOT versions with unique versions.</p> <p>So, in your POM declare the version as:</p> <pre><code>&lt;version&gt;#.#.#-SNAPSHOT&lt;/version&gt; </code></pre> <p>Then, in the <em>distributionManagement</em> section of your POM, enable unique versions for the <em>snapshotRepository...
<p>Shek's answer is probably 'the maven way', so I'll accept it as the correct answer. However, we are not ready to change our conventions, so here is the workaround that we are using.</p> <p>By using a level of indirection you can pass a version number in to the pom at build time and have the install and deploy plugi...
43,556
<p>I once was asked to increase thread priority to fix a problem. I refused, saying that changing it was dangerous and was not the root cause of the problem.</p> <p>My question is, under what circumstannces <em>should</em> I conider changing priority of threads?</p>
<p>When you've made a list of the threads you're using and defined a priority order for them which makes sense in terms of the work they do.</p> <p>If you nudge threads up here and there in order to bodge your way out of a problem, eventually they'll all be high priority and you're back where you started. Don't assume...
<p>I would say when your original design assumptions about the threads are no longer valid. </p> <p>Thread priority is mostly a design decision about what work is most important. So for some examples of when to reconsider: If you add a new feature that might require its own thread that becomes more important, then rec...
12,120
<p>I'm using Altera Quartus 2 to do a custom 8 bit processor and it takes forever to compile on my laptop. I'm only using simulations and making my processor in schematic (block diagram) and VHDL. Right now it takes around 10 minutes to compile, which is a pain since I'm more on the debugging phase of the project where...
<p>In order of decreasing important.</p> <ul> <li>More memory. 4 GB for a 32-bit OS. Some designs need more that that and require a 64-bit OS.</li> <li>Don't overconstrain the design.</li> <li>Change the compilation options to not try as hard. That's under assignments> settings> Fitter Settings>Fast Fit (or Aut...
<p>If you only need to simulate in Quartus, you do not have to run a full compilation. If you press Ctrl-K only the analysis and elaboration is performed. The quartus simulator should do this for you.</p> <p>OTH as mention by several others: 10 minutes a very short compilation time. For real designs it is not unusual ...
46,255
<p>We are changing our remote log-in security process at my workplace, and we are concerned that the new system does not use <a href="http://en.wikipedia.org/wiki/Two-factor_authentication" rel="nofollow noreferrer">multi-factor authentication</a> as the old one did. (We had been using RSA key-fobs, but they are being ...
<p>I would say "no". I don't think you can really get the "something you have" part of multi-factor authentication without issuing something the end user can carry with them. If you "have" something, it implies it can be lost - not many users lose their entire desktop machines. The security of "something you have", aft...
<p>I agree with @freespace that the the image is not part of the multi-factor authentication for the user. As you state the image is part of the anti-phishing scheme. I think that the image is actually a weak authentication of the system to the user. The image provides authentication to the user that the website is ...
9,813
<p>In my SQL Server backend for my app, I want to create history tables for a bunch of my key tables, which will track a history of changes to the rows.</p> <p>My entire application uses Stored Procedures, there is no embedded SQL. The only connection to the database to modify these tables will be through the applicat...
<p>Triggers. </p> <p>We wrote a GUI (internally called <em>Red Matrix Reloaded</em>) to allow easy creation/management of audit logging triggers.</p> <p>Here's some DDL of the stuff used:</p> <hr> <h2>The AuditLog table</h2> <pre><code>CREATE TABLE [AuditLog] ( [AuditLogID] [int] IDENTITY (1, 1) NOT NULL , ...
<p>Triggers. Right now you might be able to say that the only way data is updated is through your SPs, but things can change or you might need to do a mass insert/update that using the SPs will be too cumbersome for. Go with triggers.</p>
45,475
<p>I am accessing a .NET COM object from C++. I want to know the version information about this COM object. When I open the TLB in OLEVIEW.exe I can see the version information associated with the coclass. How can I access this information from C++? This is the information I get:</p> <pre><code>[ uuid(XXXXXXXX-XXXX-...
<p>What I typically do for a ListView is to implement my own Adapter by extending the handy BaseAdapter class. One of the abstract methods you'll implement will be getView() as the previous poster mentioned. From there you can inflate a layout containing an ImageView, get a reference to it using findViewById, and set...
<p>From the google docs for ArrayAdapter.</p> <blockquote> <p>To use something other than TextViews for the array display, for instance, ImageViews, or to have some of data besides toString() results fill the views, override getView(int, View, ViewGroup) to return the type of view you want.</p> </blockqu...
36,654
<p>I'm using DirectMusic for MIDI playback in an application I'm developing. Does anyone know if it's possible to use DirectMusic to play individual notes? Currently, I'm converting an in-memory data structure that represents entire 'songs' into a MIDI buffer and playing it back through DirectMusic. I'd like to be able...
<p>I <em>believe</em> that stuffing your note messages into a DirectMusicBuffer8 and then playing that is indeed the simplest way to do it.</p> <p>I assume you're aware that DirectMusic is deprecated, not recommended for new development etc. etc.</p>
<p>Hmm, I'll see if I can dig more info up on that on MSDN.</p> <p>I am aware DirectMusic is deprecated, however, my understanding is that XAudio2 has very poor support for MIDI. Unless I'm mistaken on that - I would switch to XAudio2 in an instant if it supports MIDI, as I'm only in the early stages of integrating Di...
20,811
<ul> <li>I have nUnit installed.</li> <li>I have VS2008 Team Edition installed.</li> <li>I have ASP.Net MVC Preview 4 (Codeplex) installed.</li> </ul> <p>How do I make Visual Studio show me nUnit as a testing framework when creating a new MVC project? At this point I still only have the Microsoft Testing Framework as...
<p>After a bunch of research and experimentation, I've found the answer. </p> <ul> <li>For the record, the current release of nUnit 2.5 Alpha <em>does not</em> seem to contain templates for test projects in Visual Studio 2008. </li> <li>I followed the directions <a href="http://vishaljoshi.blogspot.com/2008/02/aspnet...
<p>Do install <a href="http://testdriven.net" rel="nofollow noreferrer">Testdriven.net</a> to integrate NUnit with Visual Studio. MbUnit and later versions of NUnit also contain project templates for unit tests.</p> <p>You can use those project templates to create a test project and then reference to your ASP.NET MVC ...
4,143
<p>I need to write a row to the database regardless of whether it already exists or not. Before using NHibernate this was done with a stored procedure. The procedure would attempt an update and if no rows were modified it would fallback to an insert. This worked well because the application doesn't care if the record e...
<p>I`m using </p> <pre><code> public IList&lt;T&gt; GetByExample&lt;T&gt;(T exampleInstance) { return _session.CreateCriteria(typeof(T)) .Add(Example.Create(exampleInstance)) .List&lt;T&gt;(); } public void InsertOrUpdate&lt;T&gt;(T target) { ...
<p>call hibernate.saveOrUpdate() which will check if the object is in the database, update it if it is, and save (i.e. insert) it if it is not.</p>
42,234
<p>I am wondering what the best way is using php to obtain a list of all the rows in the database, and when clicking on a row show the information in more detail, such as a related image etc.</p> <p>Should I use frames to do this? Are there good examples of this somewhere?</p> <p>Edit:</p> <p>I need much simpler ins...
<p>Contrary to other's recommendations, I would not recommend a framework or abstraction level. It will insulate you from understanding how php works and requires that you learn php and the framework structure/process at the same time. An abstraction layer is good practice in a commercial environment, but from the vi...
<p>I tend to use two separate pages. One to list, which links to the one that shows the detailed record. The one that lists passes an ID parameter on the link (ie. show.php?id=145), as for the show.php page will get that parameter from <code>$_GET['id']</code>.</p> <p>This is the simplest approach to your problem.</p>...
31,140
<p>If I have a list like this:</p> <pre><code>&lt;ul id="mylist"&gt; &lt;li id="list-item1"&gt;text 1&lt;/li&gt; &lt;li id="list-item2"&gt;text 2&lt;/li&gt; &lt;li id="list-item3"&gt;text 3&lt;/li&gt; &lt;li id="list-item4"&gt;text 4&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>What's the easiest way to re...
<p>Though there's probably an easier way to do this using a JS Library, here's a working solution using vanilla js.</p> <pre><code>var list = document.getElementById('mylist'); var items = list.childNodes; var itemsArr = []; for (var i in items) { if (items[i].nodeType == 1) { // get rid of the whitespace text no...
<p>The neatest way I can think of:</p> <p>The param <code>compare</code> is just like the compare function used in <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort" rel="nofollow noreferrer">Array.sort()</a>.</p> <p>Sort child nodes.</p> <pre class="lang-js prettyprin...
35,807
<p>Is there any performance difference between tuples and lists when it comes to instantiation and retrieval of elements? </p>
<p>The <a href="https://docs.python.org/3/library/dis.html" rel="noreferrer"><code>dis</code></a> module disassembles the byte code for a function and is useful to see the difference between tuples and lists.</p> <p>In this case, you can see that accessing an element generates identical code, but that assigning a tupl...
<p>The main reason for Tuple to be very efficient in reading is because it's immutable. </p> <h2>Why immutable objects are easy to read?</h2> <p>The reason is tuples can be stored in the memory cache, unlike lists. The program always read from the lists memory location as it is mutable (can change any time).</p>
9,417
<p>Given the following code (that doesn't work):</p> <pre><code>while True: # Snip: print out current state while True: ok = get_input(&quot;Is this ok? (y/n)&quot;) if ok.lower() == &quot;y&quot;: break 2 # This doesn't work :( if ok.lower() == &quot;n&quot;: break # Do more proces...
<p>My first instinct would be to refactor the nested loop into a function and use <code>return</code> to break out. </p>
<p>Similar like the one before, but more compact. (Booleans are just numbers)</p> <pre><code>breaker = False #our mighty loop exiter! while True: while True: ok = get_input("Is this ok? (y/n)") breaker+= (ok.lower() == "y") break if breaker: # the interesting part! break # &l...
23,008
<p>I am upgrading a silverlight beta 2 app to RC0 and have a function that translates a point from a child element to it's parent. The purpose of the function is to ensure that an element appears exactly on top of the child even though they are not on the same canvas and don't share a parent.</p> <p>Here is the curre...
<p>See TransformToVisual method of framework element. It does exactly what you want: given another control, it generates a new transform that maps the coordinates of a point relative to the current control, to coordinates relative to the passed in control.</p> <pre><code>var transform = from.TransformToVisual(to); ret...
<p>Yet but... There appears to be a problem with how the rendering transform pipeline accepts updates which is different to how it works in WPF.</p> <p>I've created a wiki entry at <a href="http://support.daisley-harrison.com/wiki/DeveloperNotes.ashx" rel="nofollow noreferrer">daisley-harrison.com</a> then talks abou...
18,515
<p>I have a table in Access 2007 with 11,000 rows and about 20 columns. I want to create a form button that exports the table to an Excel sheet. The code need to be VBA.</p> <p>Any Ideas?</p>
<p>You're probably better off using the <a href="http://msdn.microsoft.com/en-us/library/system.io.directoryinfo.aspx" rel="noreferrer">System.IO.DirectoryInfo</a> class to interpret your relative path. You can then pick off folder or file names using its members:</p> <pre><code>DirectoryInfo di = new DirectoryInfo("i...
<p>Agreed with the "<em>don't do it this way</em>" answers, but, since it's tagged "<em>regex</em>"...</p> <ul> <li>You don't need the <code>?</code>. <code>*</code> already accepts 0 repetitions as a match, so <code>(.*)</code> is exactly equivalent to <code>(.*)?</code></li> <li>You rarely actually want to use <cod...
30,621
<p>I'm trying to develop specialized audio player for windows mobile devices (Professional ones). And I've ran into the problem an once.</p> <p>There no compressed audio APIs on WM or I was unable to found house in documentation. Yes there are WM6 Sound API but it cannot even pause playback or seek to specified positi...
<p>This might be of no help at all, but the (very good) podcast player <a href="http://www.codeplex.com/beyondpod" rel="nofollow noreferrer">BeyondPod</a> has a built in player, based on Windows Media Player, and it's open source - so you could have a look at what API they are using.</p> <p>Obviously if they've writte...
<p>I've found quite a sufficient compressed audio playback library <a href="http://www.fmod.org/" rel="nofollow noreferrer">FMOD</a>. There are WM version of it. And I've found sample application on <a href="http://www.codeproject.com/KB/mobile/simple_mp3_player_for_ppc.aspx" rel="nofollow noreferrer">CodeProject</a> t...
4,058
<p>I'm a Java-developer toying with Ruby, and loving it. I have understood that because of Ruby's metaprogramming facilities my unit-tests become much cleaner and I don't need nasty mocking frameworks. I have a class which needs the <code>File</code> class's services and in my test I don't want to touch my real filesys...
<p>Mocha (<a href="http://mocha.rubyforge.org/" rel="noreferrer">http://mocha.rubyforge.org/</a>) is a very good mocking library for ruby. Depending on what you're actually wanting to test (i.e. if you want to just fake out the File.new call to avoid the file system dependency or if you want to verify that the correct...
<p>In the case you've outlined, I'd suggest that what you're doing seems fine. I know that it's a technique that James Mead (the author of Mocha) has advocated. There's no need to do metaprogramming just for the sake of it. <a href="http://www.floehopper.org/articles/2007/11/29/mock-object-injection" rel="nofollow n...
9,785
<p>After I read a bunch of LINQ related stuff, I suddenly realized that no articles introduce how to write asynchronous LINQ query. </p> <p>Suppose we use LINQ to SQL, below statement is clear. However, if the SQL database responds slowly, then the thread using this block of code would be hindered.</p> <pre><code>var...
<p>While LINQ doesn't really have this per se, the framework itself does... You can easily roll your own asynchronous query executor in 30 lines or so... In fact, I just threw this together for you :)</p> <p><strong>EDIT: Through writing this, I've discovered why they didn't implement it. It cannot handle anonymous...
<p>I started a simple github project named <a href="https://github.com/JamesDunne/Asynq/" rel="nofollow">Asynq</a> to do asynchronous LINQ-to-SQL query execution. The idea is quite simple albeit "brittle" at this stage (as of 8/16/2011):</p> <ol> <li>Let LINQ-to-SQL do the "heavy" work of translating your <code>IQuery...
31,444
<p>I'm using the following code to make sure all certificates pass, even invalid ones, but I would like to know if there is a better way, as this event gets called globally and I only want the certificate to pass for a certain HTTP call and not for any others that are happening asynchronously.</p> <pre><code>// This d...
<p><a href="http://www.codeproject.com/KB/install/dotnetfx_innosetup_instal.aspx" rel="nofollow noreferrer">.NET Framework 1.1/2.0/3.5 Installer for InnoSetup</a></p>
<p>I have recently been looking into this issue but without the same requirements that you have. I haven't seen a script that does what you want but have you considered instead checking if .NET 2.0 is installed and if not then prompt them to download it. You can open a URL in the default browser and get the user to a...
15,749
<p>I need to find a way to crawl one of our company's web applications and create a static site from it that can be burned to a cd and used by traveling sales people to demo the web site. The back end data store is spread across many, many systems so simply running the site on a VM on the sale person's laptop won't wor...
<p>By using a <a href="http://en.wikipedia.org/wiki/Web_crawler" rel="noreferrer">WebCrawler</a>, e.g. one of these: </p> <ul> <li>DataparkSearch is a crawler and search engine released under the GNU General Public License.</li> <li>GNU Wget is a command-line operated crawler written in C and released under the GPL. I...
<p>You're not going to be able to handle things like AJAX requests without burning a webserver to the CD, which I understand you have already said is impossible.</p> <p><a href="http://www.gnu.org/software/wget/" rel="nofollow noreferrer">wget</a> will download the site for you (use the -r parameter for "recursive"), ...
14,306
<p>Octoprint warns me that the objects do not fit into the print volume. I noticed that this happens after a power-off cycle. Since I was overly anxious until today, I always uploaded the GCode file again and it didn't complain any more.</p> <p>Of course, always uploading the files again is also error prone. So today ...
<p>That's the purging that Slic3r PE adds, the broad line of filament at the edge of the sheet. That is outside the official print volume, which triggers this error.</p> <p>The G-Code generated by Slic3r PE at the start of the file contains the following lines:</p> <pre><code>G1 Y-3.0 F1000.0 ; go outside print area ...
<p><a href="/a/8267">This answer</a> is correct, it's normal for Prusa printers to purge at -3&nbsp;mm on the Y axis.</p> <p>This answer is an addition that describes how to get rid of the error.</p> <ol> <li>Open Octoprint web UI</li> <li>Go to <code>Settings</code> -> <code>Printer Profiles</code></li> <li>Find act...
1,222
<p>I'd like to create a Web Part with security-trimmed links for a MOSS Publishing Intranet Portal. The idea is that their logged-in user name is checked against a custom provider to determine their permissions for a particular link and the hyperlinks would be rendered based on this.</p> <p>What would be a good approa...
<p>If you don't have to have the custom provider to check permissions, you could just apply SharePoint permissions to the individual items in a list. Then, the list views would be trimmed automatically. Also, if you wanted to write your own web part to display them, you could use a CAML query to retrieve the items, an...
<p>If you don't have to have the custom provider to check permissions, you could just apply SharePoint permissions to the individual items in a list. Then, the list views would be trimmed automatically. Also, if you wanted to write your own web part to display them, you could use a CAML query to retrieve the items, an...
43,416
<p>Need to locate the following pattern:</p> <p>The letter I followed by a space then three alpha numerics followed by a space</p> <p>"I ALN " "I H21 " "I 31M "</p> <p>these items are also followed by a lat/lon that is trapped by this expression:</p> <p>Dim regex As New Regex("\d{6} \d{7}")</p> <p>Can the expressi...
<p>/I ([0-z]{3} \d{6} \d{7})/</p> <p>I don't know VB, but that regex would work with say perl.</p> <p><b>Update:</b><br/> Given the new string provided.. something like this <em>may</em> work (depending on responses to my questions)</p> <p><code> /^[A-z] ([0-z]{3}) [A-z] [0-z]{3} L (\d{6} \d{7})/ </code></p> <p>Mat...
<pre><code>I ([a-zA-Z\d]{3} \d{6} \d{7}) </code></pre> <p>Match group 1 would contain the three alphanumerics plus the numbers you already catch with your other regex.</p> <p>EDIT: Does not work because the pattern described in the question does not reflect what the author meant in the first place. What really was me...
39,305
<p>On the .Net WebBrowser control the only way I can see to load a page to it is to set the URL property. But I would like to instead give it some HTML code that I already have in memory without writing it out to a file first. Is there any way to do this? Or are there any controls that will do this?</p>
<p>You want the DocumentText Property:</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.documenttext.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.documenttext.aspx</a></p> <p>?</p> <p>from <a href="http://www.codeguru.com/forum/...
<p>Also, generally, anywhere you can use a Stream, you can use MemoryStream to wrap data you have in memory.</p>
18,073
<p><strong>Java</strong> is the key here. I need to be able to delete files but users expect to be able to "undelete" from the recycle bin. As far as I can tell this isn't possible. Anyone know otherwise?</p>
<p>For various reasons Windows <a href="http://blogs.msdn.com/oldnewthing/archive/2008/09/18/8956382.aspx" rel="noreferrer">has no concept of a folder that simply corresponds to the Recycle Bin</a>.</p> <p>The correct way is to use JNI to invoke the Windows <code>SHFileOperation</code> API, setting the <code>FO_DELETE...
<p>My 3 cents - use cmd util <a href="http://www.maddogsw.com/cmdutils/" rel="nofollow noreferrer">Recycle.exe</a> with -f to force recycle (no prompt). Works perfectly.</p> <pre><code>public class Trash { public void moveToTrash(File ... file) throws IOException { moveToTrash(false, file); } pub...
27,447
<p>A friend of mine downloaded some malware from Facebook, and I'm curious to see what it does without infecting myself. I know that you can't really decompile an .exe, but can I at least view it in Assembly or attach a debugger? </p> <p>Edit to say it is not a .NET executable, no CLI header.</p>
<p>With a <strong>debugger</strong> you can step through the program assembly interactively.<br /> With a <strong>disassembler</strong>, you can view the program assembly in more detail.<br /> With a <strong>decompiler</strong>, you can turn a program back into partial source code, assuming you know what it was written...
<p>The <a href="http://www.ntcore.com/exsuite.php" rel="nofollow noreferrer">explorer suite</a> can do what you want.</p>
34,400
<p>I have an oc4j installation bereft of any release notes or version documentation. In the absence of such documents, how do I know for sure, which version of oc4j I am using?</p>
<p>Check Server header in HTTP headers. For example with wget or curl; </p> <pre><code>wget -S &lt;url-to-server&gt; curl -I &lt;url-to-server&gt; </code></pre> <p>or with browser, which can show HTTP headers.</p> <p>There should be a header something like</p> <pre><code>Server: Oracle-Application-Server-10g/10.1.3...
<pre><code>grep Version $ORACLE_HOME/config/ias.properties </code></pre>
30,525
<p>As a .NET developer I'm asking whether JBoss alternatives exist to be "more suitable for .NET development" as an enterprise application platform.</p> <p>Please do not make any suggestions, such as "make JBoss to expose WebServices"...</p>
<p>Java lacks a "hosting" solution - this is where (mainly) all the solutions like JBoss and WhebLogic are popping up from. In .NET you have so many different hosting solutions like: services, IIS, SQL, BizTalk ... </p> <p>Now with the recent WCF features you can implement your own JBoss in 5 minutes - create an objec...
<p>If you're looking for java app servers, there's WebSphere and WebLogic. But it'd probably be little different from jBoss from you prospective. </p> <p>What are you looking for? What does jBoss do that you want the alternative to do? Are you looking for something in .NET? Is your .NET code a client that's going to i...
19,170
<p>How do I call a url in order to process the results?</p> <p>I have a stand-alone reporting servlet which I link to for reports. I want to email these reports now, if I were doing this in the browser, I could just use an xhttprequest, and process the results - I basically want to do the same thing in Java, but I'm n...
<pre><code>public byte[] download(URL url) throws IOException { URLConnection uc = url.openConnection(); int len = uc.getContentLength(); InputStream is = new BufferedInputStream(uc.getInputStream()); try { byte[] data = new byte[len]; int offset = 0; while (offset &lt; len) { ...
<p>Check out the URL and URLConnection classes. Here's some documentation: <a href="http://www.exampledepot.com/egs/java.net/Post.html" rel="nofollow noreferrer">http://www.exampledepot.com/egs/java.net/Post.html</a></p>
29,546
<p>For example, <a href="http://developer.apple.com/cocoa/pyobjc.html" rel="nofollow noreferrer">http://developer.apple.com/cocoa/pyobjc.html</a> is still for OS X 10.4 Tiger, not 10.5 Leopard.. And that's the official Apple documentation for it..</p> <p>The official PyObjC page is equally bad, <a href="http://pyobjc....
<p>I agree that that tutorial is flawed, throwing random, unexplained code right in front of your eyes. It introduces concepts such as the autorelease pool and user defaults without explaining why you would want them ("Autorelease pool for memory management" is hardly an explanation).</p> <p>That said…</p> <blockquot...
<p>This answer isn't going to be very helpful but, as a developer I hate doing documentation. This being a opensource project, it's hard to find people to do documentation.</p>
3,524
<p>Umm, I guess my questions in the title:</p> <p>How do I turn on Option Strict / Infer in a VB.NET aspx page without a code behind file?</p> <pre><code>&lt;%@ Page Language="VB" %&gt; &lt;script runat="server"&gt; Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) End Sub &lt;/scr...
<pre><code>&lt;%@ Page Language="VB" Strict="true" %&gt; </code></pre>
<p>Change the top line to </p> <pre><code>&lt;%@ Page Language="VB" strict="True" %&gt; </code></pre>
26,198
<p>Is there any way to detect if the iPhone wakes up from sleep while you're app is running? Eg: your app is running, the user locks the screen (or the screen auto locks) and some time later the user unlocks the screen and up pops your app. Is there some way to get an event at that point or detect it somehow? </p> <p>...
<p>See <code>applicationDidBecomeActive:</code> on UIApplicationDelegate.</p>
<p>Stick these in you AppDelegate.m file:</p> <pre><code>-(void) applicationWillResignActive:(UIApplication *)application { NSLog(@"Asleep"); } -(void) applicationDidBecomeActive:(UIApplication *)application { NSLog(@"Awake"); } </code></pre> <p>@Kevin - Nothing wrong with your answer - thanks by the wa...
48,041
<p>I've been wrestling with a filament grinding problem for a few weeks now and I'm stuck.</p> <p>The problem manifests itself as starting a print alright then extrusion stops while the printer keeps moving. When I pull the filament out I see indents from the gear then a depression where it ground down the filament.</p...
<p>Thingieverse does respect the orientation an item was designed in, just like most slicers will. Designers will often choose any one of the three planes (XY, YZ, ZX) as their first by preference, then work out the other parts in relation to the first. This does often not take into account the actual print orientation...
<p>When I design parts in CAD software I pick a starting plane and go from there. And that starting plane doesn't correspond to how the part is designed to be printed. That usually comes later.</p>
1,725
<blockquote> <p><strong>Edit</strong>: Now I need to solve this problem for real, I did a little more investigation and came up with a number of things to reduce duplicate content. I posted detailed code samples on my blog: <a href="http://blog.dantup.me.uk/2009/04/reducing-duplicate-content-with-aspnet.html" rel="nofo...
<p>I was working on this as well. I will obviously defer to ScottGu on this. I humbly offer my solution to this problem as well though.</p> <p>Add the following code to <strong>global.asax</strong>:</p> <pre><code>protected void Application_BeginRequest(Object sender, EventArgs e) { // If upper case letters are...
<p>i really don't know how you are going to feel after 8 years but Now ASP MVC 5 supports attribute routing for easy to remember routes and to solved duplicate content problems for SEO Friendly sites</p> <p>just add routes.MapMvcAttributeRoutes(); in your RouteConfig and then define one and only route for each action...
20,610
<p>We are in the process of nutting out the design guidelines we would like to use in our development team and got into a discussion today around how ASP.NET controls should be named. I am talking about our good friends Label, TextBox, Button etc.</p> <p>We came up with the following three possibilities that we voted ...
<p>The reason Visual Studio adds "TextBox1" when you add it to the page is because Microsoft has no way of knowing how you intend to use it. Naming it "Control1" would be too confusing because it could be any number of controls.</p> <p>Microsoft provides guidance in general for OO naming conventions, but not specifica...
<p>Not really sure about any guidelines, i suspect there are, but I always use number 2 as well!</p>
21,922
<p>I'm serializing to XML my class where one of properties has type List&lt;string&gt;.</p> <pre><code>public class MyClass { ... public List&lt;string&gt; Properties { get; set; } ... } </code></pre> <p>XML created by serializing this class looks like this:</p> <pre><code>&lt;MyClass&gt; ... &lt...
<p>Try <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlarrayitemattribute.aspx" rel="noreferrer">XmlArrayItemAttribute</a>:</p> <pre><code>using System; using System.IO; using System.Xml.Serialization; using System.Collections.Generic; public class Program { [XmlArrayItem("Property")]...
<p>Add <code>[XmlElement("Property")]</code> before the declaration of your Properties member.</p>
41,676
<p>How do I delete untracked local files from the current working tree?</p>
<blockquote> <h2><a href="https://git-scm.com/docs/git-clean" rel="noreferrer">git-clean</a> - Remove untracked files from the working tree</h2> <h3>Synopsis</h3> <pre><code>git clean [-d] [-f] [-i] [-n] [-q] [-e &lt;pattern&gt;] [-x | -X] [--] &lt;path&gt;…​ </code></pre> <h3>Description</h3> <p>Cleans the working tre...
<p>I use this:</p> <ol> <li><code>git status</code></li> <li>copy the path of the file</li> <li><code>rm &lt;path of file&gt;</code></li> </ol> <p>My project has a lot of generated files created by a giant ANT build script. Using <code>git clean</code> would create chaos.</p>
8,634
<p>Lets say I've got two interchangeable pieces of code and I want to figure out which one of them takes less processor time to execute. How would I do this?</p> <p>To get a very rough estimation I could just put NSLog() calls on either side of the code I wanted to profile, but it seems like the processor being otherw...
<p>Unless one of these two pieces of code is already in your app, <strong>and</strong> you've already profiled your app's overall performance to determine that the existing code is a major bottleneck, then what you're doing is called "premature optimization."</p> <p>Xcode includes an excellent <a href="http://en.wikip...
<p>Assuming you want to profile a whole app (not just a snippet of code), and that your app is written in C/C++/Objective-C (not, e.g. Ruby), and that you're using Xcode 3.0 or higher, you should also check out the Instruments application. The "Sampler" instrument will give you very similar information to Shark (though...
25,307
<p>A recent <a href="https://stackoverflow.com/questions/286180/">question about StyleCop</a> alerted me to the use of tools to enforce coding style. I would feel very annoyed if I were required to run one of these tools while I was developing. Do people really find them useful? Why or why not?</p> <p>Everyone that ha...
<p>Yes, it's very helpful - particularly in large projects. It means you can go to anyone else's code, and it won't look alien to you. This means that people are more portable across projects, which gives a lot more flexibility - both for the person and the company.</p> <p>The downside is that a lot of time can be spe...
<p>If style refers to <em>formatting</em> (like '{' must be at the end or at the beginning of a line), it can be very annoying, especially if merges are involves and if that style is not strictly enforced for all developers.</p> <p>If style refers to '<strong>good practice</strong>" (like the body of a 'if' statement ...
36,583
<p>When returning objects from a class, when is the right time to release the memory?</p> <p>Example,</p> <pre><code>class AnimalLister { public: Animal* getNewAnimal() { Animal* animal1 = new Animal(); return animal1; } } </code></pre> <p>If i create an instance of Animal Lister and get Animal ref...
<p>I advise returning a <code>std::tr1::shared_ptr</code> (or <code>boost::shared_ptr</code>, if your C++ implementation does not have TR1) instead of a raw pointer. So, instead of using <code>Animal*</code>, use <code>std::tr1::shared_ptr&lt;Animal&gt;</code> instead.</p> <p>Shared pointers handle reference tracking ...
<p>I really like Josh's answer, but I thought I might throw in another pattern because it hasn't been listed yet. The idea is just force the client code to deal with keeping track of the animals.</p> <pre><code>class Animal { ... private: //only let the lister create or delete animals. Animal() { ... } ~Animal(...
25,011
<p>Scenario - I need to access an HTML template to generate a e-mail from my Business Logic Layer. It is a class library contains a sub folder that contains the file. When I tried the following code in a unit test:</p> <pre><code>string FilePath = string.Format(@"{0}\templates\MyFile.htm", Environment.CurrentDirecto...
<p>You're running this from an ASP.Net app right? Use <code>Server.MapPath()</code> instead.</p> <p>Also take a look at <code>System.IO.Path.Combine()</code> for concatenating paths.</p> <p>[Edit] Since you can't use <code>System.Web</code>, try this:</p> <pre><code>System.Reflection.Assembly.GetExecutingAssembly()....
<p>Use</p> <pre><code>System.Web.HttpServerUtility.MapPath( "~/templates/myfile.htm" ) </code></pre>
29,084
<p>I've been writing some providers in c# that inherit from the providerbase class. I've found that it's hard to write tests that use the providers as most mocking frameworks will only allow you to mock an interface. </p> <p>Is there any way to mock a call to a provider that inherits from providerbase?</p> <p>If not,...
<p>Mocking frameworks should be able to create for you a mock object based on a class, as long as it's got virtual members.</p> <p>You may also want to take a look at <a href="http://www.typemock.com/" rel="noreferrer">Typemock</a></p>
<p><a href="http://ayende.com/projects/rhino-mocks.aspx" rel="nofollow noreferrer">RhinoMocks</a> or <a href="http://code.google.com/p/moq/" rel="nofollow noreferrer">Moq</a> will create test doubles for classes as well as for interfaces. The type has to have virtual methods or be abstract though. The <a href="http://w...
15,989
<p>An obvious answer is "an internal wiki". What are the pros and cons of a wiki used for software documentation? Any other suggestions? What are you using for your software documentation?</p> <p><a href="https://stackoverflow.com/users/6436/loren-segal">Loren Segal</a> - Unfortunately we don't have support for any do...
<p>That's a very open ended question, and depends on many factors. </p> <p>Generally speaking, if you use a language that has good documentation generation tools (javadoc, doxygen, MS's C# stuff), you should write your documentation above your methods and have your tools generate the pages. The advantage is that you k...
<p>My company uses a variety of Sharepoint and a wiki. Sharepoint for specific documents like requirements, presentations, contracts, etc, while the wiki is used as a help guide a developer repository for tutorials on using internally developed libraries.</p>
12,464
<p>Which is generally fastest when reading/comparing row info from a DataTable?</p> <pre><code>'assume dt as datatable' 'method 1' dim i as int32 for i = 0 to dt.rows.count - 1 .... next 'method 2' dim row as datarow for each row in dt.rows .... next </code></pre> <p>And if there's a difference, in what circ...
<p>The compiler expands For Each to a short while loop.</p> <pre><code>for each row in dt.rows // expands to: IEnumerator e = dt.rows.GetEnumerator() while e.MoveNext() row = e.Current </code></pre> <p>So you pay a small amount of overhead. But for clarities sake, I'd still stick with For Each if you're only work...
<p>The foreach implementation is actually slightly faster than the standard for implementation, because each index array access needs to be bounds checked. However, since the idiom:</p> <pre><code>for(int i =0; i &lt; myArray.Count; ++i) { // do something with myArray[i]; } </code></pre> <p>is common, the compil...
22,543
<p>We have a recurring problem at my company with build breaks in our Flex projects. The problem primarily occurs because the build that the developers do on their local machines is fundamentally different from the build that occurs on the build machine. The devs are building the projects using <code>FlexBuilder/eclips...
<ul> <li><p><code>__declspec(dllexport)</code> tells the linker that you want this object to be made available for other DLL's to import. It is used when creating a DLL that others can link to.</p></li> <li><p><code>__declspec(dllimport)</code> imports the implementation from a DLL so your application can use it.</p></...
<p>Dllexport is used to mark a function as exported. You implement the function in your DLL and export it so it becomes available to anyone using your DLL.</p> <p>Dllimport is the opposite: it marks a function as being imported from a DLL. In this case you only declare the function's signature and link your code with ...
8,245
<p>I have a div tag in the view that I'd like to update with a graph that I generate via Gruff.</p> <p>I have the following controller action which does this at the end</p> <pre><code>send_data g.to_blob, :disposition=&gt;'inline', :type=&gt;'image/png', :filename=&gt;'top_n.pdf' </code></pre> <p>Now if I directly i...
<p>In your link_to_remote tag just set :complete to something like this:</p> <pre><code>:complete =&gt; "updateImg(id_of_div, request.responseText)" </code></pre> <p>And write a JS function:</p> <pre><code>function updateImg(id, img) { $(id).innerHTML = '&lt;img src="' + img + '" /&gt;'; } </code></pre> <p>Where ...
<p>You could use a regular <code>img</code> tag to call a controller action wich returns a generated png. If you set up the controller to use <a href="http://api.rubyonrails.org/classes/ActionController/MimeResponds/InstanceMethods.html#M000245" rel="nofollow noreferrer">respond_to</a> something like this:</p> <pre><c...
42,896
<p>Should each class in my C# project get its own file (in your opinion)?</p>
<p>While the one class per file policy is strictly enforced in Java, it's not required by C#. However, it's generally a good idea.</p> <p>I typically break this rule if I have a very small helper class that is only used by the main class, but I prefer to do that as a nested inner class for clarity's sake.</p> <p>You ...
<p>Of course! Why wouldn't you? Other than private classes it is silly to have multiple classes in a single file.</p>
17,463
<p>I'm looking for an abstract representation of a grid in Java (grid as in that thing with columns and rows of data). Do such things exist? I want to be able to sort, filter, keep track of rows, set column properties etc. I'll then be realising the grid on the web.</p> <p>To be clear: I've already decided on the u...
<p>Have a look to this tutorial from Sun about the tables in java. It gives a good idea on how to implement the model.</p> <p><a href="http://java.sun.com/docs/books/tutorial/uiswing/components/table.html" rel="nofollow noreferrer">Tutorial on tables in Java</a></p>
<p><a href="http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTable.html" rel="nofollow noreferrer">JTable</a> is what you are looking for.</p>
28,441
<p>I'm getting an error when my application starts. It appears to be after it's initialized its connection to the database. It also may be when it starts to spawn threads, but I haven't been able to cause it to happen on purpose.</p> <p>The entire error message is:<br> FATAL ERROR in native method: JDWP NewGlobalRef...
<p>JVMTI is the debugging and profiling protocol. So, I'm guessint it's something peculiar to the environment you are attempting to run your application in.</p>
<p>I'm guessing you are using a native-code&ndash;based database driver (JDBC driver type 1 or 2). And I'm guessing that driver is buggy. If you could provide more information about the driver and your datasource configuration or connection string, it might help determine some answers.</p>
7,558
<p>Consider the class below that represents a Broker:</p> <pre><code>public class Broker { public string Name = string.Empty; public int Weight = 0; public Broker(string n, int w) { this.Name = n; this.Weight = w; } } </code></pre> <p>I'd like to randomly select a Broker from an a...
<p>Your algorithm is nearly correct. However, the test should be <code>&lt;</code> instead of <code>&lt;=</code>:</p> <pre><code>if (randomNumber &lt; broker.Weight) </code></pre> <p>This is because 0 is inclusive in the random number while <code>totalWeight</code> is exclusive. In other words, a broker with weight 0...
<p>I've come up with a generic version of this solution:</p> <pre><code>public static class WeightedEx { /// &lt;summary&gt; /// Select an item from the given sequence according to their respective weights. /// &lt;/summary&gt; /// &lt;typeparam name="TItem"&gt;Type of item item in the given sequence.&...
8,074
<pre><code>uint color; bool parsedhex = uint.TryParse(TextBox1.Text, out color); //where Text is of the form 0xFF0000 if(parsedhex) //... </code></pre> <p>doesn't work. What am i doing wrong?</p>
<p>Try </p> <pre><code>Convert.ToUInt32(hex, 16) //Using ToUInt32 not ToUInt64, as per OP comment </code></pre>
<p>Here is a try-parse style function:</p> <pre><code> private static bool TryParseHex(string hex, out UInt32 result) { result = 0; if (hex == null) { return false; } try { result = Convert.ToUInt32(hex, 16); return true; ...
12,390
<p>I want to use a WSDL SOAP based web service in Python. I have looked at the <a href="http://web.archive.org/web/20181001011217/http://www.diveintopython.net/soap_web_services/" rel="noreferrer">Dive Into Python</a> code but the SOAPpy module does not work under Python 2.5.</p> <p>I have tried using <a href="https:/...
<p>I would recommend that you have a look at <a href="https://fedorahosted.org/suds/" rel="noreferrer">SUDS</a></p> <p>"Suds is a lightweight SOAP python client for consuming Web Services."</p>
<p>If you're rolling your own I'd highly recommend looking at <a href="http://effbot.org/zone/element-soap.htm" rel="nofollow noreferrer">http://effbot.org/zone/element-soap.htm</a>.</p>
14,061
<p>I have some ASP.NET Master Pages located in one assembly. I need to use these Master Pages with my WebForm pages located in other assemblies that have a reference to the first assembly. I cannot seem to figure out a way to do this.</p> <p>Is there a nice way that I can do this?</p> <p>If no pretty solution exists ...
<p>Master Pages are based upon Usercontrols, therefore they cannot be shared across applications. </p> <p>That said, Dan Wahlin has a way around that particular limitation <a href="http://weblogs.asp.net/dwahlin/archive/2005/11/16/430779.aspx" rel="noreferrer">listed on his blog</a>. </p>
<p>There are no pretty solutions to this problem.</p> <p>What you can do is put it into a separate web application project and pre-compile it. Then take the precompiled dlls and ILMerge them into a single dll that you can reference in your app.</p> <p>The actual master page that you reference will have a class name ...
14,262
<p>My understanding of Hibernate is that as objects are loaded from the DB they are added to the Session. At various points, depending on your configuration, the session is flushed. At this point, modified objects are written to the database.</p> <p>How does Hibernate decide which objects are 'dirty' and need to be wr...
<p>Hibernate does/can use bytecode generation (CGLIB) so that it knows a field is dirty as soon as you call the setter (or even assign to the field afaict).</p> <p>This immediately marks that field/object as dirty, but doesn't reduce the number of objects that need to be dirty-checked during flush. All it does is impa...
<p>These answers are incomplete (at best -- I am not an expert here). If you have an hib man entity in your session, you do NOTHING to it, you can still get an update issued when you call save() on it. when? when another session updates that object between your load() and save(). here is my example of this: <a href...
10,816
<p>I'm writing a url rewrite in django that when a person goes to <a href="http://mysite.com/urlchecker/http://www.google.com" rel="nofollow noreferrer">http://mysite.com/urlchecker/http://www.google.com</a> it sends the url: <a href="http://ww.google.com" rel="nofollow noreferrer">http://ww.google.com</a> to a view ...
<p>Try this instead:</p> <p><code>(r'^urlchecker/(?P&lt;url&gt;.+)$', 'mysite.main.views.urlchecker'),</code></p> <p>This differs from yours in that:</p> <ul> <li>It will take anything after 'urlcheck/', not just "word" characters.</li> <li>It does not force the url to end in a slash.</li> </ul>
<p>I just learned something while grazing the Hidden Features of Python thread. <a href="https://stackoverflow.com/questions/101268/hidden-features-of-python#143636">Python's re compiler has a debug mode</a>! (Who knew? Well, apparently someone did :-) Anyway, it's worth a read.</p>
34,669
<p>I'm working on a something related to roughset right now. The project uses alot of sets operation and manipulation. I've been using string operations as a stop gap measure for set operation. It has worked fine until we need to process some ungodly amount of data ( 500,000 records with about 40+ columns each ) throug...
<p>.NET 3.5 already has a native set data type: <a href="http://msdn.microsoft.com/en-us/library/bb359438.aspx" rel="noreferrer">HashSet</a>. You might also want to look at <a href="http://msdn.microsoft.com/en-us/library/bb397728.aspx" rel="noreferrer">HashSet and LINQ set operators</a> for the operations.</p> <p>In ...
<p>You can use Linq to Objects in C# 3.0.</p>
13,825
<p>When are objects or something else said to be &quot;first-class&quot; in a given programming language, and why? In what way do they differ from languages where they are not?</p> <p>When one says &quot;everything is an object&quot; (like in Python), do they indeed mean that &quot;everything is first-class&quot;?</p>
<p>In short, it means there are no restrictions on the object's use. It's the same as any other object.</p> <p>A first class object is an entity that can be dynamically created, destroyed, passed to a function, returned as a value, and have all the rights as other variables in the programming language have. </p> <bl...
<p>IMO this is one of those metaphors used to describe things in a natural language. The term is essentially used in context of describing functions as first class objects. </p> <p>If you consider a object oriented language, we can impart various features to objects for eg: inheritance, class definition, ability to pa...
30,415