instruction
stringlengths
0
30k
This looks like a great resource for people like me who are coming from PHP to RoR <http://railsforphp.com/> There's also a book [Rails for PHP Developers](http://www.pragprog.com/titles/ndphpr)
**The answer to your question is 2656615626**. Here's the code that generates the answer: public static long getNumCombinations( int summands, int sum ) { if ( summands <= 1 ) return 1; long combos = 0; for ( int a = 0 ; a <= sum ; a++ ) combos += getNumCombinations( summands-1, sum-a ); re...
Trouble with selected radiobuttonlist value on postback vb.net
|.net|vb.net|postback|radiobuttonlist|selectedvalue|
I have a radio button list on a page that is used to configure products. when the page loads the first time the first list of options is displayed. you select one of them then click a "Next Step" button and the page posts back and shows a new radio button list for step 2. Now if i click a "Previous Step" button i can e...
I could use a little more information to narrow down my answer, but here is what I have: Internet Explorer has 5 different security zones be default: Local Machine Zone, Intranet, Internet, Trusted, and Restricted These are determined in urlmon.dll (Url Moniker) More information here: http://msdn.microsoft.com/en-...
How do I keep whitespace formatting using PHP/HTML?
|php|asciiart|html|
I'm parsing text from a file and storing it in a string. The problem is that some of the text in the original files contains ASCII art and whatnot that I would like to preserve. When I print out the string on the HTML page, even if it does have the same formatting and everything, since it is in HTML, the spacing and ...
|php|html|ascii|
VB.NET Get underlying system.type from nullable type
|vb.net|dataset|reflection|nullable|
I'm attempting to create a dataset based on the properties of an object. For example, I have an instance of a Person class with properties including ID, Forename, Surname, DOB etc. Using reflection, I'm adding columns to a new dataset based on the object properties: For Each pi As PropertyInfo In person.GetType(...
|vb.net|reflection|dataset|
[c#] How to pass a single object[] to a params object[]
|c#|params|
I have a method which takes params object[] such as: void Foo(params object[] items) { Console.WriteLine(items[0]); } When I pass two object arrays to this method, it works fine: Foo(new object[]{ (object)"1", (object)"2" }, new object[]{ (object)"3", (object)"4" } ); // Output:...
This probably isn't what you need, but if you want to draw a polygon (or conversely read a polygon image's pixels on a polygon basis) then one solution is to roll your own [polygon fill tool][1]. Quite frankly, this is a ton of fun, and really neat to learn about. But your question isn't very clear to me. Can you ...
Retrieving the associated shared service provider's name?
|sharepoint|moss|sharedservicesprovider|
How do you programmatically retrieve the name of a shared services provider that's associated with a specific Sharepoint web application? I have a custom solution that needs to: 1. Enumerate all web applications that it's deployed to 2. Figure out the Shared Services provider that each of the web applications is...
When interviewing recently, I was often asked to implement a data structure, usually LinkedList or HashMap. Both of these are easy enough to be doable in a short time, and difficult enough to eliminate the clueless.
It is possible to factor out try/finally (and exception and algorithms) using the Execute around idiom. However the syntax is highly verbose. public int foo() { withResource(new WithResource() { public void run(Resource resource) { doSomething(resource); }}); } ... ...
[TestFixture] public class RedirectTester { [Test] public void Should_redirect_to_success_action() { var controller = new RedirectController(); var result = controller.Index() as RedirectToRouteResult; Assert.That(result, Is.Not.Null); Assert.That(result.Values["action"], Is.EqualTo("succe...
The historical performance benefit of stored procs have generally been from the following (in no particular order): - Pre-parsed SQL - Pre-generated query execution plan - Reduced network latency - Potential cache benefits **Pre-parsed SQL** -- similar benefits to compiled vs. interpreted code, except ...
Unable to load System.Datal.Linq.dll for CodeDom
|c#|codedom|
I am trying to dynamicly compile code using CodeDom. I can load other assemblies, but I cannot load System.Data.Linq.dll. I get an error: Metadata file 'System.Data.Linq.dll' could not be found My code looks like: CompilerParameters compilerParams = new CompilerParameters(); compilerParams.CompilerOp...
I generally store them in the repository, but I do sympathise with your desire to keep the size down. If you don't store them in the repository, the absolutely do need to be archived and versioned somehow, and your build system needs to know how to get them. Lots of people in Java world seem to use Maven for fetchin...
From what I understand you want to add a choice column data type thats already prepopulated so that users can then add it to their own content types? have a look here, this is probably what you want to do: http://www.sharethispoint.com/archive/2006/08/07/23.aspx
try to learn a language which you are comfortable with, try different approach and the basics.
# <a href="http://homepages.cwi.nl/~tromp/cl/lazy-k.html">Lazy</a> <a href="http://esoteric.sange.fi/essie2/download/" title="download it">K</a> Your pure functional programming nightmares come true! The only <a href="http://en.wikipedia.org/wiki/Esoteric_programming_language">Esoteric Turing-complete Programming...
You'll probably get much better performance if you used a data structure designed for search tasks rather than a database. For example, you might try looking at building an [inverted index][1]. Rather than writing it youself, however, you might also want to look into something like [Lucene][2] which does most of the wo...
From http://docs.python.org/ref/node33.html : >Up to Python 2.1, old-style classes were the only flavour available to the user. The concept of (old-style) class is unrelated to the concept of type: if x is an instance of an old-style class, then x.`__class__` designates the class of x, but type(x) is always < type '...
Honestly, I think it boils down to code optimization, apart from just the infrastructure. In [StackOverflow Podcast 19][1], Jeff discussed about how they had to tweak SQL Server to handle the kinds of loads StackOverflow has; notice that it was not .NET that needed tweaking here. One also has to note that [MySpa...
To answer in an equally simplistic way.. ..When you stop hearing from the customers (and not because they stopped using your product).. except for enhancement requests and bouquets :)
To answer in an equally simplistic way.. ..When you stop hearing from the customers (and not because they stopped using your product).. except for enhancement requests and bouquets :) And its not a triangle, it has 4 corners - Cost Time Quality and Scope.
I have done a lot of communication with devices for the past few years, since I work for a home automation company, but we don't use Modbus. We do communication in a standard and open way using Web Services for Devices(WSD) which is also know as [Devices Profile for Web Services(DPWS)][1]. During this time at one p...
You should take a look at [OSGi][1], e.g. implemented in the [Eclipse Platform][2]. It does exactly that. You can install, uninstall, start and stop so called bundles, which are effectively JAR files. But it does a little more, as it offers e.g. services that can be dynamically discovered in JAR files at runtime. Or...
>Have I failed if user could not find out what to do from the UI? >If not, what degree of help should I provide? (both for desktop and web app) They should be able to use your your app to do basic things from the UI. eg say for an image editor, they should be able to create a new image, and draw some lines then sav...
###Three notes on help: 1. F1 / stand-alone context-sensitive help was always doomed. It was hidden by default, and so the people who most needed it were least likely to read it. There was hope at one time that we would be able to train users to always hit F1 when they ran into trouble, but too many applications wi...
How do you do fuzzy searches using bound parameters in PDO?
|php|sql|pdo|
Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound parameters to prepared statements in PDO. e.g.: $query = $db->prepare("select * from comments where comment like :search"); $query->bindParam(':search', $str); $query->execute(); I've tried numerous permutat...
What do you actually want to do? What features of SQL Compare do you want?
TOAD is a great generic tool for Oracle development and i think a similar feature is in the basic version. You can download a trial version (make sure you don't get the old free version of TOAD, that is about 4 years old) If you don't want to buy a tool, and you need something less flash you could roll your own quit...
How to Identify Postback event in Page_Load
|c#|asp.net|
We have some legacy code that needs to identify in the Page_Load which event caused the postback. At the moment this is implemented by checking the Request data like this... if (Request.Form["__EVENTTARGET"] != null && (Request.Form["__EVENTTARGET"].IndexOf("BaseGrid") > -1 // BaseGrid event ( e.g. sort) &nbs...
It's not clear what you mean saying "find the module and load it into the region". You can load module's view and add it to shell. Composite UI app block and CompositeWPF are built on top of the IoC pattern. It means that your modules should inject their menu items in shell's menu strip or subscribe to events generated...
Will PRISM help?
|wpf|prism|cal|cag|
I am considering building a application using PRISM (Composite WPF Guidance/Library). The application modules will be vertically partitioned (i.e. Customers, Suppliers, Sales Orders, etc). This is still all relatively easy... I also have a Shell with a main region were all the work will happen but now I need the follow...
|wpf|prism|cag|cal|
I am considering building a application using PRISM (Composite WPF Guidance/Library). The application modules will be vertically partitioned (i.e. Customers, Suppliers, Sales Orders, etc). This is still all relatively easy... I also have a Shell with a main region were all the work will happen but now I need the follow...
How do I convert a set of polygons into a bitmap
|algorithm|gis|
How do I take a set of polygons which contain arbitrary values and create a corresponding bitmap where each pixel contains the value of the polygon at that location? To put the question into context, my polygons contain information about the average number of people per square kilometre within the polygon. I need to...
How do I take a set of polygons which contain arbitrary values and create a corresponding bitmap where each pixel contains the value of the polygon at that location? To put the question into context, my polygons contain information about the average number of people per square kilometre within the polygon. I need to...
Have you added all the WMI components? As far as I know, you need all the WMI components to access the counters!
Have you added all the WMI components? As far as I know, you need all the WMI components to access the counters! > The Performance Counter Windows Management Instrumentation (WMI) Provider component provides a bridge between the performance registry interface and the WMI interface. This component allows WMI clients ...
Have you added all the WMI components? As far as I know, you need all the WMI components to access the counters! > The Performance Counter Windows Management Instrumentation (WMI) Provider component provides a bridge between the performance registry interface and the WMI interface. This component allows WMI clients ...
Javascript syntax highlighting in vim
No way. You look at the amount of documentation and training and marketing expenditure even MS puts up.. you'll get your answer. Try using someone else's product, and you will learn the true value of documentation - I'm learning Godiagrams right now.. :) So I can say without a doubt.. **NO and it never will.. no m...
No way. You look at the amount of documentation and training and marketing expenditure even MS puts up.. you'll get your answer. Try using someone else's product, and you will learn the true value of documentation - I'm learning Godiagrams right now.. :) So I can say without a doubt.. **NO and it never will.. no m...
1. setup coding convention and make everyone involved follow the convention 2. constantly refactoring your code (get a copy of Refactoring, by Martin Fowler) 3. write loosely coupled code (avoid writing comment by writing self-explanatory code) 4. if possible, unit test your code (or if you are macho enough, TDD...
1. setup coding convention and make everyone involved follow the convention (you wouldn't want reading code that require you to figure out where is the next statement/expression because it is not indented properly) 2. constantly refactoring your code (get a copy of Refactoring, by Martin Fowler, pros and cons are de...
I'm seeing a lot of incorrect answers here. Any correct solution needs to ignore whitespace and punction (and any non-alphabetic characters actually) and needs to be case insensitive. A few good example test cases are: "A man, a plan, a canal, Panama." "A Toyota's a Toyota." "A" "" As well as some non...
Ctrl+f then tick the "Regular expressions" checkbox. From that, you can search with regular expressions, but even more powerfully, you can include group matches in your replacement string ($1, $2, etc, or $0 for the whole match).
I've never heard of that issue in ASP.NET. However, you should trust user input about as much as you'd trust a hooker with your wallet.
the PHP email injection attack works because of a weakness in the PHP Mail() function. As a .net developer you need not worry.
ArrayList first = new ArrayList (); ArrayList copy = (ArrayList) first.clone ();
ArrayList newArrayList = (ArrayList) oldArrayList.clone();
How do you implement Levenshtein distance in Delphi?
|edit-distance|algorithm|
I'm posting this in the spirit of answering your own questions. The question I had was: How can I implement the Levenshtein algorithm for calculating edit-distance between two strings, as [described here][1], in Delphi? [1]: http://en.wikipedia.org/wiki/Levenshtein_distance
|edit-distance|algorithm|delphi|levenshtein-distance|
I'm posting this in the spirit of answering your own questions. The question I had was: How can I implement the Levenshtein algorithm for calculating edit-distance between two strings, as [described here][1], in Delphi? Just a note on performance: This thing is very fast. On my desktop (3Ghz dual-core, 2GB ram,...
|algorithm|delphi|edit-distance|levenshtein-distance|
I'm posting this in the spirit of answering your own questions. The question I had was: How can I implement the Levenshtein algorithm for calculating edit-distance between two strings, as [described here][1], in Delphi? Just a note on performance: This thing is very fast. On my desktop (2.33 Ghz dual-core, 2GB ...
What is the best/a very good meta-data reader library?
|meta-data|
Right now, I'm particularly interested in reading the data from MP3 files (ID3 tags?), but the more it can do (eg EXIF from images?) the better without compromising the ID3 tag reading abilities. I'm interested in making a script that goes through my media (right now, my music files) and makes sure the file name and...
I'm seeing a lot of incorrect answers here. Any correct solution needs to ignore whitespace and punction (and any non-alphabetic characters actually) and needs to be case insensitive. A few good example test cases are: "A man, a plan, a canal, Panama." "A Toyota's a Toyota." "A" "" As well as some non...
I'm seeing a lot of incorrect answers here. Any correct solution needs to ignore whitespace and punction (and any non-alphabetic characters actually) and needs to be case insensitive. A few good example test cases are: "A man, a plan, a canal, Panama." "A Toyota's a Toyota." "A" "" As well as some non...
I'm seeing a lot of incorrect answers here. Any correct solution needs to ignore whitespace and punctuation (and any non-alphabetic characters actually) and needs to be case insensitive. A few good example test cases are: "A man, a plan, a canal, Panama." "A Toyota's a Toyota." "A" "" As well as some ...
Ok here is the thing. I want to run a web application on php and mysql, using the CakePHP framework. And to keep the threshold of using the site at a very low place, I want to not use the standard login with username/password. (And I don't want to hassle my users with something like OpenID either. Goes to user type.) B...
I agree strongly with both toby and John Vasileff--S3 is great for off loading large media objects. (My own app does that for 10-1000MB FLVs and MP4s.) No partial requests (byte range header), though. One has to handle that 'manually'. If that is not an option, John's code looks good. I have found that a byte bu...
|javascript|vim|syntax-highlighting|editing|
Has anyone else found VIM's syntax highlighting of Javascript sub-optimal? I'm finding that sometimes I need to scroll around in order to get the syntax highlighting adjusted, as sometimes it mysteriously drops all highlighting. Are there any work-arounds or ways to fix this? I'm using vim 7.1.
OK, it DOES work in instance methods, too, and, based on your specific requirement (the one you put in the comment), you could do this: local_variables.each do |var| puts var if (eval(var).class != Fixnum) end Just replace `Fixnum` with your specific type checking.
@Nick R > I was originally using ArcGIS 9.2, but that doesn't work well with C# and 64 bit, so I am now using GDAL (http://www.gdal.org). Doesn't [gdal_rasterize][1] do exactly what you want? [1]: http://www.gdal.org/gdal_rasterize.html
What are models for storing tree structures and what are their charcteristics?
|data-structures|modeling|
So far I have encountered adjacency list, nested sets and nested intervals as models for storing tree structures in a database. I know these well enough and have migrated trees from one to another. What are other popular models? What are their characteristics? What are good resources (books, web, etc) on this topic?...
So far I have encountered adjacency list, nested sets and nested intervals as models for storing tree structures in a database. I know these well enough and have migrated trees from one to another. What are other popular models? What are their characteristics? What are good resources (books, web, etc) on this topic?...
What are models for storing tree structures and what are their characteristics?
So far I have encountered adjacency list, nested sets and nested intervals as models for storing tree structures in a database. I know these well enough and have migrated trees from one to another. What are other popular models? What are their characteristics? What are good resources (books, web, etc) on this topic?...
Export ASPX to HTML
|asp.net|html|