instruction
stringlengths
0
30k
###What tools are available? This [article describes][1] another developers frustrations with lack of C++ code coverage tools. It looks like their search led them to a tool called **[Bullseye Coverage][2] which [supports many platforms][3] including MSVC6 for Windows *and* native c++ compilers under linux/unix (like gcc)**. Other tools like [gcov][4] are also mentioned in the article. I haven't used any C++ coverage tools myself, but if you find one that works for you, find a way to get coverage to launch via a make file. Then you can hook that make file into your continuous integration build process. ###Testing Linux vs Windows So long as all your tests run correctly in both environments, you should be fine measuring coverage on one or the other. (Though Bullseye appears [to support both platforms][5]). But why aren't you doing continuous integration builds in both environments?? If you deliver to clients in both environments then you *need* to be testing in both. For that reason, it sounds like you might need to have two continuous build servers set up, one for a linux build and one for a windows build. Perhaps this can be easily accomplished with some virtualization software like [vmware][6] or [virtualbox][7]. You may not need to run code coverage metrics on both OSs, but you should definitely be running your unit tests on both. [1]: http://www.kimbly.com/blog/000331.html [2]: http://www.bullseye.com/ [3]: http://www.bullseye.com/platform.html [4]: http://gcc.gnu.org/onlinedocs/gcc/Gcov.html [5]: http://www.bullseye.com/platform.html [6]: http://www.vmware.com/ [7]: http://www.virtualbox.org/
###Which tool should I use? This [article describes][1] another developers frustrations searching for C++ code coverage tools. The author's final solution was [Bullseye Coverage][2]. **[Bullseye Coverage][2] features:** * [Cross Platform Support][3] (win32, unix, and embedded), (supports linux gcc compilers and MSVC6) * [Easy to use][4] (up and running in a few hours). * [Provides "best" metrics][5]: Function Coverage and Condition/Decision Coverage. * Uses source code instrumentation. As for hooking into your continuous integration, it depends on which CI solution you use, but you can likely hook the instrumentation / coverage measurement steps into the make file you use for automated testing. --- ###Testing Linux vs Windows? So long as all your tests run correctly in both environments, you should be fine measuring coverage on one or the other. (Though Bullseye appears [to support both platforms][3]). But why aren't you doing continuous integration builds in both environments?? If you deliver to clients in both environments then you *need* to be testing in both. For that reason, it sounds like you might need to have two continuous build servers set up, one for a linux build and one for a windows build. Perhaps this can be easily accomplished with some virtualization software like [vmware][6] or [virtualbox][7]. You may not need to run code coverage metrics on both OSs, but you should definitely be running your unit tests on both. [1]: http://www.kimbly.com/blog/000331.html [2]: http://www.bullseye.com/ [3]: http://www.bullseye.com/platform.html [4]: http://www.bullseye.com/usability.html [5]: http://www.bullseye.com/measurementTechnique.html [6]: http://www.vmware.com/ [7]: http://www.virtualbox.org/
> But how does this handle language specific sorting rules? Does it take locale into account? No, `list.sort()` is a generic sorting function. If you want to sort according to the Unicode rules, you'll have to define a custom sort key function. You can try using the [pyuca](http://jtauber.com/blog/2006/01/27/python_unicode_collation_algorithm/) module, but I don't know how complete it is.
"23||45||45||56||67".replace(/^([0-9]+\|\|){n}([0-9]+)\|\|,"$1$2&&")); where n is the one less than the nth pipe, (of course you don't need that first subexpression if n = 0)
"23||45||45||56||67".replace(/^([0-9]+\|\|){n}([0-9]+)\|\|/,"$1$2&&") where n is the one less than the nth pipe, (of course you don't need that first subexpression if n = 0)
here's something that works: "23||45||45||56||67".replace(/^((?:[0-9]+\|\|){n})([0-9]+)\|\|/,"$1$2&&") where n is the one less than the nth pipe, (of course you don't need that first subexpression if n = 0)
here's something that works: "23||45||45||56||67".replace(/^((?:[0-9]+\|\|){n})([0-9]+)\|\|/,"$1$2&&") where n is the one less than the nth pipe, (of course you don't need that first subexpression if n = 0) And if you'd like a function to do this: function pipe_replace(str,n) { var RE = new RegExp("^((?:[0-9]+\\|\\|){" + (n-1) + "})([0-9]+)\|\|"); return str.replace(RE,"$1$2&&"); }
Here's how I do it in C++ using GCC libraries: #include <execinfo.h> // Backtrace #include <cxxabi.h> // Demangling vector<Str> backtrace(size_t numskip) { vector<Str> result; std::vector<void*> bt(100); bt.resize(backtrace(&(*bt.begin()), bt.size())); char **btsyms = backtrace_symbols(&(*bt.begin()), bt.size()); if (btsyms) { for (size_t i = numskip; i < bt.size(); i++) { Aiss in(btsyms[i]); int idx = 0; Astr nt, addr, mangled; in >> idx >> nt >> addr >> mangled; if (mangled == "start") break; int status = 0; char *demangled = abi::__cxa_demangle(mangled.c_str(), 0, 0, &status); Str frame = (status==0) ? Str(demangled, demangled+strlen(demangled)) : Str(mangled.begin(), mangled.end()); result.push_back(frame); free(demangled); } free(btsyms); } return result; } Your exception's constructor can simply call this function and store away the stack trace. It takes the param `numskip` because I like to slice off the exception's constructor from my stack traces.
Best .NET obfuscation tools/strategy
|.net|security|obfuscation|
My product is both ASP.NET, Windows forms app and Windows service. 95% of code is .NET (VB if you must know). For IP reasons, I need to obfuscate the code. I am using an old dotfuscator (over 5 years old) and thinking it is time to move to a new gen. Anyone can recommend from his personal experience (don't just give me a list of vendors, I already have that) what works best for him? Taking into account real life issues like: - Dealing with the old problem of serialization/de-serialization: Currently, I simply tell the tool **not** to obfuscate any class data members. The pain of not being able to load data that was previously serialized with an old version is just to big - integrating the tool into the build process? - Working with ASP.NET which is a story since depending ont eh settings, you don't always have the same dll names (and you have lots of them, one per page), not all tools handle this well.
Distributed File System (DFS) is good for content, especially if each server (or a number of servers) host a replica synced up with File Replication Service (FRS). So if you've got two servers, each has a complete replica, so one going down doesn't mean the site goes down. If all servers in your 'cluster' will host a replica, the home directory in IIS can be configured to go against the local drive (e.g., D:). If you have more servers than replicas, then you should use the DFS mount point (\\domainname\dfsmountpointname).
Classes design decision
|oop|asp.net-membership|inheritance|
ASP.NET Membership - Class design decision
|oop|asp.net|inheritance|asp.net-providers|
Class design decision
|inheritance|oop|asp.net-membership|
I have a little dilemma that maybe you can help me sort out. I've been working today in modifying ASP.NET's Membership to add a level of indirection. Basically, ASP.NET's Membership supports Users and Roles, leaving all authorization rules to be based on whether a user belongs to a Role or not. What I need to do is add the concept of Function, where a user will belong to a role (or roles) and the role will have one or more functions associated with them, allowing us to authorize a specific action based on if the user belongs to a role which has a function assigned. Having said that, my problem has nothing to do with it, it's a generic class design issue. I want to provide an abstract method in my base RoleProvider class to create the function (and persist it), but I want to make it optional to save a description for that function, so I need to create my CreateFunction method with an overload, one signature accepting the name, and the other accepting the name and the description. I can think of the following scenarios: 1. Create both signatures with the abstract modifier. This has the problem that the implementer may not respect the best practice that says that one overload should call the other one with the parameters normalized, and the logic should only be in the final one (the one with all the parameters). Besides, it's not nice to require both methods to be implemented by the developer. 2. Create the first like virtual, and the second like abstract. Call the second from the first, allow the implementer to override the behavior. It has the same problem, the implementer could make "bad decisions" when overriding it. 3. Same as before, but do not allow the first to be overriden (remove the virtual modifier). The problem here is that the implementer has to be aware that the method could be called with a null description and has to handle that situation. I think the best option is the third one... How is this scenario handled in general? When you design an abstract class and it contains overloaded methods. It isn't that uncommon I think...
Register Multiple Assemblies to the GAC in Vista
|.net|gac|gacutil|
I've got a whole directory of dll's I need to register to the GAC. I'd like to avoid registering each file explicitly- but it appears that gacutil has no "register directory" option. Anyone have a fast/simple solution?
It should work on any POSIX system. However: `os.kill` may also fail if you don't have permission to signal the process. You would need to do something like: import sys import os import errno try: os.kill(int(sys.argv[1]), 0) except OSError, err: if err.errno == errno.ESRCH: print "Not running" elif err.errno == errno.EPERM: print "No permission to signal this process!" else: print "Unknown error" else: print "Running"
It should work on any POSIX system (although looking at the `/proc` filesystem, as others have suggested, is easier if you know it's going to be there). However: `os.kill` may also fail if you don't have permission to signal the process. You would need to do something like: import sys import os import errno try: os.kill(int(sys.argv[1]), 0) except OSError, err: if err.errno == errno.ESRCH: print "Not running" elif err.errno == errno.EPERM: print "No permission to signal this process!" else: print "Unknown error" else: print "Running"
The reason that the expression is cast to double-precision is because the literals specified are double-precision values by default. If you specify the literals used in the equation as floats, the expression will return a float. Consider the following code (Mac OS X using gcc 4.01). #include <stdio.h> int main() { float celsius; float fahr = 212; printf("sizeof(celsius) ---------------------> %d\n", sizeof(celsius)); printf("sizeof(fahr) ------------------------> %d\n", sizeof(fahr)); printf("sizeof(double) ----------------------> %d\n", sizeof(double)); celsius = (5.0f/9.0f) * (fahr-32.0f); printf("sizeof((5.0f/9.0f) * (fahr-32.0f)) --> %d\n", sizeof((5.0f/9.0f) * (fahr-32.0f))); printf("sizeof((5.0/9.0) * (fahr-32.0)) -----> %d\n", sizeof((5.0/9.0) * (fahr-32.0))); printf("celsius -----------------------------> %f\n", celsius); } Output is: sizeof(celsius) ---------------------> 4 sizeof(fahr) ------------------------> 4 sizeof(double) ----------------------> 8 sizeof((5.0f/9.0f) * (fahr-32.0f)) --> 4 sizeof((5.0/9.0) * (fahr-32.0)) -----> 8 celsius -----------------------------> 100.000008
IronRuby performance?
|.net|ruby|performance|ironruby|
While I know IronRuby isn't quite ready for the world to use it, I was wondering if anyone here tried it and tested how well it faired against the other Rubies out there in terms of raw performance? If so, what are the results, and how did you go about measuring the performance (which benchmarks etc)?
Is it signed? Also are you trying to use the debug visualizer in the same host process as the application you are trying to debug? Try compiling the visualizer and then just reference it by it's library and file location not the project.
What are Class methods in Python for?
|python|
Map Routing, a la Google Maps?
|mapping|gis|
I've always been intrigued by Map Routing, but I've never found any good introductory (or even advanced!) level writeups talking about it. Does anybody have any pointers, hints, etc?
|gis|mapping|
I've always been intrigued by Map Routing, but I've never found any good introductory (or even advanced!) level writeups talking about it. Does anybody have any pointers, hints, etc? update: I'm primarily looking for pointer as to how a map system is implemented, data structures, algorithms, etc.
I would use an auto incrementing number usually an int. You want to keep the size of the key as small as possible. This keeps your index small and benefits any foreign keys as well. Additonally you are not tightly coupling the data design to external user data (this holds true for the aspnet GUID as well). Generally GUIDs don't make good primary keys as they are large and inserts can happen at potentially any data page within the table rather than at the last data page. The main exception to this is if you are running mutilple replicated databases. GUIDs are very useful for keys in this scenario, but I am guessing you only have one database so this is not a problem.
Whats the best way to shift an array of bytes by 12-bits?
|c|gcc|
With gcc, I want to shift contents of an array of bytes by 12-bit to the left. For example, starting with this array: <pre><code>uint8_t shift[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0x0A, 0xBC};</code></pre> I'd like to shift it to the left by 12-bits resulting in: <pre><code>0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAB, 0xC0, 0x00</code></pre>
With gcc, I want to shift the contents of an array of bytes by 12-bit to the left. For example, starting with this array: <pre><code>uint8_t shift[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0x0A, 0xBC};</code></pre> I'd like to shift it to the left by 12-bits resulting in: <pre><code>0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAB, 0xC0, 0x00</code></pre>
Ignoring ORM (not because I'm either for or against it) I would keep them in the same class. They are both facets of a single responsibility and separating them just makes you look in two places where I can't really think of a good reason you would want to do that.
Why stateless session beans are single threaded ?
|java|ejb|
As per my understanding stateless session beans are used to code the business logic. They can not store data in their instance variables because their instance is shared by multiple requests. So they seem to be more like Singleton classes. However the difference is contain creates (or reuses from pool) the separate instance of stateless session beans for every request. After googling I could find the reasoning that the JEE specifiaction says they are suppose to be single threaded. But I can't get the reason why the are specified to be **SINGLE THREADED** ? Thanks in advance.
Well. The rule for refactoring is. Do unit tests. So maybe first you should place some unittests at least for the core/major things. The ORM should be designed for decreasing boilerplate code. The time/trouble vs. ROI to be enterprisy is up to you to estimate :)
I haven't looked up the whole thing, but the problem lies somewhere in the style sheets. If you copy out only the table part of it, it is displaying the map correctly. If you remove the final `</span>` tag from this part, it is also working (however the page gets mixed): <div class="inner"><span class="corners-top"><span></span></span> <div class="content" style="font-size: 1.1em;"> <!-- Stackoverflow findy thingy --> <table border="0" cellspacing="0" cellpadding="0"> So either try from the beginning with the css or try to remove one-by-one them, to see, which is causing the problem.
I heard that TypeMock is often being used to refactor legacy code.
Phil's answer really solved it, but I'll elaborate a little more. Since the epoch is in UTC, if I want to compare other times to the epoch, I need to interpret them as UTC as well. >>> calendar.timegm((2009, 1, 31, 0, 0, 0, 5, 31, -1)) 1233360000 >>> 1233360000 / (60*60*24) 14275 By converting the time tuple to a timestamp treating is as UTC time, I get a number which *is* evenly divisible by the number of seconds in a day. I can use this to convert a date to a days-from-the-epoch representation which is what I'm ultimately after.
You can use the `<probing>` element in a manifest file to tell the Runtime to look in different directories for its assembly files. <http://msdn.microsoft.com/en-us/library/823z9h8w.aspx> e.g.: <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatePath="bin;bin2\subbin;bin3"/> </assemblyBinding> </runtime> </configuration>
I think OpenID is far too confusing and clunky to force on any user, and I'm not even convinced it's solving an authentic problem. Having to register on each site I use has never struck me as a major issue. Particularly as it doesn't especially solve that problem; when I linked my OpenID to StackOverflow I had to fill out extra details _anyway_. It might as well have had a regular registration process for all the difference it makes.
I think you need to use 'display: block' on your images.
I think you need to use 'display: block' on your images. When images are inline there's a little extra space for the line spacing.
I know this might sound bad, but you need to ensure there is no whitespace between then end of you `<img>` tag and the start of the end `</td>` tag. i.e. The following will present the problem: <td> <img src="image.jpg"/> </td> And this will not: <td><img src="image.jpg"/></td> Hope that helps.
I know this might sound bad, but you need to ensure there is no whitespace between then end of you `<img>` tag and the start of the end `</td>` tag. i.e. The following will present the problem: <td> <img src="image.jpg"/> </td> And this will not: <td><img src="image.jpg"/></td> Hope that helps. Edit: OK, that wasn't the solution at all. doh!
BerkeleyDB Concurrency
|c++|berkeleydb|
This isn't a question, just more seeking expert advice. What's the optimal level of concurrency that the C++ implementation of BerkeleyDB can reasonably support? How many threads can I have hammering away at the DB before throughput starts to suffer because of resource contention? I've read the manual and know how to set the number of locks, lockers, database page size, etc., but I'd just like some advice from someone who has real-world experience with BDB concurrency. My application is pretty simple, I'll be doing gets and puts of records that are about 1kb each. No cursors, no deleting.
|c++|berkeley-db|
Thanx to Daniel, but i needed it to be done inline ... here's the solution: = System.Text.RegularExpressions.Regex.Replace(StringWithHTMLtoStrip, "<[^>]+>","") here are the links: http://weblogs.asp.net/rosherove/archive/2003/05/13/6963.aspx http://msdn.microsoft.com/en-us/library/ms157328.aspx
For C, C++, C#, Java and other .NET languages boolean expressions are optimized so that as soon as enough is known nothing else is evaluated. An old trick for doing obfuscated code was to use this to create if statements, such as: a || b(); if "a" is true, "b()" would never be evaluated, so we can rewrite it into: if(!a) b(); and similarly: a && b(); would become if(a) b(); **Please note** that this is only valid for the || and && operator. The two operators | and & is bitwise or, and and, respectively, and are therefore not "optimised".
For C, C++, C#, Java and other .NET languages boolean expressions are optimised so that as soon as enough is known nothing else is evaluated. An old trick for doing obfuscated code was to use this to create if statements, such as: a || b(); if "a" is true, "b()" would never be evaluated, so we can rewrite it into: if(!a) b(); and similarly: a && b(); would become if(a) b(); **Please note** that this is only valid for the || and && operator. The two operators | and & is bitwise or, and and, respectively, and are therefore not "optimised". EDIT: As mentioned by others, trying to optimise code using short circuit logic is very rarely well spent time. First go for clarity, both because it is easier to read and understand. Also, if you try to be too clever a simple reordering of the terms could lead to wildly different behaviour without any apparent reason. Second, go for optimisation, but only after timing and profiling. Way too many developer do premature optimisation without profiling. Most of the time it's completely useless.
The philosophy that we follow at work is to keep the trunk in a state where you can push at any time without drastic harm to the site. This is not to say that the trunk will always be in a perfect state. There will of course be bugs in it. But the point is to never, ever leave it broken drastically. If you have a feature to add, branch. A design change, branch. There have been so many times where I thought, "oh I can just do this in the trunk it isn't going to take that long", and then 5 hours later when I can't figure out the bug that is breaking things I really wished that I had branched. When you keep the trunk clean you allow the opportunity to quickly apply and push out bug fixes. You don't have to worry about the broken code you have that you conveniently branched off.
My product is both ASP.NET, Windows forms app and Windows service. 95% of code is .NET (VB if you must know). For IP reasons, I need to obfuscate the code. I am using an old dotfuscator (over 5 years old) and thinking it is time to move to a new gen. Anyone can recommend from their personal experience (please don't just give me a list of vendors, I already have that) what works best for them? Taking into account real life issues like: - Dealing with the old problem of serialization/de-serialization: Currently, I simply tell the tool **not** to obfuscate any class data members. The pain of not being able to load data that was previously serialized with an old version is just to big - Integrating the tool into the build process? - Working with ASP.NET which is a story since depending on the settings, you don't always have the same dll names (and you have lots of them, one per page), and not all tools handle this well.
Something which is less Mozilla specific and should work reasonably well with most of the browsers: - Create a hidden form with the fields set up the way you need them - Make sure that the "target" attribute of the form is set to "_BLANK" - Submit the form programatically
There's a couple of different expression types in .ASPX files. There's: <%= TextFromMethod %> which simply reserves a literal control, and outputs the text at render time. and then there's: <%# TextFromMethod %> which is a databinding expression, evaluated when the control is DataBound(). There's also expression builders, like: <%$ ConnectionStrings:Database %> but that's not really important here.... So, the <%= %> method won't work because it would try to insert a Literal into the .Text property...obviously, not what you want. The <%# %> method doesn't work because the TextBox isn't DataBound, nor are any of it's parents. If your TextBox was in a Repeater or GridView, then this method would work. So - what to do? Just call TextBox.DataBind() at some point. Or, if you have more than 1 control, just call Page.DataBind() in your Page_Load. Private Function Page_Load(sender as Object, e as EventArgs) If Not IsPostback Then Me.DataBind() End If End Function
What are some alternative bitset data structures?
|data-structures|information-retrieval|
I have an information retrieval application that tracks bit sets with sizes on the order of 10s of millions. The number of "set" bits in the set varies widely, from none to all. Currently, I'm simply setting bits in an array (`java.util.BitSet`), so each bit set takes several megabytes. My plan is to look at the cardinality of the first *N* bits, then make a decision about what data structure to use for the remainder. Clearly some data structures are better for very sparse bit sets, and others when roughly half the bits are set (when most bits are set, I can use negation to treat it as a sparse set of zeroes). - What structures might be good at each extreme? - Are there any in the middle? Here are a few constraints or hints: 1. The bits are set only once, and in index order. 2. I need 100% accuracy, so something like a Bloom filter isn't good enough. 3. After the set is built, I need to be able to efficiently iterate over the "set" bits. 4. The bits are randomly distributed, so run-length&ndash;encoding algorithms aren't likely to be much better than a simple list of bit indexes. 5. I'm trying to optimize memory utilization, but speed still carries *some* weight. Something with an open source Java implementation is helpful, but not strictly necessary. I'm more interested in the fundamentals.
Tail recursion is well-described in previous answers, but I think an example in action would help to illustrate the concept. Consider a simple function that adds the first N integers. (e.g. `sum(5)=1+2+3+4+5=15`). Here is a simple Python implementation that uses recursion: def recsum(x): if x==1: return x else: return x+recsum(x-1) If you called `recsum(5)`, this is what the Python interpreter would evaluate. recsum(5) 5+recsum(4) 5+(4+recsum(3)) 5+(4+(3+recsum(2))) 5+(4+(3+(2+recsum(1)))) 5+(4+(3+(2+1))) 15 Note how every recursive call has to complete before the Python interpreter begins to actually do the work of calculating the sum. Here's a tail-recursive version of the same function: def tailrecsum(x,running_total=0): if x==0: return running_total else: return tailrecsum(x-1,running_total+x) Here's the sequence of events that would occur if you called `tailrecsum(5)`, (which would effectively be `tailrecsum(5,0)`, because of the default second argument). tailrecsum(5,0) tailrecsum(4,5) tailrecsum(3,9) tailrecsum(2,12) tailrecsum(1,14) tailrecsum(0,15) 15 In the tail-recursive case, with each evaluation of the recursive call, the `running_total` is updated.
> Should you ever use protected member variables? Depends on how picky you are about hiding state. - If you don't want any leaking of internal state, then declaring all your member variables private is the way to go. - If you don't really care that subclasses can access internal state, then protected is good enough. If a developer comes along and subclasses your class they may mess it up because they don't understand it fully. With private members, other than the public interface they can't see the implementation specific details of how things are being done which gives you the flexibility of changing it later. Sorry if this rambled a bit. Just my 2 cents.
For detailed info on .Net access modifiers [go here][1] There are no real advantages or disadvantages to protected member variables, it's a question of what you need in your specific situation. In general it is accepted practice to declare member variables as private and enable outside access through properties. Also, some tools (e.g. some O/R mappers) expect object data to be represented by properties and do not recognize public or protected member variables. But if you know that you want your subclasses (and ONLY your subclasses) to access a certain variable there is no reason not to declare it as protected. [1]: http://articles.techrepublic.com.com/5100-10878_11-1027680.html
The general feeling nowadays is that they cause undue coupling between derived classes and their bases. They have no particular advantage over protected methods/properties (once upon a time they might have a slight performance advantage), and they were also used more in an era when very deep inheritance was in fashion, which it isn't at the moment.
Java: notify() vs. notifyAll() all over again
|java|multithreading|
If one google for "difference between notify() and notifyAll()" then a lot of explanations will pop up (leaving apart the javadoc paragraphs). It all boils down to the number of waiting threads being waken up: one in notify() and all in notifyAll(). However (if I do understand the difference between these methods right), only one thread is always selected for further monitor acquisition; in the first case the one selected by the VM, in the second case the one selected by the system thread scheduler. The exact selection procedures for both of them (in general case) are not known to the programmer. What's is the **useful** difference between notify() and notifyAll() then? Am I missing something?
I'm teaching myself Python and my most recent lesson was that [Python is not Java][1], and so I've just spent a while turning all my Class methods into functions. I now realise that I don't need to use Class methods for what I would done with `static` methods in Java, but now I'm not sure when I would use them. All the advice I can find about Python Class methods is along the lines of newbies like me should steer clear of them, and the standard documentation is at its most opaque when discussing them. Does anyone have a good example of using a Class method in Python or at least can someone tell me when Class methods can be sensibly used? [1]: http://dirtsimple.org/2004/12/python-is-not-java.html
I'm not aware of a simple client. I remember looking for one a long time ago when I researched different queue systems and trying JMS I couldn't find one then, and I couldn't find one now. One thing though - there are a ton of tutorials that get you started and you could do a simple form to achieve that. Sorry to be not more helpful.
You should probably also check that the process is actually running, so that if your script dies without cleaning itself up, it will run the next time rather than simply checking that /var/run/foo.pid exists and exiting.
I think your best bet is to get the result via SQL query and apply a regular expression programatically that will allow you to retrieve a group of words before and after the searched word. I can't test it now, but the regular expression should be something like: .*(\w+)\s*WORD\s*(\w+).* where you replace `WORD` for the searched word and use regex group 1 as before-words, and 2 as after-words I will test it later when I can ask my [RegexBuddy][1] if it will work :) and I will post it here [1]: http://www.regexbuddy.com/
You should mock an object when you have a dependancy in a unit of code you are trying to test that needs to be "just so". For example, when you are trying to test some logic in your unit of code but you need to get something from another class and what is returned from this dependancy might break what you are trying to test - mock that object. A great podcast on the topic can be found [here][1] [1]: http://www.hanselman.com/blog/HanselminutesPodcast32MockObjects.aspx
You should mock an object when you have a dependancy in a unit of code you are trying to test that needs to be "just so". For example, when you are trying to test some logic in your unit of code but you need to get something from another object and what is returned from this dependancy might affect what you are trying to test - mock that object. A great podcast on the topic can be found [here][1] [1]: http://www.hanselman.com/blog/HanselminutesPodcast32MockObjects.aspx
You should mock an object when you have a dependancy in a unit of code you are trying to test that needs to be "just so". For example, when you are trying to test some logic in your unit of code but you need to get something from another object and what is returned from this dependancy might affect what you are trying to test - mock that object. A great podcast on the topic can be found [here][1] [1]: http://www.hanselminutes.com/default.aspx?showID=43
Does the data need to be in a DataTable? Using a SortedList and binding that to a combo box would be a simpler way. If you need to use a DataTable you can use the Select method to retrieve a DataView and pass in a sort parameter. DataView dv = myDataTable.Select("filter expression", "sort");
The escape character is ', so you would need to replace the quote with two quotes. For example, `SELECT * FROM PEOPLE WHERE SURNAME='O'Keefe'` becomes `SELECT * FROM PEOPLE WHERE SURNAME='O''Keefe'` That said, it's probably incorrect to do this yourself. Your language may have a function to escape strings for use in SQL, but an even better option is to use parameters. Usually this works as follows. Your SQL command would be : `SELECT * FROM PEOPLE WHERE SURNAME=?` Then, when you execute it, you pass in "O'Keefe" as a parameter. Because the SQL is parsed with the parameter, there's no way for the parameter value to alter the structure of the SQL (and it's even a little faster if you want to run the same statement several times with different parameters). I should also point out that, while your example just causes an error, you open youself up to a lot of other problems by not escaping strings appropriately. See http://en.wikipedia.org/wiki/SQL_injection for a good starting point. ![alt text][1] ([from xkcd][2]) [1]: http://imgs.xkcd.com/comics/exploits_of_a_mom.png [2]: http://xkcd.com/327/
The escape character is ', so you would need to replace the quote with two quotes. For example, `SELECT * FROM PEOPLE WHERE SURNAME='O'Keefe'` becomes `SELECT * FROM PEOPLE WHERE SURNAME='O''Keefe'` That said, it's probably incorrect to do this yourself. Your language may have a function to escape strings for use in SQL, but an even better option is to use parameters. Usually this works as follows. Your SQL command would be : `SELECT * FROM PEOPLE WHERE SURNAME=?` Then, when you execute it, you pass in "O'Keefe" as a parameter. Because the SQL is parsed before the parameter value is set, there's no way for the parameter value to alter the structure of the SQL (and it's even a little faster if you want to run the same statement several times with different parameters). I should also point out that, while your example just causes an error, you open youself up to a lot of other problems by not escaping strings appropriately. See http://en.wikipedia.org/wiki/SQL_injection for a good starting point or the following classic [xkcd comic][2]. ![alt text][1] [1]: http://imgs.xkcd.com/comics/exploits_of_a_mom.png [2]: http://xkcd.com/327/
You can actually sort the [default view][1] on a DataTable: myDataTable.DefaultView.Sort = "Field1, Field2 DESC"; That'll sort any rows you retrieve directly from the DataTable. [1]: http://msdn.microsoft.com/en-us/library/system.data.datatable.defaultview.aspx
The SLSBs are single threaded because a TX Context, Principal is associated with a bean instance when it is called. These beans are pooled and unless the max pool size is reached are processed in separate threads ( Vendor dependent). If SLSBs were designed thread safe every call would have looked like a servlet doGet/Post with request info containing Tx Context , Security Context info and etc. So at least the code looks clean (developer dependent).
What are some alternatives to a bit array?
I have an information retrieval application that creates bit arrays on the order of 10s of million bits. The number of "set" bits in the array varies widely, from all clear to all set. Currently, I'm using a straight-forward bit array (`java.util.BitSet`), so each of my bit arrays takes several megabytes. My plan is to look at the cardinality of the first *N* bits, then make a decision about what data structure to use for the remainder. Clearly some data structures are better for very sparse bit arrays, and others when roughly half the bits are set (when most bits are set, I can use negation to treat it as a sparse set of zeroes). - What structures might be good at each extreme? - Are there any in the middle? Here are a few constraints or hints: 1. The bits are set only once, and in index order. 2. I need 100% accuracy, so something like a Bloom filter isn't good enough. 3. After the set is built, I need to be able to efficiently iterate over the "set" bits. 4. The bits are randomly distributed, so run-length&ndash;encoding algorithms aren't likely to be much better than a simple list of bit indexes. 5. I'm trying to optimize memory utilization, but speed still carries *some* weight. Something with an open source Java implementation is helpful, but not strictly necessary. I'm more interested in the fundamentals.
One way to judge what python is used for is to look at what products use python at the moment. This [wikipedia page](http://en.wikipedia.org/wiki/Python_software) has a long list including various web frameworks, content management systems, version control systems, desktop apps and IDEs. As it says [here](http://en.wikipedia.org/wiki/Python_%28programming_language%29#Usage) - "Some of the largest projects that use Python are the Zope application server, YouTube, and the original BitTorrent client. Large organizations that make use of Python include Google, Yahoo!, CERN and NASA. ITA uses Python for some of its components." So in short, yes, it is "proper for production use in the development of stand-alone complex applications". So are many other languages, with various pros and cons. Which is the best language for your particular use case is too subjective to answer, so I won't try, but often the answer will be "the one your developers know best".
BlaM's testing included all the DB calls made by WordPress. When you're making fewer DB calls, you'll see the performance gain of opcode caches be even more dramatic.
By 2038, time libraries should all be using 64-bit integers, so this won't actually be that big of a deal (on software that isn't completely unmaintained). COBOL programs might be fun though.
Operative word being "should". If you need to ensure futureproofing then you can construct your own date/time class and use that but I'd only do that if you think that what you write will be used on legacy OS'
Is num1 the variable you're having trouble with? This line: cin >> num1; is setting num1 to the value input by the user. So the value calculated for it in the previous run through the loop is being overwritten each time by the new input.
For Subversion, I agree with Ryan Duffield's comment. The chapter he refers to provides a good analyses on which system to use. The reason I asked is that Perforce provides a completely different way to create branches from SVN or CVS. Plus, there are all the DVCSs that give it's own philosophy on branching. Your branching strategy would be dictated by which tool(s) you're using. FYI, [Svnmerge.py][1] is a tool to assist with merging branches in SVN. It works very well as long as you use it frequently ( every 10-30 ) commits, otherwise the tool can get confused. [1]: http://www.orcaware.com/svn/wiki/Svnmerge.py
File database suggestion with support for multiple concurent users.
|database|ms-access|concurrency|berkeley-db|
I need a database that could be stored network drive and would allow multiple users (up to 20) to use it without any server software. I'm considering MS Access or Berkeley DB. Can you share your experience with file databases? <br> Which one did you use, did you have any problems with it?
If you're simply looking to expose a collection on your instance, then using a getter/setter to a private member variable seems like the most sensible solution to me (your first proposed option).