input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
How to handle general exceptions in Asp.Net MVC? <p>I want to transfer all unhandled exceptions to an error page in Asp.Net MVC. What is the way to handle the unhandled exceptions in Asp.net MVC? Is there anything like application_error? </p>
| <p>check out the HandleError attribute. There's a good write up <a href="http://weblogs.asp.net/scottgu/archive/2008/07/14/asp-net-mvc-preview-4-release-part-1.aspx" rel="nofollow">here</a>.</p>
|
What is my issue with tab-selecting in JQuery? <p>I want to create a webpage in which I can use the jQuery tabs both by a side-bar and by the upper button-bar of the jQuery tabs itself.</p>
<p>My code:</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD... | <p>You have a problem here :</p>
<pre><code>$("$tabs").tabs("select", 1);
</code></pre>
<p>You should use a # instead of $ :</p>
<pre><code>$("#tabs").tabs("select", 1);
</code></pre>
<p>And passing 1 as second parameter will select second tab, not third.</p>
|
UML class diagram relation type question <p>I have a data class with the following methods:</p>
<ul>
<li>ExecuteUDIQuery(string query)</li>
<li>ExecuteSelectQuery(string query)</li>
<li>ExecuteSP(string anme, string[,] params)</li>
</ul>
<p>I have a lot classes which use the data class. Now i want to create a class d... | <p>I would suggest its a <strong><em>usage</em></strong> dependency relationship.</p>
<p>See <a href="http://publib.boulder.ibm.com/infocenter/rsmhelp/v7r0m0/index.jsp?topic=/com.ibm.xtools.modeler.doc/topics/cdepend.html" rel="nofollow">here</a> for a brief description.</p>
|
ASP .Net WorldPay Integration <p>I'm wondering whether anyone has any useful information on integrating WorldPay into an ASP.Net web application? I'm looking to take payments for a fixed amount directly from the web site, no shopping cart required.</p>
<p>Essentially I'm just looking for some reference source code or ... | <p>Include on your "checkout" page the following form (with the relevant values):</p>
<pre><code><form action="https://select.worldpay.com/wcc/purchase" method="post">
<input type="hidden" name="instId" value="<your worldpay installation ID>" />
<input type="hidden" name="cartId" value="&l... |
<select> width in IE not behaving as in other browsers <p>I have three select boxes.</p>
<pre><code><div style='float: left; padding-right: 10px;'>
<select size="10" name="company_id">
// a lot of options here
</select>
</div>
<div style='float: left; padding-right: 10px;'&g... | <p>IE and select options have certain 'quirks' (some, regarding select boxes and innerHTML are detailed <a href="http://channel9.msdn.com/wiki/internetexplorerprogrammingbugs/" rel="nofollow">here</a>) about them that I've never really fully understood, but I can at least provide you with a workaround.
The trick is to ... |
How to create jQuery Tabs out of Markdown <p>I'm currently running a PHP based Content-Management-System that generates its HTML content with the help of <a href="http://michelf.com/projects/php-markdown/extra/" rel="nofollow">Markdown Extra</a>. Most of the content is structured by headings and sub-headings which resu... | <p>on your document.ready</p>
<pre><code>$("#sub1,#sub2,#sub3").each(function() {
var containerDiv = $("<div>").attr("id", $(this).attr("id") + "div");
$(this).before(containerDiv);
containerDiv.append(this);
});
</code></pre>
<p>and change your markdown to</p>
<pre><code>...
* [Topic 1](#sub1div)
... |
Logging vs. Debugging <p><strong>Background:</strong> I've inherited a web application that is intended to create on-the-fly connections between local and remote equipment. There are a tremendous number of moving parts recently: the app itself has changed significantly; the development toolchain was just updated; and... | <p>The absolutley most valueable thing done with any logging framework is a "1-click" tool that gathers all logs and mail them to me even when the application is deployed on a machine belonging to a customer.</p>
<p>And make good choices at what to log so you can roughly follow the main paths in your application.</p>
... |
What is a sequence of actions in a default MSI installation (not custom)? <p>An MSI installer calls a lot of pre-defined actions during install - FindRelatedProducts, CheckVersion, etc. Different actions are called during different install types and sequences: admin, unattended, user, execute, deffered... and custom ac... | <p>See the MSDN documentation, specifically the documentation on <a href="http://msdn.microsoft.com/en-us/library/aa372404%28VS.85%29.aspx">Using a Sequence Table</a>.</p>
<p>For offline reference, download the <a href="http://www.microsoft.com/downloadS/details.aspx?familyid=6A35AC14-2626-4846-BB51-DDCE49D6FFB6&d... |
Reading raw data from a video capture in JMF <p>I'm trying to read raw video frames from a video capture device using JMF - the Java Media Framework.</p>
<p>I've successfully written the "capture" part - using a <em>Player</em> object created by <em>Manager</em>, I can display realtime video from a webcam. I don't kno... | <p>I'm sorry, but at this point, JMF is essentially dead. You would probably use FX for that, but FX isn't exactly doing well either. </p>
|
xHTML markup checker integrated in Selenium <p>Recently, I thought about how can I improve the quality of the projects, by using Continuous checking of xHTML source at Continuous Integration machine.</p>
<p>Look, we have a project</p>
<p><a href="http://sourceforge.net/projects/jtidy" rel="nofollow">http://sourceforg... | <p>Seems like a worthwhile idea.</p>
<p>I've done two similar things with CI before:</p>
<ol>
<li><p>I've used Ant's <a href="http://ant.apache.org/manual/Tasks/xmlvalidate.html" rel="nofollow">XMLValidate</a> task to validate static xhtml files as part of the build process</p></li>
<li><p>I've used httpunit to pull ... |
Enable ASP.NET ASMX web service for HTTP POST / GET requests <p>I would like to enable a ASP.NET classic (ASMX) web service for HTTP POST and GET requests. I realise this can be done on a machine or application level by adding ...</p>
<pre><code><webServices>
<protocols>
<add name="HttpGet"/... | <p>Try to declare UseHttpGet over your method.</p>
<pre><code>[ScriptMethod(UseHttpGet = true)]
public string HelloWorld()
{
return "Hello World";
}
</code></pre>
|
dateutil.rrule.rrule.between() gives only dates after now <p>From the IPython console:</p>
<pre><code>In [16]: b
Out[16]: datetime.datetime(2008, 3, 1, 0, 0)
In [17]: e
Out[17]: datetime.datetime(2010, 5, 2, 0, 0)
In [18]: rrule(MONTHLY).between(b, e, inc=True)
Out[18]:
[datetime.datetime(2009, 3, 6, 14, 42, 1),
da... | <p>You need to pass <code>b</code> into rrule, like this:</p>
<pre><code>rrule(MONTHLY, dtstart = b).between(b, e, inc=True)
</code></pre>
<p>From these docs (<a href="http://labix.org/python-dateutil">http://labix.org/python-dateutil</a>), it looks like calling rrule without specifying dtstart will use datetime.date... |
Can I append to a BLOB in MSSQL database from C# without reading the original data? <p>I'd like to be able to append some data to a binary field in a MS SQL 2005 server from C# without reading the original data, concatenating it, and then setting it all back.</p>
<p>Is this possible?</p>
<p>Cheers!
Steve</p>
| <p>I don't know if this option exists in MSSQL 2005, but if someone is searching for appending info into varbinary(max) in MSSQL2008 it can be done like this:</p>
<pre><code>UPDATE [dbo].[Files] SET [FileContent].WRITE('0x',NULL,0)
WHERE Id = 1
</code></pre>
<p>Hope this will help someone. </p>
|
Python metaclasses <p>I've been hacking classes in Python like this:</p>
<pre><code>def hack(f,aClass) :
class MyClass(aClass) :
def f(self) :
f()
return MyClass
A = hack(afunc,A)
</code></pre>
<p>Which looks pretty clean to me. It takes a class, A, creates a new class derived from it that has an ext... | <p>The definition of a class in Python is an instance of type (or an instance of a subclass of type). In other words, the class definition itself is an object. With metaclasses, you have the ability to control the type instance that becomes the class definition.</p>
<p>When a metaclass is invoked, you have the ability... |
What is the impact of ITIL or CMMI on the development? <p>I read a lot of books about what practices work well or not in software development.
And I have NEVER heard about methodoly like ITIL or CMMI in any webcast or book or blogs in the development field.</p>
<p>I have heard about these methodologies in my school, a... | <p>ITIL is more focused on the infrastructure and support side and not development, so discussion of ITIL is probably more appropriate on the "IT" focused version of StackOverflow that is supposedly in development. As an aside, I take exception with calling that other site "IT" focused as IT encompasses infrastructure... |
Hibernate SQL Audit Logging <p>I want to do audit logging generated SQL statements in Hibernate. I wrote Custom Interceptor that extents EmptyInterceptor. I overrided <strong>onPrepareStatement</strong> method to get generated SQL. But When I debug this code I am only getting generated SQL without parameters like this.... | <p>In hibernate cfg, you may set hibernate.show_sql property to true, this will cause Hibernate to output the perpared statements (without the parameter values bound to a query) to stdout.</p>
<p>To have the precompiled statements and list of parameters bound to them logged, set log4j.logger.org.hibernate.SQL=DEBUG in... |
JSF commandButton with immediate="true" <p>I have a situation where there is a selectOneMenu that has a value bound to a backing bean.</p>
<p>I need to have a button that doesn't update model values (that is why it has immediate="true" property).</p>
<p>That button's action method changes the value the selectOneMenu ... | <p>As it frequently happens a few moments after posting this question I have found an answer:</p>
<p>The cause of the problem is in detail explained here: <a href="https://cwiki.apache.org/confluence/display/MYFACES/Clear+Input+Components" rel="nofollow">ClearInputComponents</a></p>
<p>The problem is (as explained) t... |
Deserializing Chrome Bookmark JSON Data in C# <p>In response to a question I asked a few days ago, I'm attempting to stretch myself a little, and do something that I've not really focussed on much before. I've done some searching (both here, and in general), but can't find the answers (or even reasonable hints) to wha... | <p>It is not necessary to declare a type that reflects the json structure:</p>
<pre><code> using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.IO;
using System;
class Program
{
static void Main(string[] args)
{
string json =
@"
{
""roots"": {
""... |
How can I make networking work in my WinCE app without launching IE first? <p>I have a simple WinCE network application (in C, Win32 APIs). I find that networking doesn't seem to work unless I launch IE (or another network app) first. I assume that IE is setting up my network interface in some way.</p>
<p>How can I do... | <p>All I know is that Internet Explorer uses <a href="http://msdn.microsoft.com/en-us/library/aa383630%28VS.85%29.aspx" rel="nofollow">WinInet</a> (wininet.dll) for its networking, and you can too. WinInet is a MS API for working with http and ftp protocols. Many of the settings on the "Internet Options" control panel ... |
Getting Firefox 3 to work with JSUnit <p>Thus far this is what I've tried, I'm using Firefox 3.07</p>
<ol>
<li><p>Make sure in <strong>about:config</strong> that the property <strong>browser.cache.check_doc_frequency</strong> is set to <strong>1</strong> which the browser interprets as "check for a new page every time... | <p>Have you tried CTRL + SHIFT + R to refresh without using cache?</p>
|
MVC + Templates <p>I am working on a system that gets templatse dynamicly, they contain tags like {{SomeUserControl}} {{SomeContent}}</p>
<p>I was wonder how I could use MVC to render those templates and replacing the tags in the best possible way as the templates will be edited via a web front end, and the content / ... | <p>You might wanna take a look at maybe using another view engine, here are some examples.</p>
<p><a href="http://andrewpeters.net/2007/12/19/introducing-nhaml-an-aspnet-mvc-view-engine/" rel="nofollow">NHaml</a><br />
<a href="http://dev.dejardin.org/" rel="nofollow">Spark</a><br />
<a href="http://nvelocity.sourcefo... |
.Net inserting NULL values into SQL Server database from variable values <p>There have been similar questions but the answers weren't what I was looking for. I want to insert the a value of NULL into the SQL Server database if the reference is NULL or a value has not yet been assigned. At the moment I am testing for nu... | <p>Even better than the ternary is the double-question-mark (??) operator. Takes the first non-null value. So:</p>
<pre><code>string x = null;
command.Parameters.AddParameter(
new SqlParameter("@column", (object)x ?? DBNull.Value);
</code></pre>
<p>would give you a parm with a value of DBNull.Value, but</p>
<pr... |
Detect difference between & and %26 in location.hash <p>Analyzing the location.hash with this simple javascript code:</p>
<p><code><script type="text/javascript">alert(location.hash);</script></code></p>
<p>I have a difficult time separating out GET variables that contain a & (encoded as %26) and a &a... | <p>There is no difference between %26 and & in a fragment identifier (âhashâ). â&â is only a reserved character with special meaning in a query (âsearchâ) segment of a URI. Escaping â&â to â%26â need be given no more application-level visibility than escaping âaâ to â%61â.</p>
<... |
Get all lucene values that have a certain fieldName <p>To solve <a href="http://stackoverflow.com/questions/618227/faster-way-to-get-distinct-values-from-lucene-query">this</a> problem I created a new Lucene index where all possible distincted values of each field are indexed seperatly.</p>
<p>So it's an index with a ... | <p>This should work (I take it it still is in C#)</p>
<pre><code>IndexReader.Open(/* path to index */).Terms(new Term("companyName", String.Empty));
</code></pre>
|
Using ASP.NET default Model Binders with DateTime <p>I've been trying to use the default ASP.NET MVC model binders but I'm having issues with binding DateTime. I've looked at Scott's post <a href="http://www.hanselman.com/blog/SplittingDateTimeUnitTestingASPNETMVCCustomModelBinders.aspx" rel="nofollow">here</a> but it ... | <p>If you don't like Hanselman's solution you could try Castle's binders. They work like <a href="http://www.castleproject.org/monorail/documentation/trunk/usersguide/smartcontroller.html#date" rel="nofollow">this</a> and they can be <a href="http://blogger.forgottenskies.com/?p=258" rel="nofollow">used through MvcCont... |
Test to see if an xelement exists <p>I'm reading an XML file that looks like this:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<VehicleList>
<Vehicle>
<Item>
<Name>F-150</Name>
<Maker>Ford</Maker>
<Color>Black</Color>
<Price>300... | <p>It depends on what you want to do when the node is not there. For instance if Nothing is acceptable then you can switch from .Single to .SingleOrDefault. The latter will return Nothing in the case of an empty sequence and will not throw an exception. </p>
<pre><code>Dim vehicles = From v in doc...<Vehicle> ... |
Javascript image slider <p>Hi I'm looking for a simple Javascript Image slider that have the following features.
A little horizontal box that shows images thumbnail and slides them.
Once you select a thumbnail, the image shows on a div or some else where on the page.
I want something easy and pro looking.
Thanks</p>
| <p>If you can use jQuery there is a neat plugin called jQuery Cycle that can perform all sorts of image cycling.</p>
<p><a href="http://malsup.com/jquery/cycle/" rel="nofollow">link text</a></p>
|
Possible to call a function inside BoundColumn.DataField? <pre><code><asp:BoundColumn DataField="pos" HeaderText="Principal Office" />
</code></pre>
<p>would it be possible to somehow...</p>
<pre><code><asp:BoundColumn DataField="postProccess(pos)" HeaderText="Principal Office" />
</code></pre>
<p>...so ... | <p>Here is the full snippet you'd want to use for your template column...</p>
<pre><code><asp:TemplateColumn HeaderText="Principal Office">
<ItemTemplate>
<%# postProcess(Eval("pos")) %>
<ItemTemplate>
<asp:TemplateColumn>
</code></pre>
|
How to keep the document-tabs sorted by their last usage in Visual Studio 2008 <p>What is the registry change to tell Visual Studio to always position the current document in the window to the left.</p>
<p>The default implementation is such that if you have 10 documents open and you are editing the 5th one it's tab wi... | <p>(From <a href="http://blogs.msdn.com/saraford/archive/2008/10/09/did-you-know-you-can-keep-recently-used-files-from-falling-off-the-file-tab-channel-331.aspx" rel="nofollow">Sara Ford's blog</a>):</p>
<p>Under the <strong>HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0</strong> key create a <strong>DWORD UseM... |
Eclipse: Build and conform to different JRE versions <p>Is there a way to build my app using one version of the JRE but have my source conform to another version?</p>
<p>I would like to debug my app locally using 1.6 because OS X's 1.6 is much better than 1.4.2, but because of backwards compatibility reasons we actual... | <p>You can manage this though the Run Configurations options. Create a new Run Configuration --> Java Application and then you can specify the JRE you want to use for that configuration. </p>
|
What's the most efficient test of whether a PHP string ends with another string? <p>The standard PHP way to test whether a string <code>$str</code> ends with a substring <code>$test</code> is:</p>
<pre><code>$endsWith = substr( $str, -strlen( $test ) ) == $test
</code></pre>
<p>Is this the fastest way?</p>
| <p>What Assaf said is correct. There is a built in function in PHP to do exactly that.</p>
<pre><code>substr_compare($str, $test, strlen($str)-strlen($test), strlen($test)) === 0;
</code></pre>
<p>If <code>$test</code> is longer than <code>$str</code> PHP will give a warning, so you need to check for that first.</p>
... |
Do Django custom authentication backends need to take a password? <p>Here's how my university handles authentication: we redirect the user to a website, they enter in their username and password, then they get redirected back to us with the username and a login key passed in the query string. When we get the user bac... | <p>The <a href="http://docs.djangoproject.com/en/dev/topics/auth/">Django docs</a> say this:</p>
<blockquote>
<p>Either way, authenticate should check
the credentials it gets, and it should
return a User object that matches
those credentials, if the credentials
are valid. If they're not valid, it
should re... |
Rails: I can't call a function in a module in /lib - what am I doing wrong? <p>I know I'm doing something stupid or failing to do something intelligent - I'm frequently guilty of both.</p>
<p>Here's an example of what's causing me pain:</p>
<p>I have a module saved in /lib as test_functions.rb that looks like this</p... | <p>If you want <code>Module</code>-level functions, define them in any of these ways:</p>
<pre><code>module Foo
def self.method_one
end
def Foo.method_two
end
class << self
def method_three
end
end
end
</code></pre>
<p>All of these ways will make the methods available as <code>Foo.method_o... |
c# Label Visible and Invoke <p>I'm devolping a <strong>Windows Mobile</strong> aplication in <strong>Compact Framework 2.0 SP1</strong>.</p>
<p>How can I make invisible a label using invoke?</p>
<p>Thanks!</p>
| <p>You simply want to change the Label's Visible property? Generically speaking it's something like this:</p>
<pre><code>private void SetVisibility(Control target, bool visible)
{
if (target.InvokeRequired)
{
target.Invoke(new EventHandler(
delegate
{
target.Vis... |
I need help resetting the DEFAULT settings for ActiveX and Flash Player <p>When I start my web browser and I want to view a website or view something on a Flash Player I get this message:</p>
<blockquote>
<p>Your Security settings do not allow websites to use ActiveX controls installed on your computer. This page ma... | <p>i take it you are using Internet Explorer? Get a better browser like firefox if you are. </p>
|
Determining Class Responsibility and Collaborators <p>I'm using ActiveRecord to maintain information about users. The User class has the expected load(), insert(), update(), and delete() methods, setters, getters, and a few others. But I am having trouble deciding whether or not certain other methods should be included... | <p>You should delegate this task to a collaborator, which manages a <code>confirmations</code> table.</p>
<p>You would use the <code>Confirmation</code> model to track all confirmation requirements. The model will belong to <code>User</code>, as well as manage the confirmation hash and the action-to-be-confirmed (e.g... |
Is there a task supporting modern multithreaded archivers - 7zip, winrar etc.? <p>We are using the <a href="http://ant.apache.org/manual/Tasks/zip.html" rel="nofollow">Ant Zip task</a>, which is a bit obsolete (low processing speed for big files).</p>
<p>Can anyone point me to a mature Ant task, ready for production u... | <p>Why not use the <a href="http://ant.apache.org/manual/Tasks/exec.html" rel="nofollow">exec task</a> with the command line version of 7zip?</p>
|
Java DomImplementationLS <p>I'm looking to create XML Document objects in Java and serialize them to a byte array (prior to sending them across a TCP connection). I currently have code that looks like this:</p>
<pre><code>public byte [] EncapsulateThingy( ThingyType thingy )
{
parser.reset(); // parser is a pre-e... | <p>Hope this helps:</p>
<pre><code>import java.io.ByteArrayOutputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.junit.Test;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.ls.DOMImplementat... |
What influences the speed of code? <p>The way to see how fast your code is going, is performance profiling. There are tools for it and such, but I wonder what the factors are for code speed.</p>
<p>For instance, I've been told that image-editting software will use bitwise operations instead of integer variables to cal... | <p>Integers <em>are</em> binary. Or rather, integers are simply integers, and can be represented in any number base. In base 10 you'd write 13, in base 16 you'd write d (or 0xd), in binary you'd write 1101 (or 0b1101). The Romans would've written XIII. They all represent the same <em>concept</em> of the number 'thirtee... |
What are the differences between HTTP 1.0 and 1.1? <p>The latest StackOverflow <a href="http://blog.stackoverflow.com/2009/03/podcast-44/" rel="nofollow">podcast</a> has piqued my interest in the differences between HTTP 1.0 and HTTP 1.1.</p>
<p>Can anyone provide a simple list of the major differences between the HTT... | <p>Have you checked <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.6.1">HTTP/1.1 â 19.6.1 Changes from HTTP/1.0</a>?</p>
|
Can I use Entity Framework with ASP.NET Membership? <p>I'm creating (really, re-creating) an app that has existing user and other data in MS-Access databases. The data will be moved to SQL Server, and part of that involves migrating users. I want to use EF to do ORM, and I am pretty sure I know what the data model wi... | <p>Why not do it the other way around? You can implement your own Membership provider for asp.net, that uses the model you want/need. </p>
<p>If the features you need aren't a complete match with the built-in asp.net membership implementation, you can just roll your own provider. If you will use just a couple features... |
how to move a block or column of text <p>I have the following text as a simple case:</p>
<pre><code>...
abc xxx 123 456
wer xxx 345 678676
...
</code></pre>
<p>what I need to move a block of text xxx to another location:</p>
<pre><code>...
abc 123 xxx 456
wer 345 xxx 678676
...
</code></pre>
<p>I think I use visual... | <p>You should use blockwise visual mode (<kbd>Ctrl</kbd>+<kbd>v</kbd>).
Then <kbd>d</kbd> to delete block, <kbd>p</kbd> or <kbd>P</kbd> to paste block.</p>
|
How can I rewrite all urls to "/"? <p>Server: Apache</p>
<p>I'm looking to rewrite my urls in the following way, and I can't figure out a way to get it to work.</p>
<pre><code>http://website.com/index.html
</code></pre>
<p>I want it to redirect to:</p>
<pre><code>http://website.com/
</code></pre>
<p>So basically I... | <p>I believe this should work:</p>
<pre><code>RewriteEngine on
RewriteRule ^index\.html(.*)$ /$1 [R=permanent,L]
</code></pre>
<p>This will redirect any requests that start with <code>/index.html</code> to simply "<code>/</code>" and will preserve any arguments that come after <code>index.html</code></p>
|
How can I get the width and height of a text string with CAM::PDF? <p>I use the following to read a PDF file and get text strings of a page:</p>
<pre><code>my $pdf = CAM::PDF->new($pdf_file);
my $pagetree = $pdf->getPageContentTree($page_no);
# Get all text strings of the page
# MyRenderer is a separate package... | <p>getStringWidth() depends heavily on the font metrics you provide. If it can't find the character widths in that data structure, then it falls back to the following code:</p>
<pre><code> if ($width == 0)
{
# HACK!!!
#warn "Using klu... |
What's the best way to find the closest matching type to an existing type? <p>I've got a registry of classes and types in Python 2.5, like so:</p>
<pre><code>class ClassA(object):
pass
class ClassB(ClassA):
pass
MY_TYPES = {
basestring : 'A string',
int : 'An integer',
ClassA : 'This is ClassA o... | <pre><code>from inspect import getmro
[st for cls, st in MY_TYPES.items() if cls in getmro(ClassB)]
['This is ClassA or a subclass']
</code></pre>
<p>or if you're only interested in first match(es) generator version:</p>
<pre><code>(st for cls, st in MY_TYPES.iteritems() if cls in getmro(ClassB))
</code></pre>
|
How to add value in a public property of List<string> type in c#? <pre><code>private List<string> _Baseline = new List<string>();
public List<string> Baseline
{
get { return _Baseline; }
set { _Baseline = value; }
}
</code></pre>
<p>How can I set this property?
It does not let me add using ... | <p>It should work if you did what you wrote here.
I guess you are using generics, and I can't see them in your post.</p>
<p>If you have a complex expression, split it. For example, change ObjectA.Prop.Other.Xyz.Add(..) to:</p>
<pre><code>SomeClass a = ObjectA.Prop;
SomeClass2 b = a.Other;
SomeClass3 c = b.Xyz;
c.Add(... |
Referencing an external library in an Ant build <p>We have an ant build script for a project we're developing for a PDA. In eclipse we have a load of referenced libraries and I know how to get them to work when we run the jar on the PDA because we have a .lnk file where you can add the external libraries simply by add... | <p>From what I can tell, you need to add the classpath elements to the manifest. Should look something like this:</p>
<pre><code> <manifest file="${dist}/MANIFEST.MF">
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Main-Class" value="j2medemo.Routes.SAXParse"/>
<att... |
SQLAlchemy Obtain Primary Key With Autoincrement Before Commit <p>When I have created a table with an auto-incrementing primary key, is there a way to obtain what the primary key would be (that is, do something like reserve the primary key) without actually committing?</p>
<p>I would like to place two operations insid... | <p>You don't need to <code>commit</code>, you just need to <code>flush</code>. Here's some sample code. After the call to <a href="http://docs.sqlalchemy.org/en/latest/orm/session_api.html#sqlalchemy.orm.session.Session.flush">flush</a> you can access the primary key that was assigned. Note this is with SA 0.4.8.</p... |
Degrafa: Adding a RasterImage in ActionScript <p>I'm trying to add a RasterImage component to a Surface at runtime. My code runs as follows:</p>
<pre><code>var ri:RasterImage = new RasterImage();
ri.loadingLocation = new LoadingLocation('http://resources.mydomain.com/','crossdomain.xml');
ri.source = 'http://resource... | <p>Nevermind- This was a bug in the framework. The Degrafa team heard about it and posted a fix in under an hour (!)</p>
|
Is there a way to get a difference report on two Jet (.mdb) databases? <p>I have code that depends a relatively small MS Jet (created in Access) database. Our source control process is far from all that it could/should be (which is a problem that needs to be solved immediately) and we have ended up with two versions of... | <p>Output all the forms and modules to text files and use a text compare utility.</p>
<p>For example:</p>
<pre><code>Sub ToText()
Dim frm, mdl
For Each frm In CurrentProject.AllForms
Application.SaveAsText acForm, frm.Name, "c:\docs\" _
& frm.Name & ".txt"
</code></pre>
<p>'SO formatting</p>
<... |
What's the best way to get rid of nested ifs in code while checking for conditions? <p>I'm developing a BlackBerry app in Java and I have an Options class where all user settings are stored. The problem is I need to check some conditions in order to know how to react. As I keep adding more features, more GUI options ar... | <p>Another option is to make methods such as <code>injectDMTFTone()</code> check to see if they want to handle that condition, and return true or false depending on if it was handled or not.</p>
<p>For instance:</p>
<pre><code>public void run() {
callTimeSeconds++;
do {
if (handleInjectDMTFTone())
... |
Best way to decorate databound text in a wpf TextBlock <p>Let's say I have some multiline text that I'd like to format, and let's also say that it's databound. So, in XAML:</p>
<pre><code><TextBlock TextWrap="Wrap">
<TextBlock.Inlines>
<Run TextWeight="Bold" Text="{Binding Path=FirstName}" ... | <p>There is a workaround posted <a href="http://code.logos.com/blog/2008/01/data%5Fbinding%5Fin%5Fa%5Fflowdocument.html" rel="nofollow">here</a>. It basically involves subclassing Run to be bindable. Works though.</p>
|
For a large project, what planning should be done before coding and how should it be approached? <p>What is your method of "mapping out" an idea before creating it? </p>
<p>Say I wanted to take on a big project, for example at the scale of a site like Facebook or MySpace. What planning/design steps should I take be... | <p>For a large project first think of a one-liner to description of your site (try to not use any buzzwords here). Next think of three design maxims (rules your design Should never conflict with). Then draw a few views and think up a few user cases (1 day) then work in code for 2 weeks (this will be a throw away protot... |
How to filter myself out of Google Analytics with a dynamic IP address? <p>Does anyone know how to setup Google Analytics to filter yourself out if you're visiting the site from a dynamic IP address? I don't want to include myself in my stats from home use where I have a dynamic IP address via Verizon FiOS.</p>
| <p>Google currently has a browser add-on that will block any visits of yours from showing up in any Analytics. <a href="http://tools.google.com/dlpage/gaoptout">http://tools.google.com/dlpage/gaoptout</a></p>
<p>Pluses and minuses of this opt-out versus filters are discussed in <a href="http://www.debi-z.com/2011/05/1... |
NULL pointer with boost::shared_ptr? <p>What's the equivalent to the following:</p>
<pre><code>std::vector<Foo*> vec;
vec.push_back(NULL);
</code></pre>
<p>when dealing with <code>boost::shared_ptr</code>? Is it the following code?</p>
<pre><code>std::vector< boost::shared_ptr<Foo> > vec;
vec.push_... | <p>Your suggestion (calling the <code>shared_ptr<T></code> constructor with no argument) is correct. (Calling the constructor with the value 0 is equivalent.) I don't think that this would be any slower than calling <code>vec.push_back()</code> with a pre-existing <code>shared_ptr<T></code>, since construc... |
What is the difference between signed and unsigned variables? <p>I have seen these mentioned in the context of C and C++, but what is the difference between signed and unsigned variables? </p>
| <p><strong>Signed variables</strong>, such as signed integers will <em>allow you to represent numbers both in the positive and negative ranges</em>.</p>
<p><strong>Unsigned variables</strong>, such as unsigned integers, will <em>only allow you to represent numbers in the positive</em>.</p>
<p>Unsigned and signed vari... |
Checkboxes on Rails <p>What's the correct way of making checkboxes that are related to a certain question in Ruby on Rails? At the moment I have:</p>
<pre><code><div class="form_row">
<label for="features[]">Features:</label>
<br><%= check_box_tag 'features[]', 'scenarios' %> Scen... | <p>You are looking at the following:</p>
<pre><code><div class="form_row">
<label for="features[]">Features:</label>
<% [ 'scenarios', 'role_profiles', ... , 'polls' ].each do |feature| %>
<br><%= check_box_tag 'features[]', feature,
(params[:features] || {}... |
free country, city database for sql server <p>have anyone used this before, i need free country, city, IP database for sqlserver</p>
| <p>I have used <a href="http://www.maxmind.com/app/geolitecity">http://www.maxmind.com/app/geolitecity</a> . It is a less exact version of their paid database. The free database claims to be "over 99.5% on a country level and 79% on a city level for the US within a 25 mile radius". You can see their accuracy detaile... |
Schedule Controls for ASP.Net MVC <p>Are there any scheduling components, commercial or otherwise, for ASP.Net MVC? Our company currently uses the Infragistics WebSchedule controls, but they don't appear to support MVC.</p>
<p><strong>Edit:</strong>
I think I may have been a bit unclear, I am not looking for a task s... | <p>I just wanted to update with the scheduling tool we eventually choose.
<a href="http://www.dhtmlx.com/docs/products/dhtmlxScheduler/index.shtml">dhtmlxScheduler</a> - we are very happy with both the tool and the support.</p>
<p>Also - since it was never mentioned in any of the answers above, Telerik has a schedule ... |
Calling ASP.net Web Service from C# Application <p>I have a question. How can i invoke a web service and get the result from a C# desktop application. I am making a desktop app and I want it to be able to connect to my online ASP.net web services. How is this possible?</p>
| <ol>
<li>In Solution Explorer, right-click your project node and select Add <strong>Service</strong> Reference.</li>
<li>Enter the URL where your service WSDL is located. This is usually the URL of the service itself.</li>
<li>This generates a strongly-typed proxy class in a new Services References folder in your proj... |
Add a summary information to WiX generated MSI <p>How to add (or change a default values) a summary page information to a WiX-generated MSI file?</p>
<p>Summary page is the tab page which is visible if you right click on the MSI file in the Windows Explorer and includes following text fields:</p>
<p>Title,
Subject,
A... | <p>That information is set in the field, for example:</p>
<pre><code><Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>
<Product
UpgradeCode="SOMEGUID-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
Name='MyApp'
Id='????????-????-????-????-????????????'
Language='1033'
Codepage='1252'
Version='1.0.0' ... |
how to convert byte* into jpeg file in VC++ <p>how to convert byte* into jpeg file in VC++</p>
<p>i am capturing Video samples and writing it as bmp files, but i want to write that video samples into jpeg file using MFC support in ATL COM.</p>
| <p>Use libjpg. Download from: <a href="http://www.ijg.org/" rel="nofollow">http://www.ijg.org/</a></p>
|
What does re.compile(r'[[]]') match? <p>With Python's re module, why do the following act differently:</p>
<pre><code>>>> r = re.compile(r'[][]')
>>> r.findall(r'[]')
['[', ']']
>>> r = re.compile(r'[[]]')
>>> r.findall(r'[]')
['[]']
>>> r.findall(r'][')
[]
</code></pre>
| <p>The regular expression "[[]]" matches the substring "[]". The first [ in the expression begins a character class, and the first ] ends it. There is only one character ([) in the class, and then it has to be followed by the second ]. So the expression is "any of the characters in "[", followed by a "]".</p>
|
Naming keys in resource files best practice <p>Does anyone have any recommendations on naming keys in resource files? For instance, do you base the name of your key on the text that needs to be localized or on the control that uses the text?</p>
<p>Say you have an edit button in several screens (one to edit a user, on... | <p>I prefix my literals by usecase or action classname. eg:</p>
<pre>PlaceOrder.invalidId=Invalid id for order {0}
PlaceOrder.success=Your order {0} was successful
PlaceOrder.fail.visa=Your visa was ...
PlaceOrder.fail.communications=We could not...
PlaceOrder.submit=Buy now
Login=Login
Login.fail=Your credentials di... |
ofstream error <p>This is in reference to another question I asked, though it is its own question entirely.</p>
<p>when I compile I get two errors:</p>
<p>1>.\asst4.cpp(73) : error C2065: 'outfile' : undeclared identifier</p>
<p>1>.\asst4.cpp(73) : error C2228: left of '.close' must have class/struct/union</p>
<p>I... | <p>Scoping issue. You are declaring outfile within your while loop, yet are trying to access it outside of said while loop.</p>
<p>Move <code>ofstream outfile("encrypted.txt", ios::out);</code> to the line right after your <code>ifstream infile(filename.c_str());</code> which is before your <code>while(!infile.eof())<... |
What is the purpose of "remove unused references" <p>I have read that removing unused references <a href="http://blogs.msdn.com/csharpfaq/archive/2004/10/20/245411.aspx">makes no difference</a> to the compiler as it ignores assemblies that are not being referenced in the code itself.</p>
<p>But I find it hard to belie... | <p>It prevents the CLR from loading the referenced module at runtime. This will reduce startup time (since it takes time to load each module). Depending on the size of the module it might noticeably reduce startup time.</p>
<p>One way to test this is to create a test WinForms project, add a reference to an assembly... |
Boolean column in Microsoft Access and filtering data using linq <p>[Apologies for long question but I thought it would be clearer for others to answer]</p>
<p>I have a Microsoft Access database and it contains a table "Customers" with following columns:</p>
<ul>
<li>ID (auto number)</li>
<li>Name (Text)</li>
<li>Act... | <p>Try just using the OleDbCommand object with the generated SQL and iterating through what is returned using OleDbDataReader.</p>
<p>Then try with this SQL string</p>
<pre><code>SELECT [t0].[ProductID] AS [ID], [t0].[ProductName] AS [Name], [t0].[Active]
FROM
[Products] AS [t0]
WHERE [t0].[Active] = YES
</code></... |
How to Persist the dependencies across postbacks in a Web application using Unity? <p>This link for unity framework on msdn states
<em>"<strong>You want to be able to cache or persist the dependencies across postbacks in a Web application</strong>"</em></p>
<p><a href="http://msdn.microsoft.com/en-us/library/dd203319.... | <p>I have written a short example of using Session and also using Cache. I have created a test class called incrementer which is very similar to if I made the class static or at least the variable. RegisterInstance is for a Singleton Resolve</p>
<pre><code> public class Incrementer
{
private int count;
pr... |
SWF object not playing my XML Playlist <p>I've tried to include <a href="http://www.youtubetune.com/" rel="nofollow">youtubetune</a> player to social network, but for somereason it wont play the xml files it should play.
I got around issue that the tracks dint even appear by uploading the neccessary swf files and swfob... | <p>Ok, solved it.. Seems like i forgot yt.swf file. (I saw that the media player used JW Player)</p>
|
business logic in constructors a good idea? <p>I'm currently rebuilding a specialised ticket system at work (mainly used to support people with faults in remote sensing hardware...). Anyway, I was wondering whether doing lots of workflow type activity in an object's constructor is a good idea.</p>
<p>For example, ther... | <p>If the constructor does all that work then the constructor knows about many other domain objects. This creates a dependency problem. Should the <code>ticket</code> really know about the <code>Customer</code> and the <code>HelpDesk</code>? When new features are added, isn't it likely that new domain objects will b... |
Simple DataBinding question <p>I can't figure out what is wrong for this simple binding.
when click on first or second radio button, no first or last name display.</p>
<p>1) Xaml</p>
<pre><code><Window x:Class="WpfApplication2.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmln... | <p>You need to actually set the binding source in code, to do that you need a name for the StackPanel. You must add the name to the last stack panel. The one in Row 1</p>
<pre><code><StackPanel
...
Name="m_panel" />
</code></pre>
<p>In the event code update the DataContext</p>
<pre><code>public void onC... |
Natural language parsing, practical example <p>I am looking to use a natural language parsing library for a simple chat bot. I can get the Parts of Speech tags, but I always wonder. What do you do with the POS. If I know the parts of the speech, what then?</p>
<p>I guess it would help with the responses. But what ... | <p>Natural language processing is wide and deep, with roots going back at least to the 60s. You could start reading up on <a href="http://en.wikipedia.org/wiki/Computational%5Flinguistics">computational linguistics</a> in general, <a href="http://en.wikipedia.org/wiki/Natural%5Flanguage%5Fgeneration">natural language g... |
Best way to search for a saturation value in a sorted list <p>A question from <a href="http://www.math.toronto.edu/oz/turgor/mathbattle/problems/mathbattleE1.pdf" rel="nofollow">Math Battle</a>.
This particular question was also asked to me in one of my job interviews.</p>
<p>" A monkey has two coconuts. It is fooling... | <p>Interview questions like this are designed to see how you think. So I would probably mention a O(N^0.5) solution as above, but also I would give the following discussion...</p>
<p>Since the coconuts may have internal cracking over time, the results may not be so consistent to a O(N^0.5) solution. Although the O(N... |
Free JPEG2000 Library or SDK for de-compression <p>I have written code to compress and decompress image files using a proprietary SDK for transmission from an aircraft via satellite. Unfortunately a license must be purchased for decompression as well as compression. Until now my applications have been mostly used in-h... | <p>It's just a thought, but the de facto standard for JPEG2000 is <a href="http://www.kakadusoftware.com/">Kakadu</a> because Dr. Taubman pretty much wrote the JPEG2000 standard. Although it costs some money, it is the best library that I know of.</p>
|
Encode/Decode xxxclass to byte[] than send it to Remote PC with C# <p>Hi i have got a TCP/IP Socket project.</p>
<p>i can send string messages to Server with Client side and i can get responses from server.
But getting one string message and sending only one string (or any other object).I wanna Encode Personel class t... | <p>Take a look at object serialization. <a href="http://www.codeproject.com/KB/cs/objserial.aspx" rel="nofollow">See here</a> for examples. That should get you going in the right direction.</p>
|
Calculate Bounding box coordinates from a rotated rectangle, Picture inside <p><img src="http://img7.imageshack.us/img7/2464/boundedbox.png" alt="Schema"></p>
<p>I have the coordinates of the top left Point of a rectangle as well as its width, height and rotation from 0 to 180 and -0 to -180.</p>
<p>I am trying to ge... | <ul>
<li>Transform the coordinates of all four corners</li>
<li>Find the smallest of all four x's as <code>min_x</code> </li>
<li>Find the largest of all four x's and call it <code>max_x</code></li>
<li>Ditto with the y's</li>
<li>Your bounding box is <code>(min_x,min_y), (min_x,max_y), (max_x,max_y), (max_x,min_y)</co... |
.Net Remoting vs. WCF <p>I am working on a .Net website which is going to have 1000s of concurrent users.</p>
<p>I am thinking of keeping the business components on the app server and UI components on the web server. Database (MS SQL Server 2005) will be hosted on another server. I am planning to use the load balancin... | <p>You can check <a href="http://msdn.microsoft.com/en-us/library/bb310550.aspx">here</a> a performance comparison between WCF and other communication technologies (including .Net remoting). The conclusion is : WCF is faster.</p>
|
Problem calling a function when it is in a .lib <p>I have a class with a static method that looks roughly like:</p>
<pre><code>class X {
static float getFloat(MyBase& obj) {
return obj.value(); // MyBase::value() is virtual
}
};
</code></pre>
<p>I'm calling it with an instance of MyDerived which ... | <p>Since a lib is just a container, if you are linking the same .obj file in both cases then as Brian says they shouldn't (can't?) be a difference.</p>
<p>One thing to watch is if you changed the definition of MyBase you obviously need to recompile both the library and the code using it. For example, if you added a n... |
PHP: return life of current session <p>I am looking for a way to check on the life of a php session, and return the number of seconds a session has been "alive". </p>
<p>Is there a php function that I am missing out on?</p>
| <p>You could store the time when the session has been initialized and return that value:</p>
<pre><code>session_start();
if (!isset($_SESSION['CREATED'])) {
$_SESSION['CREATED'] = time();
}
</code></pre>
<p>And for retrieving that information from an arbitrary session:</p>
<pre><code>function getSessionLifetime(... |
How to localize a Rails plugin? <p>I'd like to translate the OpenIdAuthentication plugin into another language but I'd like not to change the plugin directly.</p>
<p>Here's the basic structure of the messages I want to translate:</p>
<pre>module OpenIdAuthentication
class Result
ERROR_MESSAGES = {
:missi... | <p>You can simply overwrite <code>OpenIdAuthentication::Result::ERROR_MESSAGES</code> by redefining it at any time after the plugin loads.</p>
<p>You may do so through a different plugin (that loads after <code>OpenIdAuthentication</code>), or from a file required after the plugin loads (e.g. <code>require lib/open_id... |
Expose memory as read-only <p>In C can a function expose memory that it "manageds" at a lower level as readonly to those calling that function (exposing its address). <code>return * const</code> is not effective but I wondered if I was overlooking a programming tick?</p>
<p>Thanks.</p>
<pre><code>const uint8_t * get_... | <p>It's C! You can't :) There is always a way to circumvent it. Just make it <code>const</code> and hope somebody will not change it.</p>
<p>If you are hosting an add-in or something, you should run it in a separate process to limit its access to memory.</p>
|
Emacs command to insert and indent line above cursor <p>I frequently find myself typing on a line, when I realize I need(ed) a variable definition (or something similar) on the line above. What I would like is to </p>
<ol>
<li>press C-return from anywhere on a line and have the cursor move to a newly inserted blank li... | <p>Here's my humble solution:</p>
<p><code><pre>
(defun insert-before-line ()
(interactive)
(let ((pos (point))
(cur-max (point-max)))
(beginning-of-line)
; I've changed the order of (yank) and (indent-according-to-mode)
; in order to handle the case when yanked line comes with its own indent
... |
Thread does not receive messages <p>There is a thread in my Delphi application that has a message-waiting loop. Every time it receives a message, it starts doing some work. Here is the execute procedure of that thread:</p>
<pre><code>procedure TMyThread.Execute;
begin
while GetMessage(Msg, 0, 0, 0) and not Terminate... | <blockquote>
<p>Only when the main thread finishes its work or the Application.ProcessMessages method is called, does GetMessage return and my thread starts doing its work.</p>
</blockquote>
<p>I doubt that this is really what's happening. AFAIK the two message loops should be independent of each other, as long as y... |
BI with Django? <p>Is there a way to develop Bi (Business Intelligence) solutions with Django? Therefore it should be possible to define models with more than one Datasource.
Is anybody out there who has experienced BI with Django?
How could it work ?</p>
| <p>I'm not sure what your definition of BI is or why you assume that a BI solution requires more than one data source. </p>
<p>In my experience, BI means statistical analysis of data. A reporting schema, using dimensional techniques, can be the basis for it. The data is usually ETL'd from various transactional sour... |
Android: Is there a PC port? <p>Is it possible to have Android running on <code>x86</code> computers?</p>
| <p>Looks like someone is working on it... <a href="http://www.androidx86.org/" rel="nofollow">http://www.androidx86.org/</a></p>
|
Named/Optional parameters in C# 3.0? <p>Is there a way to add optional parameters to C# 3.0 like there will be in C# 4.0? I gotta have this feature, I just can't wait!</p>
<p><b>Edit:</b></p>
<p>If you know a work-around/hack to accomplish this, post it also. Thanks!</p>
| <p>You can use an anonymous type and reflection as a workaround to named parameters:</p>
<pre><code>public void Foo<T>(T parameters)
{
var dict = typeof(T).GetProperties()
.ToDictionary(p => p.Name,
p => p.GetValue(parameters, null));
if (dict.ContainsKey("Message"))
{
... |
Why would pthread_create() fail with only 2 threads active? <p>I'm having some trouble in my first foray into threads in C. I'm trying (for now) to write a very simple server program that accepts a socket connection and starts a new thread to process it. It seems to work fine except that it will only create about 300 t... | <p>If you are not creating the thread with the attribute <a href="http://www.opengroup.org/onlinepubs/000095399/functions/pthread%5Fattr%5Fsetdetachstate.html" rel="nofollow"><code>PTHREAD_CREATE_DETACHED</code></a> (or detaching them with <a href="http://www.opengroup.org/onlinepubs/000095399/functions/pthread%5Fdetac... |
C# hashes <p>I'm new to C#</p>
<blockquote>
<ol>
<li>How do i hash files with C#</li>
<li>What is available ? (md5, crc, sha1, etc)</li>
<li>Is there an interface i should inherit?</li>
</ol>
</blockquote>
<p>Basically i want to checksum multiple files and store it in a db along with using two of my own che... | <blockquote>
<p>1.) How do i hash files with C#?</p>
</blockquote>
<p>You can utilize .NET classes under <em><a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.aspx">System.Security.Cryptography</a></em></p>
<blockquote>
<p>2.) What is available?</p>
</blockquote>
<ul>
<li><a href="htt... |
Purposely create two files to have the same hash? <p>If someone is purposely trying to modify two files to have the same hash, what are ways to stop them? Can md5 and sha1 prevent the majority case?</p>
<p>I was thinking of writing my own and I figure even if I don't do a good job if the user doesn't know my hash he m... | <p>MD5 is generally considered insecure if hash collisions are a major concern. SHA1 is likewise no longer considered acceptable by the US government. There <s>is</s> was a <a href="http://en.wikipedia.org/wiki/SHA-3">competition</a> under way to find a replacement hash algorithm, but the recommendation at the moment... |
How can I open 2+ instances of VLC and control them programmatically? <p>I was thinking about writing an app (in either C++ or C#) to help me sort videos faster and I was wondering: How can I open more then 2 (maybe more) instance of VLC and control them though my EXE? What are my options? I know I can <code>SendMess... | <p>Ryan is on the right path. You need to use the Process class to open a vlc.exe process, but then you need to append a command-line statement to that. VLC has a rich command-line argument syntax that will let you do a lot of things to a video file or capture device. </p>
<p>I recently wrote an application that allow... |
C++ development on linux - where do I start? <p>I decided to leave my windows install behind and am now running Debian as my default OS. I have always coded in Windows and specifically with Visual Studio. I am currently trying to get used to compiling my code under linux.</p>
<p>Although I still have a lot of document... | <blockquote>
<p>What are recommended guides on creating a make file, how do I compile from this makefile (do I call g++ myself, do I use 'make'?)</p>
</blockquote>
<p>You build from the makefile by invoking "make". And inside your makefile, you compile and link using g++ and ld.</p>
<blockquote>
<p>Looking at oth... |
Is the Repository Pattern the same as the Asp.net Provider Model? <p>Since Asp.net 2.0, there is the Provider Model. On the implementation detail, a provider is class derived from ProviderBase which is an abstract class rather than an interface, but anyway the Provider Model is there so that we can have different impl... | <p>The Repository and Provider patterns overlap, but they don't formally describe the same thing. I would almost say the Repository is a subset of Provider. In practice, I think the Repository pattern was <em>borne out of</em> a specific need - abstracting repositories - and evolved in the community into a more generic... |
Git and Trac (or similar) <p>In the past I have really enjoyed using <a href="http://trac.edgewall.org/">Trac</a> with subversion repositories hosted on some of my own servers. The integrated ticketing and online code browsing is very convenient.</p>
<p>I have used <a href="http://github.com">github</a> for some of m... | <p>You should take a look at Redmine (<a href="http://www.redmine.org/">http://www.redmine.org/</a>). It has all of the features you mention and more. You can host it on your own vps (I do).</p>
|
How to convert *.txt file into Unicode <p>I have a requirement where a client will supply a file in encoding ANSI, but my system can only successfully read a file in UNICODE. So how do I tackle this issue? I know when I "save as" the file into as UNICODE encoded the file gets picked up. It's difficult to make the clie... | <p><a href="http://en.wikipedia.org/wiki/Iconv"><code>iconv</code></a> can do that:</p>
<pre><code>Usage: iconv [OPTION...] [FILE...]
Convert encoding of given files from one encoding to another.
Input/Output format specification:
-f, --from-code=NAME encoding of original text
-t, --to-code=NAME en... |
How to add Application Settings from a custom component (WinForms) <p>I have a WinForms user control that, when added to a form, should automatically add some elements to application settings. (Of course, the user should be able to customize/disable this behavior.)</p>
<p>is that advisable? What is the "good" way to d... | <p>I don't think your control should be adding anything to the config file, unless it's been asked to do so.</p>
<p>Still, if the user "opts in" to this, then I think you're going to have to add some designer support to your control. Either through the ToolBoxItem, or through the designer being notified on a new contr... |
Why can't I directly add attributes to any python object? <p>I have this code:</p>
<pre><code>>>> class G:
... def __init__(self):
... self.x = 20
...
>>> gg = G()
>>> gg.x
20
>>> gg.y = 2000
</code></pre>
<p>And this code:</p>
<pre><code>>>> from datetime import da... | <p>My guess, is that the implementation of datetime uses <a href="http://docs.python.org/reference/datamodel.html#id3">__slots__</a> for better performance.</p>
<p>When using <code>__slots__</code>, the interpreter reserves storage for just the attributes listed, nothing else. This gives better performance and uses le... |
Changing Visual Studio 2008 New Tab Position <p>One of my pet peeves ever since Visual Studio 2005 (behavior is unchanged in VS 2008) came out was the placement of the new tabs when opened. These opened on the left of current tabs which was the opposite of where new tabs opened in Visual Studio 2003 and beyond.</p>
<p... | <p>** Not actually for VS 2008 - Only adding this here because it's the top hit on goog **</p>
<p>To set up tabs on the right for VS 2010 </p>
<p><a href="http://blogs.msdn.com/b/zainnab/archive/2010/04/16/the-best-of-visual-studio-2010-insert-documents-to-the-right-of-existing-tabs.aspx" rel="nofollow">Tools -> Opti... |
A good uncertainty (interval) arithmetic library? <p><em>edited</em> </p>
<p>Given that the words "uncertain" and "uncertainty" are fairly ubiquitous, it's hard to Google "uncertainty arithmetic" and get anything immediately helpful. Thus, can anyone suggest a good library of routines, in almost any programming/script... | <p>I believe "<a href="http://en.wikipedia.org/wiki/Interval%5Farithmetic">Interval Arithmetic</a>" is the more common name for what you're looking for.
<a href="http://www.boost.org/doc/libs/1%5F38%5F0/libs/numeric/interval/doc/interval.htm">boost::interval</a> would be my first choice for a supporting library.</p>
|
Detecting Overridden Methods in Perl <p>Last week I was bitten <em>twice</em> by accidentally overriding methods in a subclass. While I am not a fan of inheritance, we (ab)use this in our application at work. What I would like to do is provide some declarative syntax for stating that a method is overriding a parent m... | <p>One way to enforce this:</p>
<pre><code>package Base;
...
sub new {
my $class = shift;
...
check_overrides( $class );
...
}
sub check_overrides {
my $class = shift;
for my $method ( @unoverridable ) {
die "horribly" if __PACKAGE__->can( $method ) != $class->can( $method );
... |
What is the easiest way to display the contents of an ArrayList of Objects in a JTable? <p>I have an ArrayList of Track objects.
Each Track object has the following fields (all Strings): </p>
<p>url, title, creator, album, genre, composer</p>
<p>I want to display these tracks in a JTable, with each row being an insta... | <p>In order to add contents to display on a <a href="http://java.sun.com/javase/6/docs/api/javax/swing/JTable.html"><code>JTable</code></a>, one uses the <a href="http://java.sun.com/javase/6/docs/api/javax/swing/table/TableModel.html"><code>TableModel</code></a> to add items to display.</p>
<p>One of a way to add a r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.