instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Following techniques from 'Modern C++ Design', I am implementing a persistence library with various compile-time optimisations. I would like the ability to dispatch a function to a templated member variable if that variable derives from a given class:</p>
<pre><code>template<class T, template <class> class... | <p>Overloading can be useful to implement compile-time dispatching, as proposed by <em>Alexandrescu</em> in his book "Modern C++ Design".</p>
<p>You can use a class like this to transform at compile time a boolean or integer into a type:</p>
<pre><code>template <bool n>
struct int2type
{ enum { value = n}; };
<... | <p>Look into the boost template meta programming library. Also, depending on what you are trying to accomplish look at the boost serialization library, since it may already have what you need.</p>
| 17,578 |
<p>Platform: IIS 6, ASP.Net 2.0 (.Net 3.5), Server 2003.</p>
<p>I'm building an application that accepts files from a user, processes them, and returns a result. The file is uploaded using HTTP POST to an ASP.Net web form. The application is expecting some large files (hundreds of MB).</p>
<p>I'm using SWFUpload to a... | <p>Urlscan was active on all websites, and has it's own request entity length limit. I wasn't aware that Urlscan was running on our server because it was a global ISAPI filter, not running on my individual website. </p>
<p>Note: to locate global ISAPI filters, right click on the Web Sites folder in IIS Admin and click... | <p>You can also try <a href="http://www.codeplex.com/velodocxp" rel="nofollow noreferrer">Velodoc XP Edition</a> which has several advantages over NeatUpload including the fact that it uses ASP.NET Ajax extensions. See also <a href="http://www.velodoc.com" rel="nofollow noreferrer">the Velodoc web site</a> for more inf... | 25,253 |
<p>in C# .net 2.0, is there a quick and easy way to retrieve a message (including its possible attachments) from exchange 2003 and save it to disk in .MSG (outlook) format.</p>
<p>Thanks,</p>
| <p>I've had a lot of luck using <a href="http://www.independentsoft.de/webdavex/index.html" rel="nofollow noreferrer">WebDav.NET</a> to interact with exchange from C# code. You should evaluate it and see if it'll do what you're looking to do :-) Best of luck</p>
| <p>I'm looking for the same solution. So far, I found :
<a href="http://www.codeproject.com/KB/cs/Exchange_2003_with_WebDav.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/cs/Exchange_2003_with_WebDav.aspx</a></p>
<p>It's a demo application that contains all the code necessary to communicate with Exchang... | 29,041 |
<p>Considering the criteria listed below, which of Python, Groovy or Ruby would you use?</p>
<ul>
<li><em>Criteria (Importance out of 10, 10 being most important)</em></li>
<li>Richness of API/libraries available (eg. maths, plotting, networking) (9)</li>
<li>Ability to embed in desktop (java/c++) applications (8)</li... | <p>I think it's going to be difficult to get an objective comparison. I personally prefer Python. To address one of your criteria, Python was designed from the start to be an embeddable language. It has a very rich C API, and the interpreter is modularized to make it easy to call from C. If Java is your host enviro... | <p>I know it's not on your list, but at least look at perl.</p>
<ul>
<li>Richness of Api/Libraries to sink a ship. </li>
<li>Runs on more systems than most people realise exists. </li>
<li>Works well with Binary libraries. </li>
<li>Has a huge community.</li>
<li>Portability, See above.</li>
<li>Database manipulation:... | 32,161 |
<p>I am a heavy command line user and use the <code>find</code> command extensively in my build system scripts. However on Mac OS X when I am not concentrating I often get output like this:</p>
<pre><code>$ find -name \*.plist
find: illegal option -- n
find: illegal option -- a
find: illegal option -- m
find: illegal ... | <p>If you can't discipline yourself to use <code>find</code> 'correctly', then why not install GNU <code>find</code> (from <code>findutils</code>) in a directory on your PATH ahead of the system <code>find</code> command.</p>
<p>I used to have my own private variant of <code>cp</code> that would copy files to the curr... | <p>This is probably not what you want but how about: <code>alias find="find ."</code></p>
<p>or choose a new name (<code>findl</code> for find local?)</p>
| 23,661 |
<p>We'd like to override DataGridView's default behavior when using a mouse wheel with this control. By default, the DataGridView scrolls a number of rows equal the SystemInformation.MouseWheelScrollLines setting. What we'd like to do is scroll just one item at a time. </p>
<p>(We display images in the DataGridView... | <p>I just did a little scrounging and testing of my own. I used <a href="http://www.red-gate.com/products/reflector/" rel="nofollow noreferrer">Reflector</a> to investigate and discovered a couple things. The <code>MouseWheel</code> event provides a <code>MouseEventArgs</code> parameter, but the <code>OnMouseWheel()</c... | <p>I would subclass the DataGridView into my own custom control (you know, add a new Windows Forms --> Custom Control file and change the base class from Control to DataGridView).</p>
<pre><code>public partial class MyDataGridView : DataGridView
</code></pre>
<p>Then override the WndProc method and substitute somethi... | 16,362 |
<p>That's the question. Give only one reason you think why have OODB failed or why many systems nowadays still use relational databases.</p>
| <p>Can we answer more than once? Another reason is that relational DB's have a strong foundation in mathematics: from the definition of a relation, right through to the normal forms, the theory is rock solid. It is true that the relational model does not map well to OO, but IMHO the benefits and stability of that mod... | <p>I think that's because big guys like Oracle had been investing in relational databases while object oriented movement was getting momentum...may be they will become mainstream if Oracle / Microsoft invest in it in a big way...which seems unlikely because they don't have a strong reason to do so...it will simplify li... | 20,587 |
<p>Recently there has been quite some hype around all the different mocking frameworks in the .NET world. I still haven't quite grasped what is so great about them. It doesn't seem to be to hard to write the mocking objects I need myself. Especially with the help of Visual Studio I quickly can write a class that implem... | <p>Once I finally got the hang of mock objects, I realized that they're essential for unit testing for the same reason that double blind testing or control groups are essential for scientific trials: they isolate what you're actually testing. </p>
<p>If you're testing a class which has quite a bit of interaction via o... | <p>One of the good things about a mocking framework is that it allows setting expectations on the objects being mocked. With the expectations I can then set up all sorts of conditions to exercise the code thats being tested.</p>
| 38,469 |
<p>I'm trying to create a custom JSP tag that would take an array object and display the elements of the tag in an HTML table. Does anyone have suggestions on how to do this?</p>
| <p>Extreme slowness is a known/common problem for enumerating Win32_Products</p>
<p>If you need an alternate solution, consider building your own list of products using the 'Uninstall' registry entries (as suggested in one of the answers to the <a href="https://stackoverflow.com/questions/198087/how-do-i-list-installe... | <p>I suspected a network issue and Wireshark proved me right.</p>
<p>It seems that Windows Installer happily attempts to reopen all the original .msi files, including those who lived on network shares.</p>
| 25,559 |
<p>I have a JSF woodstock table with checkboxes. When a row is selected I want to do some processing with those items. I managed to get a selection of RowKey objects but can't find out how to get the original objects I put in back. The table is populated by an ObjectListDataProvider.</p>
| <p>Always nice to be able to answer you own questions.
I managed to solve it by casting the table's data provider to ObjectListDataProvider and use the method 'getObject' to get my original object back.</p>
| <p>So I stumbled across this and was hoping to find how to actually do the selecting and get the row information. I eventually figured it out and I thought others might benefit from how I did it.</p>
<p>I added a RadioButton to a table column in the JSP and added a valueChangeListener</p>
<pre><code><ui:radioButto... | 12,611 |
<p>OK,</p>
<p>This question has probably been answered before, but I'm not sure of how to word the Title.</p>
<p>I have a class that has methods which return many composite LINQ queries. Most of these queries form Anonymous Types in order to get the data I need. I found out that I'm not able to return an Anonymous ... | <p>You could explictly define the anonymous types you are using as classes, and instead return those classes.</p>
<p>Generally if you are writing a library for others to consume, explicitly defined classes are a best practice.</p>
| <p>or you can use technic of <a href="https://stackoverflow.com/users/748/dp">dp</a> in this <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c">post</a></p>
<pre><code>// Useful? probably not.
private void foo()
{
var user = AnonCast(GetUserTuple(), new { Name = default(string), Badges = defau... | 48,756 |
<p>In JavaScript, you can do this:</p>
<pre><code>var a = null;
var b = "I'm a value";
var c = null;
var result = a || b || c;
</code></pre>
<p>And 'result' will get the value of 'b' because JavaScript short-circuits the 'or' operator.</p>
<p>I want a one-line idiom to do this in ColdFusion and the best I can come u... | <p>ColdFusion doesn't have nulls.</p>
<p>Your example is basing the choice on which item is an empty string.</p>
<p>If that is what you're after, and all your other values are simple values, you can do this:</p>
<pre><code><cfset result = ListFirst( "#a#,#b#,#c#" )/>
</code></pre>
<p>(Which works because the ... | <p>Note: other CFML engines do support nulls.</p>
<p>If we really are dealing with nulls (and not empty strings), here is a function that will work for Railo and OpenBlueDragon:</p>
<pre><code><cffunction name="FirstNotNull" returntype="any" output="false">
<cfset var i = 0/>
<cfloop index="i" ... | 18,799 |
<p>I cannot generate the upper part of the solid properly which contain a hole (as in the picture). The solid part (bottom section) printed well. </p>
<p><a href="https://i.stack.imgur.com/QpBfR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QpBfRm.jpg" alt="enter image description here"></a></p>
... | <p>It appears that the upper part of your print contains less plastic than the lower. This would mean that as the printer begins to operate in that area, the previously deposited plastic has less time to cool.</p>
<p>The distortions are difficult to see from the distortions of the photograph, but I've experienced simi... | <p>This can be a product of poor overhang profiles and bridging. Issues with overhanging features can most easily be fixed by:</p>
<ul>
<li>applying active cooling (for PLA)</li>
<li>slowing down your feedrate on outer shells</li>
<li>or adjusting some of the more advanced slicing settings related to bridging/overhang... | 655 |
<p>I have to add a coupon table to my db. There are 3 types of coupons : percentage, amount or 2 for 1.</p>
<p>So far I've come up with a coupon table that contains these 3 fields. If there's a percentage value not set to null then it's this kind of coupon.</p>
<p>I feel it's not the proper way to do it. Should I cre... | <p>You're correct, I think a CouponType table would be fit for your problem.</p>
<p>Two tables: Coupons and CouponTypes. Store the CouponTypeId inside the Coupons table.</p>
<p>So for an example, you'll have a Coupon record called "50% off", if would reference the percent off CouponType record and from there you cou... | <p>I would definitely create a CouponType lookup table. That way you avoid all the NULL's and allow for more coupon types in the future.</p>
<p>Coupon
coupon_id INT
name VARCHAR
coupon_type_id INT <- Foreign Key</p>
<p>CouponType
coupon_type_id INT
type_description VARCHAR
...</p>
<p>Or I suppose you coul... | 27,919 |
<p>The FILESTREAM feature of SQL Server 2008, allows storage of and efficient access to BLOB data using a combination of SQL Server 2008 and the NTFS file system.</p>
<p>When insert a row on a table which contains varbinary column with filestream attribute, the file (data) is stored directly on the file system and ass... | <p>The file name is that 00000016-00000079-0006 that you found - look for it in the directory where you configured the FileStream storage. Just do a select * from your filestream-enabled table, and you'll get the file name for each row.</p>
| <p>SQL Server and Filestream do not expose the physical path, as it may change at any time based on partition splits and similar operations. You can get the logical path with the PathName() method and open it through the various Filestream capable functions.</p>
| 40,813 |
<p>I am using <a href="http://www.codeproject.com/KB/vb/TabPages.aspx" rel="nofollow noreferrer">this</a> - otherwise excellent - vb tab control in one of my c# apps. When the app using it is installed on another machine, Windows tells the user in its usual friendly and descriptive manner that "The application encounte... | <p>Since the tab control appears to be managed code as well, your 'crash' is most likely an unhandled .NET exception.</p>
<p>Looking at the error details (by expanding the error dialog using the button provided for that purpose...) should give you the exception message, which should give you an idea of what's going on... | <p>Is the dll containing the control distributed with your app? Perhaps you have a dependancy in the GAC thay you are missing?</p>
| 31,497 |
<p>Working on a project at the moment and we have to implement soft deletion for the majority of users (user roles). We decided to add an <code>is_deleted='0'</code> field on each table in the database and set it to <code>'1'</code> if particular user roles hit a delete button on a specific record.</p>
<p>For future m... | <p>You could perform all of your queries against a view that contains the <code>WHERE IS_DELETED='0'</code> clause.</p>
| <pre><code>@AdditionalCriteria("this.status <> 'deleted'")
</code></pre>
<p>put this on top of your <code>@entity</code></p>
<p><a href="http://wiki.eclipse.org/EclipseLink/Examples/JPA/SoftDelete" rel="nofollow noreferrer">http://wiki.eclipse.org/EclipseLink/Examples/JPA/SoftDelete</a></p>
| 9,382 |
<p>GWT's serializer has limited <code>java.io.Serializable</code> support, but for security reasons there is a whitelist of types it supports. The documentation I've found, for example <a href="http://www.gwtproject.org/doc/latest/FAQ_Server.html#Does_the_GWT_RPC_system_support_the_use_of_java.io.Serializable" rel="no... | <p>Any specific types that you include in your service interface and any types that they reference will be automatically whitelisted, as long as they implement java.io.Serializable, eg:</p>
<pre><code>public String getStringForDates(ArrayList<java.util.Date> dates);
</code></pre>
<p>Will result in ArrayList and... | <p>To anyone who will have the same question and doesn't find previous answers satisfactory...</p>
<p>I'm using GWT with GWTController, since I'm using Spring, which I modified as described <a href="http://markmail.org/message/k5j2vni6yzcokjsw" rel="nofollow noreferrer">in this message</a>. The message explains how to... | 16,708 |
<p>This is also a question that I asked in a comment in one of Miško Hevery's <a href="http://misko.hevery.com/2008/11/11/clean-code-talks-dependency-injection/" rel="noreferrer">google talks</a> that was dealing with dependency injection but it got buried in the comments.</p>
<p>I wonder how can the factory / builder... | <p>This talk is about Java and dependency injection.<br></p>
<p>In C++ we try <b>NOT</b> to pass RAW pointers around. This is because a RAW pointer have no ownership semantics associated with it. If you have no ownership then we don't know who is responsible for cleaning up the object.</p>
<p>I find that most of the ... | <p>You can also check the <a href="http://code.google.com/p/ffead-cpp/wiki/DependencyInjection" rel="nofollow noreferrer"><strong>FFEAD Dependency Injection</strong></a>. It provides DI on the lines of Spring for JAVA and has a non-obtrusive way of dealing with things. It also has a lot of other important features like... | 45,962 |
<p>A library using off_t as a parameter for one function (seek). Library and application are compiled differently, one with large file support switched off, the other with large file support. This situation results in strange runtime errors, because both interpret off_t differently. How can the library check at runtime... | <p>You could add an API to the library to return the sizeof(off_t) and then check it from the client. Alternatively the library could require every app to provide the API in order to successfully link:</p>
<p>library.c:</p>
<pre><code>size_t lib_get_off_t_size (void)
{
return (sizeof(off_t));
}
</code></pre>
<p... | <p>As said before, the library will not be able to know how the application (being client to the library) is compiled, but the other way round has to work. Besides, I think you are talking about dynamic linking, since static linking certainly would not have different switches at same build time.</p>
<p>Similar to the ... | 30,844 |
<p>Let's say I have an html form. Each input/select/textarea will have a corresponding <code><label></code> with the <code>for</code> attribute set to the id of it's companion. In this case, I know that each input will only have a single label.</p>
<p>Given an input element in javascript — via an onkeyup ... | <p>First, scan the page for labels, and assign a reference to the label from the actual form element:</p>
<pre><code>var labels = document.getElementsByTagName('LABEL');
for (var i = 0; i < labels.length; i++) {
if (labels[i].htmlFor != '') {
var elem = document.getElementById(labels[i].htmlFor);
... | <p>Use a JQuery selector:</p>
<pre><code>$("label[for="+inputElement.id+"]")
</code></pre>
| 36,252 |
<p>Reading <a href="http://www.paulgraham.com/articles.html" rel="noreferrer">Paul Graham's essays</a> on programming languages one would think that <a href="http://wiki.c2.com/?LispMacro" rel="noreferrer">Lisp macros</a> are the only way to go. As a busy developer, working on other platforms, I have not had the privil... | <p>To give the short answer, macros are used for defining language syntax extensions to Common Lisp or Domain Specific Languages (DSLs). These languages are embedded right into the existing Lisp code. Now, the DSLs can have syntax similar to Lisp (like Peter Norvig's <a href="http://norvig.com/paip/prolog.lisp" rel... | <p>In python you have decorators, you basically have a function that takes another function as input. You can do what ever you want: call the function, do something else, wrap the function call in a resource acquire release, etc. but you don't get to peek inside that function. Say we wanted to make it more powerful, ... | 33,602 |
<p>How can I determine the IP of my router/gateway in Java? I can get my IP easily enough. I can get my internet IP using a service on a website. But how can I determine my gateway's IP?</p>
<p>This is somewhat easy in .NET if you know your way around. But how do you do it in Java?</p>
| <p>Java doesn't make this as pleasant as other languages, unfortunately. Here's what I did:</p>
<pre><code>import java.io.*;
import java.util.*;
public class ExecTest {
public static void main(String[] args) throws IOException {
Process result = Runtime.getRuntime().exec("traceroute -m 1 www.amazon.com");... | <p>I'm not sure if it works on every system but at least here I found this:</p>
<pre><code>import java.net.InetAddress;
import java.net.UnknownHostException;
public class Main
{
public static void main(String[] args)
{
try
{
//Variables to find out the Default Gateway IP(s)
... | 3,305 |
<p>I was checking out the <a href="http://www.tibco.com/devnet/gi/" rel="nofollow noreferrer">TIBCO GI</a> the other day and I was impressed.</p>
<ul>
<li>Has anyone used it extensively?</li>
<li>What are your thoughts?</li>
<li>What drawbacks did you encounter?</li>
<li>Is it suitable for Internet or only Intranet ap... | <p>Yes, I have used it pretty extensively, here are some of my thoughts. Will add to them as the occur.</p>
<ul>
<li><p>I don't rate the approach of implementing the IDE in the framework itself (it runs in a browser window). There are many, many quirks and it can lead to a very frustrating experience. I normally devel... | <p>I completely agree with mysomic, but:</p>
<ul>
<li><p>Unfortunately Tibco GI has a huge disadvantage of it's weight and how slow it runs.</p></li>
<li><p>jQuery is much much faster.</p></li>
<li><p>Also I run into issues of different behavior of developed UI under IE and firefox.</p></li>
<li><p>Lack of documentati... | 29,064 |
<p>I need some sort of interactive chart control for my .NET-based web app. I have some wide XY charts, and the user should be able to interactively scroll and zoom into a specific window on the x axis. Something that acts similar to the google finance control would be nice, but without the need for the date labels o... | <p>How about using the "real" google finance tool from the Google visualizations project?</p>
<p><a href="http://code.google.com/apis/visualization/documentation/gallery/annotatedtimeline.html" rel="noreferrer">http://code.google.com/apis/visualization/documentation/gallery/annotatedtimeline.html</a></p>
| <p>I've recently used two generic libraries with my .NET work - they both have many different charttypes which include the zooming and scrolling you're after: one is free (<a href="http://zedgraph.org/wiki/index.php?title=Main_Page" rel="nofollow noreferrer">ZedGraph</a>) the other is not (<a href="http://www.dundas.co... | 13,655 |
<p>I have a web page that displays a long line graph inside a div with overflow-x: scroll.
This works well as a web page allowing the use to scroll back and forward through the graph.</p>
<p>However, when printing the page the scroll position is reset to zero.
Is there a way to overcome this?</p>
| <p>I think you're going to have to specify an alternate CSS for printing where you somehow need to remove the overflow:</p>
<pre><code><link rel="stylesheet" type="text/css” href="sheet.css" media="print" />
</code></pre>
<p>However, maybe there is an approach with JavaScript or even Flash? If I understand corr... | <p>A simple approach would be to have some javascript which posts back to your page with the user's selected scroll position on a link saying something like 'setup for printing'. Then the server side returns a page with the graph relatively positioned at the scroll position with <code>overflow:hidden</code> to clip the... | 29,283 |
<p>Here is my short implementation of <a href="http://en.wikipedia.org/wiki/Ancient_Egyptian_multiplication" rel="noreferrer">Russian Peasant Multiplication</a>. How can it be improved?</p>
<p><em>Restrictions</em> : only works when a>0,b>0</p>
<pre><code>for(p=0;p+=(a&1)*b,a!=1;a>>=1,b<<=1);
</code><... | <p>It can be improved by adding whitespace, proper indentation, and a proper function body:</p>
<pre><code>int peasant_mult (int a, int b) {
for (p = 0;
p += (a & 1) * b, a != 1;
a /= 2, b *= 2);
return p;}
</code></pre>
<p>See? Now it's clear how the three parts of the <code>for</code> declarat... | <p>Answer with no multiplication or division:</p>
<pre><code>function RPM(int a, int b){
int rtn;
for(rtn=0;rtn+=(a&1)*b,a!=1;a>>=1,b<<=1);
return rtn;
}
</code></pre>
| 32,566 |
<p>I have the Maven plugin for NetBeans and it successfully set up a local repository for me. Now I need to add a 3rd party library (specifically Oracle JDBC driver) to my repository. The build fails with instructions on how to install a third party module but it doesn't look like I can run that command with the NetBea... | <p>What you could do (at least in NetBeans 6.5) is following:</p>
<ul>
<li>add dependency to the library in your pom</li>
<li>go to Projects->your project->Libraries (you should see the library with exclamation mark) </li>
<li>right click on the library, choose 'Manually install artifact' </li>
<li>select the jar from... | <p>I ended up downloading Maven here:
<a href="http://maven.apache.org/download.html" rel="nofollow noreferrer">http://maven.apache.org/download.html</a>
and using the standalone Maven binaries to install the jar into my Maven repository. If anyone has any thoughts on the question, I am still interested in knowing the ... | 41,554 |
<p>I'm in the midst of writing a 3d engine and I've come across the LookAt algorithm described in the DirectX documentation:</p>
<pre><code>zaxis = normal(At - Eye)
xaxis = normal(cross(Up, zaxis))
yaxis = cross(zaxis, xaxis)
xaxis.x yaxis.x zaxis.x 0
xaxis.y yaxis.y ... | <p><strong>Note the example given is a left-handed, row major matrix</strong>.</p>
<p>So the operation is: Translate to the origin first (move by -<em>eye</em>), then rotate so that the vector from <em>eye</em> to <em>At</em> lines up with +z:</p>
<p>Basically you get the same result if you pre-multiply the rotation ... | <p>It is necessary to put the eye point in your axis space, not in the world space. When you dot a vector with a coordinate unit basis vector, one of the x,y,z, it gives you the coordinates of the eye in <em>that</em> space. You transform location by applying the three translations in the last place, in this case the... | 45,419 |
<p>Yesterday I was having a heated debate with a coworker on what would be the preferred error reporting method. Mainly we were discussing the usage of exceptions or error codes for reporting errors between application layers or modules.</p>
<p><strong>What rules do you use to decide if you throw exceptions or return ... | <p>I normally prefer exceptions, because they have more contextual information and can convey (when properly used) the error to the programmer in a clearer fashion.</p>
<p>On the other hand, error codes are more lightweight than exceptions but are harder to maintain. Error checking can inadvertently be omitted. Error ... | <p>Error codes also don't work when your method returns anything other than a numeric value...</p>
| 31,575 |
<p>My good friend, Wikipedia, <a href="http://en.wikipedia.org/wiki/Language_binding" rel="noreferrer">didn't give me a very good response</a> to that question. So:</p>
<ul>
<li>What are language bindings?</li>
<li>How do they work?</li>
</ul>
<p>Specifically accessing functions from code written in language X of a l... | <p>Let's say you create a C library to post stuff to stackoverflow. Now you want to be able to use the same library from Python. In this case, you will write Python bindings for your library.</p>
<p>Also see SWIG: <a href="http://www.swig.org" rel="noreferrer">http://www.swig.org</a></p>
| <p>In Flex (Actionscript 3). <a href="http://livedocs.adobe.com/flex/1/flex_builder_en/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Using_Flex_Builder&file=brady712.htm" rel="nofollow noreferrer">Source</a></p>
<p>A data binding copies the value of a property in one object to a property in another object. You can... | 4,545 |
<p>i want something like this</p>
<ol>
<li><p>the user enter a website link</p></li>
<li><p>i need check the link if the link
doesn't start with 'http://' I want
to append 'http://' to the link .</p></li>
</ol>
<p>how can I do that in PHP ? </p>
| <pre><code>if (stripos($url, 'http://') !== 0) {
$url = 'http://' . $url;
}
</code></pre>
| <pre><code>if (!preg_match("/^http:\/{2}/",$url)){
$url = 'http://' . $url;
}
</code></pre>
| 34,279 |
<p>I'm trying to figure out how to execute a custom query with Castle ActiveRecord. </p>
<p>I was able to run simple query that returns my entity, but what I really need is the query like that below (with custom field set):</p>
<p><em>select count(1) as cnt, data from workstationevent where serverdatetime >= :minDate... | <p>In this case what you want is <code>HqlBasedQuery</code>. Your query will be a projection, so what you'll get back will be an <code>ArrayList</code> of tuples containing the results (the content of each element of the ArrayList will depend on the query, but for more than one value will be <code>object[]</code>).</p>... | <p>Be aware though, if you're using ActiveRecord 1.0.3 (RC3) as I was, this will result in a runtime InvalidCastException. ActiveRecordMediator.ExecuteQuery returns an ArrayList and not a generic ICollection. So in order to make it work, just change this line:</p>
<pre><code>var results = (ICollection<object[]>)... | 39,690 |
<p>Many programs include an auto-updater, where the program occasionally looks online for updates, and then downloads and applies any updates that are found. Program bugs are fixed, supporting files are modified, and things are (usually) made better.</p>
<p>Unfortunately no matter how hard I look, I can't find informa... | <p>I think that "language agnostic" is going to be a limiting factor here. Applications come in so many shapes and sizes that there is no one-size-fits-all answer. I have implemented several auto-updaters in several languages, and no two were similar.</p>
<p>The most general philosophy is that the application checks... | <p>If you are searching for an cross-platform software update solution, take a look at <a href="http://www.updatenode.com" rel="nofollow">www.updatenode.com</a></p>
<p>Some highlights:</p>
<ul>
<li>free for Open Source projects</li>
<li>cross-platform & Open Source update client tool</li>
<li>localized already fo... | 28,757 |
<p>The Dragon Book includes an exercise on converting integers to roman numerals using a syntax-directed translation scheme.</p>
<p>How can this be completed?</p>
| <p>I would consider parsing from right-to-left.</p>
<p>First, I would map the units column:</p>
<pre><code>0 -> ''
1 -> 'I'
2 -> 'II'
3 -> 'III'
4 -> 'IV'
...
9 -> 'IX'
</code></pre>
<p>Then, if there was a second column (e.g. second from the right = tens column), I would use that to map to </p>
<... | <p>Another way is to store in two-dimensional array the roman numerals for 1, 5, 10, 50, 100, 500, 1000 and so on. Example (in PHP array):</p>
<pre><code>$roman = array(
[0] = array( 1=>"I", 5=>"V", 10=>"X" ),
[1] = array( 1=>"X", 5=>"L", 10=>"C" ),
[2] = array( 1=>"C", 5=>"D", 10=>"M"... | 33,532 |
<p>So the official XML-RPC standard doesn't support 64-bit values. But in these modern times, 64-bit values are increasingly common.</p>
<p>How do you handle these? What XML-RPC extensions are the most common? What language bindings are there? I'm especially interested in Python and C++, but all information is app... | <p>Some libraries support 64 bits extensions, indeed, but there doesn't seem to be a standard. <a href="http://xmlrpc-c.sourceforge.net/" rel="nofollow noreferrer">xmlrpc-c</a>, for example, has a so called i8 but it doesn't work with python (at least not by default).</p>
<p>I would recommend to either:</p>
<ul>
<li>... | <p>I don't know anything about how XMLRPC could be extended but I did find <a href="http://mail.python.org/pipermail/python-list/2006-May/381032.html" rel="nofollow noreferrer">this mail</a> about the subject:</p>
<blockquote>
<p>In XML-RPC, everything is transmitted
as a string, so I don't think that
choice is ... | 13,306 |
<p>I would like to be able to step through an application deployed to a remote location which as yet has nothing bar version 3.5 of the .Net framework. </p>
<p>What steps do I need to go through to achieve this and how long would you envisage this taking?</p>
| <p>If you have unrestricted TCP/IP access to the remote location, this will be very easy (as in, 5 minutes tops to get it to work): see <a href="http://msdn.microsoft.com/en-us/library/bt727f1t.aspx" rel="nofollow noreferrer">How to: Set Up Remote Debugging</a> and <a href="http://msdn.microsoft.com/en-us/library/xf8k2... | <p><a href="http://msdn.microsoft.com/en-us/library/bt727f1t.aspx" rel="nofollow noreferrer">How to: Set Up Remote Debugging</a></p>
<p><a href="http://www.microsoft.com/uk/msdn/screencasts/screencast/313/Visual-Studio-2008-Remote-Debugging-with-MSVSMONEXE.aspx" rel="nofollow noreferrer">Screencast for Visual Studio 2... | 18,479 |
<p>I'm writing a GUI in C#, Visual Studio 2008, using the Designer and WinForms. I've got a ComboBox control, and I'd like it to only allow to select from the provided options and not to accept a user-entered string. It doesn't appear to have a ReadOnly property, and disabling it hinders the readability of the contro... | <p>Set DropDownStyle to "DropDownList"</p>
| <p>Try using a DropDownListbox</p>
| 19,703 |
<p>I am using CYGWIN as a platform and would like to use wxPython. Is there a way to get the source compiled and working in cygwin?</p>
| <p>I found this link to <a href="http://gnuradio.org/redmine/projects/gnuradio/wiki/WxPythonCygwin" rel="noreferrer">build wxPython under Cygwin</a>. To me this is a much better option than installing all the X11 stuff. I tried it out using wxPython-src-2.8.12.1, and following the instructions to a tee, it worked per... | <p>Isn't the whole point of using wxPython being to use WxWidgets? Isn't the whole point of using THAT being to have a cross platform GUI library?</p>
<p>In other words, forget about X11, and just use the native wxPython on windows.</p>
<p>If you want to avoid requiring the user to install wxPython and its dependenci... | 39,970 |
<p>How would you define testing? In the interest of full disclosure, I'm posting this because I already have some answers I like.</p>
| <p>Testing is any process by which it is verified that each feature (user story, requirement...) has been developed as required, or not.</p>
| <p>Its better to just test like try this application
<a href="http://www.testalways.com/2010/07/05/find-bugs-and-patterns/" rel="nofollow noreferrer">http://www.testalways.com/2010/07/05/find-bugs-and-patterns/</a></p>
<p>and then describe what you just did. That I would consider defining the process of testing</p>
| 13,410 |
<p>When using the CHECKSUM column type to artificially create a hash index, is the lookup actually O(1) or is it still O(lg n) like it is for a clustered index? I have a table from which I will select based on its ID column and I need the lookup to be as fast as possible, so is the clustered index the fastest possible ... | <p>Okay, 2 points.<br>
The SQL CHECKSUM function does not produce a hash value. It actually calculates a CRC value. It is not a very good candidate to base a hash check on becuase there will be a relativly large number of collisions. You should check the hash_bytes function if you want a hash function.<br>
Secondly,... | <p>There's no advantage to searching an indexed CHECKSUM over a clustered index on the ID field if the ID field is an int since both will do a clustered index seek. Also, a CHECKSUM of an int column always returns the same value as the column (i.e. CHECKSUM(535) = 535). However, a CHECKSUM lookup will generally perfo... | 41,122 |
<p>I have a spool of PLA filament where the diameter is visibly inconsistent. So it will only print a meter or two and then start slipping instead of being fed into the nozzle. Is this still useful for anything or can it be salvaged somehow?</p>
<p>I can't return it, the shipping costs more than the spool.</p>
| <p>In principle you can re-extrude it with a somewhat simpler machine/setup than making filament from scratch, but controlling the diameter is the hard part of making filament - as you can see from how the manufacturer of yours botched it.</p>
<p>I would first try insisting on a refund without returning the item unless... | <p>Personally I store all my filament waste in tubs for the day a recycling/reuse solution offers itself. You can "compact" waste prints using hot air which also sticks the whispy pieces together. Someone will eventually come out with a "re-extruder" that simply cooks old filament and then produc... | 2,136 |
<p>I have one field that I need to sum lets say named items
However that field can be part of group a or b
In the end I need to have all of the items summed for group a and group b</p>
<p>when I say grouped I mean there is a LEFT OUTER JOIN to another table the previous table has a type for the items and the one being... | <p>Maybe I'm not understanding the complexity of what you're asking but... shouldn't this do?</p>
<pre><code>SELECT groupname, SUM(value)
FROM items
WHERE groupname IN ('a', 'b')
GROUP BY groupname
</code></pre>
<p>And if you don't care which of a or b the item belongs to then this will do:</p>
<pre><code>SELECT SUM... | <p>Please refer this Image (<a href="https://i.stack.imgur.com/5R9ou.png" rel="nofollow noreferrer">1</a>)</p>
<pre><code>SELECT category_id,SUM(amount) AS count FROM expense GROUP BY category_id;
</code></pre>
| 5,044 |
<p>I mean 3D forms like these? In a small scale (height: 1-2 cm, width: 0.5 cm).</p>
<p><a href="https://i.stack.imgur.com/Yd8Cl.png" rel="nofollow noreferrer" title="Detailed 3D form#1"><img src="https://i.stack.imgur.com/Yd8Cl.png" alt="Detailed 3D form#1" title="Detailed 3D form#1"></a></p>
<p><a href="https://i.s... | <p>Best option for something like this would be to use an SLA printer. They can do sharper image detail compared to FDM style printers.</p>
<p>That being said, printing something like this poses its own set of challenges. In order to print a part, some surface needs to be in contact with the built platform, and depend... | <p>You could use something like a Stratsys Objet 30 Pro. </p>
<p>The printer uses layers of liquid deposited on a bed and cured with UV light, instead of extruded plastics. This just means that the level of detail you can achieve is far higher than that typically achieved by a conventional ABS or PLA printer. That bei... | 575 |
<p>Unfortunately I don't have access to a *nix box at work or at home. The only way I can play with Haskell is on windows. Anyone here using Haskell on Windows? What's your setup?</p>
| <p>I've used Haskell on Windows, but only when forced to. Not because the combination Haskell+Windows is particularly bad, but just because I don't really like Windows.</p>
<p>My setup was basically the following:</p>
<ul>
<li>GHC</li>
<li><a href="http://vim.org/" rel="noreferrer">Vim</a></li>
<li><a href="http://w... | <p>Or You could partition your hard-drive a duel boot between linux and windows :)</p>
<p>Doesn't answer your question, but it is an alternative.</p>
| 39,151 |
<p>In JSP I can reference a bean's property by using the tag
${object.property}</p>
<p>Is there some way to deal with properties that might not exist? I have a JSP page that needs to deal with different types. Example:</p>
<pre><code>public class Person {
public String getName()
}
public class Employee extends Pe... | <p>Just use the EL empty operator IF it was a scoped attribute, unfortunately you'll have to go with surrounding your expression using employee.salary with <c:catch>:</p>
<pre><code><c:catch var="err">
<c:out value="${employee.salary}"/>
</c:catch>
</code></pre>
<p>If you really need <em>i... | <p>You could always have a type field.</p>
<pre><code>public class Person {
public String getType() { return "Person"; }
public String getName()
}
public class Employee extends Person {
public String getType() { return "Employee"; }
public float getSalary()
}
</code></pre>
<p>Your JSP would look like<... | 31,782 |
<p>I would like to print parts (e.g. jewellery) for use which I don't want to look or feel like a plastic, but metal-like, so briefly people won't see much difference.</p>
<p>Are there any specific type of home-printers that can achieve that? Or it's rather kind of filament that you should use?</p>
| <p>If you'd like to print on RepRap like <a href="https://en.wikipedia.org/wiki/Fused_deposition_modeling" rel="nofollow noreferrer">FDM printers</a>, you cannot print from metal, but you can use some filament that tries to look like metal. I have good experience with <a href="http://colorfabb.com/bronzefill" rel="nofo... | <p>There's also an interesting discussion of printing with specially-designed solder alloys, at <a href="http://blog.reprap.org/2011/06/new-approach-to-printing-metals.html" rel="nofollow noreferrer">RepRap: Blog - A new approach to printing metals</a>. </p>
<p>The author settled on 57.5%Sn, 41.3%Bi, 1.2% In, which be... | 91 |
<p>When a template is added using the add-template stsadm command, it becomes available to everyone when creating a subsite. Is there any way to make it only available when a site collection is being created?</p>
| <p>go to site actions -> Site Settings -> view all site settings -> site templates and page layouts and remove the site template from the list of allowed items.</p>
<p>Gary Lapointe may also have made an stsadm extenstion for it; check <a href="http://stsadm.blogspot.com" rel="nofollow noreferrer">stsadm.blogspot.com<... | <p>The url to the blog post mentioned above, for hiding the stp templates using the stsadm extention, is <a href="http://stsadm.blogspot.com/2007/08/set-available-site-templates.html" rel="nofollow noreferrer">http://stsadm.blogspot.com/2007/08/set-available-site-templates.html</a></p>
<blockquote>
<p>Here’s an exam... | 7,418 |
<p>We are in a stage of creating a prototype of some IoT device with some electric boards and sensors.
The device will be connected to the power and the boards inside might be warm a bit.</p>
<p>What material whould you recommended to print it? Will you recommend it to production as well?
Thanks</p>
| <p>Well I got a perfect print as follows:</p>
<ol>
<li>Loaded the .stl file.</li>
<li>Set Cura to use the 'Good' profile downloaded from CHEPCLUB
(recommended by a friend).</li>
<li>Used <strike>Pritt-stick</strike> Scotch (glue stick) on the bed.</li>
</ol>
<p>I was quite loath to use glue stick, as I thought heated b... | <p>For a good adhesion the print bed should be free of any oil or fat. Wipe the print bed with pure alcohol just befor the start of printing.</p>
| 2,041 |
<p>I have data that needs to be executed on a certain background thread. I have code coming from all other threads that need to call into this. does anyone have a good tutorial or best practice on having a queue for synchronization to support this threading requirement</p>
| <p>Check out <a href="http://www.albahari.com/threading/" rel="noreferrer">Threading in C#</a>, by Joseph Albahari, very complete reference about multithreading. In particular, he covers <a href="http://www.albahari.com/threading/part2.aspx#_ProducerConsumerQWaitHandle" rel="noreferrer">producer/consumer queues</a>.</p... | <p>You can try this solution. It shows you how to implement the producer-consumer pattern. Has also some explanation on what can be done with it. Like different combinations of the number of producers and consumers. </p>
<p><a href="http://devpinoy.org/blogs/jakelite/archive/2009/01/12/threading-patterns-the-producer-... | 45,057 |
<p>I've read all the advice on const-correctness in C++ and that it is important (in part) because it helps the compiler to optimize your code. What I've never seen is a good explanation on how the compiler uses this information to optimize the code, not even the good books go on explaining what happens behind the curt... | <p>I think that the const keyword was primarily introduced for compilation checking of the program semantic, not for optimization.</p>
<p>Herb Sutter, in the <a href="http://www.gotw.ca/gotw/081.htm" rel="noreferrer">GotW #81 article</a>, explains very well why the compiler can't optimize anything when passing paramet... | <p><code>const</code> helps compilers optimize mainly because it makes you write optimizable code. Unless you throw in <code>const_cast</code>.</p>
| 26,086 |
<p>I am not a DBA by any means, but being a web developer means that I will have to install, setup, and administer databases. In the past, I have just followed the default installation for SQL Server. Over time, I have grown smarter and learned that default installations almost always leave doors open and leak.</p>
<p... | <p>Every setting is critical - but the things I always double check are:</p>
<ol>
<li><p>Authentication type - Integrated or SQL? If SQL, make sure you put in a very strong sa password.</p></li>
<li><p>Service Accounts - think through what you want for the accounts. I generally create a domain user for each service ... | <p>The Microsoft documentation in Books on Line and elsewhere is pretty thorough and accurate. I think it's the best documentation that Microsoft does. So I'd be rigorous about "RTM" before anything I would write here, which would be incomplete and inadequately explained in any case by comparison.</p>
<p>That said, th... | 48,777 |
<p>I want to convert from char representing a hexadecimal value (in upper or lower case) to byte, like</p>
<pre><code>'0'->0, '1' -> 1, 'A' -> 10, 'a' -> 10, 'f' -> 15 etc...
</code></pre>
<p>I will be calling this method extremely often, so performance is important. Is there a faster way than to use a... | <p>A preinitialised array would be faster than a HashMap. Something like this:</p>
<pre><code>int CharValues['f'-'0'+1] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, ... -1, 10, 11, 12, ...};
if (c < '0' || c > 'f') {
throw new IllegalArgumentException();
}
int n = CharValues[c-'0'];
if (n < 0) {
throw ne... | <p>A table of 16-bit values where you could look up two digits at a time should be quicker than the 8-bit-value arrays suggested in other answers. You would be iterating the data twice as quickly, accessing the array half as often, and accessing shorts instead of bytes, all of which gives the CPU less to do and more to... | 27,226 |
<p>Given the Below Tables. How do I get the Distinct name given the other ID of 76 in LINQ?</p>
<pre><code>**Table S**
SID OtherID
------------------------------
1 77
2 76
**Table Q**
QID SID HighLevelNAme LoweLevelName
---------------------------------------
10 1 Name1 Engi... | <p>If you have the foreign key relationships defined in your database, and generated the LINQ classes via the designer, then the joins should be represented in the object model, right? So each QItem has a property SItem? If not, I guess you can use the Join extension method for that part. </p>
<p>Anyhow, I didn't test... | <p>Using the answer by Troy, this query methods also works.</p>
<pre><code>List<string> highLevelNames = dataContext
.Q
.Where<Q>(item => item.S.OtherID == id)
.Select<Q, string>(item => item.HighLevelNAme)
.Distinct()
.ToList<string>();
</code></pre>
| 25,795 |
<p>I have been looking at the new <a href="http://cappuccino.org/" rel="noreferrer">Objective-J / Cappuccino</a> javascript framework from <a href="http://280north.com/" rel="noreferrer">280North</a>. They provide plug-ins for SubEthaEdit and TextMate to handle syntax highlighting, but I primarily use vi. Does anyone... | <p>The Objective-J Tools package (<a href="http://cappuccino.org/download" rel="noreferrer">http://cappuccino.org/download</a>) and the source on github now include a vim highlight module.</p>
| <p>If regular javascript syntax highlighting is good enough, you can map that to .j files by adding something like this to your .vimrc file:</p>
<pre><code> augroup objective-j
au! BufRead,BufNewFile *.j set filetype=objective-j
au! Syntax objective-j source /usr/share/vim/vim71/syntax/javascript.vim
augrou... | 7,232 |
<p>Consider the following HTML:</p>
<pre><code><div class="foo" id="obj">
I should be changed red
<div class="bar" style="color:black;">
I should not be changed red.
<div class="foo">I should be changed red.</div>
</div>
</div>
</code></pre>
<p>Given a DOM elem... | <p>If I understand you correctly:</p>
<pre><code>$(currentDiv).contents().addBack('.foo').css('color','red');
</code></pre>
<p>I renamed the "div" to "currentDiv" for clarity. This selects the current element and all of the elements it contains, then filters out the ones that do not have class <code>foo</code> and a... | <pre><code> $('div.foo, div.foo > *').css('color','red');
</code></pre>
<p>The main idea is that you can separate different rules to match on by commas. Just like in css. As far as I know everything <a href="http://css.maxdesign.com.au/selectutorial/index.htm" rel="nofollow noreferrer">here</a> is supoprted by jque... | 47,618 |
<p>I'm using SQL Server 2008 with Advanced Services on my Vista Home Premium. I'd installed Full-text searching during installation, The SQL Full-text Filter Daemon Launcher is running thorough an admin user account. When I go to a database through the SQL Server Management Studio, I don't see the "Storage" option unde... | <p>Ok, the answer is: </p>
<p>SQL Management Studio Basic doesn't support Full-text catalogs. Catalogs can only be created via T-SQL. <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3912985&SiteID=1" rel="nofollow noreferrer">This is a feature that might be added in the future</a>.</p>
| <p>First,</p>
<pre><code>EXEC sp_fulltext_database 'enable';
GO
</code></pre>
<p>Then,</p>
<pre><code>CREATE FULLTEXT CATALOG ftcatalog;
GO
</code></pre>
<p>Then,</p>
<pre><code>CREATE FULLTEXT INDEX ON dbo.Tablename ( Column )
KEY INDEX PK_PriKeyIndex
ON ftcatalog
WITH CHANGE_TRACKING AUTO
GO
</code></pre>
| 16,777 |
<p>Is there a UI library to create a message box or input box in python?</p>
| <p>Your best bet is the tkMessageBox module, which should work on all systems (as Python will typically come with Tkinter).</p>
<p>If you can restrict yourself to a specific operating system, better choices might be available.</p>
| <p>from Tkinter </p>
<pre><code>import *
import os
class Dialog(Toplevel):
def __init__(self, parent, title = None):
Toplevel.__init__(self, parent)
self.transient(parent)
if title:
self.title(title)
self.parent = parent
self.result = None
body... | 32,119 |
<p>I have signed up with BizSpark and it is a great deal, especially for people like myself in perennial startup mode. As part of BizSpark you get 3 year deployment licenses for software such as Windows Server and SQL Server. Is there any dedicated hosting companies that will allow you to use these licenses without hav... | <p>So far, I have found two hosting providers aware of BizSpark:</p>
<ul>
<li><a href="http://www.peer1.com/hosting/bizspark.php" rel="nofollow noreferrer">http://www.peer1.com/hosting/bizspark.php</a></li>
<li><a href="http://www.servepath.com/bizspark/" rel="nofollow noreferrer">http://www.servepath.com/bizspark/</a... | <p>As far as I know you have a few options.</p>
<ol>
<li>BizSpark has a hosting company agreement, you could contact them</li>
<li>Most hosting companies with dedicated systems will sell you a basic configuration and allow you to install your own software. (However, windows might be the only tricky one).</li>
</ol>
... | 43,134 |
<p>I wonder if this would be doable ? To insert an array into one field in the database.</p>
<p>For instance I have a title, I want to have that title with only one id, but it's going to be bilingually used on the website.</p>
<p>It feels a bit unnecessary to make another table to have their global ids and then anoth... | <p>it's doable:</p>
<pre><code>$title = serialize($array);
</code></pre>
<p>and then to decode:</p>
<pre><code>$title = unserialize($mysql_data);
</code></pre>
<p>but as mentioned it really lessens the benefits of a database in the first place. i'd definitely suggest looking into a multi-table or multi-column optio... | <p>There is the JSON data-type, which will also store "arrays".</p>
<p><a href="https://dev.mysql.com/doc/refman/8.0/en/json.html" rel="nofollow noreferrer">https://dev.mysql.com/doc/refman/8.0/en/json.html</a></p>
| 22,453 |
<p>Assume the following class:</p>
<pre><code>public class MyEnum: IEnumerator
{
private List<SomeObject> _myList = new List<SomeObject>();
...
}
</code></pre>
<p>It is necessary to implement the IEnumerator methods in MyEnum.
But is it possible to 'delegate' or redirect the implementation for IEnume... | <p><strong>Method 1:</strong>
Continue to use encapsulation and forward calls to the List implementation.</p>
<pre><code>class SomeObject
{
}
class MyEnum : IEnumerable<SomeObject>
{
private List<SomeObject> _myList = new List<SomeObject>();
public void Add(SomeObject o)
{
_myLi... | <p>Not unless you derive from List<T>.</p>
<pre><code>public class MyEnum : List<SomeObject>, IEnumerable<SomeObject>{}
</code></pre>
| 15,344 |
<p>I'm trying to figure out the best way to parse a GE Logician MEL trace file to make it easier to read.</p>
<p>It has segments like </p>
<pre>>{!gDYNAMIC_3205_1215032915_810 = (clYN)}
execute>GDYNAMIC_3205_1215032915_810 = "Yes, No"
results>"Yes, No"
execute>end
results>"Yes, No"
>{!gDYNAMIC_3205_1215032893_294... | <p>Make a grammar using ANTLR. If you're using C, lex/yacc are native. ANTLR creates native parsers in Java, Python and .NET. Your output looks like a repl; try asking the vendor for a spec on the input language.</p>
| <p>You could try ANTLR or lex/yacc.</p>
| 10,055 |
<p>I have a complex sharepoint deploy with multiple EventReceivers and Workflows. </p>
<p>I also have schema changes to existing lists, adding new columns of metadata and changing existing columns. </p>
<p>Should I package a single feature, eventreceiver or workflow, to a single solution, or should I put multiple f... | <p>I would advise <b>against</b> splitting everything into multiple solutions. Maintaing that can quickly become nightmare. Try to structure your project, which should is used to create WSP, in same manner as 12 folder of sharepoint. Then you can use <a href="http://www.codeplex.com/wspbuilder" rel="nofollow noreferrer... | <p>Basically (for the reasons you've mentioned), you should think of solutions as you would .Net assemblies - atomic units of code that can be deployed separately from others. Using upgradesolution will cause a redeploy of all the contained features - if nothing's changed, then nothing should change for the sites that... | 49,047 |
<p>I had a recent problem where Tie::File proved the best answer I could work with for a Perl program. I'm at a point where I'm ready to work with CGI, and I need to ask: are there Perl modules that can't be used in CGI, especially that Tie::File? If there are any complications, are there ways to reconcile them?</p>
| <p>A CGI is basically just a program that reads a request on STDIN and spews header + HTML on STDOUT. It isn't really special: there aren't any modules you can't use, if you try hard enough.</p>
<p>You could even get graphical (e.g., GTK) ones working with enough pain. Not that you'd want to. Unless you're a third-par... | <p>Make sure your data file is readable <em>and</em> writable by your CGI process. I'm adding this answer because it led to a very odd bug. I had a script that wouldn't run from CGI. In fact the CGI could read the contents of the data just fine, but Tie::File failed (even though it worked fine if I called it from the c... | 49,826 |
<p>Compiling a program on Linux that calls POSIX timer functions (eg: timer_create, timer_settime) returns errors such as:</p>
<pre>
In function `foo':
timer.c:(.text+0xbb): undefined reference to `timer_create'
timer.c:(.text+0x187): undefined reference to `timer_settime'
collect2: ld returned 1 exit status
</pre>
<... | <p>Compile it with <code>-lrt</code> option. It will get compiled.</p>
| <p>This should be documented in the man page. Given it isn't add <code>-lrt</code>.</p>
| 32,461 |
<p>I have a few internal .net web application here that require users to "log out" of them. I know this may seem moot on an Intranet application, but nonetheless it is there.</p>
<p>We are using Windows authentication for our Intranet apps, so we tie in to our Active Directory with Basic Authentication and the credent... | <p>I've come up with a fix that seems fairly consistent but is hacky and <a href="https://stackoverflow.com/questions/6277919">I'm still not happy with it</a>.</p>
<p>It does work though :-)</p>
<p>1) Redirect them to a Logoff page</p>
<p>2) On that page fire a script to ajax load another page with dummy credentials... | <p>Hopefully this will be useful until someone actually comes along with an explicit answer - <a href="http://forums.mozillazine.org/viewtopic.php?t=366028&" rel="nofollow noreferrer"><strong>this issue was discussed two years ago on a message board</strong></a>.</p>
<p>HTH</p>
| 5,126 |
<p>Suppose you have a large file made up of a bunch of fixed size blocks. Each of these blocks contains some number of variable sized records. Each record must fit completely within a single block and then such records by definition are never larger than a full block. Over time, records are added to and deleted from th... | <p>This sounds like a variation of the <a href="http://en.wikipedia.org/wiki/Bin_packing_problem" rel="nofollow noreferrer">bin packing problem</a>, but where you already have an inferior allocation that you want to improve. So I suggest looking at variations of the approaches which are successful for the bin packing ... | <p>Here's an algorithm you might be able to leverage, albeit your records within fixed size blocks might require a little bit more work.</p>
<p><a href="http://cse.seas.wustl.edu/techreportfiles/getreport.asp?384" rel="nofollow noreferrer">Heap Defragmentation in Bounded Time</a></p>
| 15,813 |
<p>I have a SQL Server 2000, C# & ASP.net web app. We want to control access to it by using Active Directory groups. I can get authentication to work if the group I put in is a 'Global' but not if the group is 'Universal'. </p>
<p>How can I make this work with 'Universal' groups an well?
Here's my authorization... | <p>Depending on your Active Directory topology, you might have to wait for the Universal Group membership to replicate around to all the Domain Controllers. Active Directory recommends the following though:</p>
<ol>
<li>Create a Global group for each domain, e.g., "Domain A Authorized Users", "Domain B Authorized Use... | <p>Depending on your Active Directory topology, you might have to wait for the Universal Group membership to replicate around to all the Domain Controllers. Active Directory recommends the following though:</p>
<ol>
<li>Create a Global group for each domain, e.g., "Domain A Authorized Users", "Domain B Authorized Use... | 11,781 |
<p>Is there a way to run some custom Javascript whenever a client-side ASP.NET validator (<code>RequiredFieldValidator</code>, <code>RangeValidator</code>, etc) is triggered? </p>
<p>Basically, I have a complicated layout that requires I run a custom script whenever a DOM element is shown or hidden. I'm looking for a ... | <p>See <a href="https://stackoverflow.com/questions/124682/can-you-have-custom-client-side-javascript-validation-for-standard-aspnet-web-f#125158">this comment</a> for how I managed to extend the ASP.Net client side validation. <a href="http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=362" rel="nofollow nor... | <p>The best solution I've identified for my specific situation is this:</p>
<ol>
<li>Create a global JS data structure mapping control IDs to a visibility state.</li>
<li>Register the client IDs of the validators (or anything else, for that matter) in this data structure.</li>
<li>Every 250 milliseconds, loop through ... | 19,420 |
<h2><strong>NEW UPDATE BELOW</strong></h2>
<hr />
<p>I am having trouble finding the cause for this under-extrusion at start/end of each layer.
Something changes halfway into the print creating a visible seam at some specific layer height.</p>
<p>This also creates dimensional inaccuracy making my parts unusable.<br />
... | <h1>That's not under extrusion</h1>
<p>That is the seam, and technically it is over extruding around it. You will find that if you turn the item, you have such a spot on every layer, actually with an inner and outer perimeter, you'll have two visible seams. The seam is where the extrusion line meets itself, and thus th... | <h1>That's not under extrusion</h1>
<p>That is the seam, and technically it is over extruding around it. You will find that if you turn the item, you have such a spot on every layer, actually with an inner and outer perimeter, you'll have two visible seams. The seam is where the extrusion line meets itself, and thus th... | 2,147 |
<p>I'm a simple soul with simple needs, and I'm trying to configure a form. I detest forms.</p>
<p>It needs to have JavaScript to transfer the data, it needs to send an e-mail with the data to an e-mail address, and it needs to redirect visitors to a pdf. CGI has always been confusing to me, and I don't know much Ja... | <p>SOunds like you need to validate the form and then send it to a server wich then revalidates (javascript can not be thrusted) and sends the mail-request to an e-mail server. </p>
<p>I'd recommend PHP for the server that revalidates the form and sends the request to the e-mail server because it's easy and wide suppo... | <p>OK, first thing's first, we need to clarify you're wording. JavaScript and Java are two significantly different languages.</p>
<p>In order to send mail, you need to use whichever language you're using in conjunction with an SMTP server, which is what would have to be what actually sends the e-mail, not JavaScript ... | 37,289 |
<p>I need to have a single instance application (as per this <a href="https://stackoverflow.com/questions/19147/what-is-the-correct-way-to-create-a-single-instance-application#19326">answer</a>), but it needs to be deployed via click once.</p>
<p>The problem is that I require that click once doesn't automatically dete... | <p>To tackle the problem, we built a prototype application which has the following two functionalities.</p>
<ol>
<li><p>Multiple instances on one pc are disabled. A single instance application is deployed via clickonce. When a user tries to start a second instance of the app, a message will pop up indicating that "Ano... | <p>I don't think you'll be able to do it quite like this as the check before run is outside of your code.</p>
<p>However you can change the clickonce deployment options to check for updates during code execution.</p>
<p>If you need more control then you can use the <a href="http://msdn.microsoft.com/en-us/library/sys... | 30,910 |
<p>I'm writing a CMS application in PHP and one of the requirements is that it must be able to interface with the customer's Exchange server. I've written up this functionality a few times before and have always used <a href="http://en.wikipedia.org/wiki/WebDAV" rel="noreferrer">WebDAV</a> to do it, but now I'm leanin... | <p><strong>Update as of 2020:</strong><br />
Over a decade since this question and things have moved on. Microsft now has a <a href="https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/office-365-rest-apis-for-mail-calendars-and-contacts" rel="nofollow noreferrer">Rest API</a> that will al... | <p>I'm not a PHP dev but Google says that PHP 5+ can instantiate COM components. If you can install Outlook on a box you could write a PHP web service around the COM component to handle the requests you need. </p>
<pre><code>$outlook = COM("Outlook.Application")
</code></pre>
<p><a href="http://msdn.microsoft.com/en-... | 2,300 |
<pre><code>% rails
...
General Options:
...
-c, --svn Modify files with subversion. (Note: svn must be in path)
-g, --git Modify files with git. (Note: git must be in path)
</code></pre>
<p>What do these "Modify files" options do for me?</p>
<p>Edit: It is unclear to me w... | <p>Looks like <code>--git</code> was added in <a href="http://dev.rubyonrails.org/changeset/8772" rel="nofollow noreferrer">r8772</a> in response to <a href="http://dev.rubyonrails.org/ticket/10690" rel="nofollow noreferrer">ticket #10690</a>. Reading that patch is the closest thing to documentation I've found. The o... | <p>Many dewelopers use a version control system to manage their projects. For Rails apps Subversion and Git are the most popular choices, Git tending to take over these days.</p>
<p>These systems help teams of developers collaborate by editing files without 'stepping on each other's toes'. That is to say if 2 collabor... | 42,134 |
<p>Is it possible to assign a custom ID to a HTTP session through Servlet API?</p>
<p>I know that session handling from any application server, Tomcat for example, it's enough good to generate unique IDs. But I have custom unique session IDs based on information per user and time, so it won't be repeated.</p>
<p>And ... | <p>If you are using Tomcat, you may be able to create a custom session manager (see <a href="http://markmail.org/message/im3wkoeskkgjaphv#query:tomcat%20custom%20session%20Manager+page:1+mid:lgl2bdm26avvjx37+state:results" rel="nofollow noreferrer">this discussion</a>). You would then have access to the Tomcat <a href... | <p>Um...if you have the code to generate a unique ID, you can just do this:</p>
<pre><code>/**
* The String key of the user id attribute.
*/
public static final String USER_ID_KEY = "userIdKey";
// Set the user attribute (createUniqueUserId's parameters and return type are up to you)
httpSession.setAttrib... | 23,843 |
<p>I created a C++ console app and just want to capture the cout/cerr statements in the Output Window within the Visual Studio 2005 IDE. I'm sure this is just a setting that I'm missing. Can anyone point me in the right direction?</p>
| <p>I've finally implemented this, so I want to share it with you:</p>
<pre><code>#include <vector>
#include <iostream>
#include <windows.h>
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/tee.hpp>
using namespace std;
namespace io = boost::iostreams;
struct DebugSink
{
... | <p>Also, depending on your intentions, and what libraries you are using, you may want to use the <a href="http://msdn.microsoft.com/en-us/library/4wyz8787(VS.80).aspx" rel="nofollow noreferrer">TRACE macro</a> (<a href="http://en.wikipedia.org/wiki/Microsoft_Foundation_Class_Library" rel="nofollow noreferrer">MFC</a>) ... | 9,895 |
<p>The <code>end()</code> function in jQuery reverts the element set back to what it was before the last destructive change, so I can see how it's supposed to be used, but I've seen some code examples, eg: <a href="http://alistapart.com/articles/prettyaccessibleforms" rel="nofollow noreferrer">on alistapart</a> <em>(wh... | <p>That <code>end()</code> doesn't do anything. There's no point to coding like that. It will return <code>$('#myBox')</code> -- the example is pretty poor. More interesting is something like this:</p>
<pre><code>$('#myBox').show ().children ('.myClass').hide ().end ().blink ();
</code></pre>
<p>Which will show <code... | <p>From <a href="http://api.jquery.com/end/" rel="nofollow">jquery doc</a> there is an example:</p>
<pre><code>$('ul.first').find('.foo')
.css('background-color', 'red')
.end().find('.bar')
.css('background-color', 'green')
.end();
</code></pre>
<p>and after it a clarification:</p>
<blockquote>
<p>The last end... | 20,014 |
<p>Im having trouble using a .NET COM in vb6, It compiles ok and I use regasm to register it, add a reference to it in the vb6 project, it even has intellisense. But when I try to make make an instance it gives me an 'Automation Error'. Any one can help?</p>
<p>Thanks in advance.</p>
| <p>You probably need to make sure your .NET assemblies are in the VB6 application's directory, or if debugging in the VB6 IDE that they are in the VB6.exe's directory.</p>
<p>It is possible to make COM interop with .NET assemblies work more like COM dlls (see the codebase option of <a href="http://msdn.microsoft.com/e... | <p>I think you have to compile the .Net project in a certain way to be used by COM objects. And the .Net dlls need to be next to, in the same directory, as the COM object that calls them (If they occupy the same space I think).</p>
<p>Project Property Pages\Configuration Properties\Build\Register for COM Interop = tr... | 34,018 |
<p>I'm trying to get a file with ant, using the get property. I'm running apache 2, and I can get the file from the indicated URL using wget and firefox, but ant gives me the following error:</p>
<pre><code>[get] Error opening connection java.io.IOException:
Server returned HTTP response code: 503 for URL: http://loc... | <p>503 is <em>Service Unavailable</em>, which probably means that the <code>src</code> URL isn't getting interpreted properly and sent by the ANT task or perhaps the JRE.</p>
<p>Here are some things to try:</p>
<ul>
<li><p>As always, with ANT, execute the smallest possible build.xml with <strong>-verbose</strong> to ... | <p>The HTTP request might be going through a proxy which is rejecting the request. Alternatively <code>ant</code> might not be using a proxy where it should.</p>
| 28,735 |
<p>I want to force the current execution line to a specific line in the same function, possibly skipping intermediate lines. All my old school debuggers had this feature, but I can't find it in eclipse. Is there a way to do it without changing code?</p>
| <p>The first two answers seem to miss the topic, unless it is me not understanding the question.</p>
<p>My understanding, a feature I searched myself, is that you want to <em>skip</em> a number of lines (when stepping in code) and set the program counter (to take assembly vocabulary) to the given line. It might be int... | <p>"Run to line" appears to need the program to be running and in a paused state to use. The other option is to set a breakpoint for that line when running in debug-mode.</p>
<ol>
<li>Double-click far-left vertical bar in the source pane on the same line to add a breakpoint; or,</li>
<li>Select the line and go to Run... | 23,229 |
<p>One small function of a large program examines assemblies in a folder and replaces out-of-date assemblies with the latest versions. To accomplish this, it needs to read the version numbers of the existing assembly files without actually loading those assemblies into the executing process.</p>
| <p>I found the following <a href="http://blogs.msdn.com/alejacma/archive/2008/09/05/how-to-get-assembly-version-without-loading-it.aspx" rel="noreferrer">in this article</a>.</p>
<pre><code>using System.Reflection;
using System.IO;
...
// Get current and updated assemblies
AssemblyName currentAssemblyName = Assembly... | <p>A <code>.netcore</code> update to Joel's answer, using <a href="https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/understanding-assemblyloadcontext" rel="nofollow noreferrer">AssemblyLoadContext</a>:</p>
<pre class="lang-cs prettyprint-override"><code>using System.IO;
using System.Reflection;
using Sy... | 22,785 |
<p>I'm working on a java program, and I have several vectors defined and filled (from a file) inside a method. I need to return the contents of all the vectors from the method. I have heard you can put them all in one object to return them. Is that possible, and if so, how? If not, do you have any possible solution... | <p>Personnally, I'd scrap that approach completely. It seems like you need a Product class:</p>
<pre><code>public class Product {
private String itemName;
private int itemID;
// etc etc
public Product(String itemName, int itemID) {
this.itemName = itemName;
this.itemID = itemID;
... | <p>While in general I heartily agree with the advice to use List/ArrayList instead of Vector, it is important to know why. Indeed, I have to vehemently disagree with Dustin who says not to use Vector "ever".</p>
<p>A Vector is in essence a synchronized ArrayList. If you truly need synchronization, by all means then,... | 41,696 |
<p>If you have a Property that gets and sets to an instance variable then normally you always use the Property from outside that class to access it. </p>
<p>My question is should you also always do so within the class? I've always used the Property if there is one, even within the class, but would like to hear some ar... | <p>One of the stronger argument for accessing local (class scope) variables through properties is that you add a level of abstraction in your class. If you change <strong>any</strong> logic concerning how that field is stored then the rest of your code will be left unaffected.</p>
<p>For example you might change that ... | <p>I think it's purely preference.</p>
<p>Though, I find myself using the properties a lot more in C# 3.0 with the auto-property support:</p>
<pre><code>class Foo {
public string Value { get; set; }
public void Write() {
Console.Write(Value);
}
}
</code></pre>
| 34,117 |
<p>I would like to find a way to take JPEG (or GIF/PNG) images and reduce the amount of colors to e.g. 20. Could someone recommend some library or other reference? Also source codes in other languages are welcome.</p>
| <p>Take a look at the <a href="http://java.sun.com/javase/technologies/desktop/media/jai/" rel="nofollow noreferrer">Java Advanced Imaging API</a>. There are a number of algorithms implemented in that API for doing color reduction.</p>
| <p>JAI API is the way to go. WIth today's JVM performance is very close to assembler code. I know I've done it.</p>
| 11,257 |
<p>In the setup method to a JUnit test case I'm working on I need it to run a sql script on my database before each test case, and then a rollback afterwards.</p>
<p>I have tried using a tokenizer, which added each SQL command to a batch and then executing them. But I can't get working.
So my question is if there is s... | <p>You can try <a href="http://dbunit.sourceforge.net/" rel="nofollow noreferrer">DbUnit</a></p>
<blockquote>
<p>DbUnit is a JUnit extension (also usable with Ant) targeted at database-driven projects that, among other things, puts your database into a known state between test runs. This is an excellent way to avoid th... | <p>You can try <a href="http://dbunit.sourceforge.net/" rel="nofollow noreferrer">DbUnit</a></p>
<blockquote>
<p>DbUnit is a JUnit extension (also usable with Ant) targeted at database-driven projects that, among other things, puts your database into a known state between test runs. This is an excellent way to avoid th... | 43,680 |
<p>I know you can do redirection based on the domain or path to rewrite the URI to point at a site-specific location and I've also seen some brutish <code>if</code> and <code>elif</code> statements for every site as shown in the following code, which I would like to avoid.</p>
<pre class="lang-py prettyprint-override">... | <p>Django has this built in. See <a href="http://docs.djangoproject.com/en/dev/ref/contrib/sites/#ref-contrib-sites" rel="noreferrer">the sites framework</a>.</p>
<p>As a general technique, include a 'host' column in your database schema attached to the data you want to be host-specific, then include the <code>Host</... | <p>I use CherryPy as my web server (which comes bundled with Turbogears), and I simply run multiple instances of the CherryPy web server on different ports bound to localhost. Then I configure Apache with mod_proxy and mod_rewrite to transparently forward requests to the proper port based on the HTTP request.</p>
| 11,066 |
<p>On a more abstract level then <a href="https://stackoverflow.com/questions/299729/javascript-to-flash-communication">a previous question</a>, in my experience there are 3 ways to call a javascript function on an html page from an embedded .swf using AS3: ExternalInterface, fscommand, and navigateToURL.</p>
<p>Let's... | <p>ExternalInferface was created to make communication between JS and Flash easier, so it doens't really make sense to use anything else. Common practice is to check if its available first by evaluating the value of the ExternalInterface.available property before making a call to some JS. This property tells you if the... | <p><strong>ExternalInterface</strong></p>
<ul>
<li>You can get the return value from JS-AS and AS-JS calls</li>
<li>Encodes your arguments (call with arrays, objects, etc. No need to encode them)</li>
<li>Cross browser</li>
<li>Flawed when you send HTML or JSON (special encoding), it <a href="http://codinginparadise.o... | 40,324 |
<p>Last try to get an answer on this.</p>
<p>I have a simple ASP.NET app which uses Hibernate for data access.
GUI can call methods on Customer object like "CalculateTotalSumOfOrders()".
Lazy loading (even though it's not optimal) will work for me, and when Orders and OrderLines collections are referenced in the domai... | <p>Your best bet for supporting all of those platforms is to use a web service. There are many different flavors that you can choose from, .NET 2.0 Web Services (ASMX), WCF, REST, if you are using Silverlight, you may want to consider using WCF + LINQ to SQL which is demonstrated <a href="http://blogs.msdn.com/swiss_dp... | <p>You're trying to take a server-side app that interacts with your database and does lazy loading, and convert it into a client-side app without a lot of work? Sorry, it's just not going to work. What you need is a major rearchitecting of your application.</p>
<p>Sorry...</p>
| 39,504 |
<p>As I'm <a href="http://methodsandmessages.vox.com/library/post/the-year-of-smalltalk.html" rel="noreferrer">riding the wave of resurgence of Smalltalk</a> (especially because many Ruby-on-Rails people are rediscovering Smalltalk and seeing <a href="http://seaside.st" rel="noreferrer">Seaside</a> as their next upgrad... | <p>Everything's different. Want to go to the end of the line? It's not <kbd>Ctrl</kbd>-<kbd>E</kbd>. Want to jump a few words over, by word? It's not Meta-F....</p>
<p>Text editing is a <em>fundamental programming activity</em>. Messing with those inputs is messing with something deep in my mind.</p>
<p>Edit: and ... | <p>For the Windows world, there is nothing like Dolphin Smalltalk. The IDE is fantastic. Another quality product if you want to try is Visualworks, it works well, has a very fast VM and the documentation is pretty good.</p>
<p>I've used both in the past, there is nothing to fear. </p>
| 21,611 |
<p>I'm using Python 2.5. The DLL I imported is created using the CLR. The DLL function is returning a string. I'm trying to apply "partition" attribute to it. I'm not able to do it. Even the partition is not working. I think "all strings returned from CLR are returned as Unicode".</p>
| <p>Could you post your error message?
Could you post what type of object you have (<code>type(yourvar)</code>)?</p>
<p>Please check if you have a <code>partition(sep)</code> method for this object (<code>dir(yourvar)</code>).</p>
<p>Applying <code>partition</code> method should look like:</p>
<pre><code>>>>... | <p>If by <em>CLR</em> you mean <a href="http://msdn.microsoft.com/en-us/library/ddk909ch.aspx" rel="nofollow noreferrer">.NET CLR</a>, try using <a href="http://www.codeplex.com/IronPython" rel="nofollow noreferrer">IronPython</a> :</p>
<blockquote>
<p>IronPython is a new implementation of the Python programming lan... | 48,505 |
<p>I have the the following html elements:</p>
<pre><code><tr>
<td> <label for="casenumber">Case:</label></td>
<td>
<%=Html.TextBox("casenumber", "", new Dictionary<string, object>
{
{"id", "casenumberID"}
})%>
</td>
</tr>
<tr>... | <p>I use <a href="http://www.texotela.co.uk/code/jquery/select/" rel="nofollow noreferrer">this</a> for selectboxes in jquery</p>
| <p>Here's the code, for those who's going to need it, tested working with ASP.NET MVC beta 1:</p>
<p>Server side AJAX:</p>
<pre><code> public JsonResult GetOpenByUser(string casenumber)
{
return Json(userContext.OpenBy(casenumber));
}
</code></pre>
<p>The HTML:</p>
<pre><code> <form id="subF... | 40,492 |
<p>I am designing a page to Add/Edit users - I used a repeater control and a table to display users. In users view the individual columns of the table row have labels to display a record values and when users click on edit button, the labels are hidden and text boxes are displayed for users to edit values - The problem... | <p>Dealing with tables, the question is: can your labels span on multiple text rows (ie: can you have long texts)? If yes, you may encounter layout problems any way. If no, a simple approach can be creating a CSS Class:</p>
<pre><code>
.CellContent { display:block; width: ...; height: ...; }
</code></pre>
<p>with you... | <p>I'd use JS+CSS... You'll have to get your hands dirty for this one though. Visual Studio isn't going to help you much. </p>
<p>Here's how I'd do it:</p>
<ol>
<li>Get the <code><td></code> clientWidth and clientHeight.</li>
<li><em>Set</em> the <code><td></code>'s width and height to those px values (so... | 15,342 |
<p>So let's say I'm using Python 2.5's built-in default sqlite3 and I have a Django model class with the following code:</p>
<pre><code>class SomeEntity(models.Model):
some_field = models.CharField(max_length=50, db_index=True, unique=True)
</code></pre>
<p>I've got the admin interface setup and everything appear... | <p>Yes this can easily be done by adding a unique index to the table with the following command:</p>
<p>CREATE UNIQUE INDEX uidxName ON mytable (myfield COLLATE NOCASE)</p>
<p>If you need case insensitivity for nonASCII letters, you will need to register your own COLLATION with commands similar to the following:</p>
... | <p>Perhaps you can create and use a custom model field; it would be a subclass of CharField but providing a <a href="http://docs.djangoproject.com/en/dev/howto/custom-model-fields/#db_type" rel="nofollow noreferrer">db_type</a> method returning "text collate nocase"</p>
| 34,889 |
<p>When I first discovered the Strategy pattern, I was amazed of the seemingly endless possibilities it offered to me and my programs. I could better encapsulate my models' behaviour and even exchange this behaviour on the fly. But the strategy could also be used to to provide traits and payload to the containing objec... | <p>Policies are largely set at compile time, while strategies are set at runtime. Further, policies are generally a C++ concept, and apply only to a minority of other languages(for example D), while strategy pattern is available to many (most?) object oriented languages, and languages that treat functions as first cla... | <p>I thought they were the <a href="http://en.wikipedia.org/wiki/Strategy_pattern" rel="noreferrer">same thing</a>.</p>
| 28,632 |
<p>I am using xampp on Windows, but I would like to use something closer to my server setup.</p>
<p><a href="http://phpimpact.wordpress.com/2008/05/24/virtual-appliances-lamp-development-made-easy/" rel="nofollow noreferrer">Federico Cargnelutti tutorial</a> explains how to setup LAMP VMWARE appliance; it is a great i... | <p>This is my install scrpt, I use it on debian servers, but it will work in Ubuntu (Ubuntu is built on Debian)</p>
<pre><code>apt-get -yq update
apt-get -yq upgrade
apt-get -yq install sudo
apt-get -yq install gcc
apt-get -yq install g++
apt-get -yq install make
apt-get -yq install apache2
apt-get -yq install php5
ap... | <p>I don't really understand your question because i really didn't see one. But i'll do my best to infer two: to change your keyboard layout, check this <a href="http://ubuntuforums.org/showthread.php?t=884533&highlight=change+keyboard+layout" rel="nofollow noreferrer">forum post</a> on ubuntu forums and to change ... | 3,581 |
<p>When I use Cura with the Pronterface UI it sometime just stops printing.</p>
<p>When it stops the printer just stops, the UI looks like it's still printing but nothing is moving in the printer, also, trying to control the printer from the UI does nothing.</p>
<p>It always stops early in the printing process, usual... | <p>The Monoprice Architect is is a bare-bones FlashForge Creator that has been re-badged for Monoprice. The Creator line is a very popular set of printers, so there is lots of good advice out there. The FlashForge Google Group is a good community to join: <a href="https://groups.google.com/forum/#!forum/flashforge" rel... | <p>Since the printer has no heater, I'd advise some sleuthing</p>
<ol>
<li>Look at the motherboard. Find the big black square chip and see if it is a ATmega 1280 or 2560. Likely it's a 1280, but you never know. This will impact which firmware build you use.</li>
<li>If you will eventually add a heater PCB, then fig... | 157 |
<p>What is the most efficient, secure way to pipe the contents of a postgresSQL database into a compressed tarfile, then copy to another machine?</p>
<p>This would be used for localhosting development, or backing up to a remote server, using *nix based machines at both ends.</p>
| <p><a href="http://www.cyberciti.biz/faq/how-to-back-up-a-web-server/" rel="nofollow noreferrer">This page</a> has a complete backup script for a webserver, including the pg_dump output.</p>
<p>Here is the syntax it uses:</p>
<pre><code>BACKUP="/backup/$NOW"
PFILE="$(hostname).$(date +'%T').pg.sql.gz"
PGSQLUSER="vive... | <p><a href="http://www.cyberciti.biz/faq/how-to-back-up-a-web-server/" rel="nofollow noreferrer">This page</a> has a complete backup script for a webserver, including the pg_dump output.</p>
<p>Here is the syntax it uses:</p>
<pre><code>BACKUP="/backup/$NOW"
PFILE="$(hostname).$(date +'%T').pg.sql.gz"
PGSQLUSER="vive... | 10,740 |
<p>I have several deployment projects. In order to deploy an application, I need to do several tasks, one of them is to change each deployment project's product version and product code.</p>
<p>I can't find a way to programmatically change them.</p>
<p>Since it's a Deployment project (which finally produces an execut... | <p>I was searching for the exact same thing today. I found this using google:</p>
<pre><code>static void Main(string[] args)
{
string setupFileName = @"<Replace the path to vdproj file>";
StreamReader reader = File.OpenText(setupFileName);
string file = string.Empty;
try
{
Rege... | <p>Look into the use of RCS, CVS and/or subversion. I am only familiar with RCS; my understanding is that CVS is based on RCS but more comprehensive. I have read on various boards that subversion is the better, but I have never used it. RCS has been adequate for keeping track of changes and versions on all my documents... | 39,394 |
<p>I know it makes little difference to a project but, assuming you use #defined header guards for your C++ code, what format do you use? e.g. assuming a header called <code>foo.hpp</code>:</p>
<pre><code>#ifndef __FOO_HPP__
...
#ifndef INCLUDED_FOO_HPP
...
#ifndef SOME_OTHER_FORMAT
</code></pre>
<p>I'm sold on th... | <p>I always included the namespace or relative path in the include guard, because only the header name alone has proven to be dangerous.</p>
<p>For example, you have some large project with the two files somewhere in your code</p>
<pre><code>/myproject/module1/misc.h
/myproject/module2/misc.h
</code></pre>
<p>So if ... | <p>I tend to use:</p>
<pre><code>#ifndef FILE_DATE_H_
</code></pre>
<p>(replace _H_ with the appropriate extension like _HPP_, etc). The date stamp is to avoid collisions with other same named headers in other directions/libraries.</p>
<p>so in the end it looks like this:</p>
<pre><code>#ifndef SOMEFILE_20082411_H_... | 40,657 |
<p>How do you calculate the angle between two normals in glsl? I am trying to add the fresnel effect to the outer edges of an object (combining that effect with phong shading), and I think that the angle is the only thing I am missing.</p>
<p>Fragment Shader:</p>
<pre><code>varying vec3 N;
varying vec3 v;
void main(... | <p>dot product between two vectors will return the cosine of the angle (in GLSL it's dot(a,b)). Taking arc-cosine of that will return angle in radians (in GLSL it's acos(x)).</p>
<p>Dot product is very cheap, arc-cosine is quite expensive.</p>
<p>However, Fresnel effect does not really need the angle. Just having dot... | <p>From the dot product of two vectors you can get the cosine of the angle between them</p>
<pre><code>cos A = DotProduct(v1, v2) / (Length(v1) * Length(v2))
</code></pre>
<p>Using this, you don't need to calculate the cosine when calculating F. Since your vectors are unit vectors, e.g., have length one, you can eve... | 43,983 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.