instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<pre><code>class Ball:
a = []
def __init__(self):
pass
def add(self,thing):
self.a.append(thing)
def size(self):
print len(self.a)
for i in range(3):
foo = Ball()
foo.add(1)
foo.add(2)
foo.size()
</code></pre>
<p>I would expect a return of :</p>
<pre><code>2
2
2
</code></pre>
<p>But I ... | <p><em>doh</em></p>
<p>I just figured out why.</p>
<p>In the above case, the a is a class attribute, not a data attribute - those are shared by all Balls(). Commenting out the a=[] and placing it into the <strong>init</strong> block means that it's a data attribute instead. (And, I couldn't access it then with foo.a,... | <p>"Can I define a class variable and replace it with a data variable?"</p>
<p>No. They're separate things. A class variable exists precisely once -- in the class.</p>
<p>You could -- to finesse code completion -- start with some class variables and then delete those lines of code after you've written your class. ... | 39,618 |
<p>I've just finished a flash project where I did the entire project in "pure" AS3, without the use of the Flex framework. I found very little written about this on the web, so I'm not sure if this is a common way to develop RIA's, or if I've jumped off the shoulders of giants and done something stupid that will bite ... | <p>There's nothing wrong with it. People do that every day using FlashDevelop and AS3-only frameworks like <a href="http://puremvc.org/" rel="noreferrer">PureMVC</a>. Doing a complex app without any framework to support may get difficult to support in the future, but should be OK if you adhere to well known best prac... | <p>Thanks all! I've been very happy with AS3, and like the amount of control I get, as opposed to using MXML/Flex. It's good to hear I'm not crazy!</p>
| 31,849 |
<p>Where can I find a good tutorial on learning ASP.NET MVC using VB.net 2008 as the language? Most in-depth tutorials that I found in searching the web were written in C#.</p>
| <p>Have you tried adding the word "VB" to your searches??</p>
<p><a href="http://www.myvbprof.com/2007_Version/MVC_Intro_Tutorial.aspx" rel="nofollow noreferrer">http://www.myvbprof.com/2007_Version/MVC_Intro_Tutorial.aspx</a></p>
<p><a href="http://www.asp.net/learn/mvc/tutorial-07-vb.aspx" rel="nofollow nor... | <p><a href="http://quickstarts.asp.net/3-5-extensions/mvc/default.aspx" rel="nofollow noreferrer">http://quickstarts.asp.net/3-5-extensions/mvc/default.aspx</a></p>
<p>Is that relevant?</p>
| 5,262 |
<p>I have an app that needs to handle very large strings between a SQL Server database and .NET code. I have a LINQ query that generates the strings when saving them <i>to</i> the database, but when trying to create the strings <i>from</i> the database, the app crashes with an OutOfMemoryException because of the size o... | <p>What do you call "very large"? And what is the string? CLOB? BLOB? xml?</p>
<p>I suspect you should be using things like <code>ExecuteReader()</code>, which (via <code>IDataReader</code>) exposes methods for reading such columns in chunks:</p>
<pre><code> using (var reader = cmd.ExecuteReader(
C... | <p>I haven't measured the size of the strings, but they quickly reach .Net limits. The information is XML "stored" in a XStreamingElement object generated by a LINQ query. I will give a shot to your IDataReader suggestion to see if it solves the problem. Basically, I'm reading back with LINQ to SQL, is there any hook s... | 41,863 |
<p>I am trying to set the <code>fieldValue</code> of the check box to a value I got from the property tag.</p>
<p>I am having trouble with the syntax.</p>
<p>This is what I have tried:</p>
<pre><code><s:form id="myForm" method="post" action="removeUser" enctype="multipart/form-data">
<s:iterator value=... | <p>I don't think you can do that:</p>
<p><em><s:checkbox label="delete" name="delete" fieldValue="<s:property value='id'/>"/></em></p>
<p>fieldValue expects a OGNL expression. I did some Struts, not too much, you could try:</p>
<p>fieldValue="%{id}"</p>
| <p>Try doing:</p>
<pre><code>fieldValue="<s:property value= "${id }" />"
</code></pre>
<p>or</p>
<pre><code>fieldValue="<s:property value=<c:out value="${id }"/> />"
</code></pre>
<p>this will require:</p>
<pre><code><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
</code>... | 40,265 |
<p>I am trying to install <a href="http://subtextproject.com/" rel="nofollow noreferrer">Subtext</a> in a medium trust level environment (host: <a href="http://www.crystaltech.com/" rel="nofollow noreferrer">Crystaltech</a>) and am getting the following error (see below). I was able to do the administration setup but ... | <p>I don't think there is another way to get around the error other than moving to full trust or removing the call to CheckUrlAccessForPrincipal() and recompiling.</p>
<p>But by the looks of things, this particular issue has already been corrected in the subtext SVN (revision 3290). They have also added a new build ta... | <p>More grist to <a href="https://stackoverflow.com/questions/175075/subtext-install-gives-error-in-medium-trust-level#175132">add to the mill</a> from csgero:</p>
<p><a href="http://www.kowitz.net/archive/2008/08/15/upgrading-to-subtext-2.0-fail.aspx" rel="nofollow noreferrer">http://www.kowitz.net/archive/2008/08/15... | 21,108 |
<p>Does anybody know a good code generation tool (other than Subsonic because it doesn't support IQueryable in current version) to generate repository and other projects in a way Rob Conery worked in MVC Storefront?</p>
| <p>Rob Conery has put out a Visual Studio plug-in that generates MVC code, using repositories that use IQueryable, although I believe the model is generated using Linq to SQL classes in visual studio, which wasn't the case in MVC Storefront.</p>
<p>You can find it <a href="http://blog.wekeroad.com/blog/subsonic-mvc-ad... | <p>Is <a href="http://www.olegsych.com/2008/09/t4-tutorial-creating-reusable-code-generation-templates/" rel="nofollow noreferrer">T4</a> the answer for your needs?</p>
| 30,836 |
<p>In your opinion, is it ever valid to use the @ operator to suppress an error/warning in PHP whereas you may be handling the error?</p>
<p>If so, in what circumstances would you use this?</p>
<p>Code examples are welcome.</p>
<p>Edit: Note to repliers. I'm not looking to turn error reporting off, but, for example,... | <p>Note: Firstly, I realise 99% of PHP developers use the error suppression operator (I used to be one of them), so I'm expecting any PHP dev who sees this to disagree.</p>
<blockquote>
<p>In your opinion, is it ever valid to use the @ operator to suppress an error/warning in PHP whereas you may be handling the erro... | <p>I use it when trying to load an HTML file for processing as a DOMDocument object. If there are any problems in the HTML... and what website doesn't have <em>at least one</em>... DOMDocument->loadHTMLFile() will throw an error if you don't suppress it with @. This is the only way (perhaps there are better ones) I've ... | 16,565 |
<p>I'm writing a WinForms application and one of the tabs in my TabControl has a SplitContainer. I'm saving the SplitterDistance in the user's application settings, but the restore is inconsistent. If the tab page with the splitter is visible, then the restore works and the splitter distance is as I left it. If some ot... | <p>I found the problem. Each tab page doesn't get resized to match the tab control until it gets selected. For example, if the tab control is 100 pixels wide in the designer, and you've just set it to 500 pixels during load, then setting the splitter distance to 50 on a hidden tab page will get resized to a splitter di... | <p>Restoring splitter distances has given me a lot of grief too. I have found that restoring them from my user settings in the form (or user control) Load event gave much better results than using the constructor. Trying to do it in the constructor gave me all sorts of weird behaviour.</p>
| 15,730 |
<p>So I was hoping that some old school Vim'ers could help me out. These are all separate questions and normally I would put them up each on their own but I'm not sure if that qualifies as question whoring here. </p>
<p>Plus I think if you know enough to be asking any of these questions they will all be coming up in t... | <p>Re 3)</p>
<p>If you put a makefile in your root dir, you can simply write
:make</p>
<p>This will run make and (iirc) put any errors into a seperate buffer, and make vim goto the first compile error. From there you can navigate all erroring lines using :next-error</p>
<p>Also, see this page
<a href="http://wiki.b... | <p>2)</p>
<pre><code>:cd {path}
</code></pre>
<p>For help:</p>
<pre><code>:he cd
</code></pre>
<p>A few others like <code>:lcd</code> might be better suited. Just scroll down that help page.</p>
| 34,661 |
<p>I do have to say I'm fairly inexperienced when it comes to C++, don't be too harsh on me.</p>
<p>Recently stumbled unto the wonders of the win32 API and have chosen to practice using it (I'd rather not use MFC/wxWidgets/etc at this point, just for educational purposes).</p>
<p>Well, my real question is:
How do you... | <p>I personally would use MFC instead of reinventing the wheel here. However, if you insist you need to have an application object that is instantiated when the program is run and contains the message loop and a mechanism for forwarding messages to the correct window objects. </p>
<p>That's the way MFC does it, at le... | <p>The only reason I would recommend not reinventing the wheel is you are neither an expert at C++ nor the Win32 API. Trying to learn two unrelated subjects at once will not be productive. If you want to become better at C++, write a library for a subject you know a lot about. If you want to learn the Win32 API, progra... | 47,151 |
<p>I am trying to print a model I designed in Blender on Shapeways.</p>
<p>The object has a hole in it:</p>
<p><a href="https://i.stack.imgur.com/iCaGP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iCaGP.png" alt="enter image description here"></a></p>
<p>But when I upload it to Shapeways as a S... | <p>Double-check that your model is solid (i.e. watertight). Holes in the mesh, or (as other's mentioned in the comments) or problems with thickness can cause those issues. You can use <a href="https://netfabb.azurewebsites.net/" rel="nofollow">Netfabb's Cloud Services</a>, or download the free version of their app. The... | <p>Just like the other already have mentioned, most likely your model has 3D printing errors. Either way, I would run it through a repairing service just to make sure it's free of 3D printing errors. I repair my models using this free automatic tool <a href="https://makeprintable.com/" rel="nofollow">https://makeprinta... | 378 |
<p>I'm new to 3D printing, but I've solved all of my problems except for this rough surface shown in the image of a Benchy print:</p>
<p><a href="https://i.stack.imgur.com/rhJhL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rhJhL.jpg" alt="Benchy showing printing defects"></a></p>
<p>Any suggest... | <p>You print too hot and probably with not enough cooling. These typical defects are caused by too much heat input into your model. You see this best at the overhang of the bow of Benchy, it should be smooth like the bottom part of the side of your Benchy. It clearly shows heat induced defects. Lower the temperature at... | <p>Try to re-compile the gcode, sometimes the slicer "freaks out" whilst writing the file. Which slicer are you using? (Cura, Slic3r, Repetier, etc.)</p>
<p>I sometimes have that errors, and giving that they do seem quite consistent in shape in the pics I would say that's the issue.</p>
| 1,188 |
<p>I'm currently maintaining a CVS repository for source control. There is a push afoot to move to StarTeam. It has already been purchased and is a corporate standard for most projects. I was told by the corporate owners of the StarTeam servers that there is no known way to do a complete migration of our current CVS... | <p>I wonder why a "professional" tool does not provide any means to import from well known legacy systems...</p>
<p>Although it may sound queer at first, i would recommend converting the cvs repos to subversion ( using e.g. <a href="http://cvs2svn.tigris.org/" rel="nofollow noreferrer">cvs2svn</a>, offered by tigris.o... | <p>Here is a document that talks about importing PVCS or SourceSafe repositories into StarTeam. Though not specifically addressing CVS it may give you some ideas on how something like this could be accomplished. There are also some comments at the bottom of the article that look helpful as well.</p>
<p><a href="http... | 27,003 |
<p>I have a function called:</p>
<pre><code>void initializeJSP(string Experiment)
</code></pre>
<p>And in my MyJSP.h file I have:</p>
<pre><code>2: void initializeJSP(string Experiment);
</code></pre>
<p>And when I compile I get this error:</p>
<blockquote>
<p>MyJSP.h:2 error: variable or field initializeJSP dec... | <p>It for example happens in this case here:</p>
<pre><code>void initializeJSP(unknownType Experiment);
</code></pre>
<p>Try using <code>std::string</code> instead of just <code>string</code> (and include the <code><string></code> header). C++ Standard library classes are within the namespace <code>std::</code>... | <p>The thing is that, when you call a function you should not write the type of the function, that means you should call the funnction just like </p>
<pre><code>initializeJSP(Experiment);
</code></pre>
| 47,550 |
<p>I have just started working with the <code>AnimationExtender</code>. I am using it to show a new div with a list gathered from a database when a button is pressed. The problem is the button needs to do a postback to get this list as I don't want to make the call to the database unless it's needed. The postback ho... | <p>The flow you are seeing is something like this:</p>
<ol>
<li>Click on button</li>
<li>AnimationExtender catches action and call clickOn callback</li>
<li>linkPostback starts asynchronous request for page and then returns flow to AnimationExtender</li>
<li>Animation begins</li>
<li>pageRequest returns and calls play... | <p>With help from the answer given the final solution was as follows:</p>
<p>Add another button and hide it.</p>
<pre><code><input id="btnHdn" runat="server" type="button" value="button" style="display:none;" />
</code></pre>
<p>Point the AnimationExtender to the hidden button so the firing of the unwanted cli... | 7,198 |
<p><b> The background </b> </p>
<p>I'm building a fair-sized web application with a friend in my own time, and we've decided to go with the Django framework on Python. Django provides us with a lot of features we're going to need, so please don't suggest alternative frameworks.</p>
<p>The only decision I'm having tro... | <p>Django does <a href="http://wiki.python.org/jython/DjangoOnJython" rel="nofollow noreferrer">work on Jython</a>, although you'll need to use the development release of Jython, since technically Jython 2.5 is still in beta. However, Django 1.0 and up should work unmodified.</p>
<p>So as to whether you should use th... | <p>Django is supposed to be jython-compatible sinc version 1.0.</p>
<p><a href="http://wiki.python.org/jython/DjangoOnJython" rel="nofollow noreferrer">This tutorial</a> is a bit outdated, but from there you can see there are no special issues.</p>
| 40,532 |
<p><strong>SQL Server 2000:</strong> Is there a way to find out server memory / CPU parameters in Query Analyzer?</p>
| <p>select * from sysperfinfo</p>
<p>it has everything in there that perfmon has. plus make sure you check out all the sql configuration parameters by running sp_configure. also running xp_msver shows a bunch more info about the sql server instance.</p>
<p>between those three i don't know what else you'd want to know.... | <p>Try:</p>
<pre><code>SELECT *
FROM sys.dm_os_sys_info
</code></pre>
<p>Sorry, that's 2005 only. In 2000, you can <code>xp_cmdshell</code> out to an external tool or use a COM object through <code>sp_OA</code>.</p>
| 36,204 |
<p>A few years ago, I read a book that described how you could override the default event 'dispatcher' implementation in .NET with your own processor.</p>
<pre><code> class foo {
public event EventHandler myEvent;
...
}
...
myFoo.myEvent += myBar1.EventHandler;
myFoo.myEvent += my... | <p>It could have been one of many books or web articles.</p>
<p>There are various reasons why you might want to change how events are subscribed/unsubscribed:</p>
<ul>
<li>If you have many events, many of which may well not be subscribed to, you may want to use <a href="http://msdn.microsoft.com/en-us/library/system.... | <ol>
<li>No</li>
<li>You might, for example, need to break the call chain based on the result of one of the handlers. Say your CustomEventArgs object has a property 'Blocked', which when set to true suppresses all further event handler invocations.</li>
</ol>
| 19,673 |
<p>This is a self-explanatory question:</p>
<p>Why does this thing bubble into my try catch's even when nothing is wrong? </p>
<p>Why is it showing up in my log, hundreds of times?</p>
<p><strong>I know its a newb question, but if this site is gonna get search ranking and draw in newbs we have to ask them</strong></... | <p>This is probably coming from a Response.Redirect call. Check this link for an explanation:</p>
<p><a href="http://dotnet.org.za/armand/archive/2004/11/16/7088.aspx" rel="noreferrer">http://dotnet.org.za/armand/archive/2004/11/16/7088.aspx</a></p>
<p>(In most cases, calling Response.Redirect(url, false) fixes the ... | <p>Knowing that there are (at least) three APIs that internally use <code>Thread.Abort</code>, I'd like to answer in more practical terms, how to work out what to do about it.</p>
<p>For us, this error started being logged all-of-a-sudden. What changed? We fixed a bug in some database procedure that was dealing with s... | 3,348 |
<p>we can use <code>time</code> in a unix environment to see how long something took...</p>
<pre><code>shell> time some_random_command
real 0m0.709s
user 0m0.008s
sys 0m0.012s
</code></pre>
<p>is there an equivalent for recording memory usage of the process(es)?</p>
<p>in particular i'm interested in pe... | <p>Check the man page for time. You can specify a format string where it is possible to output memory information. For example:</p>
<pre>>time -f"mem: %M" some_random_command
mem: NNNN</pre>
<p>will output maximum resident set size of the process during its lifetime, in Kilobytes.</p>
| <p>Can you not use ps? e.g. <code>ps v <pid></code> will return memory information.</p>
| 25,456 |
<p>I want to create a trace on a database server from my C# app, like what you do in SQL Server Profiler. I have found stored procedures (sys.sp_trace_create etc...) that dont seem to work for my SQL management studio. I was wondering if anyone could help with the coding, or where i would start to do this?!</p>
| <p>Are you wanting this to be real-time, just like the Profiler itself? That'd be tough to do. You'd basically be re-creating the profiler. </p>
<p>If that is not a requirement, I would recommend simply calling the sp_trace_create stored procs that you found to start a server-side trace, then use your application to o... | <p>If you're using LINQ to SQL then all of the SQL commands it generates can be sent to the output window (or logged to a file if you want). See here : <a href="http://www.u2u.info/Blogs/Kris/Lists/Posts/Post.aspx?ID=11" rel="nofollow noreferrer">http://www.u2u.info/Blogs/Kris/Lists/Posts/Post.aspx?ID=11</a></p>
| 38,296 |
<p>I'd like to start moving our application business layers into a collection of REST web services. However, most of our Intranet has been built using Classic ASP and most of the developers where I work keep programming in Classic ASP. Ideally, then, for them to benefit from the advantages of a unique set of web APIs, ... | <p>You could use a combination of JQuery with JSON calls to consume REST services from the client</p>
<p>or</p>
<p>if you need to interact with the REST services from the ASP layer you can use</p>
<p>MSXML2.ServerXMLHTTP</p>
<p>like:</p>
<pre><code>Set HttpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
HttpReq.... | <p>All you need is an HTTP client. In .Net, WebRequest works well. For classic ASP, you will need a specific component like <a href="http://web.archive.org/web/20140829190201/http://www.coalesys.com/products/httpclient/features/default.asp" rel="nofollow noreferrer">this one</a>.</p>
| 3,238 |
<p>Every night I need to trim back a table to only contain the latest 20,000 records. I could use a subquery:</p>
<pre><code>delete from table WHERE id NOT IN (select TOP 20000 ID from table ORDER BY date_added DESC)
</code></pre>
<p>But that seems inefficient, especially if we later decide to keep 50,000 records. ... | <p>If it just <em>seems</em> inefficient, I would make sure it is inefficient before I start barking up the wrong tree.</p>
<p>Measure the time, cpu usage, disk I/O, etc. to see how well it performs. I think you'll find it performs better than you think.</p>
| <p>Surely this is a prime case for wrapping up into a procedure and using two sql statements - the first to select the latest ID and subtract 20,000, then the second to delete all rows with ID's lower than this. </p>
<p>However it does on the face of it sound like you're going to end up with a lot of fragmentation go... | 36,268 |
<p>I can't seem to understand the margins that Cura uses or how to fix them for my machine. Look at this:</p>
<p><a href="https://i.stack.imgur.com/5oD0d.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5oD0d.png" alt="Screenshot of Cura, depicting large grey area"></a></p>
<p>I can't seem to tweak ... | <p>I had mistakenly left the setting "one at a time" in print sequence. This meaning the printhead needs a lot of room since it will go back and forth in z.</p>
<p>Cura allocates this extra space even if there's only one object.</p>
| <p>That looks like you've got the "brim" set to a very wide value. I know you said it's not explained by skirts --which, as Greenonline pointed out, is not the same as a brim--, but you didn't post that setting. At the same time, make sure you don't have a 'raft' set up. </p>
<p>One other possibility is that your so... | 612 |
<p>I am trying to use the <code>InternalsVisibleTo</code> assembly attribute to make my internal classes in a .NET class library visible to my unit test project. For some reason, I keep getting an error message that says:</p>
<blockquote>
<p>'MyClassName' is inaccessible due to its protection level</p>
</blockquote... | <p>Are you absolutely sure you have the correct public key specified in the attribute?
Note that you need to specify the full public key, not just the public key token. It looks something like:</p>
<pre><code>[assembly: InternalsVisibleTo("MyFriendAssembly,
PublicKey=00240000048000009400000006020000002400005253413100... | <p>As a side note, if you want to easily get the public key without having to use sn and figure out its options you can download the handy program <a href="http://www.davidarno.org/2008/01/15/c-and-friend-assemblies-made-easy/" rel="nofollow">here</a>. It not only determines the public key but also creates the "assembl... | 13,245 |
<p>Where can I find description of how to map ODBC datatypes to JDBC?
Or maybe anybody knows where source code of a jdbc-odbc bridge driver can be downloaded?</p>
| <p>The JDBC-ODBC Bridge is bundled with the Java 2 SDK Standard Edition...</p>
<p>Check out the FAQ's at Sun - <a href="http://java.sun.com/products/jdbc/faq.html" rel="nofollow noreferrer">http://java.sun.com/products/jdbc/faq.html</a></p>
| <p>According to <a href="http://en.wikipedia.org/wiki/JDBC_driver" rel="nofollow noreferrer">wikipedia</a>, </p>
<blockquote>
<p>Sun provides a JDBC-ODBC Bridge
driver. sun.jdbc.odbc.JdbcOdbcDriver.
This driver is native code and not
Java, and is closed source.</p>
</blockquote>
<p>But I've downloaded sources... | 43,691 |
<p>When running an old MFC application in Visual Studio's debugger I've seen a lot of warnings in the Output window like the following:</p>
<blockquote>
<p>Warning: skipping non-radio button in group.</p>
</blockquote>
<p>I understand that in MFC you put radio buttons in groups to indicate which sets of radio butto... | <p>The warning means that there's some control other than a radio button in the tab order between the first and last radio buttons in the group. A control with the <code>WS_GROUP</code> style set marks the start of a group.</p>
<p>To fix this, use the dialog editor to change the tab order and make sure that all the ra... | <p>For point 2, which is why I guess you're keeping this unanswered, I can't picture anything simplier then doing a text search (*.rc) for all dialogs with radio buttons. For each hit, visually inspect the resource code for this issue and correct it. I'd do it by hand in the resource file's source vs. trying to play wi... | 15,844 |
<p>Consider that I have a transaction:</p>
<pre><code>BEGIN TRANSACTION
DECLARE MONEY @amount
SELECT Amount AS @amount
FROM Deposits
WHERE UserId = 123
UPDATE Deposits
SET Amount = @amount + 100.0
WHERE UserId = 123
COMMIT
</code></pre>
<p>And it gets executed on 2 threads, in the order:</p>
<ol>
<li>thread ... | <p>Nice well stated scenario. I decided to test it.</p>
<p>Here's my setup script:</p>
<pre><code>CREATE TABLE Deposits(Amount Money, UserID int)
INSERT INTO Deposits (Amount, UserID)
SELECT 0.0, 123
--Reset
UPDATE Deposits
SET Amount = 0.00
WHERE UserID = 123
</code></pre>
<p>Here's my test script.</p>
<pre><code... | <p>I believe that you would want to use Repeatable read, which would lock the records, the first select would get the value, then it would update blocking thread two until it was completed. Thus an end result of 200 in your example</p>
<p>Read uncommitted would result in both records setting the value to 100.</p>
<p... | 32,350 |
<p>I was wondering if there are any code or class libraries out there on how to implement multithreading or "green threading" in ActionScript.</p>
<p>As you've might seen, Scott Peterson is developing some kind of toolset, but I haven't found any more info on this other than his performance on the Adobe MAX Chicago ev... | <p>Here's a Green Threading lib from Drew Cummins:</p>
<p><a href="http://blog.generalrelativity.org/?p=29" rel="nofollow noreferrer">http://blog.generalrelativity.org/?p=29</a></p>
| <p>I'm a graphics guy, not a programmer, so I'm not sure this will help you. BUT!</p>
<p>I make all my GUIs multi-frame "movies" and write each gui thread on a different frame. Make sure that you only have 1-3 threads, and set your FPS to 30 or 60.</p>
<p>This is useful for little projects because its bug-resistant a... | 9,561 |
<p>I have over the course of a few projects developed a pattern for creating immutable (readonly) objects and immutable object graphs. Immutable objects carry the benefit of being 100% thread safe and can therefore be reused across threads. In my work I very often use this pattern in Web applications for configuration ... | <p>For info, the second approach is called "popsicle immutability".</p>
<p>Eric Lippert has a series of blog entries on immutability starting <a href="https://learn.microsoft.com/en-us/archive/blogs/ericlippert/immutability-in-c-part-one-kinds-of-immutability" rel="nofollow noreferrer">here</a>. I'm still getting to g... | <p>System.String is a good example of a immutable class with setters and mutating methods, only that each mutating method returns a new instance.</p>
| 33,004 |
<p>Is there any way to output the contents of an XDocument without the BOM? When reading the output with Flash, it causes errors.</p>
| <p>If you're writing the XML with an XmlWriter, you can set the Encoding to one that has been initialized to leave out the BOM. </p>
<p>EG: System.Text.UTF8Encoding's constructor takes a boolean to specify whether you want the BOM, so:</p>
<pre><code>XmlWriter writer = XmlWriter.Create("foo.xml");
writer.Settings.Enc... | <p>You could probably use System.Text.Encoding.Convert() on the output; Just as something to try, not something I have tested.</p>
| 19,247 |
<p>In C++, it's not possible to initialize array members in the initialization list, thus member objects should have default constructors and they should be properly initialized in the constructor. Is there any (reasonable) workaround for this apart from not using arrays?</p>
<p>[Anything that can be initialized using... | <p>One possible workaround is to avoid the compiler calling the OtherClass constructor at all, and to call it on your own using placement new to initialize it whichever way you need. Example:</p>
<pre><code> class Foo
{
private:
char inst[3*sizeof(OtherClass)]; // Array size fixed. OtherClass has no default c... | <p>Array members are not initialized by default. So you could use a static helper function that does the initialization, and store the result of the helper function in a member.</p>
<pre><code>#include "stdafx.h"
#include <algorithm>
#include <cassert>
class C {
public: // for the sake of demonstration..... | 14,599 |
<p>What would be a good place to go to understand arrows? Ideally, I am just looking for some place with a concise definition with motivation from some good examples, something similar to Wadler's exposition on monads.</p>
| <p><a href="http://en.wikibooks.org/wiki/Haskell/Understanding_arrows" rel="nofollow noreferrer"><a href="http://en.wikibooks.org/wiki/Haskell/Understanding_arrows" rel="nofollow noreferrer">http://en.wikibooks.org/wiki/Haskell/Understanding_arrows</a></a></p>
| <p>If you learn better from practice than theory, try using <a href="http://www.fh-wedel.de/~si/HXmlToolbox/" rel="nofollow noreferrer">HXT</a> for XML manipulation, or <a href="http://www.cs.helsinki.fi/u/ekarttun/PArrows/" rel="nofollow noreferrer">PArrows</a> for general parsing. They both have APIs centered around... | 9,060 |
<p>All objects in my program inherit from a Container class. The Container class has a <code>virtual BaseNode* getParent() const;</code> method and a <code>virtual void setParent(BaseNode *p);</code> method. </p>
<p>I have a <code>Set</code> class (Set in a tennis match, not a data structure) which has the <code>Match... | <p>The problem is that <code>getParent()</code> returns a <code>BaseNode*</code>, which could be a pointer to any type of <code>BaseNode</code> - it might point to an unrelated class that also derives from <code>BaseNode</code>. If you're 100% sure that the parent must be of type <code>Match</code>, you should cast th... | <p>I think you really need to re-organize your hierarchy and method names... This has nothing to do with your question, but in general it seems hard to fathom why Set inherits from Match. (doesn't a match have sets?) </p>
<p>games are composed of points, sets are composed of games and a match is composed of sets...... | 44,412 |
<p>I'm attempting to map a set of key presses to a set of commands. Because I process the commands from several places, I'd like to set up a layer of abstraction between the keys and the commands so that if I change the underlying key mappings, I don't have to change very much code. My current attempt looks like this... | <p>Array references aren't "constant enough", regardless.</p>
<p>You just need to do the mapping slightly differently. You want the same action to occur when the logical key is pressed, so use the logical key codes in the <code>case</code> clauses of the <code>switch</code> statement. Then map the actual key code to... | <p>Is there a comparison operator defined for the "LogicalMappings"? If not then that is the error.</p>
| 47,965 |
<p>This is an often-asked question that has views on both side. Those in favour will argue:</p>
<ul>
<li>To design a system for coders you must understand how to code (and be coding)</li>
<li>You can't design a system without being aware of what is happening at ground level</li>
<li>Architecture is not just about broa... | <p>Even if your argument against coding is valid, I think it's important for the dev team to respect you and your design decisions. If you "suffer the consequences" of your architecture decisions right along with them, then they're <em>much</em> less likely to question them.</p>
<p>All the time, I see architects who a... | <p>Some times, they have to code. For instance, when the team is only one person.</p>
<p>In my opinion, they can code if they want but must not lose the big picture. A no go is to change the designed structures every day.</p>
| 26,093 |
<p>I control access to some of my static web resources with some PHP logic. Because directory-based authorization through the webserver is not suitable or easily possible.</p>
<p>A combination of things determines whether access is granted or denied. And these rules change from time to time.</p>
<p>In the beginning... | <p>You might want to check out <a href="http://framework.zend.com/manual/en/zend.acl.html" rel="nofollow noreferrer">Zend_Acl</a>, which is an object-oriented PHP class to manage hierarchies of privileges on hierarchies of resources. You might not be able to use this component as is, but it could give you some insight... | <p>You could also use a small logic engine (think prolog) to easily state facts and rules which would allow you to quickly query wether or not access to a resource should be allowed. Logic based rule engines like this are often very efficient and should allow you to very easily model a solution for this kind of problem... | 34,047 |
<p>If so, does it effectively deprecate the <code>visibility</code> property?</p>
<p>(I realize that Internet Explorer does not yet support this CSS2 property.)
<br/>
<a href="http://en.wikipedia.org/wiki/Comparison_of_layout_engines_(CSS)#Properties" rel="noreferrer">Comparisons of layout engines</a></p>
<p><a href=... | <p>Here is a compilation of verified information from the various answers.</p>
<p>Each of these CSS properties is unique. In addition to rendering an element not visible, they have the following additional effect(s):</p>
<ol>
<li><strong>Collapses</strong> the space that the element would normally occupy</li>
<li>Res... | <p>What Phil says is true.</p>
<p>IE supports opacity though:</p>
<pre><code>filter:alpha(opacity=0);
</code></pre>
| 34,273 |
<p>I'm moving from Java Development to a MSFT environment. The app is currently written in VB6 and while its going to go to VB.NET/C# in the future, I need to find a way to pick up VB6 now. I'm told its old, and there will be no books on it available these days. </p>
<p>Any tips? Sites?</p>
| <p>The best tip is to... RUN! ;-)</p>
<p>No, there are still tons to vb sites out there, and you should still be able to pick up loads of second hand books for VB6 for next to nothing.</p>
| <p>I'm sure you can get some books on it. If Amazon has none, try Ebay?</p>
<p>It's a simple language, though - you shouldn't have much trouble picking it up! There's always the MSDN documentation.</p>
<p>I'm having the opposite problem: I've got a few old apps in VB and need to update one of them, but can't find the... | 20,064 |
<p>Is <a href="http://en.wikipedia.org/wiki/OpenID" rel="noreferrer">OpenID</a> a secure method of authentication users on a website?</p>
<p>And, if not, what are the security risks associated with OpenID?</p>
| <p>Actually I always disliked OpenID for various reasons.</p>
<ul>
<li><p>I have to trust the OpenID provider who I gave my data. I do trust certain sides to certain degrees, but just because I may trust Stack Overflow, I don't automatically trust any of the well known OpenID providers.</p>
<ol start="2">
<li><p>If m... | <p>I like Verisign's VIP access which sites can make use of, and there is a nice little iPhone application that will let you have your generated token to get in, much like secureID</p>
| 22,023 |
<p>I use an SQL statement to remove records that exist on another database but this takes a very long time.</p>
<p>Is there any other alternative to the code below that can be faster? Database is Access.</p>
<p>email_DB.mdb is from where I want to remove the email addresses that exist on the other database (table New... | <p>I worked on a project to run a user's logon script whenever they connected our network over VPN. To do this, I wrote a helper unit that retrieves adapter info and stores it into a simple record.</p>
<p>I then setup up a registry notification, <a href="http://delphi.about.com/od/kbwinshell/l/aa052003a.htm" rel="nofo... | <p>Look at InternetGetConnectedState in WinINet.</p>
<p>Some applications might also poll for a known server and not do anything until they get a valid connection.</p>
| 42,214 |
<p>I'm debating the best way to propagate fairly complex permissions from the server to an AJAX application, and I'm not sure the best approach to take.</p>
<p>Essentially, I want my permissions to be defined so I can request a whole set of permissions in one shot, and adjust the UI as appropriate (the UI changes can ... | <p>If you have a clear set of permissions, like a "user level" or "user type", you could just pass the value down in a hidden field and access the value through the DOM. You could still do this if your permissions were more granular, but you would either have a lot of hidden fields or you would have to encode the infor... | <p>Encode them as <a href="http://json.org" rel="nofollow noreferrer">JSON</a>.</p>
| 30,348 |
<p>I am starting a normal Java SE project and i am planning to use JPA/Hibernate. I was wondering if anyone could enlighten me as to what is considered the best way to interact with Hibernate in this environment (data access layers)?</p>
| <p>I'm not sure what's considered the best approach to this, but at my workplace, we have based most of our Hibernate interaction on these articles: </p>
<p><a href="http://www.onjava.com/pub/a/onjava/2006/09/13/dont-let-hibernate-steal-your-identity.html" rel="noreferrer">Don't let Hibernate steal your identity</a>
a... | <p>Here is the guide for using <a href="http://www.skill-guru.com/blog/2009/08/06/hibernate-tutorial-continued-using-annotations/" rel="nofollow noreferrer">JPA with Hibernate</a></p>
<p>We have used this approach in our application 1.5 years back and I do not think there is anything new in SE6 related to this.
We hav... | 39,281 |
<p>I am wondering if anyone has any insight into this. I am thinking of going to grad school to get some computer science related degree. I have always been intrigued by people who are working on problems using statistical packages or simulation to solve problems. What would I study to get a good breadth of knowledge o... | <p>My girlfriend is getting a degree in mathematics with an emphasis in Statistics and <a href="http://en.wikipedia.org/wiki/Operations_research" rel="nofollow noreferrer"> Operations Research.</a></p>
<p>She does a lot of work with SAS and other statistical software to maximize certain functions and predict the like... | <p>I would assume that your school would offer some actual Statistics courses, probably in the Math department, which you could take to learn all about this.</p>
| 37,911 |
<p>Does anybody know a good tool to assist in the development of an SNMP MIB with correct formatting and syntax?</p>
<p>If possible, it should be free and run under Linux.</p>
| <p>According to <a href="http://net-snmp.sourceforge.net/wiki/index.php/Writing_your_own_MIBs" rel="nofollow noreferrer">this</a> net-snmp howto, there is a tool called <a href="http://www.ibr.cs.tu-bs.de/projects/libsmi/smilint.html" rel="nofollow noreferrer">smilint</a> from the <a href="http://www.ibr.cs.tu-bs.de/pr... | <p>I've been using <a href="http://www.mibexplorer.com/download/download.html" rel="nofollow">MIB Explorer Lite</a> which has a syntax checker whenever you load a MIB. There's a free trial which I think lasts about 30 days.</p>
| 49,408 |
<p>At a previous employer, we were writing binary messages that had to go "over the wire" to other computers. Each message had a standard header something like:</p>
<pre><code>class Header
{
int type;
int payloadLength;
};
</code></pre>
<p>All of the data was contiguous (header, immediately followed by data)... | <p>I'd go for crime against coding.</p>
<p>Both methods will generate the exact same object code. The first makes it's intention clear. The second is very confusing, with the only advantage that it saves a couple keystrokes. (Just learn to freakin' type).</p>
<p>Also, note that NEITHER method is guaranteed to work.... | <p>Perhaps you should have used a verbose method, but replaced it with a #define macro? This way you can use your shorthand when typing, but anyone needing to debug the code can follow along without issue.</p>
| 27,553 |
<p>I have worked on several distributed client/server projects recently, and one pain point that we always run into is translating the DTO objects into our entities and vice-versa. I was wondering if anyone has a "simple" solution to this time sink?</p>
<p>One thing I thought about was coming up with some sort of tra... | <p>I have been using <a href="http://automapper.codeplex.com/" rel="nofollow noreferrer">AutoMapper</a> recently, and it works like a charm.</p>
| <p>I've had success using tools like XDoclet (although it shouldn't be to hard to script) to automatically generate transfer objects and simple entity translations.</p>
<p>That said, if you believe your Entity translations are simple enough to be done using reflection, is there a reason you can't just pass the Entity ... | 25,061 |
<p>Earlier this week I ask a question about filtering out duplicate values in sequence at run time. Had some good answers but the amount of data I was going over was to slow and not feasible.</p>
<p>Currently in our database, event values are not filtered. Resulting in duplicate data values (with varying timestamps). ... | <p>If I understand correctly, what you want to do is simply prevent the dupes from even getting in the database. If that is the case, why not have a PK (or Unique Index) defined on the first two columns and have the database do the heavy lifting for you. Dupe inserts would fail based on the PK or AK you've defined. Yo... | <p>If I understand correctly, what you want to do is simply prevent the dupes from even getting in the database. If that is the case, why not have a PK (or Unique Index) defined on the first two columns and have the database do the heavy lifting for you. Dupe inserts would fail based on the PK or AK you've defined. Yo... | 16,225 |
<p>I need to consume a wcf service dynamically when all i know is its URL. I do not have the option of creating a service reference or web reference as my client side code picks up the URL from a config file. What classes and methods can i use from the System.ServiceModel namespace for doing so.</p>
| <p>If you don't have the service interface, you must, at the very least, have an idea as to what the messages the server expects look like; otherwise it be pretty hard to do :)</p>
<p>But there is certainly a way to do that. You can start by creating the raw message the server expects as input, and create it in a Mess... | <p>If you know the contract then you can do something like:</p>
<pre><code>using (WebChannelFactory<IService> wcf = new WebChannelFactory<IService>(new Uri("http://localhost:8000/Web")))
</code></pre>
<p>More <a href="http://msdn.microsoft.com/en-us/library/bb412196.aspx" rel="nofollow noreferrer">here</a... | 18,980 |
<p>I am trying to use the following code, which I have not been able to test yet, because I get the following errors:</p>
<pre><code>#!/usr/bin/perl
use warnings;
use strict;
use Text::Wrap;
use Mail::Box::Manager;
use HTML::Obliterate qw(extirpate_html);
open (MYFILE, '>>data.txt');
binmode(MYFILE, ':encoding... | <p>So line 36 seems to be</p>
<pre><code>print MYFILE wrap("", "", <<"");
</code></pre>
<p>which means perl will wrap the following text until there is terminator <code>""</code> (I never use confusing item like this, I always use END or UNTIL_END for simplicity.)</p>
<p>That terminator is then found on line 4... | <p>Answer to your modified question: </p>
<p>Instead of extirpating the message body, you extirpate the whole message instead. And then you don't use it anywhere.</p>
<pre><code>my $nohtml = extirpate_html( $msg );
$body =~ s/^>.*$//msg;
$Text::Wrap::columns=80;
print MYFILE wrap("", "", <<"");
\n
From: $fro... | 48,571 |
<p>I have some funny deadlock caused by a stupid simple SQL UPDATE query, on a flat plain table, under default "READ COMMITED" transaction.</p>
<pre><code>UPDATE table SET column=@P1 WHERE PK=@P2
</code></pre>
<p>Column <code>PK</code> is <code>varchar(11)</code>, has a clustered index on it.
no trigger or table rela... | <p>You have 2 options to reduce the lock escalation:</p>
<p>1) add the WITH (ROWLOCK) hint to ask sql server to take finer granularity locks (your mileage may vary:</p>
<blockquote>
<p>UPDATE table WITH (ROWLOCK) SET
column=@P1 WHERE PK=@P2; While PK
varchar(11), has a clustered index on
it. no tigger or tabl... | <p>In the normal, simple case this type of begavior is not often seen. My question to you is this : what's on the 'other side' of this transaction? What's the other update statement that is running and causing this deadlock? That, I think, will be the key to diagnosing this problem. Honestly, my money is on this ot... | 41,534 |
<p>I have a web application that generates a medium sized XML dataset to be consumed by a third party.<br>
I thought it would be a good idea to provide some form of schema document for the XML that I generate so I pasted the XML into Visual Studio and got it to generate an XSD.<br>
The annoying thing is that my XML doe... | <p>Whether you choose XSD and/or Schematron depends on what you are trying to validate. XSD is probably the most common validation strategy, but there are limits on what it can validate. If all you want to do is ensure that the right type of data is in each field, XSD should work for you. If you need to assert, for exa... | <p>You will be able to validate your XML with either an XML Schema or a DTD using C#. DTDs are older standards as compared to XML Schemas.</p>
<p>So, I recommend an XML Schema approach.</p>
| 3,732 |
<p>What are the pros/cons of using black-box reuse over white-box reuse?</p>
| <p>In my experience, White box reuse is normally done through inheritance and black box is done through composition. </p>
<h1>White Box Reuse</h1>
<p>Pro: You can customize the module to fit the specific situation, this allows reuse in more situations<br>
Con: You now own the customized result, so it adds to your cod... | <p>White-box:</p>
<p>pros:</p>
<ul>
<li>simple (very natural concept)</li>
<li>you have more control over things</li>
</ul>
<p>cons:</p>
<ul>
<li>requires intrinsic knowledge on
component internals</li>
<li>can be difficult to implement (OO inheritance constraints)<br>
sometimes it leads to broken\incorrect inherit... | 12,426 |
<p>Obviously (methinks), creating an index on a <code>BIT</code> column is unnecessary. However, if you had a column that you need to search in which every value is likely unique, like <code>BlogPost</code> or <code>StreetAddress</code> or something, then an index seems appropriate (again, methinks).</p>
<p>But what's... | <p>The best answer to this is to profile your queries and see if the index improves your queries. The difficulty in answering this is that it is nearly impossible to generalize the behavior of the query optimizer.</p>
<p>That said, a rule-of-thumb is if your selectivity is 10% or less on a given query on a table, then... | <p>I would say it all depends on how the table is being used and the overall system requirements. For example, if it's part of a large JOIN and the parent is a huge report type table then you'd want the index for sure. If it's relatively small in comparison to your other tables in the database, and it's heavily inser... | 31,137 |
<p>I'm completely stumped on this one. I have three different lists that need to be displayed on the screen. It's completely possible that the lists will extend past the bottom edge of the screen, so I would need scrolling.</p>
<p>I've tried using a <code>ScrollView</code> with a <code>LinearLayout</code> child, and ... | <p>I haven't done this yet, but I've been thinking about it since I'll probably need to do it. I can think of three options: use only one list with the contents of all lists. You can make a ListAdapter that does that and inserts some kind of header. This could probably be something very re-usable.</p>
<p>The other ide... | <p>Although this answer is for scroll view's instead of list view's, the problem is the same and this solution worked well for me. Scrolling the left scrollview will scroll the right scrollview and viceversa.</p>
<pre><code>public class MainActivity extends Activity implements OnTouchListener {
private ScrollView ... | 39,445 |
<p>I want to link to a page which contains multiple support topics.
When the user clicks on the link while being on an external site, the topic should be expanded as soon as the user arrives on the support page.</p>
<p>Example:</p>
<p>I link to this page</p>
<pre><code>http://www.nintendo.de/NOE/de_DE/support/ninten... | <p>Good idea, but I don't see the question... :-)</p>
<p>The way I saw on some sites, like deviantART, is to use the sharp anchor notation: myURL.com/foo/page.html#TopicToExpand</p>
<p>JS can analyze the current URL and get the anchor part, then do whatever you need to do to highlight/jump to the right place.</p>
| <p>Good idea, but I don't see the question... :-)</p>
<p>The way I saw on some sites, like deviantART, is to use the sharp anchor notation: myURL.com/foo/page.html#TopicToExpand</p>
<p>JS can analyze the current URL and get the anchor part, then do whatever you need to do to highlight/jump to the right place.</p>
| 43,270 |
<p>If you have an 68K application written using CodeWarrior for Palm OS, how do you assign individual functions to different segments without manually moving files around in the segment tab in the IDE?</p>
| <p><a href="https://stackoverflow.com/questions/90246/how-would-i-store-a-date-that-can-be-partial-ie-just-the-year-maybe-the-month-t#90273">As proposed by Jhenzie</a>, create a bitmask to show which parts of the date have been specified. 1 = Year, 2 = Month, 4 = Day, 8 = Hour <em>(if you decide to get more specific)</... | <p>Is it really necessary to store it as a datetime at all ? If not stored it as a string 2008 or 2008-8 or 2008-8-1 - split the string on hyphens when you pull it out and you're able to establish how specific the original input was </p>
| 11,567 |
<p>In order to handle concurrency issue, is locking-- any form of locking, whether it's row, table or database locking a good solution?</p>
<p><strong>If not, how to handle concurrency issue?</strong></p>
| <p>If you believe Oracle, no, not at all. That's because Oracle went to great lengths to avoid it.</p>
<p>The problem is that readers can block writers and writers block readers, and a writer has to wait until all readers have finished with a row before it can write. That delays the writing process and its caller. Exc... | <p>Do you mean to handle concurrency in your application, or to solve a concurrency problem you're having with the database. If the former, it doesn't strike me as a good approach. If the latter, this may be your only answer without re-engineering your schemas.</p>
| 27,892 |
<p>I am building an ObjectQuery like this:</p>
<pre><code> string query = "select value obj from Entities.Class as obj " +
"where obj.Property = @Value";
ObjectQuery<Class> oQuery = new ObjectQuery<Class>(query, EntityContext.Instance);
oQuery.Parameters.Add(n... | <p><code>ObjectQuery<T></code> implements <code>IQueryable<T></code>, so can't you simply use the extension method:</p>
<pre><code>int count = oQuery.Count();
</code></pre>
<p>What happens if you execute this? I would have expected the overall query to just do a Count()... (not that I've done much EF...).... | <p>If the count is lower than 1 then it has found a new record, if not, it already has that record.</p>
| 27,321 |
<p>Say you're coding some kind of web application. Something where people can contribute content, e.g. a simple photo-sharing site.</p>
<p>How many good reasons can you think of to <em>not</em> go with an object-oriented database (e.g. db4o)?</p>
| <p>An OODBMS is better if you only need to access your data through your objects. If your solution requires additional pathways to your data (e.g. ad-hoc queries, reporting, other applications that need data access but can't make use of your objects), then a traditional RDBMS system is better.</p>
<p>Note: OODBMSes ... | <p>My personal opinion, where there's data ... there's reporting.</p>
<p>No OODBs is going to give your data the appropriate storage model to be available to your reporting applications.</p>
| 20,848 |
<p>I need a simple SQL to accomplish the below:</p>
<p>Problem:</p>
<p>When a petrol bunk runs out of fuel, the admin makes note of the DateTime (RunOutDate) when it ran out of fuel and notes also the DateTime (ResupplyDate) when the fuel supply was back on.</p>
<p>I need to create a report on how many <em>days</em>... | <pre><code>DATEDIFF(d, RunOutDate, ResupplyDate) + 1
</code></pre>
<p>Remember that DATEDIFF always counts the number of BOUNDARIES that you cross. For days (first argument d), it counts the number of times the clock passed midnight. So to count the number of days covered you just add 1.</p>
| <p>DATEDIFF using day, then add 1.</p>
<p>DATEDIFF uses the midnight to count days so you'll get 0, 1, 1 for each example above. Then add 1.</p>
<pre><code>DATEDIFF(day, '16 Dec 2008 10:10', '16 Dec 2008 10:50') + 1
</code></pre>
| 49,364 |
<p>Can someone tell me the different between LinkButton.PostBackUrl and HyperLink.NavigateUrl? I've got a asp.net 2.0 application that uses both methods throughout the application and everything works fine. However if I connect to the application over the company vpn all of the links that use LinkButton.PostBackUrl g... | <p>NavigateURL: Submits a 'Get' request to the URL (just like if you had typed it in your browser)</p>
<p>PostBackURL: Submits a 'Post' request containing the information from the form to the specified URL; I don't believe this is commonly used</p>
| <p>The PostBackURL for the linkbutton tells you which form the button is posting data to. (more <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutton.postbackurl.aspx" rel="nofollow noreferrer">details</a>)</p>
<p>The NavigateURL for the Hyperlink tells you which control, the link is ge... | 31,781 |
<p>I've been using the (Java) <a href="http://lucene.apache.org/java/2_4_1/lucene-sandbox/index.html#Term%20Highlighter" rel="nofollow noreferrer">Highlighter for Lucene</a> (in the Sandbox package) for some time. However, this isn't really very accurate when it comes to matching the correct terms in search results - i... | <p>There is a new faster highlighter (needs to be patched in but will be part of release 2.9)</p>
<p><a href="https://issues.apache.org/jira/browse/LUCENE-1522" rel="nofollow noreferrer">https://issues.apache.org/jira/browse/LUCENE-1522</a></p>
<p>and a <a href="https://issues.apache.org/jira/browse/LUCENE-1522?focus... | <p>You could look into using Solr. <a href="http://lucene.apache.org/solr" rel="nofollow noreferrer">http://lucene.apache.org/solr</a></p>
<p>Solr is a sort of generic search application that uses Lucene and supports highlighting. It's possible that the highlighting in Solr is usable as an API outside of Solr. You co... | 10,785 |
<p>I'm trying to get my head around the Error Handling in MVC.
What I'm looking for is a centralized way to catch errors, log them, if possible resolve them, if nessecary take other actions and finally show the correct view to the user.</p>
<p>I think I can use the [HandleError] filter for this, but I don't see any wa... | <p><a href="http://www.codeplex.com/aspnet/SourceControl/FileView.aspx?itemId=266465&changeSetId=16503" rel="nofollow noreferrer">HandleErrorAttribute</a> that comes with MVC is a pretty basic IExceptionFilter.</p>
<p>You have a few options to achieve what i think u want.</p>
<p>You can either use [HandleError (T... | <p>What I'm doing (which may or may not be a good practice) is this:</p>
<p>When an error occurs: </p>
<ul>
<li>If I expected it and can handle it, I do (logging it with ELMAH)</li>
<li>If I expected it and can't handle it, I log it to ELMAH and return a ViewResult that is my error page
<ul>
<li>Include a descripti... | 24,022 |
<p>When designing parts that should either fit with external objects or other printed parts, what measures can one take to ensure that the dimensions of the final print are accurate and fit the other object?</p>
<p>To my knowledge, you at least have two options to account for printer inaccuracy and shrinkage:</p>
<ul... | <p>I think the best way to go about this would be to calibrate your printer and slicer as best you can. One of my pet peeves is when people upload STLs that have been adjusted to fit their printer/material. There are many suppliers of material that vary in quality as well as many materials and different printers that... | <p>A few suggestions I haven't seen explicitly stated in the other answers.</p>
<h1>Export resolution</h1>
<p>When you export your STL files you can increase the resolution. If dimensional accuracy is extremely critical, you'll want to confirm that the STL conversion process hasn't altered the dimensions of curved surf... | 154 |
<p>My SQL is rusty -- I have a simple requirement to calculate the sum of the greater of two column values:</p>
<pre><code>CREATE TABLE [dbo].[Test]
(
column1 int NOT NULL,
column2 int NOT NULL
);
insert into Test (column1, column2) values (2,3)
insert into Test (column1, column2) values (6,3)
insert into Te... | <p>Try this:</p>
<pre><code> SELECT SUM(CASE WHEN column1 > column2
THEN column1
ELSE column2 END)
FROM test
</code></pre>
| <p>FYI, the more complicated case should be fine, so long as all of those columns are part of the same table. It's still looking up the same number of rows, so performance should be very similar to the simpler case (as SQL Server performance is usually IO bound).</p>
| 30,140 |
<p>I know in certain circumstances, such as long running processes, it is important to lock ASP.NET cache in order to avoid subsequent requests by another user for that resource from executing the long process again instead of hitting the cache.</p>
<p>What is the best way in c# to implement cache locking in ASP.NET? ... | <p>Here's the basic pattern:</p>
<ul>
<li>Check the cache for the value, return if its available</li>
<li>If the value is not in the cache, then implement a lock</li>
<li>Inside the lock, check the cache again, you might have been blocked</li>
<li>Perform the value look up and cache it</li>
<li>Release the lock</li>
<... | <p>This article from CodeGuru explains various cache locking scenarios as well as some best practices for ASP.NET cache locking:</p>
<p><a href="http://www.codeguru.com/csharp/.net/net_asp/article.php/c5363/" rel="nofollow noreferrer">Synchronizing Cache Access in ASP.NET</a></p>
| 6,018 |
<p>I am getting ready to start building a new web project in my spare time to bring to fruition an idea that has been bouncing around my head for a while.</p>
<p>I have never gotten down whether I am better off first building the model and then the consuming application or the other way around.</p>
<p>What are the be... | <p>When you're building the whole application yourself, I would start with the user. What does the user want? What information do they need? That should drive the design of the application and model, not the other way round. When the model is designed first, there is a temptation to expose the user to it directly, whic... | <p>My tactic is roughly this:</p>
<p>Read the requirements, and write down all nouns or "players" in the document. These are usually 80% of the things you need to store or interact with.</p>
<p>With these things on a sheet of paper, read the requirements again and see if you can find that the things you have on paper... | 42,656 |
<p>I have a table of about a million rows and I need to update every row in the table with the result of a lengthy calculation (the calculation gets a potentially different result for each row). Because it is time consuming, the DBA must be able to control execution. This particular calculation needs to be run once a y... | <p>I would tend to be wary about using jobs like this to control execution. Either the delay between successive jobs would tend to be too short for the DBA to figure out what job to kill/ pause/ etc. or the delay would be long enough that a significant fraction of the run time would be spent in delays between successi... | <p>Another avenue to explore would be the dbms scheduler's support tools for execution windows and resource plans.</p>
<p><a href="http://www.oracle-base.com/articles/10g/Scheduler10g.php" rel="nofollow noreferrer">http://www.oracle-base.com/articles/10g/Scheduler10g.php</a></p>
<p>and also:</p>
<p><a href="http://d... | 31,348 |
<p>I am using oracle wallet to store the oracle database passwords,
the batch file to create the wallet asks for password when you run it.
is there any way to modify the batch file , and provide the password before hand </p>
<p>so that i can avoid inputtting the password every time i run that.</p>
<p>so to generalize... | <p>You can use the pipe operator "|" to redirect the standard output stream of one program into the input stream of another. I works both on unix and windows platforms.</p>
<p>In your example you would have a script doing just</p>
<pre><code>echo mypassword
</code></pre>
<p>and you would run this from the command l... | <p>Enter the password in a text file like password.txt</p>
<p>and you can run like</p>
<p>myprogram.exe < password.txt </p>
<p>if the program accepts two inputs then type the second input in the second line of the text file.</p>
| 42,135 |
<p>I'm in an environment with a lot of computers that haven't been
properly inventoried. Basically, no one knows which IP goes with which
mac address and which hostname. So I wrote the following:</p>
<pre><code># This script goes down the entire IP range and attempts to
# retrieve the Hostname and mac address and outp... | <p>Today I also needed reverse DNS lookup and I've found very simple standard solution:</p>
<pre><code>require 'resolv'
host_name = Resolv.getname(ip_address_here)
</code></pre>
<p>It seems it uses timeout which helps in rough cases.</p>
| <p>This also works:</p>
<pre><code>host_name = Socket.getaddrinfo(current_ip,nil)
append_to_file("#{host_name[0][2]} - #{current_ip} - #{mac_addr}\n")
</code></pre>
<p>I'm not sure why <code>gethostbyaddr</code> didn't also work.</p>
| 2,513 |
<p>What's the best tool for viewing and editing a merge in Git? I'd like to get a 3-way merge view, with "mine", "theirs" and "ancestor" in separate panels, and a fourth "output" panel.</p>
<p>Also, instructions for invoking said tool would be great. (I still haven't figure out how to start kdiff3 in such a way that i... | <p><a href="http://meldmerge.org/" rel="noreferrer">Meld</a> is a free, open-source, and cross-platform (UNIX/Linux, OSX, Windows) diff/merge tool.</p>
<p>Here's how to install it on:</p>
<ul>
<li><a href="http://web.archive.org/web/20200512144500/https://linuxpitstop.com/install-meld-on-ubuntu-and-mint-linux/" rel="... | <p>gitx <a href="http://gitx.frim.nl/" rel="nofollow noreferrer">http://gitx.frim.nl/</a></p>
<p>Some bugs when working with large commit sets but great for browsing through changes and picking different changes to stage and then commit.</p>
| 16,587 |
<p>How can I remove the very first "1" from any string if that string starts with a "1"?</p>
<pre><code>"1hello world" => "hello world"
"112345" => "12345"
</code></pre>
<p>I'm thinking of doing</p>
<pre><code>string.sub!('1', '') if string =~ /^1/
</code></pre>
<p>but I' wondering there's a better way. Thank... | <p>Why not just include the regex in the <code>sub!</code> method?</p>
<pre><code>string.sub!(/^1/, '')
</code></pre>
| <p>I'd like to post a tiny improvement to the otherwise excellent answer by Zach. The <code>^</code> matches the beginning of every <em>line</em> in Ruby regex. This means there can be multiple matches per string. Kenji asked about the beginning of the string which means they have to use this regex instead:</p>
<pre><... | 48,376 |
<p>I have four tables (A,B,C,D) where A is the parent of one to many relationships with B and C. C and D are parents to a one to many relationship with table D. Conceptually, the primary keys of these tables could be:</p>
<ul>
<li>A: Aid </li>
<li>B: Aid, bnum (with foreign key to A)</li>
<li>C: Aid, cnum (with fore... | <p>Show the throbber before the code is run and hide it after.</p>
<p>Using JQuery:</p>
<pre><code>$("#throbber").show();
/* Your AJAX calls */
$("#throbber").hide();
</code></pre>
| <p>Take a look on: <a href="http://plugins.jquery.com/project/throbber" rel="nofollow">http://plugins.jquery.com/project/throbber</a></p>
| 46,591 |
<p>I am developing a Web Album using Grails and for image processing, I am using grails-image-tools plugin. I need a functionality to resize the images if the uploaded images size is too big (for eg: more than 600 * 840 ) . In this case I need to resize this image to 600 * 840). What is the most efficient way to do thi... | <pre><code>import java.awt.Image as AWTImage
import java.awt.image.BufferedImage
import javax.swing.ImageIcon
import javax.imageio.ImageIO as IIO
import java.awt.Graphics2D
static resize = { bytes, out, maxW, maxH ->
AWTImage ai = new ImageIcon(bytes).image
int width = ai.getWidth( null )
... | <p>Use ImageTool plugin.
<a href="https://grails.org/plugin/image-tools" rel="nofollow noreferrer">https://grails.org/plugin/image-tools</a>
P.S. Available only for grails v2.</p>
| 47,289 |
<p>Are there any good (and preferably free) code coverage tools out there for Perl?</p>
| <p>Yes, <a href="https://metacpan.org/pod/Devel::Cover" rel="nofollow noreferrer">Devel::Cover</a> is the way to go.</p>
<p>If you develop a module, and use <a href="https://metacpan.org/pod/Module::Build" rel="nofollow noreferrer">Module::Build</a> to manage the installation, you even have a <code>testcover</code> ta... | <p>Moritz discusses how modules built with Module::Build can use Devel::Cover easily.</p>
<p>For modules using ExtUtils::MakeMaker, an extension module exists to invoke the same functionality. Adding the following code before the call to WriteMakefile():</p>
<pre><code>eval "use ExtUtils::MakeMaker::Coverage";
if( !$... | 28,479 |
<p>I've been tasked with writing a outlook .MSG files from XML files that have associated metadata. I've tried using the Aspose library, but all of the exposed MapiMessage properties are read only. Using the Outlook Object Model I'm unable to change the creation date, and other properties that I must have access to. I'... | <p>Use Windows <a href="http://msdn.microsoft.com/en-us/library/ms684161(VS.85).aspx" rel="noreferrer">Job Objects</a>. Jobs are like process groups and can limit memory usage and process priority.</p>
| <p>Depending on your applications, it might be easier to limit the memory the language interpreter uses. For example with Java you can set the amount of RAM the JVM will be allocated.</p>
<p>Otherwise it is possible to set it once for each process with the windows API</p>
<p><a href="http://msdn.microsoft.com/en-us/l... | 23,437 |
<p>Usually it will either will rip the tape, or break the print somehow. Currently using ABS on a taped glass bed with a layer of hairspray for adhesion.</p>
| <p>I moved to a plain glass heated bed with a brush applied acetone and ABS mixture. Using an old emptied nail polish bottle with brush, I added some acetone and then threw in ABS pieces until it reached a brush-able consistency. I then brush it on the glass build plate where I believe the print will occur, and it work... | <p>I have had best results with ABS on a heated printbed
(untaped) with a thin coat of UHU Stic. It can be a little tricky to remove but minimizes damage.</p>
| 142 |
<p>I've got a rather large flex app that we've just built for a client. Now, the bossman tells me that more clients are interested in the app. However, their implementations will need a few small tweaks (don't they always!).</p>
<p>We're using Cairngorm and from what I can tell thus far, the only things that will be d... | <p>You could solve the problem by using a <strong>class factory</strong>. Instead of creating instances of new components directly, you would ask a factory class to create the component for you, and based on some criteria (perhaps a static constant value in the Application?) the factory would decide which class to inst... | <p>No matter what you are going to be changing a reference to a specific class somewhere. You can subclass (using extends) components and then modify their behavior, but you have to change your references to talk to the subclass instead of the parent class. </p>
<p>I would just create a subclass for only those thing... | 38,326 |
<p><b>Background</b><br />
I'm researching the efficiency of messaging within contemporary web applications, examining the use of alternatives to XML. This is a university project whose results will be released publicly - the greater the participation of the community, the greater the value of the results that are give... | <p>Probably not the answer you want, but I never use XML, it's too complicated, (for my simple needs anyway), but even if my needs were complicated, XML is too complicated a beast it scares me to use it in a complicated problem.</p>
| <p><a href="http://www.eucaris.net/technology.php" rel="nofollow noreferrer">Eucaris</a> is a web application to retrieve car registration data. The backend uses XSD-typed XML data for request and response messages.</p>
| 47,761 |
<p>My application is implemented as a service (running under services.exe).
I am adding a new feature which requires being notified when the user sends an SMS.</p>
<p>I have tried using <code>IMAPIAdviseSink</code>, registering with both <code>IMAPISession</code> and <code>IMsgStore</code>, but I do not get any notifi... | <p>You can't use <code>IMAPIAdviseSink</code> from a service.</p>
<p>You need to use it from separate process and notify the service of the events you're interested in.</p>
| <p>edit: oops, missed that it was users creating the message, not incoming.</p>
<p>Are you targetting windows mobile 5+?</p>
<p>I think what you're looking for is the MessageInterceptor class in the Microsoft.WindowsMobile.PocketOutlook.MessageInterception Namespace.</p>
<p>Here is a link to some example code:
<a hr... | 23,973 |
<p>What tool would you recommend to monitor the connectivity status of a machine, this is if a given machine it is able to connect to some web servers over time. It should be able to log the status.</p>
<p>There is a long list of freeware at <a href="http://ping-monitors.qarchive.org/" rel="nofollow noreferrer">http:/... | <p>I tend to use Nagios and OpenNMS to monitor large batches of servers (and in the Unix environment, not windows). However, some pure windows-only shops I've worked with have really liked using <a href="http://www.whatsupgold.com" rel="nofollow noreferrer">What's Up Gold</a>. Alternately, a combination of a quick perl... | <p>When we had to do something similar, we just mocked up some VBS script to attempt to connec to the machines we needed to log. Obviously behind the firewall, on the same domain. Dumped the logs into Excel. Quick and dirty for some network diagnostics, but not a long term solution.</p>
| 14,419 |
<p>Is it possible to do image processing in silverlight 2.0?</p>
<p>What I want to do is take an image, crop it, and then send the new cropped image up to the server. I know I can fake it by clipping the image, but that only effects the rendering of the image. I want to create a new image.</p>
<p>After further rese... | <p>Well, you can actually do local image processing in Silverlight 2... But there are no built in classes to help you. But you can load any image into a byte array, and start manipulating it, or implement your own image encoder.</p>
<p>Joe Stegman got lots of great information about "editable images" in Silverlight ov... | <p>There is first-class support for bitmap surfaces in Silverlight 3: <a href="http://blogs.msdn.com/kaevans/archive/2009/03/20/some-silverlight-3-goodness-using-writeablebitmap.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/kaevans/archive/2009/03/20/some-silverlight-3-goodness-using-writeablebitmap.aspx</a></p... | 5,556 |
<p>Does anyone have details in setting up Qt4 in Visual Studio 2008? Links to other resources would be appreciated as well.</p>
<p>I already know that the commercial version of Qt has applications to this end. I also realize that I'll probably need to compile from source as the installer for the open source does not s... | <p>As of release 1.102 the <a href="http://wiki.delphi-jedi.org/index.php?title=JEDI_Code_Library" rel="noreferrer">JEDI Code Library</a> has support for <a href="http://en.wikipedia.org/wiki/7-Zip" rel="noreferrer">7-Zip</a> built into the <a href="http://jcl.svn.sourceforge.net/viewvc/jcl/trunk/jcl/source/common/JclC... | <p>I tried many solutions and had problems, this one worked.</p>
<p>Download <a href="https://github.com/zedalaye/d7zip" rel="nofollow noreferrer">https://github.com/zedalaye/d7zip</a>
Copy 7z.dll and sevenzip.pas to your project diroctory and add sevenzip.pas to your project.</p>
<p>Then you can use this to unzip:</... | 10,018 |
<p>Ruby's standard popen3 module does not work on Windows. Is there a maintained replacement that allows for separating stdin, stdout, and stderr?</p>
| <p><a href="http://popen4.rubyforge.org/" rel="nofollow noreferrer">POpen4</a> gem has a common interface between unix and Windows. The following example (from their website) works like a charm.</p>
<pre><code>require 'rubygems'
require 'popen4'
status =
POpen4::popen4("cmd") do |stdout, stderr, stdin, pid|
std... | <p>popen3 works with MRI 1.9.x on windows. See <a href="http://en.wikibooks.org/wiki/Ruby_Programming/Running_Multiple_Processes" rel="nofollow noreferrer">http://en.wikibooks.org/wiki/Ruby_Programming/Running_Multiple_Processes</a></p>
| 14,847 |
<p>I'm still new to the ASP.NET world, so I could be way off base here, but so far this is to the best of my (limited) knowledge!</p>
<p>Let's say I have a standard business object "Contact" in the <em>Business</em> namespace. I write a Web Service to retrieve a Contact's info from a database and return it. I then wri... | <p>You are on the right track. To get the data from the proxy object back into one of your own objects, you have to do left-hand-right-hand code. i.e. copy property values. I'll bet you that there is already a generic method out there that uses reflection.</p>
<p>Some people will use something other than a web serv... | <p>I would recommend that you look at writing a Schema Importer Extension, which you can use to control proxy code generation. This approach can be used to (gracefully) resolve your problem without kludges (such as copying around objects from one namespace to another, or modifying the proxy generated reference.cs class... | 2,842 |
<p>I'm seeing some wierd behaviour when throwing exceptions and catching them in the <code>Application.ThreadException</code> event handler.</p>
<p>Basically whats happening in the sample below is that an exception is thrown in the <code>DoWork</code> event handler of a <code>BackgroundWorker</code>. The <code>RunWork... | <p>The RunWorkerCompleted event is marshaled from the BGW thread to the UI thread by the WF plumbing that makes Control.Invoke() work. Essentially, there's a queue with delegates that is emptied by the message loop. The code that does this, Control.InvokeMarshaledCallbacks(), you'll see it on the call stack, has a ca... | <pre><code> if (e.Error != null)
{
throw new Exception("worker_RunWorkerCompleted", new Exception("Inner", new Exception("Inner inner")));
}
</code></pre>
<p>You get "inner inner" at the end. It seems that this is the behavior of Application_ThreadException method to look at the inne... | 45,217 |
<p>I've been using <a href="https://en.wikipedia.org/wiki/Remote_Desktop_Services#Remote_Desktop_Connection" rel="noreferrer">Remote Desktop Connection</a> to get into a workstation. But in this environment, I cannot use the power options in Start Menu. I need an alternative way to shutdown or restart.</p>
<p>How do I... | <p>The most common ways to use the <a href="https://ss64.com/nt/shutdown.html" rel="noreferrer"><code>shutdown</code></a> command are:</p>
<ul>
<li><code>shutdown -s</code> — Shuts down.</li>
<li><code>shutdown -r</code> — Restarts.</li>
<li><code>shutdown -l</code> — Logs off.</li>
<li><p><code>shutdown -h</code> — H... | <p>Some additions to the <a href="https://ss64.com/nt/shutdown.html" rel="nofollow noreferrer">shutdown</a> and <code>rundll32.exe shell32.dll,SHExitWindowsEx n</code> commands.</p>
<p><a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logoff" rel="nofollow noreferrer"><strong>LOG... | 19,630 |
<p>I have a virtual path (example: "~/Images/Banner.jpg") and I want to make that an absolute web path (example: "/ApplicationRoot/Images/Banner.jpg"). There is a method that will do this, I believe in a class called something like HTTPUtility or similar name. Though ever time I need this method, it takes me hours ... | <pre><code>System.Web.VirtualPathUtility.ToAbsolute("yourRelativePath");
</code></pre>
<p>There you go :)</p>
| <pre><code>Control.ResolveClientUrl(url)
</code></pre>
<p>or </p>
<pre><code>Control.ResolveUrl(url)
</code></pre>
<p>Whichever one you need (honestly I dont know the difference, as both seem to return mostly the same, perhaps someone can illuminate me :) ).</p>
| 45,995 |
<p>Perl 6 seems to have an explosion of equality operators. What is <code>=:=</code>? What's the difference between <code>leg</code> and <code>cmp</code>? Or <code>eqv</code> and <code>===</code>?</p>
<p>Does anyone have a good summary?</p>
| <p><a href="http://doc.perl6.org/routine/%3D%3A%3D" rel="noreferrer">=:=</a> tests if two containers (variables or items of arrays or hashes) are aliased, ie if one changes, does the other change as well?</p>
<pre><code>my $x;
my @a = 1, 2, 3;
# $x =:= @a[0] is false
$x := @a[0];
# now $x == 1, and $x =:= @a[0] is tru... | <p>This is also a handy reference guide:</p>
<p><a href="http://www.ozonehouse.com/mark/periodic/" rel="nofollow noreferrer">Perl6 Periodic Table of Operators</a></p>
| 21,245 |
<p>I consider myself to be relatively proficient in terms of application design, but I've never had to work with sensitive data. I've been wondering about what the best practices were for audit trails and how exactly one should implement them. I don't have to do it right now, but it'd be nice to be able to confidently ... | <p>Oracle has a product called Oracle Audit Vault- DB2 probably has an equivalent.</p>
<p>You should start by <em>prevention</em>. The system should not allow invalid actions. Period. If the system allows 'dubious' actions that need to be monitored, that's "business logic", you are probably better of implementing like... | <p>Oracle has a product called Oracle Audit Vault- DB2 probably has an equivalent.</p>
<p>You should start by <em>prevention</em>. The system should not allow invalid actions. Period. If the system allows 'dubious' actions that need to be monitored, that's "business logic", you are probably better of implementing like... | 40,698 |
<p>Correct me if I am wrong,</p>
<p>int is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31)<br>
long is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31)</p>
<p>What is the difference in C++? Can they be used interchangeably?</p>
| <p>It is implementation dependent. </p>
<p>For example, under Windows they are the same, but for example on Alpha systems a long was 64 bits whereas an int was 32 bits. This <a href="http://software.intel.com/en-us/articles/size-of-long-integer-type-on-different-architecture-and-os" rel="noreferrer">article</a> cove... | <p>It depends on your compiler. You are guaranteed that a long will be at least as large as an int, but you are not guaranteed that it will be any longer.</p>
| 34,085 |
<p>Having trouble linking the Stomp.framework into an iPhone SDK application.</p>
<p><a href="http://code.google.com/p/stompframework/" rel="nofollow noreferrer">http://code.google.com/p/stompframework/</a></p>
<p>I follow the instructions, adding it to the project, adding a Build Phase for Copying the Files, and inc... | <p>The iPhone SDK doesn't support embedding frameworks in applications. I believe it supports dylibs, though I'm not certain of that fact. However, the safest thing to do would be to take the source of that framework and compile it directly into your application.</p>
| <p>Make sure that whatever folder contains the .framework bundle is listed in the Framework Search Paths setting of your target or project.</p>
<p>There's more you'd need to do if you want to embed the framework in your application but that's another question.</p>
<p><em>edit:</em> Totally ignored the iPhone requirem... | 47,630 |
<p>I've created a python object, but I want to send signals on it. I made it inherit from gobject.GObject, but there doesn't seem to be any way to create a new signal on my object.</p>
| <p>You can also define signals inside the class definition:</p>
<pre><code>class MyGObjectClass(gobject.GObject):
__gsignals__ = {
"some-signal": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (object, )),
}
</code></pre>
<p>The contents of the tuple are the the same as the three last arguments to <code>... | <p>Here is how:</p>
<pre><code>import gobject
class MyGObjectClass(gobject.GObject):
...
gobject.signal_new("signal-name", MyGObjectClass, gobject.SIGNAL_RUN_FIRST,
None, (str, int))
</code></pre>
<p>Where the second to last argument is the return type and the last argument is a tuple of argument types.</p>... | 9,225 |
<p>I'm trying to use the <a href="http://optiflag.rubyforge.org/discussion.html" rel="nofollow noreferrer">Optiflag</a> package in my Ruby code and whenever I try to do the necessary <code>require optiflag.rb</code>, my program fails with the standard <code>no such file to load -- optiflag</code> message. I added the d... | <p>is it a gem? Are you doing </p>
<pre><code>require 'rubygems'
require 'optiflag'
</code></pre>
<p>or equivalent?</p>
| <p>I also keep having this problem with RubyXL, tried to use single and double quotes. Is there something else that needs to be done? Maybe putting a file somewhere? I already succesfully installed the gem with sudo gem install rubyXL (RubyXL actually din't work).</p>
| 7,670 |
<p>I'm trying to use route constraints in an Asp.Net MVC Application. </p>
<pre><code>routes.MapRoute(
"theRoute",
"MyAction/{page}",
new { controller = "TheController", action = "MyAction", page = 1 },
new { page = @"[0-9]" });
</code></pre>
<p>When I enter an url like ~/MyAction/aString, an YSOD is ... | <p>The problem is that you do not have a route that matches the route that ends in a string.</p>
<p>Modify your routes similar to:</p>
<pre><code>routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameter... | <p>Just to mention a more general redirection:</p>
<p>You can write in the Web.config of your application:</p>
<pre><code><system.web>
...
...
<customErrors mode="On">
<error
statusCode="404"
redirect="/Home/MyCustomError" />
... | 40,591 |
<p>It seems rather common (around here, at least) for people to recommend SVN to newcomers to source control because it's "easier" than one of the distributed options. As a very casual user of SVN before switching to Git for many of my projects, I found this to be not the case at all.</p>
<p>It is conceptually <em>eas... | <p>A distributed versioning system is A Very Good Thing (tm), but I find the primary barrier to adoption being educating users on the new possibilities a new SCM gives.</p>
<p>This coupled with an often lack-luster amount of UI tools (half-finished tortoise implementations etc), brings a blank stare to the eye of many... | <p>We struggle to make it as easy as possible at Codice, but it's always a little bit harder to explain, of course, it depends on the audience.</p>
<p>For OSS projects and small teams, specially people working on their laptops and moving here and there, working at home, plane sometimes, and so on, it's pretty easy. Bu... | 21,496 |
<p>There seems to be a lot of heated discussion on the net about the changes to the reduce() function in python 3.0 and how it should be removed. I am having a little difficulty understanding why this is the case; I find it quite reasonable to use it in a variety of cases. If the contempt was simply subjective, I canno... | <p>As Guido says in his <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=98196" rel="noreferrer">The fate of reduce() in Python 3000</a> post:</p>
<blockquote>
<p>So now reduce(). This is actually the one I've always hated most, because, apart from a few examples involving + or *, almost every time I see a... | <p>Using reduce to compute the value of a polynomial with Horner's method is both compact and expressive.</p>
<p>Compute polynomial value at x.
a is an array of coefficients for the polynomial</p>
<pre><code>def poynomialValue(a,x):
return reduce(lambda value, coef: value*x + coef, a)
</code></pre>
| 21,911 |
<p>How do I call the parent function from a derived class using C++? For example, I have a class called <code>parent</code>, and a class called <code>child</code> which is derived from parent. Within
each class there is a <code>print</code> function. In the definition of the child's print function I would like to mak... | <p>I'll take the risk of stating the obvious: You call the function, if it's defined in the base class it's automatically available in the derived class (unless it's <code>private</code>).</p>
<p>If there is a function with the same signature in the derived class you can disambiguate it by adding the base class's name... | <pre><code>struct a{
int x;
struct son{
a* _parent;
void test(){
_parent->x=1; //success
}
}_son;
}_a;
int main(){
_a._son._parent=&_a;
_a._son.test();
}
</code></pre>
<p>Reference example.</p>
| 46,585 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.