instruction stringlengths 0 30k ⌀ |
|---|
Weborb ([http://www.themidnightcoders.com/weborb/][2]) has some awesome benefits on the data access side if you're looking to do some AMF as well as streaming video it could be a very decent option (and has a php and .net version).
On the python side I found ([http://rtmpy.org/][3]) but couldn't say too much about it as I have never used it...
[1]: http://osflash.org/red5
[2]: http://www.themidnightcoders.com/weborb/
[3]: http://rtmpy.org/ |
Problems with disabling IIS shutdown of idle worker process? |
|iis| |
I ran into an issue with an IIS web app shutting down an idle worker process. The next request would then have to re-initialize the application, leading to delays. I disabled the IIS shutdown of idle worker processes on the application pool to resolve this. Are there any issues associated with turning this off? If the process is leaking memory, I imagine it is nice to recycle the process every now and then. Are there any other benefits to having this process shutdown? |
> This also has issues, because I have to explicitly null the session value during non postbacks in order to emulate how ViewState works.
Why do you **have** to explicitly null out the value (aside from memory management, etc)? Is it not an option to check Page.IsPostback, and either do something with the Session variable or not? |
For simple sites, I actually prefer ASP vs. ASP.NET, especially if you know HTML well. However with ASP, separating business logic from view is hard; the code you write will likely be challenging to read + maintain.
PHP is better than ASP though - and somewhat similar at the basic level. And you could always go to Rails or Django, if you're interested in self-contained web development stack (but a lot longer learning curve). |
One advantage to ASP.NET is that you have the option of coding your site exactly as you did with classic ASP, along with access to the richness of the .NET framework. You can keep existing functionality and add new ASP.NET functionality were needed. They mix well.
Unfortunately the author of the referenced [article][1] isn't very well versed in the technology behind ASP.NET as evident by his remarks (and maybe not even classic ASP). Most of his points are invalid or simply wrong.
[1]: http://www.packtpub.com/article/Classic-ASP |
There are two approaches in the standard library. One is to use java.text.DecimalFormat. The other more cryptic methods (String.format, PrintStream.printf, etc) based around java.util.Formatter should keep C programmers happy(ish). |
I was also thinking on lines of [XML Diff][1] since basically HTML is a subset of XML.
The challenge with HTML is that it might not be always well formed. Found one more here showing how to use [XMLDiff class][2].
[1]: http://msdn.microsoft.com/en-us/library/aa302294.aspx
[2]: http://msdn.microsoft.com/en-us/library/aa302295.aspx |
I was thinking on lines of [XML Diff][1] since HTML can be represented as an XML Document.
The challenge with HTML is that it might not be always well formed. Found one more here showing how to use [XMLDiff class][2].
[1]: http://msdn.microsoft.com/en-us/library/aa302294.aspx
[2]: http://msdn.microsoft.com/en-us/library/aa302295.aspx |
Did you try [GOA WinForms][1]?
[1]: http://www.netikatech.com/products/default.aspx |
Your declaration: `DIM arr(3,3) As Integer` allready specifies that there are 3 elements in any given row (or 4, I'm not so sure about VB)
You could try:
Dim arr(3) as Integer()
You should then be able to do:
arr(n).Length
To find the length of row n.
I'm a bit rusty on VB6 and never learned VB.NET, but this should give you a 'jagged' array. Check out the msdn documentation on multidimensioned arrays. |
In bioinformatics when you align two sequences you can have a model that will have a different cost based on if it's a transition or a transversion. This is exactly what you want but instead of a 4x4 matrix, you want a 40x40 --or however many keys you want to include.
So the cost of a replacement is from the matrix, not a constant.
Be sure that deletions and insertions are weighted properly though so they aren't over accepted as the minimum.
int LevenshteinDistance(char s[1..m], char t[1..n])
// d is a table with m+1 rows and n+1 columns
declare int d[0..m, 0..n]
for i from 0 to m
d[i, 0] := i
for j from 0 to n
d[0, j] := j
for i from 1 to m
for j from 1 to n
{
**if s[i] = t[j] then cost := 0
else cost := 1**
d[i, j] := minimum(
d[i-1, j] + 1, // deletion
d[i, j-1] + 1, // insertion
d[i-1, j-1] + cost // substitution
)
}
return d[m, n]
That cost, surrounded by the double-stars, is now a function (or a table/matrix) that represents the cost of that transition from s[i] to j[i]...
|
In bioinformatics when you align two sequences you can have a model that will have a different cost based on if it's a transition or a transversion. This is exactly what you want but instead of a 4x4 matrix, you want a 40x40 --or however many keys you want to include.
So the cost of a replacement is from the matrix/function, not a constant.
**CAVEAT: Be sure that deletions and insertions are weighted properly though so they aren't over accepted as the minimum. You'll just have a string of insertions/deletions and every character that matches otherwise.**
int LevenshteinDistance(char s[1..m], char t[1..n])
// d is a table with m+1 rows and n+1 columns
declare int d[0..m, 0..n]
for i from 0 to m
d[i, 0] := i
for j from 0 to n
d[0, j] := j
for i from 1 to m
for j from 1 to n
{
**if s[i] = t[j] then cost := 0
else cost := 1**
d[i, j] := minimum(
d[i-1, j] + 1, // deletion
d[i, j-1] + 1, // insertion
d[i-1, j-1] + cost // substitution
)
}
return d[m, n]
That cost, surrounded by the double-stars, is now a function (or a table/matrix) that represents the cost of that transition from s[i] to j[i]...
|
mweerden: NT has been designed for multi-user from day one, so this is not really a reason. However, you are right about that process creation plays a less important role on NT than on Unix as NT, in contrast to Unix, favors multithreading over multiprocessing.
Rob, it is true that fork is relatively cheap when COW is used, but as a matter of fact, fork is mostly followed by an exec. And an exec has to load all images as well. Discussing the performance of fork therefore is only part of the truth.
When discussing the speed of process creation, it is probably a good idea to distinguish between NT and Windows/Win32. As far as NT (i.e. the kernel itself) goes, I do not think process creation (NtCreateProcess) and thread creation (NtCreateThread) is significantly slower as on the average Unix. There might be a little bit more going on, but I do not see the primary reason for the performance difference here.
If you look at Win32, however, you'll notice that it adds quite a bit of overhead to process creation. For one, it requires the CSRSS to be notified about process creation, which involves LPC. It requires at least kernel32 to be loaded additionally, and it has to perform a number of additional bookkeeping work items to be done before the process is considered to be a full-fledged Win32 process. And let's not forget about all the additional overhead imposed by parsing manifests, checking if the image requires a compatbility shim, checking whether software restriction policies apply, yada yada.
That said, I see the overall slowdown in the sum of all those little things that have to be done in addition to the raw creation of a process, VA space, and initial thread. But as said in the beginning -- due to the favoring of multithreading over multitasking, the only software that is seriously affected by this additional expense is poorly ported Unix software. Although this sitatuion changes when software like Chrome and IE8 suddenly rediscover the benefits of multiprocessing and begin to frequently start up and teardown processes... |
I can wholeheartedly recommend writing such a process with a simple Perl client using the Mail::IMAPClient module.
#!/usr/bin/perl -w
use strict;
use Mail::IMAPClient;
# returns an unconnected Mail::IMAPClient object:
my $imap = Mail::IMAPClient->new(
Server => $host,
User => $id,
Password=> $pass,
) or die "Cannot connect to $host as $id: $@";
$imap->expunge();
This can then be run from crontab or some other scheduler.
Regards
Arjen |
You may want to take a look to [cpp-sockets][1], a C++ wrapper for the sockets system calls. It works with many operating systems (Win32, POSIX, Linux, *BSD). I don't think it will work with z/OS but you can take a look at the include files it uses and you'll have many examples of tested code that works well on other OSs.
[1]: http://sourceforge.net/projects/cpp-sockets/
|
You can easily simulate user input. You can submit form on the web page from you program by sending post\get request to a website. It's not clear what language\framework you're going to use. For example there is a whole framework for screen scraping (including login functionality) written in perl - [WWW::Mechanize][1]
[1]: http://search.cpan.org/dist/WWW-Mechanize/ |
You can easily simulate user input. You can submit form on the web page from you program by sending post\get request to a website.
Typical login form looks like:
<form name="loginForm" method="post" Action="target_page.html">
<input type="Text" name="Username">
<input type="Password" name="Password">
</form>
You can send a post request to the website providing values for Username & Password fields. What happens after you send your request is largely depends on a website, usually you will be redirected to some page. You authorization info will be stored in the sessions\cookie. So if you scrape client can maintain web session\understands cookies you will be able to access protected pages.
It's not clear from your question what language\framework you're going to use. For example there is a framework for screen scraping (including login functionality) written in perl - [WWW::Mechanize][1]
Note, that you can face some problems if site you're trying to loging to uses java scripts or some kind of CAPTCHA.
[1]: http://search.cpan.org/dist/WWW-Mechanize/ |
One thing you might want to look at are [Soundex][1] searches, which are quite useful for misspellings and contractions.
This however is not an in-database validation so it may or may not be what you're looking for.
[1]: http://en.wikipedia.org/wiki/Soundex |
Both of John's solutions would work. Another option that allows HTMLDecorator to remain very simple and clean is to monkey-patch it in as a base class. This also works only for user-defined classes, not builtin types:
import cgi
class ClassX(object):
pass # ... with own __repr__
class ClassY(object):
pass # ... with own __repr__
inst_x=ClassX()
inst_y=ClassY()
class HTMLDecorator:
def html(self): # an "enhanced" version of __repr__
return cgi.escape(self.__repr__()).join(("<H1>","</H1>"))
ClassX.__bases__ = (HTMLDecorator, object)
ClassY.__bases__ = (HTMLDecorator, object)
print inst_x.html()
print inst_y.html()
Be warned, though -- monkey-patching like this comes with a high price in readability and maintainability of your code. When you go back to this code a year later, it can become very difficult to figure out how your ClassX got that html() method, especially if ClassX is defined in some other library.
|
Both of John's solutions would work. Another option that allows HTMLDecorator to remain very simple and clean is to monkey-patch it in as a base class. This also works only for user-defined classes, not builtin types:
import cgi
class ClassX(object):
pass # ... with own __repr__
class ClassY(object):
pass # ... with own __repr__
inst_x=ClassX()
inst_y=ClassY()
class HTMLDecorator:
def html(self): # an "enhanced" version of __repr__
return cgi.escape(self.__repr__()).join(("<H1>","</H1>"))
ClassX.__bases__ += (HTMLDecorator,)
ClassY.__bases__ += (HTMLDecorator,)
print inst_x.html()
print inst_y.html()
Be warned, though -- monkey-patching like this comes with a high price in readability and maintainability of your code. When you go back to this code a year later, it can become very difficult to figure out how your ClassX got that html() method, especially if ClassX is defined in some other library.
|
I think it's not possible with Team Explorer. But you can with [CodePlex Source Control Client][1] or [Tortoise][2]
[1]: http://www.codeplex.com/CodePlexClient
[2]: http://www.codeplex.com/CodePlex/Wiki/View.aspx?title=Using%20TortoiseSVN%20with%20CodePlex&referringTitle=Source%20control%20clients |
I think you have to use the [CodePlex Source Control Client][1]. In includes cpc.exe which supports the anonymous access features of CodePlex TFS servers for non-coordinator/developer access. But according to the site:
> The CodePlex Client is not currently
> being maintained. The focus of the
> CodePlex team now is on the [SvnBridge][2].
I'm using TortoiseSVN with SvnBridge with no problems.
[1]: http://www.codeplex.com/CodePlexClient
[2]: http://www.codeplex.com/SvnBridge |
You could try integrating Sphinx with [Asterisk][1]:
[http://www.syednetworks.com/asterisk-integration-with-sphinx-voice-recognition-system][2]
[1]: http://www.asterisk.org/
[2]: http://www.syednetworks.com/asterisk-integration-with-sphinx-voice-recognition-system |
I used VisualSVN until Ankh hit 2.0, and ever since, I've abandoned VisualSVN. Ankh has surpassed VisualSVN in functionality, in my mind, and all the 1.x perf and integration issues are gone. |
There's also [Zinc][1] that also provides API:s for accessing the filesystem and other thinks that AIR does, but less restrictive.
[1]: http://www.multidmedia.com/software/zinc/ |
I have used ASP.NET MVC for a few projects recently and its like a breath of fresh air compared to WebForms. It works *with* the web rather than against it, and feels like a much more natural way to develop.
I use SubSonic rather than NHibernate, and find it fits very nice within the MVC architecture.
The building blocks I commonly use for a website are:-
Asp.net mvc
Subsonic
SQL Server
Lucene
JQuery
|
@[Kevin](#23889):
> I was just trying to point out that spl_autoload_register is a better alternative to __autoload since you can define multiple loaders, and they won't conflict with each other. Handy if you have to include libraries that define an __autoload function as well.
Are you sure? The [documentation](http://www.php.net/function.spl_autoload_register) says differently:
> If your code has an existing __autoload function then this function must be explicitly registered on the __autoload stack. This is because spl_autoload_register() will effectively replace the engine cache for the __autoload function by either spl_autoload() or spl_autoload_call().
=> you have to explicitly register any library's `__autoload` as well. But apart from that you're of course right, this function is the better alternative. |
If you want to code in Java I really recommend SerialIOs [SerialPort][1]. It is very ease to use and saves you days of work.
My advice: do not use Sun's serial IO framework! It is from 1998 and full of bugs. You can use [rxtx][2] but serialio is better!
[1]: http://serialio.com/products/serialport/serialport.php
[2]: http://www.rxtx.org/ |
Block the finalizer. |
You can also use X-Http-Verb-Override:DELETE inst. of HTTP DELETE. This is also usefull for Silverlight clients who cant change the HTTP verbs and only support GET and POST... |
If JConsole can't be used you can
- press CTRL+BREAK under Windows
- send `kill -3 <process id>` under Linux
to get a full Thread Dump. This doesn't affect performance and can always be run in production. |
davidg was on the right track, and I am crediting him with the answer.
But the WMI query necessary was a little less than straightfoward, since I needed not just a list of users for the whole machine, but the subset of users *and groups*, whether local or domain, that were members of the local Administrators group. For the record, that WMI query was:
SELECT PartComponent FROM Win32_GroupUser WHERE GroupComponent = "Win32_Group.Domain='thehostname',Name='thegroupname'"
Here's the full code snippet:
public string GroupMembers(string targethost, string groupname, string targetusername, string targetpassword)
{
StringBuilder result = new StringBuilder();
try
{
ConnectionOptions Conn = new ConnectionOptions();
if (targethost != Environment.MachineName) //WMI errors if creds given for localhost
{
Conn.Username = targetusername; //can be null
Conn.Password = targetpassword; //can be null
}
Conn.Timeout = TimeSpan.FromSeconds(2);
ManagementScope scope = new ManagementScope("\\\\" + targethost + "\\root\\cimv2", Conn);
scope.Connect();
StringBuilder qs = new StringBuilder();
qs.Append("SELECT PartComponent FROM Win32_GroupUser WHERE GroupComponent = \"Win32_Group.Domain='");
qs.Append(targethost);
qs.Append("',Name='");
qs.Append(groupname);
qs.AppendLine("'\"");
ObjectQuery query = new ObjectQuery(qs.ToString());
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
{
ManagementPath path = new ManagementPath(m["PartComponent"].ToString());
{
String[] names = path.RelativePath.Split(',');
result.Append(names[0].Substring(names[0].IndexOf("=") + 1).Replace("\"", " ").Trim() + "\\");
result.AppendLine(names[1].Substring(names[1].IndexOf("=") + 1).Replace("\"", " ").Trim());
}
}
return result.ToString();
}
catch (Exception e)
{
Console.WriteLine("Error. Message: " + e.Message);
return "fail";
}
}
So, if I invoke Groupmembers("Server1", "Administrators", "myusername", "mypassword"); I get a single string returned with:
SERVER1\Administrator
MYDOMAIN\Domain Admins |
In bioinformatics when you align two sequences you can have a model that will have a different cost based on if it's a transition or a transversion. This is exactly what you want but instead of a 4x4 matrix, you want a 40x40 matrix or some, need i say distance function? So the cost of a replacement is from the matrix/function, not a constant.
**CAVEAT: Be sure that deletions and insertions are weighted properly though so they aren't over accepted as the minimum. You'll just have a string of insertions/deletions and every character that matches otherwise.**
int LevenshteinDistance(char s[1..m], char t[1..n])
// d is a table with m+1 rows and n+1 columns
declare int d[0..m, 0..n]
for i from 0 to m
d[i, 0] := i
for j from 0 to n
d[0, j] := j
for i from 1 to m
for j from 1 to n
{
**if s[i] = t[j] then cost := 0
else cost := 1**
d[i, j] := minimum(
d[i-1, j] + 1, // deletion
d[i, j-1] + 1, // insertion
d[i-1, j-1] + cost // substitution
)
}
return d[m, n]
That cost, surrounded by the double-stars, is now a function (or a table/matrix) that represents the cost of that transition from s[i] to j[i]... Clearly I didn't change the deletion or insertion cost. But you need to assess what is best for what you want to achieve.
|
In bioinformatics when you align two sequences of DNA you might have a model that has a different cost based on if the substitution is a transition or a transversion. This is exactly what you want but instead of a 4x4 matrix, you want a 40x40 matrix or some, dare I say distance function? So the cost of a replacement is from the matrix/function, not a constant.
**CAVEAT: Be sure that deletions and insertions are weighted properly though, so they aren't over accepted as the minimum. You'll end up with a string of insertions/deletions/no-change-substitution characters.**
The new function you are trying to minimize would be:
d[i, j] := minimum(
d[i-1, j] + del_cost,
d[i, j-1] + ins_cost,
d[i-1, j-1] + keyboard_distance( s[i], t[j] )
) |
Windows XP support for Remote NDIS |
|windows|embedded|usb|drivers|ndis| |
I'm looking at developing a device which will need to support Ethernet over USB (hosted in Linux, XP, and Vista). As I understand it, Vista and Linux support the industry standard USB CDC. However, in classic Windows style, XP only supports it's own Remote NDIS. So, now I'm thinking of just bowing down and doing it over RNDIS, as opposed to rolling my own CDC driver for XP.
I've been reading some older documentation that says even XP is pretty buggy with NDIS (suprise!). Does anyone have experience with XP's RNDIS drivers? Are they safe for product development? Any insight would be much appreciated. |
sys.argv[0] usually contains this information.
Check the [sys documentation][1] for more details.
[1]: http://docs.python.org/lib/module-sys.html |
It's not entirely clear what you mean by "the filepath of the file that is currently running within the process".
`sys.argv[0]` usually contains the location of the script that was invoked by the Python interpreter.
Check the [sys documentation][1] for more details.
As @[Tim](#50521) and @[Pat Notz](#50505) have pointed out, the \_\_file\_\_ attribute provides access to
> the file from which the module was
> loaded, if it was loaded from a file
[1]: http://docs.python.org/lib/module-sys.html |
You can easily simulate user input. You can submit form on the web page from you program by sending post\get request to a website.
Typical login form looks like:
<form name="loginForm" method="post" Action="target_page.html">
<input type="Text" name="Username">
<input type="Password" name="Password">
</form>
You can send a post request to the website providing values for Username & Password fields. What happens after you send your request is largely depends on a website, usually you will be redirected to some page. You authorization info will be stored in the sessions\cookie. So if you scrape client can maintain web session\understands cookies you will be able to access protected pages.
It's not clear from your question what language\framework you're going to use. For example there is a framework for screen scraping (including login functionality) written in perl - [WWW::Mechanize][1]
Note, that you can face some problems if site you're trying to login to uses java scripts or some kind of CAPTCHA.
[1]: http://search.cpan.org/dist/WWW-Mechanize/ |
Free JSP plugin for eclipse? |
|eclipse|jsp| |
I was looking out for a free plugin for developing/debugging JSP pages in eclipse.
Any suggestions? |
Read this article on Chrome and Open Source on Linux:
<http://arstechnica.com/journals/linux.ars/2008/09/02/google-unveils-chrome-source-code-and-linux-port>
The Google V8 JavaScript Engine is also open source and available here if you want to contribute;
<http://code.google.com/p/v8/>
If you want to contribute on Chronium, here are the instructions:
<http://dev.chromium.org/developers/contributing-code>
>
> [Chromium][1] is an open-source browser
> project that aims to build a safer,
> faster, and more stable way for all
> Internet users to experience the web.
> This site contains design documents,
> architecture overviews, testing
> information, and more to help you
> learn to build and work with the
> Chromium source code.
Here is how you can get started:
<http://dev.chromium.org/developers/how-tos/getting-started>
[1]: http://dev.chromium.org/Home |
Read this article on Chrome and Open Source on Linux:
<http://arstechnica.com/journals/linux.ars/2008/09/02/google-unveils-chrome-source-code-and-linux-port>
The Google V8 JavaScript Engine is also open source and available here if you want to contribute;
<http://code.google.com/p/v8/>
If you want to contribute on Chronium, here are the instructions:
<http://dev.chromium.org/developers/contributing-code>
>
> [Chromium][1] is an open-source browser
> project that aims to build a safer,
> faster, and more stable way for all
> Internet users to experience the web.
> This site contains design documents,
> architecture overviews, testing
> information, and more to help you
> learn to build and work with the
> Chromium source code.
Here is how you can get started:
<http://dev.chromium.org/developers/how-tos/getting-started>
----------
EDIT: Two more questions was added to the original question.
Building on Linux requires the following software:
- Subversion >= 1.4
- pkg-config >= 0.20
- Python >= 2.4
- Perl >= 5.x
- gcc/g++ >= 4.2
- bison >= 2.3
- flex >= 2.5.34
- gperf >= 3.0.3
- libnss3-dev >= 3.12
On Ubuntu 8.04, you can fetch all of the above as follows:
$ sudo apt-get install subversion pkg-config python perl g++ bison flex gperf libnss3-dev
> **Note**: There is no working
> Chromium-based browser on Linux.
> Although many Chromium submodules
> build under Linux and a few unit tests
> pass, all that runs is a command-line
> "all tests pass" executable.
[1]: http://dev.chromium.org/Home |
You could try integrating Sphinx with [Asterisk][1]:
- [http://www.syednetworks.com/asterisk-integration-with-sphinx-voice-recognition-system][2]
- [http://www.voip-info.org/wiki/view/Sphinx][3]
[1]: http://www.asterisk.org/
[2]: http://www.syednetworks.com/asterisk-integration-with-sphinx-voice-recognition-system
[3]: http://www.voip-info.org/wiki/view/Sphinx |
Reflection is a set of functions which allows you to access the runtime information of your program and modify it behavior (with some limitations).
It's useful because it allows you to change the runtime behaivour depending on the meta information of your program, that is, you can check the return type of a function and change the way you handle the situation.
In C# for example you can load an assembly (a .dll) in runtime an examine it, navigating through the classes and taking actions according to what you found. It also let you create an instance of a class on runtime, invoke its method, etc.
Where can it be useful? Is not useful everytime but for concrete situations. For example you can use it to get the name of the class for loggin purposes, to dinamically create handlers for events according to what's specified on a configuration file and so on... |
Not every language supports reflection but the principles are usually the same in languages that support it.
Reflection is the ability to "reflect" on the structure of your program. Or more concrete. To look at the objects and classes you have and programmatically get back information on the methods, fields, and interfaces they implement. You can also look at things like annotations.
It's usefull in a lot of situations. Everywhere you want to be able to dynamically plug in classes into your code. Lot's of object relational mappers use reflection to be able to instantiate objects from databases without knowing in advance what objects they're going to use. Plug-in architectures is another place where reflection is usefull. Being able to dynamically load code and determine if there are types there that implement the right interface to use as a plugin is important in those situations. |
Most programmers don't like to stray out of their comfort zones (note that the intersection of the 'most programmers' set and the 'Stack Overflow' set is the probably the empty set). "If it worked before (or even just worked) then keep on doing it". The project I'm currently on required a lot of argument to get the older programmers to use XML/schemas/data sets instead of just CSV files (the previous version of the software used CSV's). It's not perfect, the schemas aren't robust enough at validating the data. But it's a step in the right direction. The code I develop uses OO abstractions on the data sets rather than passing data set objects around. Generally, it's best to teach by example, one small step at a time.
Skizz |
The name reflection is used to describe code which is able to inspect other code in the same system (or itself).
For example, say you have an object of an unknown type in Java, and you would like to call a 'doSomething' method on it if one exists. Java's static typing system isn't really designed to support this unless the object conforms to a known interface, but using reflection, your code can look at the object and find out if it has a method called 'doSomething', and then, call it if you want to.
One very common case in Java is the usage with annotations. JUnit 4, for example, will use reflection to look through your classes for methods tagged with the @Test annotation, and will then call them when running the unit test.
There are some good reflection examples to get you started at [http://java.sun.com/developer/technicalArticles/ALT/Reflection/index.html][1]
[1]: http://java.sun.com/developer/technicalArticles/ALT/Reflection/index.html |
Backup and Restore is the most straight-forward way I know. You have to be careful between servers as security credentials don't come with the restored database. |
Sounds like you might like [Git][1]. There's a Google Talk [explaining all about it][2].
[1]: http://git.or.cz/
[2]: http://www.youtube.com/watch?v=4XpnKHJAok8 |
If you are consuming your Web service from a .NET page/application, you should be able to access the enumeration after you add your Web reference to the project that is consuming the service. |
From the [preg_replace documentation][1] on php.net:
> *replacement* may contain references of
> the form \\n or (since PHP 4.0.4) $n,
> with the latter form being the
> preferred one. Every such reference
> will be replaced by the text captured
> by the n'th parenthesized pattern.
See Flubba's example.
[1]: http://us.php.net/manual/en/function.preg-replace.php |
Its probably not exactly what your looking for, but you may be able to implement OS level clustering. |
I like [TestDriven.NET][1] (even though I use ReSharper) and I'm pretty happy with [XUnit.net][2]. It uses Facts instead of Tests which many people dislike but I like the difference in terminology. It's useful to think of a collection of automatically provable Facts about your software and see which ones you violate when you make a change.
Be aware that [Visual Studio 2008 Professional (and above) now comes with integrated Unit Testing][3] (it used to be available only with the Team System Editions) and may be suitable for your needs.
[1]: http://www.testdriven.net/overview.aspx
[2]: http://www.codeplex.com/xunit
[3]: http://blogs.msdn.com/buckh/archive/2007/03/27/orcas-unit-testing-to-be-available-in-visual-studio-professional.aspx |
*@Dillie-O: Your answer put me in the right direction (I should have expected it to just be a registry change) and I got this working. But I'm going to mark this as the answer because I'm going to put some additional information that I found while working on this.*
The solution to this question really doesn't matter what programming language you're using, as long as there's some way to modify Windows registry settings.
- To associate a program with the mailto protocol for **all users** on a computer, change the HKEY_CLASSES_ROOT\mailto\shell\open\command Default value to:
"*Your program's executable*" "%1"
- To [associate a program with the mailto protocol for the **current user**](http://windowsxp.mvps.org/permail.htm), change the HKEY_CURRENT_USER\Software\Classes\mailto\shell\open\command Default value to:
"*Your program's executable*" "%1"
The %1 will be replaced with the entire mailto URL, for example, given the link:
<a href="mailto:user@example.com">Email me</a>
The following will be executed:
"*Your program's executable*" "mailto:user@example.com"
Note: [The mailto syntax allows for more than just the email address](http://www.ianr.unl.edu/internet/mailto.html). |
*@Dillie-O: Your answer put me in the right direction (I should have expected it to just be a registry change) and I got this working. But I'm going to mark this as the answer because I'm going to put some additional information that I found while working on this.*
***Edit:** So I can't mark this as the answer, probably because I don't have enough reputation. So if people see this, at least upmod it, and if you upmodded another answer here, please un-upmod it. That way people will actually be able to see this answer.*
The solution to this question really doesn't matter what programming language you're using, as long as there's some way to modify Windows registry settings.
- To associate a program with the mailto protocol for **all users** on a computer, change the HKEY_CLASSES_ROOT\mailto\shell\open\command Default value to:
"*Your program's executable*" "%1"
- To [associate a program with the mailto protocol for the **current user**](http://windowsxp.mvps.org/permail.htm), change the HKEY_CURRENT_USER\Software\Classes\mailto\shell\open\command Default value to:
"*Your program's executable*" "%1"
The %1 will be replaced with the entire mailto URL, for example, given the link:
<a href="mailto:user@example.com">Email me</a>
The following will be executed:
"*Your program's executable*" "mailto:user@example.com"
Note: [The mailto syntax allows for more than just the email address](http://www.ianr.unl.edu/internet/mailto.html). |
Context Menu Resets ComboBox's SelectedIndex |
|contextmenu|combobox|selectedindex| |
I have a ContextMenu that is displayed after a user right clicks on a ComboBox. When the user selects an item in the context menu, a form is brought up using the ShowDialog() method.
If frmOptions.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
LoadComboBoxes()
End If
When that form is closed, I refresh all the data in the ComboBoxes on the parent form. However, when this happens the ComboBox that opened the ContextMenu is reset to have a selected index of -1 but the other selected indexes of the other ComboBoxes remain the same.
How do I prevent the ComboBox that opened the context menu from being reset? |
|.net|winforms|combobox|contextmenu|selectedindex| |
Dim arr(3, 3) As Integer
Dim y As Integer
Dim x As Integer
For x = 0 To arr.Rank - 1
For y = 0 To arr.GetLength(x) - 2
arr(x, y) = x + y
Next
Next
The above code worked for me.
Edit, the code feels dirty though. I'm wondering what it is you are trying to accomplish? |
multiple top level windows are easy to implement and have all the advantages of MDI - that's what MS selected for the newer versions of Office |
There have been cases where the tools (capital) a company has purchased is worth more than the company, and the company is purchased and gutted just to obtain those tools at a discount.
This is bad for the company, of course, but the tool vender especially doesn't want this to happen - they lose a potential full-price customer for software where there is no real competitor. Further, the company that originally purchased the tool doesn't mind the contract because it helps prevent acquisitions based only on getting the capital. (Corollary: If your company is negotiating out of such a contract, get ready to be purchased...)
For tools that are very, very expensive, this is not unheard of. Think 10's of thousands of dollars per seat, and you can see why this economy becomes reality.
-Adam |
There have been cases where the tools (capital) a company has purchased is worth more than the company, and the company is purchased and gutted just to obtain those tools at a discount.
This is bad for the company, of course, but the tool vender especially doesn't want this to happen - they lose a potential full-price customer for software where there is no real competitor. Further, the company that originally purchased the tool doesn't mind the contract because it helps prevent acquisitions based only on getting the capital. (Corollary: If your company is negotiating out of such a contract, get ready to be purchased...)
For tools that are very, very expensive, this is not unheard of. Think 10's of thousands of dollars per seat, and you can see why this economy becomes reality. Further, sometimes tools are purchased for the company by a client (DoD) and they are actually a small company ( a few developers that won a nice contract) - if the client does not retain the license, then the company might go bust and the license sold for pennies on the dollar at an auction to pay creditors.
Etc, etc, etc. In short, very, very expensive licenses change the economic playground enough that very strange rules apply. Note that "expensive" may also mean scarce, as in the case of liquor licenses for restaurants, or otherwise difficult to get (Qualcomm might not want to sell a given company a license for their CDMA patents, but they may not be able to legally prevent that company from acquiring such a license through legal methods).
-Adam |
Compile a PHP script in Linux |
|php|linux| |
I know php scripts don't actually compile until they are run. However say I want to create a small simple program and compile it to a binary without requiring the php binary. How could I do this?
I'v seen a few IDE's out there that would do this, but either they are all for windows or the linux versions don't actually build properly.
What I would like is something like py2exe that does it in the script itself. |
Many of the above, plus TED talks and Shareware Radio. Links here: <http://successfulsoftware.net/category/podcasts/> |
I second Tom's answer that you should pick the one that is easier to understand and maintain.
The query plan of any query in any database cannot be predicted because you haven't given us indexes or data distributions. The only way to predict which is faster is to run them against *your* database.
As a rule of thumb I tend to use sub-selects when I do not need to include any columns from tblB in my select clause. I would definitely go for a sub-select when I want to use the 'in' predicate (and usually for the 'not in' that you included in the question), for the simple reason that these are easier to understand when you or someone else has come back and change them. |
Having a normalized database will give you the most flexibility and the easiest maintenance. I always start with a normalized database and then un-normalize only when there is an real life problem that needs addressing.
I view this similarly to code performance i.e. write maintainable, flexible code and make compromises for performance when you *know* that there is a performance problem. |
SharePoint Infrastructure Upgrade - whoops |
|sharepoint| |
I applied the MOSS infrastructure upgrade w/o applying the WSS one before it -- uh, help! |
I am very heavy into Java development and I personally use Ubuntu, so I agree with Sean on this one.
The package manager allows you to easily install the various SDKs (the SUN one, or even the upcoming OpenJDK 7).
Regards,
Arjen |
You can try [Webrenderer][1] or [Ice Browser][2]
[1]: http://www.webrenderer.com/products/swing/product/
[2]: http://www.icesoft.com/products/icebrowser.html |
FiveRuns have a gem named [DataFabric][1] that does application-level sharding and master/slave replication. It might be worth checking out.
[1]: http://blog.fiveruns.com/2008/7/9/introducing-data_fabric |
Django has a built in template helper for this exact scenario:
http://www.djangoproject.com/documentation/templates/#unordered-list |
There is this: http://www.bambalam.se/bamcompile/ but that compiles to Windows bytecode. There are a few others, but all I have seen will compile for windows only.<br /><br />Few More:
<br />http://www.nusphere.com/products/phpdock.htm |
There is this: http://www.bambalam.se/bamcompile/ but that compiles to Windows bytecode. There are a few others, but all I have seen will compile for windows only.<br /><br />Few More:
<br />http://www.nusphere.com/products/phpdock.htm
Edit: I almost forgot if your looking to make it work on linux without regard for windows you can just add
#!/usr/bin/php
to the top of the script and you should be able to run it from the command line. Don't forget to chmod +x the file first.
|
The name reflection is used to describe code which is able to inspect other code in the same system (or itself).
For example, say you have an object of an unknown type in Java, and you would like to call a 'doSomething' method on it if one exists. Java's static typing system isn't really designed to support this unless the object conforms to a known interface, but using reflection, your code can look at the object and find out if it has a method called 'doSomething', and then, call it if you want to.
So, to give you a code example of this in Java (imagine the object in question is foo) :
Method method = foo.getClass().getMethod("doSomething", null);
method.invoke(foo, null);
One very common use case in Java is the usage with annotations. JUnit 4, for example, will use reflection to look through your classes for methods tagged with the @Test annotation, and will then call them when running the unit test.
There are some good reflection examples to get you started at [http://java.sun.com/developer/technicalArticles/ALT/Reflection/index.html][1]
And finally, yes, the concepts are pretty much similar in other statically types languages which support reflection (like C#). In dynamically typed languages, the use case described above is less necessary (since the compiler will allow any method to be called on any object, failing at runtime if it does not exist), but the second case of looking for methods which are marked or work in a certain way is still common.
[1]: http://java.sun.com/developer/technicalArticles/ALT/Reflection/index.html |
Displaying XML data in a Winfoms control |
|xml|winforms|formatting|c#| |
I would like to display details of an xml error log to a user in a winforms application and am looking for the best control to do the job.
The error data contains all of the sever variables at the time that the error occurred. These have been formatted into an XML document that looks something to the effect of:
<error>
<serverVariables>
<item>
<value>
</item>
</serverVariables>
<queryString>
<item name="">
<value string="">
</item>
</queryString>
</error>
I would like to read this data from the string that it is stored in and display it to the user via a windows form in a useful way. XML Notepad does a cool job of formatting xml, but is not really was I am looking for since I would prefer to rather display item details in a *Name : string* format.
Any suggestions or am I looking and a custom implementation?
|
|c#|xml|winforms|formatting| |
I would like to display details of an xml error log to a user in a winforms application and am looking for the best control to do the job.
The error data contains all of the sever variables at the time that the error occurred. These have been formatted into an XML document that looks something to the effect of:
<error>
<serverVariables>
<item>
<value>
</item>
</serverVariables>
<queryString>
<item name="">
<value string="">
</item>
</queryString>
</error>
I would like to read this data from the string that it is stored in and display it to the user via a windows form in a useful way. XML Notepad does a cool job of formatting xml, but is not really was I am looking for since I would prefer to rather display item details in a *Name : string* format.
Any suggestions or am I looking and a custom implementation?
[EDIT] A section of the data that needs to be displayed:
<?xml version="1.0" encoding="utf-8"?>
<error host="WIN12" type="System.Web.HttpException" message="The file '' does not exist." source="System.Web" detail="System.Web.HttpException: The file '' does not exist. at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath) at" time="2008-09-01T07:13:08.9171250+02:00" statusCode="404">
<serverVariables>
<item name="ALL_HTTP">
<value string="HTTP_CONNECTION:close HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) " />
</item>
<item name="AUTH_TYPE">
<value string="" />
</item>
<item name="HTTPS">
<value string="off" />
</item>
<item name="HTTPS_KEYSIZE">
<value string="" />
</item>
<item name="HTTP_USER_AGENT">
<value string="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)" />
</item>
</serverVariables>
<queryString>
<item name="tid">
<value string="196" />
</item>
</queryString>
</error>
|
Try to write code to be more flexible. For example, if you have a method that accepts an array as a parameter, would you be able to accept an IEnumerable or IList instead? |
We use 50. |
The site GetSatisfaction has been an increasingly popular way to get customer feedback.
http://getsatisfaction.com/for_companies
GetSatisfaction is a community based site that builds a community around your application. Users can post questions, comments, and feedback about and application and get answers to their questions either from other members or from members of the development team themselves.
They also have an API so you can incorporate GetSatifaction into your app, and/or your site.
I've been playing with it for a couple of weeks and it is pretty cool. Kind of like stackoverflow, but for customer feedback. |
If it's full name in one field, I usually go with 128 - 64/64 for first and last in separate fields - you just never know. |
I usually go with varchar(255) (255 being the maximum length of a varchar type in MySQL). |
@Jonathan Holland I saw that you were voted down, but that is a VERY VALID point. I have been reading some posts around the intertubes where people seem to be confusing ASP.NET MVC *[the framework][1]* and MVC *[the pattern][2]*.
MVC in of itself is a **DESIGN PATTERN**. If all you are looking for is a "separation of concerns" then you can certainly achieve that with webforms. Personally, I am a big fan of the [MVP pattern][3] in a standard n-tier environment.
If you really want TOTAL control of your mark-up in the ASP.NET world, then MVC the ramework is for you.
[1]: http://www.asp.net/mvc/
[2]: http://en.wikipedia.org/wiki/Model-view-controller
[3]: http://msdn.microsoft.com/en-us/magazine/cc188690.aspx |
The dialog you're looking for is this one in the project properties:
![Platform target][1]
(linked from [this blog][2])
by default, the target will be "Any CPU" which means it'll run as 64bit on a 64bit OS (like you're using), or 32bit on a 32bit OS - so this wont stop it from working on 32bit systems. But like you said, to use Edit & Continue you will need to target x86 (so it runs as 32bit).
[1]: http://www.jameskovacs.com/blog/content/binary/WindowsLiveWriter/KeyboardJedionVistax64_98A8/image_thumb%5B9%5D_4.png
[2]: http://www.jameskovacs.com/blog/KeyboardJediOnVistaX64.aspx |
The dialog you're looking for is this one in the project properties:
![Platform target][1]
by default, the target will be "Any CPU" which means it'll run as 64bit on a 64bit OS (like you're using), or 32bit on a 32bit OS - so this wont stop it from working on 32bit systems. But like you said, to use Edit & Continue you will need to target x86 (so it runs as 32bit).
**Edit**: fixed screenshot (I had the C# one, not the VB one)
[1]: http://farm4.static.flickr.com/3193/2803506716_e4e1285f0b_o.jpg |
The average first name is about 6 letters. That leaves 43 for a last name. :) Seems like you could probably shorten it if you like.
The main question is how many rows do you think you will have? I don't think varchar(50) is going to kill you until you get several million rows. |
Django Sessions |
|django|python| |