instruction
stringlengths
0
30k
Here is how they do it on StackOverflow.com: <http://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/>
Actually Process.MainWindowHandle is a handle of top-most window, it's not really the "Main Window Handle"
To add new method to jQuery You need to use jQuery.fn.methodName attribute, so in this case it will be: jQuery.fn.addOption = function (value, text) { jQuery(this).append(jQuery('<option></option>').val(value).text(text)); }; But keep in mind that this addOption will be accessible from result of any $() call.
C++ UI resources.
|c++|user-interface|resources|
No that I know C++ i want to get into desktop application that have a UI instead of Command Prompt stuff, where should I start, and what are some good online resources?
Now that I know C++ i want to get into desktop application that have a UI instead of Command Prompt stuff, where should I start, and what are some good **online** resources?
I use [Codegear][1]'s C++ Builder. It's C++ language support is not 100% but it more than makes up for it by having a great two-way RAD IDE and the ability to use a huge library of existing Delphi components. [1]: http://www.codegear.com
The "class" that you've constructed above is what most people would use a *struct* for in other languages. I'm not sure what the performance implications are in PHP, though I suspect instantiating the objects is probably more costly here, if only by a little bit. That being said, if the cost is relatively low, it IS a bit easier to manage the objects, in my opinion. I'm only saying the following based on the title and your question, but: Bear in mind that classes provide the advantage of methods and access control, as well. So if you wanted to ensure that people weren't changing weights to negative numbers, you could make the `weight` field private and provide some accessor methods, like `getWeight()` and `setWeight()`. Inside `setWeight()`, you could do some value checking, like so: public function setWeight($weight) { if($weight >= 0) { $this->weight = $weight; } else { // Handle this scenario however you like } }
Generally, I follow this rule: 1) Make it a class if multiple parts of your application use the data structure. 2) Make it a 2D array if you're using it for quick processing of data in one part of your application.
Anti aliasing workaround
|wpf|
Anti aliasing [cannot be turned off][1] in WPF. But I want to remove the blurred look of WPF fonts when they are small. One possibility would be to use a .net 2.0 component. This looks like it would lose the transparency capability and Blend support. Never tried it though. Anyone has a solution for this? Any drawbacks from it? Thank you [1]: http://forums.msdn.microsoft.com/en-US/wpf/thread/1ad9a62a-d1a4-4ca2-a950-3b7bf5240de5
WPF Anti aliasing workaround
|.net|wpf|
You can also programmatically determine the location of the class file by using structured naming conventions that map to physical directories. This is how Zend do it in [Zend Framework][1]. So when you call `Zend_Loader::loadClass("Zend_Db_Table");` it explodes the classname into an array of directories by splitting on the underscores, and then the Zend_Loader class goes to load the required file. Like all the Zend modules, I would expect you can use just the loader on its own with your own classes but I have only used it as part of a site using Zend's MVC. But there have been concerns about performance under load when you use any sort of dynamic class loading, for example see [this blog post][2] comparing Zend_Loader with hard loading of class files. As well as the performance penalty of having to search the PHP include path, it defeats opcode caching. From a comment on that post: >>When using ANY Dynamic class loader APC can’t cache those files fully as its not sure which files will load on any single request. By hard loading the files APC can cache them in full. [1]: http://framework.zend.com/ [2]: http://blog.digitalstruct.com/2007/12/23/zend-framework-performance-zend_loader/
One issue that hasn't been raised by others is whether **double** is the same as a **float**. On some systems a different format specifier was needed for a double compared to a float. Not least because the parameters passed could be of different sizes. <PRE> %f - float %lf - double %g - double </PRE>
At my work we use CCNET, but with builds on check-in more than nightly - although it's easily configured for either or both. You can very easily set up unit testing to run on every checkin as well, FXCop testing, and a slew of other products. I would also advise checking out [Team City][1] as an option, because it has a free version, and the reporting and setup is reportedly much simpler (it does look nice to me). It does have a limit of somewhere around 20 team members/projects, before it hits a pay-for window. That said, we started with CCNET, and have grown several products too large to look at Team City on the free version and are very happy with what we have. Features that help with CCNET include: - XML based configuration - you can usually copy and paste most of what you need. - More or less you'll be able to plug your treesurgeon script in as your build script, and point CCNET at that as an executable task to run the compilation. - Lots of documentation and very easy to set up nunit, ncover, fxcop, etc. - Taskbar app that will let you know the status of your projects at any time, and it can also fire off an email or keep an RSS feed with the same information. But I'd definitely go with running a CI build on every check-in - for the most part will run the unit tests before checking in, but let the CCNET server handle run any applications/assemblies that would have dependencies on the assembly we're checking in, and they get re-built, and re-tested on every checkin. Given that CCNET is free free and takes very little time to set up - I'd highly recommend just going for it and seeing if it suits you, then expanding from there. (There's another thread here where I posted pretty much the same/with a few alterations - but some of the other comments may help too! [Automated Builds][2]) Edit to add: You can easily set up your own deployment scheme for CCNET, and there are a tonne of blog posts out there to assist, and email notifications can really be set up fairly granularly, either on all successes, all failures, when it changes from success to fail, etc. There's also built in RSS, and you could even set up your own notifiers for other systems. [1]: http://www.jetbrains.com/teamcity/ [2]: http://stackoverflow.com/questions/36568/automated-builds#37204
**UPDATE table SET X=Y, Y=X** will do precisely what you want. The values are taken from the old row and assigned to a new copy of the same row, then the old row is replaced. You do not have to resort to using a temporary table, a temporary column, or other swap tricks.
**UPDATE table SET X=Y, Y=X** will do precisely what you want. The values are taken from the old row and assigned to a new copy of the same row, then the old row is replaced. You do not have to resort to using a temporary table, a temporary column, or other swap tricks. @DAV360: I see. That is shocking and unexpected. I use PostgreSQL and my answer works correctly there (I tried it). See the [PostgreSQL UPDATE docs](http://www.postgresql.org/docs/8.3/static/sql-update.html) (under Parameters, expression), where it mentions that expressions on the right hand side of SET clauses explicitly use the old values of columns. I see that the corresponding [MySQL UPDATE docs](http://dev.mysql.com/doc/refman/6.0/en/update.html) contain the statement "Single-table UPDATE assignments are generally evaluated from left to right" which implies the behaviour you describe. Good to know.
Qt Child Window Placement
|user-interface|qt|
Is there a way to specify a child's initial window position in Qt? I have an application that runs on Linux and Windows and it looks like the default behavior of Qt lets the Window Manager determine the placement of the child windows. On Windows, this is in the center of the screen the parent is on which seems reasonable. On Linux, in GNOME (metacity) it is always in the upper left-hand corner which is annoying. I can't find any window manager preferences for metacity that allow me to control window placement so I would like to override that behavior.
What is a resonable length limit on person "Name" fields?
|sql|html|textbox|
I have a simple webform that will allow unauthenticated users to input their information, including name. I gave the name field a limit of 50 characters to coincide with my database table where the field is varchar(50), but then I started to wonder. Is it more appropriate to use something like the Text column type or should I limit the length of the name to something reasonable? I'm using SQL Server 2005, in case that matters in your response.
I have a simple webform that will allow unauthenticated users to input their information, including name. I gave the name field a limit of 50 characters to coincide with my database table where the field is varchar(50), but then I started to wonder. Is it more appropriate to use something like the Text column type or should I limit the length of the name to something reasonable? I'm using SQL Server 2005, in case that matters in your response. **EDIT:** I did not see [this broader question][1] regarding similar issues. [1]: http://stackoverflow.com/questions/20958/list-of-standard-lengths-for-database-fields#21012
Both JavaScript's regex and PHP's preg_match are based on Perl, so there shouldn't be any porting problems. Do note, however, that Javascript only supports a subset of modifiers that Perl supports. For more info for comparing the two: * [Javascript Regular Expressions][1] * [PHP Regular Expressions][2] As for delivery method, I'd suggest you'd use [JSON][3], the slimmest data interchange format as of date (AFAIK) and directly translatable to a JavaScript object through eval(). Just put that bad boy through an [AJAX][4] session and you should be set to go. I hope this helps :) [1]: http://www.regular-expressions.info/javascript.html [2]: http://www.regular-expressions.info/php.html [3]: http://json.org/ [4]: http://en.wikipedia.org/wiki/Ajax_(programming)
@Ian Nelson: I'm wondering if others see the problem there. Let's say you have split fields. That's 70 characters total, 35 for first name and 35 for last name. However, if you have one field, you neglect the space that separates first and last names, short changing you by 1 character. Sure, it's "only" one character, but that could make the difference between someone entering their full name and someone not. Therefore, I would change that suggestion to "35 characters for each of Given Name and Family Name, or 71 characters for a single field to hold the Full Name".
MS do have a history of "fire and movement" with regards to introducing new technology into their development stack, but they also have a strong history of maintaining support for the older stuff, and backwards-compatibility. WPF seems to be getting stuff added to it with each new release of the framework but the things you learn aren't being superceded or invalidated. The only breaking change I've seen in my own WPF applications with a new release of the framework was one recently in 3.5 SP1, and that was because we were unknowingly relying on a bug to get a certain behaviour from our code. We adjusted the XAML to be more correct and it started working fine. So yeah, I think WPF is pretty "stable" as a client-side development technology.
I like it to. div tag with a fade. http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Walkthrough/UsingAnimations.aspx
I would also suggest Xml serialization as others have already mentioned. Here is a sample I threw together to demonstrate. Attributes are used to connect the names from the Xml to the actual property names and types in the data structure. Attributes also list out all the allowed types that can go into the `Things` collection. Everything in this collection must have a common base class. You said you have a common interface already -- but you may have to change that to an abstract base class because this code sample did not immediately work when `Thing` was an interface. using System; using System.Collections.Generic; using System.Text; using System.Xml.Serialization; using System.IO; namespace ConsoleApplication1 { class Program { static void Main() { string xml = "<?xml version=\"1.0\"?>" + "<config>" + "<stuff>" + " <class1 prop1=\"foo\" prop2=\"bar\"></class1>" + " <class2 prop1=\"FOO\" prop2=\"BAR\" prop3=\"42\"></class2>" + "</stuff>" + "</config>"; StringReader sr = new StringReader(xml); XmlSerializer xs = new XmlSerializer(typeof(ThingCollection)); ThingCollection tc = (ThingCollection)xs.Deserialize(sr); foreach (Thing t in tc.Things) { Console.WriteLine(t.ToString()); } } } public abstract class Thing { } [XmlType(TypeName="class1")] public class SomeThing : Thing { private string pn1; private string pn2; public SomeThing() { } [XmlAttribute("prop1")] public string PropertyNumber1 { get { return pn1; } set { pn1 = value; } } [XmlAttribute("prop2")] public string AnotherProperty { get { return pn2; } set { pn2 = value; } } } [XmlType(TypeName="class2")] public class SomeThingElse : SomeThing { private int answer; public SomeThingElse() { } [XmlAttribute("prop3")] public int TheAnswer { get { return answer; } set { answer =value; } } } [XmlType(TypeName = "config")] public class ThingCollection { private List<Thing> things; public ThingCollection() { Things = new List<Thing>(); } [XmlArray("stuff")] [XmlArrayItem(typeof(SomeThing))] [XmlArrayItem(typeof(SomeThingElse))] public List<Thing> Things { get { return things; } set { things = value; } } } }
**UPDATE table SET X=Y, Y=X** will do precisely what you want. The values are taken from the old row and assigned to a new copy of the same row, then the old row is replaced. You do not have to resort to using a temporary table, a temporary column, or other swap tricks. @D4V360: I see. That is shocking and unexpected. I use PostgreSQL and my answer works correctly there (I tried it). See the [PostgreSQL UPDATE docs](http://www.postgresql.org/docs/8.3/static/sql-update.html) (under Parameters, expression), where it mentions that expressions on the right hand side of SET clauses explicitly use the old values of columns. I see that the corresponding [MySQL UPDATE docs](http://dev.mysql.com/doc/refman/6.0/en/update.html) contain the statement "Single-table UPDATE assignments are generally evaluated from left to right" which implies the behaviour you describe. Good to know.
While I'm not 100% sure what the Web Service behavior does, I recall it allows client-side script to call Web Services, which would make AJAX it's contemporary replacement. Since you're using .NET 1.1 how about using [Ajax.NET Professional][1] to connect to the web services? [1]: http://www.ajaxpro.info
Looking for a n-ary tree implementation in Perl
|perl|beginner|algorithm|tree|
I'm writing a Perl script and would like to use a n-ary tree data structure. Is there a good implementation that is available as source code (rather than part of a Perl library) ?
|algorithm|perl|beginner|
Swapping column values in MySQL
|mysql|database|
I have a MySQL table with coordinates, the column names are X and Y. Now I want to swap the column values in this table, so that X becomes Y and Y becomes X. The most apparent solution would be renaming the columns, but I don't want to make structure changes since I don't necessarily have permissions to do that. Is this possible to do with <b>UPDATE</b> in some way? <b>UPDATE table SET X=Y, Y=X</b> obviously won't do what I want.
|database|mysql|
I have a MySQL table with coordinates, the column names are X and Y. Now I want to swap the column values in this table, so that X becomes Y and Y becomes X. The most apparent solution would be renaming the columns, but I don't want to make structure changes since I don't necessarily have permissions to do that. Is this possible to do with <b>UPDATE</b> in some way? <b>UPDATE table SET X=Y, Y=X</b> obviously won't do what I want. - - - Edit: Please note that my restriction on permissions, mentioned above, effectively prevents the use of ALTER TABLE or other commands that change the table/database structure. Renaming columns or adding new ones are unfortunately not options.
FinalBuilder does support emailing and just executing FinalBuilder each night will give you nightly builds. You don't really need other software for that if you don't want to. You could also use CCNet to trigger a build when needed and have it execute FinalBuilder for the build. You can then decide if FinalBuilder or CCNet should email. Finally FinalBuilder has a Server version which is sorta like CCNet in that it is a continues integration tool using FinalBuilder. See http://www.finalbuilder.com/finalbuilder-server.aspx Of course the biggest advantage of CCNet is that it is free and open source.
I'm using the JSCalendar from Dynarch for a project I'm currently working on. It is LGPL licensed and really flexible (easy to customize to your needs). It has lots of features and looks good, too. http://www.dynarch.com/projects/calendar/
Fundamental Data Structures in C#
|c#|.net|data-structures|
I would like to know how people implement the following data structures in C# without using the base class library implementations:- - Linked List - Hash Table - Binary Search Tree - Red-Black Tree - B-Tree - Binomial Heap - Fibonacci Heap and any other fundamental data structures people can think of! I am curious as I want to improve my understanding of these data structures and it'd be nice to see C# versions rather than the typical C examples out there on the internet!
Kronoz is right. After setting it at designtime it adds this to the .designer.cs: dataGridViewCellStyle1.NullValue = "null"; If I modify **"null"** to **null** then it works fine. I checked the DataGridViewCellStyle.NullValue set_NullValue(Object) and get_NullValue with reflector and I think that a string value shouldn't raise any error here. Anyway be careful with this and if you want to set it designtime then don't forget to modify the .design.cs.
@edg, I guess it's an error in MSDN. You can clearly see in Relfector, that "Main window" check in .NET looks like: private bool IsMainWindow(IntPtr handle) { return (!(NativeMethods.GetWindow(new HandleRef(this, handle), 4) != IntPtr.Zero) && NativeMethods.IsWindowVisible(new HandleRef(this, handle))); } When .NET code enumerates windows, it's pretty obvious that first visible window (i.e. top level window) will match this criteria.
There's a series of [MSDN articles](http://msdn.microsoft.com/en-us/vcsharp/aa336800.aspx) on this subject. However, I haven't really read the text myself. I believe that the collections framework by .NET has a broken interface and cannot be extended very well. There's also [C5](http://www.itu.dk/research/c5/), a libray that I am investigating right now. For the reason mentioned above, I've had the project to implement my own collections library for .NET but I've stopped this project after the first benchmark revealed that even a straightforward, non-thread-safe generic `Vector` implementation is slower than the native `List<T>`. Since I've taken care not to produce any inefficient IL code, this means that .NET is simply not suited (yet) for writing on-par replacements for intrinsic data structures, and that the .NET framework has to use some behind-the-scenes knowledge to optimize the builtin collection classes.
Best Ruby on Rails social networking framework
|ruby|ruby-on-rails|website|socialnetworking|
I'm planning on creating a social networking + MP3 lecture downloading / browsing / commenting / discovery website using Ruby on Rails. Partially for fun and also as a means to learn some Ruby on Rails. I'm looking for a social networking framework that I can use as a basis for my site. I don't want to re-invent the wheel. Searching the web I found three such frameworks. Which of these three would you recommend using and why? http://portal.insoshi.com/ http://www.communityengine.org/ http://lovdbyless.com/
As far as I know, the only direct ways to do it are: 1. Commit the txn - Probably not a reasonable option 2. Clear the Persistence Context - EntityManager.clear() - This is brutal, but would clear it out 3. Copy the object - Most of the time your JPA objects are serializable, so this should be easy (if not particularly efficient).
For example the webserver username and group is <b>apache:www</b>, if you set your to check UID, the php process will only have access to any file owned by the user <b>apache</b>. So if you have another webserver running on your system,for example tomcat with the username and group of <b>tomcat:www</b>, any files created by the tomcat process won't be accessible by php because it is owned by the <b>tomcat</b> user. But if you instead use GID check, the files created by the tomcat process will be readable by the php process because the belong to the same <b>www</b> group
We've been using WPF since it was first released and yes it had it's problems at the beginning that caused us headaches and had us scratching our heads to find a work around, but each new update the stack has actually become pretty stable. It definitely became easier and easier to develop with it with the addition of Expression Blend. Creating the XAML in VS 2005 was not fun. The templating engine alone is enough to switch from WinForms, let alone the animation support. Either way, I agree with Matt that it is pretty stable as a framework for developing client applications.
Uising Reflector you can see that Microsoft.ReportViewer.Common.dll has a dependency on "Microsoft.Build.Framework, Version=3.5.0.0" and "Microsoft.Build.Utilities.v3.5, Version=3.5.0.0". So strictly speaking it does have a 3.5 requirement. But if the reporting functionality you use never executes the code that uses/loads these, then you *might just* be OK :-)
I recently did something very similar, I used an abstract factory. In fact, you can see the basic concept here: http://stackoverflow.com/questions/27294/abstract-factory-design-pattern
try using a static class member. class Shipment { public static $DefaultWeight = '0'; public function createShipment($startZip,$endZip,$weight=Shipment::DefaultWeight){ //you function } }
How do I check the active solution configuration Visual Studio built with at runtime?
|visual-studio|microsoft|
I would like to enable/disable some code based on a custom solution configuration I added in Visual Studio. How do I check this value at runtime?
Best way to test if a generic type is a string? (c#)
|c#|generics|
I have a generic class that should allow any type, primitive or otherwise. The only problem with this is using `default(T)`. When you call default on a value type or a string, it initializes it to a reasonable value (such as empty string). When you call `default(T)` on an object, it returns null. For various reasons we need to ensure that if it is not a primitive type, then we will have a default instance of the type, **not** null. Here is attempt 1: T createDefault() { if(typeof(T).IsValueType) { return default(T); } else { return Activator.CreateInstance<T>(); } } Problem - string is not a value type, but it does not have a parameterless constructor. So, the current solution is: T createDefault() { if(typeof(T).IsValueType || typeof(T).FullName == "System.String") { return default(T); } else { return Activator.CreateInstance<T>(); } } But this feels like a kludge. Is there a nicer way to handle the string case?
I recommend that if VS Express is not good enough, use Professional. Standard is missing some really useful features, like a Remote Debugger. Here is a detailed comparison: [http://msdn.microsoft.com/en-us/vs2008/products/cc149003.aspx][1] I'd say cancel TechNet and get one of the bottom two MSDN Subscriptions, Visual Studio Professional with either MSDN Professional or with MSDN Premium. [1]: http://msdn.microsoft.com/en-us/vs2008/products/cc149003.aspx
Most people here have mentioned SQL Injection and XSS, which is *kind of* correct, but don't be fooled - the most important things you need to worry about as a web developer is INPUT VALIDATION, which is where XSS and SQL Injection stem from. For instance, if you have a form field that will only ever accept integers, make sure you're implementing something at both the client-side AND the server-side to sanitise the data. Check and double check any input data especially if it's going to end up in an SQL query. I suggest building an escaper function and wrap it around anything going into a query. For instance: $query = "SELECT field1, field2 FROM table1 WHERE field1 = '" . myescapefunc($userinput) . "'"; Likewise, if you're going to display any user-inputted information onto a webpage, make sure you've stripped any &lt;script&gt; tags or anything else that might result in Javascript execution (such as onLoad= onMouseOver= etc. attributes on tags).
I don't actually know the answer but I suspect that it has something to do with the aspect of invoking methods on string literals directly. If I recall correctly (I didn't actually verify this because I don't have an old IDE handy), early versions of the C# IDE had trouble detecting method calls against string literals in IntelliSense, and that has a big impact on the discoverability of the API. If that was the case, typing the following wouldn't give you any help: "{0}".Format(12); If you were forced to type new String("{0}").Format(12); It would be clear that there was no advantage to making the Format method an instance method rather than a static method. The .NET libraries were designed by a lot of the same people that gave us MFC, and the String class in particular bears a strong resemblance to the CString class in MFC. MFC does have an instance Format method (that uses printf style formatting codes rather than the curly-brace style of .NET) which is painful because there's no such thing as a CString literal. So in a MFC codebase that I worked on I see a lot of this: CString csTemp = ""; csTemp.Format("Some string: %s", szFoo); which is painful. (I'm not saying that the code above is a great way to do things even in MFC, but that does seem to be the way that most of the developers on the project learned how to use CString::Format). Coming from that heritage, I can imagine that the API designers were trying to avoid that sort of situation again.
>>It's the speed that I am thinking of mostly, for anything more complex than what I have here I'd probably go with classes but the question is, what is the cost of a class? This would seem to be premature optimisation. Your application isn't going to take any real-world performance hit either way, but using a class lets you use getter and setter methods and is generally going to be better for code encapsulation and code reuse. With the arrays you're incurring cost in harder to read and maintain code, you can't unit test the code as easily and with a good class structure other developers should find it easier to understand if they need to take it on. And when later on you need to add other methods to manipulate these, you won't have an architecture to extend.
Note that many **cultures** have 'second surnames' often called family names. For example, if you are dealing with Spanish people, they will appreciate having a family name separated from their 'surname'. Best bet is to define a data type for the name components, use those for a data type for the surname and tweak depending on locale.
Aren't there environment settings? I have `VCToolkitInstallDir` and `VS71COMNTOOLS` although I'm using VS2003, I don't know if that changed for later versions. Type "set V" at the command line and see if you have them.
There is not a native way to do it, but you can achieve it with a macro. The details are described here in full: [http://www.helixoft.com/blog/archives/32][1] You just have to add a little VB Macro to the EvironmentEvents macro section and restart VS. Note: The path will not show up when you first load VS, but will whenever you change which file you are viewing. There is probably a way to fix this, but it doesn't seem like a big deal. [1]: http://www.helixoft.com/blog/archives/32
If you need to consider localisation (for those of us outside the US!) and it's possible in your environment, I'd suggest: Define data types for each component of the name - NOTE: some cultures have more than two names! Then have a type for the full name, Then localisation becomes simple (as far as names are concerned). **The same applies to addresses, BTW - different formats!**
I have worked extensively with templated control and I have not found a better solution. Why are you referencing the contentLable in the event handler? The sender is the label you can cast it to the label and have the reference to the label. Like below. //add a custom data binding contentLabel.DataBinding += (object sender, EventArgs e ) => { //do custom stuff at databind time ((Label)sender).Text = //bound content }; Then you should be able to dispose of the label reference in InstantiateIn. Please note I have not tested this.
As usually happens when I post questions like this, I found the problem. It turns out the Crypt::SSLeay module was not installed or at least not up to date. Of course the error messages didn't give me any clues. Updating it and all the problems go away and things are working fine now.
What does this javascript error mean? Permission denied to call method to Location.toString
|javascript|flash|
This error just started popping up all over our site. ***Permission denied to call method to Location.toString*** I'm seeing google posts that suggest that this is related to flash and our crossdomain.xml. What caused this to occur and how do you fix?
Using MVP - How to use Events Properly for Testing
|asp.net|design-patterns|mvp|
I've just started using the MVP pattern in the large ASP.NET application that I'm building (re-building actually) and I am having a hard time figuring out how I should be using Events applied to the view. Say I have 2 drop down lists in a User Control, where one is dependent on the other's value: <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ucTestMVP.ascx.vb" Inherits=".ucTestMVP" %> <asp:DropDownList ID="ddlCountry" runat="server" AutoPostBack="True" /> <asp:DropDownList ID="ddlCity" runat="server" /> How should should the AutoPostBack Event be defined in the interface? Should it be an event that is handled by the User Control like this: Public Partial Class ucTestMVP Inherits System.Web.UI.UserControl Implements ITestMVPView Protected Sub PageLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then Dim presenter As New TestMVPPresenter(Me) presenter.InitView() End If End Sub Private Sub ddlCountrySelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlCountry.SelectedIndexChanged Dim presenter as New TestMVPPresenter(Me) presenter.CountryDDLIndexChanged() End Sub End Class Or should there be an event defined at the Interface? If this is the preferred pattern, how do I add events to be handled and used?
Usually when creating Cocoa applications that front UNIX commands or other headless programs you use an [`NSTask`][1]: > Using the NSTask class, your program can run another program as a subprocess and can monitor that program’s execution. An NSTask object creates a separate executable entity; it differs from NSThread in that it does not share memory space with the process that creates it. > A task operates within an environment defined by the current values for several items: the current directory, standard input, standard output, standard error, and the values of any environment variables. By default, an NSTask object inherits its environment from the process that launches it. If there are any values that should be different for the task, for example, if the current directory should change, you must change the value before you launch the task. A task’s environment cannot be changed while it is running. You can communicate with the backend process by way of `stdin`/`stdout`/`stderr`. Bascially `NSTask` is a high-level wrapper around `exec` (or `fork` or `system`, I always forget the difference). As I understand it you don't want the Erland program to be a background daemon that runs continuously, but if you do, go with [@Chris's][2] suggestion. [1]: http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSTask_Class/Reference/Reference.html [2]: http://stackoverflow.com/questions/37381/whats-a-good-way-to-write-a-cocoa-front-end-to-an-erlang-application#37408
replace URL with HTML Links javascript
|javascript|regex|
i am using the next function to match urls inside a given text and replace them for html links. The regex is working great but currently i am only replacing the first match. Does anyone knows how I can replace all the url? I guess i should be using *exec* command but i did not really figured how to do it. function replaceURLWithHTMLLinks(text) { var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/i; return text.replace(exp,"<a href='$1'>$1</a>"); }
The portable way to get epsilon in C++ is #include <limits> std::numeric_limits<double>::epsilon() Then the comparison function becomes #include <cmath> #include <limits> bool AreSame(double a, double b) { return fabs(a - b) < std::numeric_limits<double>::epsilon(); }
Add a "g" to the end of the Regex to enable global matching. /ig;
Not massively. I've never had an issue with it in desktop development unless as Martin states you're using it in a silly location. I've heard a lot of people have utterly irrational fears about its performance in desktop development. In the Compact Framework (which i'm usually in) though it's pretty much anethema and should be avoided like the plague in most cases. I can still get away with using it infrequently but I have to be real careful with its application which is way less fun. :(
Eclipse Plugin Dev: How do I get the paths for the currently selected project?
|java|eclipse|plugin-development|eclipse-api|
Best practices for integrating third-party modules into your app
|architecture|system-integration|
We have a few projects that involve building an application that is composed of maybe 50% custom functionality, but then pulls in, say, a wiki, a forum, and other components that are "wheels" that have already been invented that we do not wish to re-write from scratch. These third-party applications usually have their own databases, themes, and authentication systems. Getting things to work like a single-sign-on, or a common theme, or tagging/searching across entities in multiple sub-apps are pretty challenging problems, in my experience. What are some of the best practices for this kind of integration project? Our approach, so far, has been to try and pick your components carefully, choosing ones that have a clearly defined API, preferably via HTTP (like REST or SOAP), though that isn't always possible (we haven't found a decent forum that works that way). Are there suggestions folks can give to anyone trying to do this, as I suspect many of us are more and more frequently these days?
[wxWidgets](http://www.wxwidgets.org/) is a cross platform GUI library for C++ (and other languages). The main site should have enough pointers to resources to get going.
[wxWidgets](http://www.wxwidgets.org/) is a cross platform GUI library for C++ (and other languages). The main site should have enough pointers to resources to get going. You might also want to check out [this](http://stackoverflow.com/questions/4347/where-is-a-good-place-to-start-programming-guis-for-windows) question/answer here on stack overflow if you are specifically thinking of Windows
I've started with Hibernate on Java project at my workplace, and then realized that there exist the .Net port (NHibernate) and used it again in a .Net project. I've also came across the article that *joesteele* mentions, and used it as a base for my projects with some minor modifications when needed, mostly when needed to target transaction beginning and ending manually. The same practice and library that can be applied to both Java and C# platforms, targeting the Windows, or Linux as application platforms, makes development on different platforms easier than needing to learn different frameworks. Although i'm planning to exmine the Subsonic, iBatis and LINQ, for now Hibernate and NHibernate seem like the right tool for the job while i have to target both Windows and Linux platforms.
On Linux and maybe Windows, you can use [Gtk+](http://gtk.org) with [Glade](http://glade.gnome.org/). Gtk+ is the GUI toolkit. Glade is a GUI drag and drop GUI editor. If you came from Windows or Java and thought GUI programming is hard, this stuff is easy.
How about [QT](http://trolltech.com/products/qt/)? Its cross-platform and its is used in a lot of commercial softwares.
I think developing a custom solution for running background tasks doesn't always worth, so I recommend to use the [Quartz Scheduler][1] in Java. In your situation (need to run background tasks in a web application) you could use the ServletContextListener included in the distribution to [initialize the engine at the startup of your web container][2]. After that you have a number of possibilities to start (trigger) your background tasks (jobs), e.g. you can use Calendars or cron-like expressions. In your situation most probably you should settle with [SimpleTrigger][3] that lets you run jobs in fixed, regular intervals. The jobs themselves can be described easily too in Quartz, however you haven't provided any details about what you need to run, so I can't provide a suggestion in that area. [1]: http://www.opensymphony.com/quartz/ [2]: http://www.opensymphony.com/quartz/api/org/quartz/ee/servlet/QuartzInitializerListener.html [3]: http://www.opensymphony.com/quartz/api/org/quartz/SimpleTrigger.html