instruction
stringlengths
0
30k
Message Passing Interface (MPI) (<http://www-unix.mcs.anl.gov/mpi/>) is a highly scalable and robust library for parallel programming, geared original towards C but now available in several flavors <http://en.wikipedia.org/wiki/Message_Passing_Interface#Implementations>. While the library doesn't introduce new syntax, it provides a communication protocol to orchestrate the sharing of data between routines which are parallelizable. Traditionally, it is used in large cluster computing rather than on a single system for concurrency, although multi-core systems can certainly take advantage of this library. Another interesting solution to the problem of parallel programming is OpenMP, which is an attempt to provide a portable extension on various platforms to provide hints to the compiler about what sections of code are easily parallelizable. For example (<http://en.wikipedia.org/wiki/OpenMP#Work-sharing_constructs>): #define N 100000 int main(int argc, char *argv[]) { int i, a[N]; #pragma omp parallel for for (i=0;i<N;i++) a[i]= 2*i; return 0; } There are advantages and disadvantages to both, of course, but the former has proven to be extremely successful in academia and other heavy scientific computing applications. YMMV.
Next to the GOF [Command Pattern][1] you might also want to have a look at the [Transaction Script][2] pattern from [P of EAA][3]. You should probably create a Composite Command (or Transaction Script) that executes in sequence. [1]:http://en.wikipedia.org/wiki/Command_Pattern [2]:http://martinfowler.com/eaaCatalog/transactionScript.html [3]:http://martinfowler.com/books.html#eaa
What are the important Ruby commands?
|ruby|
I'm not sure of all of them, but what are the commands to do things like update Ruby, download a new gem, or update an existing gem? What other important things are there?
I'm not sure of all of them, but what are the commands to do things like update Ruby, download a new gem, or update an existing gem? What other important things are there? Since it might matter, I'm running Windows.
Adding to everyones lists, [Tamper Data][1] is quite useful, lets you intercept requests and change the data in them. It can be used to bypass javascript validation and check whether the server side is doing its thing. [1]: https://addons.mozilla.org/en-US/firefox/addon/966
I use [Web Developer][1], it's a real time saver. [1]: https://addons.mozilla.org/en-US/firefox/addon/60
You still need to be aware of alignment issues when laying out a class or struct in C(++). In these cases the compiler will do the right thing for you, but the overall size of the struct/class may be more wastefull than necessary For example: struct { char A; int B; char C; int D; }; Would have a size of 4 * 4 = 16 bytes (assume Windows on x86) whereas struct { char A; char C; int B; int D; }; Would have a size of 4*3 = 12 bytes. This is because the compiler enforces a 4 byte alignment for integers, but only 1 byte for chars. In general pack member variables of the same size (type) together to minimize wasted space.
I use my own exceptions. You can handle them quite simple - also they contain text. I use the format: throw Exception( "comms::serial::serial( )", "Something failed!" ); Also I have a second exception format: throw Exception( "comms::serial::serial( )", ::GetLastError( ) ); Which is then converted from a DWORD value to the actual message using FormatMessage. Using the where/what format will show you what happened and in what function.
Designing a threaded commenting system
|sql|
What would be the best way to design a threaded commenting system so that it doesn't hammer the database?
One that wasn't mentioned yet is this [HTML Validator](http://users.skynet.be/mgueury/mozilla/) extension that I found very useful.
How do I write a sort worse than O(n!)
|interviewquestion|madscientist|evilgenius|amusement|
I wrote an O(n!) sort for my amusement that can't be trivially optimized to run faster without replacing it entirely. [And no, I didn't just randomize the items until they were sorted]. How might I write an even worse Big-O sort, without just adding extraneous junk that could be pulled out to reduce the time complexity? [http://en.wikipedia.org/wiki/Big_O_notation][1] has various time complexities sorted in growing order. [1]: http://en.wikipedia.org/wiki/Big_O_notation#Orders_of_common_functions
I actually like the first one because when there are a lot of variables intermingled with the text it seems easier to read to me. Plus, it is easier to deal with quotes when using the string.Format(), uh, format. Here is [decent analysis][1] of string concatenation. [1]: http://blog.cumps.be/string-concatenation-vs-memory-allocation/
Dynamic Alphabetical Navigation
|javascript|sql|html|jquery|coldfusion|
I'm using ColdFusion to return a result set from a SQL database and turn it into a list. I need some way to generate an Alphabetical Navigation bar for that list. I have ColdFusion and the jQuery library available. I'm looking to generate something like this: A | B | C | ... - A - A - B - B - B - C - D Where clicking on one of the letters drops you down the page to the first item for that letter. Not all 26 letters of the alphabet are necessarily in use.
your temp table is out of scope, it is only 'alive' during the first connection and will not be available in the 2nd connection Just move all of it in one block of code and execute it inside one conection
1. Formatting is the “.NET” way of doing it. Certain refactoring tools (Refactor! for one) will even propose to refactor the concat-style code to use the formatting style. 2. Formatting is easier to optimize for the compiler (although the second will probably be refactored to use the 'Concat' method which is fast). 3. Formatting is usually clearer to read (especially with “fancy” formatting). 4. Formatting means implicit calls to '.ToString' on all variables, which is good for readability. 5. According to “Effective C#”, the .NET 'WriteLine' and 'Format' implementations are messed up, they autobox all value types (which is bad). “Effective C#” advises to perform '.ToString' calls explicitly, which IMHO is bogus (see [Jeff's posting](http://www.codinghorror.com/blog/archives/000878.html)) 6. At the moment, formatting type hints are not checked by the compiler, resulting in runtime errors. However, this could be amended in future versions.
In framework 3.5, RemoveAll method takes a predicate as a parameter. So you may use list.RemoveAll(item => ShouldIRemoveThis(item)); where ShouldIRemoveThis is a method that returns a boolean indicating whether the item must be removed from the list.
Can you use LINQ? If so, you can just use the .Take() method and specify how many records you want (maybe as total - N).
I like to use VBscript for this kind of thing. The VBS engine is on every recent windows machine and the language is a little more like real programming than a batch script. Also, if your installer grows to require WMI functions too, this becomes a piece of cake.
While I totally understand the style preference and picked concatenation for my first answer partly based on my own preference, part of my decision was based on the thought that concatenation would be faster. So, out of curiosity, I tested it and the results were staggering, especially for such a small string. Using the following code: System.Diagnostics.Stopwatch s = new System.Diagnostics.Stopwatch(); var p = new { FirstName = "Bill", LastName = "Gates" }; s.Start(); Console.WriteLine("{0} {1}", p.FirstName, p.LastName); s.Stop(); Console.WriteLine("Console.WriteLine(\"{0} {1}\", p.FirstName, p.LastName); took: " + s.ElapsedMilliseconds + "ms - " + s.ElapsedTicks + " ticks"); s.Reset(); s.Start(); Console.WriteLine(p.FirstName + " " + p.LastName); s.Stop(); Console.WriteLine("Console.WriteLine(p.FirstName + \" \" + p.LastName); took: " + s.ElapsedMilliseconds + "ms - " + s.ElapsedTicks + " ticks"); I got the following results: Bill Gates Console.WriteLine("{0} {1}", p.FirstName, p.LastName); took: 2ms - 7280 ticks Bill Gates Console.WriteLine(p.FirstName + " " + p.LastName); took: 0ms - 67 ticks Using the formatting method is over 100 times slower!! Concatenation didn't even register as 1ms, which is why I output the timer ticks as well.
For my blog I am wanting to use the Output Cache to save a cached version of a perticular post for around 10 minutes, and thats fine... <%@OutputCache Duration="600" VaryByParam="*" %> However, if someone posts a comment, I want to clear the cache so that the page is refreshed and the comment can be seen. How do I do this in ASP.Net C#?
|c#|asp.net|
|c#|asp.net|output-cache|
People avoid cursor because they generally are more difficult to write than a simple while loops, however, a while loop can be expensive because your constantly selecting data from a table, temporary or otherwise. With a cursor, which is readonly fast forward, the data is kept in memory and has been specifically designed for looping. [This article][1] highlights that an average cursor runs 50 times faster than a while loop. [1]: http://www.sqlteam.com/article/cursor-performance
I used Lucene.NET along with MySQL. My approach was to store primary key of db record in Lucene document along with indexed text. In pseudo code it looks like: - Store record: insert text, other data to the table get latest inserted ID create lucene document put (ID, text) into lucene document update lucene index - Querying search lucene index for each lucene doc in result set load data from DB by stored record's ID Just to note, I switched from Lucene to [Sphinx][1] due to it superb performance [1]: http://www.sphinxsearch.com
This isn't strictly against the hardcoding restriction, but comes terribly close. Why not programatically download this list and print it out, instead? http://primes.utm.edu/lists/small/10000.txt
A quick Google indicates that it's not really supported. There's more than a few folks out there trying to [hack][1] [their][2] way to it - but I'd strongly suggest just rendering a server side PDF instead. [1]: http://www.daniweb.com/forums/showthread.php?t=14877&page=2&highlight=javascript+print+landscape [2]: http://home.tampabay.rr.com/bmerkey/examples/landscape-test.html
What's the idiomatic way to do async socket programming in Delphi?
|delphi|sockets|winapi|networking|asynchronous|
What is the normal way people writing network code in Delphi use Windows-style overlapped asynchronous socket I/O? Here's my prior research into this question: The [Indy][1] components seem entirely synchronous. On the other hand, while ScktComp unit does use WSAAsyncSelect, it basically only asynchronizes a BSD-style multiplexed socket app. You get dumped in a single event callback, as if you had just returned from select() in a loop, and have to do all the state machine navigation yourself. The .NET situation is considerably nicer, with Socket.BeginRead / Socket.EndRead, where the continuation is passed directly to Socket.BeginRead, and that's where you pick back up. A continuation coded as a closure obviously has all the context you need, and more. [1]: http://indyproject.org/
I really don't have much experience with Sharepoint, but I thought I could at least provide *some* answer - even if it's the wrong one. From another dev I've spoken to it sounds like it's tough to get into any subfolders, so you might need to look at making your own custom workflow. Maybe something like LINQ to Sharepoint might be able to help you with actually getting in and enumerating the subfolders and getting to the data that you need? [LINQ to Sharepoint][1] [1]: http://www.codeplex.com/LINQtoSharePoint
Here are some more valid classes. Actionscript 3 classes (and packages) must start with a letter, "_", or "$". They may also contain (but not start with) a number. public class $Test {} public class _Test {} public class test {}
I have dealt with something similar, and the hardest part is figuring out exactly what you needed to "fake" to get authorized. In my case it was authorizing into some Lotus Notes webservice, but the details are unimportant, the method is the same. Essentially, we need to record a regular user session. I would recommend Fiddler <http://www.fiddler2.com> but if you're on linux or something, then you'll need to use wireshark to figure some of the things out. Not sure if there is a firefox plugin that could be used. Anyway, start up IE, then start up Fiddler. Complete the login process. Stop what you're doing. Switch to the fiddler pane, and examine the recorded sessions in detail. It should give you exactly what you need to fake using WebRequests.
You can use the System.XML namespace to do it. Of course you can also use LINQ. But I choose the .NET 2.0 approach because I am not sure which version of .NET you are using. XmlDocument doc = new XmlDocument(); // Create the Where Node XmlNode whereNode = doc.CreateNode(XmlNodeType.Element, "Where", string.Empty); XmlNode eqNode = doc.CreateNode(XmlNodeType.Element, "Eq", string.Empty); XmlNode fieldNode = doc.CreateNode(XmlNodeType.Element, "Field", string.Empty); XmlAttribute newAttribute = doc.CreateAttribute("FieldName"); newAttribute.InnerText = "Name"; fieldNode.Attributes.Append(newAttribute); XmlNode valueNode = doc.CreateNode(XmlNodeType.Element, "Value", string.Empty); XmlAttribute valueAtt = doc.CreateAttribute("Type"); valueAtt.InnerText = "Text"; valueNode.Attributes.Append(valueAtt); // Can set the text of the Node to anything. valueNode.InnerText = "Value Text"; // Or you can use //valueNode.InnerXml = "<aValid>SomeStuff</aValid>"; // Create the document fieldNode.AppendChild(valueNode); eqNode.AppendChild(fieldNode); whereNode.AppendChild(eqNode); doc.AppendChild(whereNode); // Or you can use XQuery to Find the node and then change it // Find the Where Node XmlNode foundWhereNode = doc.SelectSingleNode("Where/Eq/Field/Value"); if (foundWhereNode != null) { // Now you can set the Value foundWhereNode.InnerText = "Some Value Text"; }
When working with XML, always use the XML API that works with your programming environment. Don't try to roll your own XML document building and escaping code. As Longhorn213 mentioned, in .Net all the appropriate stuff is in the System.XML namespace. Trying to to write your own code for writing XML documents will just result in many bugs and troubles down the line.
Maybe <a href="http://www.phpdoctrine.org/">Doctrine</a> would do the job? It seems to be inspired by <a href="http://www.hibernate.org/">Hibernate</a>.
Unfortunately I think your only option is to use the ADSI API. You can switch between NT4 and Active Directory by changing providers in your code. NT4 uses the WinNT provider and Active Directory uses the LDAP provider. If you query the RootDSE node of whichever provider you are using, that should return naming contexts to which you can bind, including domains. RootDSE is an LDAP schema specific identifier. For WinNT you can query the root object as "WinNT:" to get available domains. ADSI is available through VB script BTW.
# BASIC: old school 10 HOME 20 INPUT N 30 LET ANS = 1 40 FOR I = 1 TO N 50 ANS = ANS * I 60 NEXT I 70 PRINT ANS
Most OS'es have support for Microsoft's [Core Fonts For the Web](http://en.wikipedia.org/wiki/Core_fonts_for_the_Web). They all come bundled with OSX, and I'm reasonably sure they'll work (or have near-identical variants) on most any linux distro. [The Microsoft Typography page is also pretty cool](http://www.microsoft.com/typography/fonts/default.aspx)
Tips for working in a large library?
|time-management|organizing|
I'm currently working on a quite large library (5M lines of code, in C++ under VS2005, 1 solution and close to 100 projects). Even though we distribute compilation, and use incremental linking, recompilation and relinking after small source modifications takes between a few minutes (usually at least 3) and close to one hour. This means that our modify code/build/debug cycles tend to be really long (to my taste!), and it's quite easy to lose the 'flow' during a build: there's typically not much time to do anything useful (maybe do a bit of email, otherwise read some article online or a few pages of a book). When writing new code or doing major refactoring, I try to compile one file at a time only. However, during debugging for example, it really gets on my nerves! I'm wondering how I could optimize my time? I guess I'm not the only one in that situation: what do/would *you* do?
Rule of thumb: If the function you are testing needs a complicated object as a parameter, and it would be a pain in the ass to build said complicated object, use a mock.
The 'Best Practice' of avoiding cursors in SQL Server dates back to SQL Server 2000 and earlier versions. The rewrite of the engine in SQL 2005 addressed most of the issues related to the problems of cursors, particularly with the introduction of the fast forward option. Cursors are not neccessarily worse than set-based and are used extensively and successfully in Oracle PL/SQL (LOOP). The 'generally accepted' that you refer to **was** valid, but is now outdated and incorrect - go on the assumption that fast forward cursors behave as advertised and perform. Do some tests and research, basing your findings on SQL2005 and later
I'm aware of SQLite, but that doesn't really help - I'm talking about figuring out the best schema (regardless of the database) for storing this data.
howto track data changes in a database table
|database|
What is the best way to track changes in a database table? Imagine you got an application in which users (in the context of the application not DB users ) are able to change data which are store in some database table. What's the best way to track a history of all changes, so that you can show which user at what time change which data how?
Generally a unit test is intended to exercise the public interface of a class or unit, private methods therefore are implementation detail that you would not expect to test.
Another request for sample data. As has been mentioned I would work backwards from the zip. Once you have a zip I would query a zip database, store the results, and remove them & the zip from the string. That will leave you with the address mess. MOST (All?) addresses will start with a number so find the first occurrence of a number in the remaining string and grab everything from it to the (new) end of the string. That will be your address. Anything to the left of that number is likely an addressee. You should now have the City, State, & Zip stored in a table and possibly two strings, addressee and address. For the address, check for the existence of "Suite" or "Apt." etc. and split that into two values (address lines 1 & 2). For the addressee I would punt and grab the last word of that string as the last name and put the rest into the first name field. If you don't want to do that, you'll need to check for salutation (Mr., Ms., Dr., etc.) at the start and make some assumptions based on the number of spaces as to how the name is made up. I don't think there's any way you can parse with 100% accuracy.
#temp is out of scope in q2. All your work can be done in one query: <pre><code> SELECT a.columnA, a.columnB,..., a.columnZ FROM table2 a INNER JOIN (SELECT databaseA..table1.column1 FROM databaseA..table1 WHERE databaseA..table1.xyz = 'A') b ON a.columnB = b.column1 </code></pre>
[CXF][1] - I'd look into CXF. I've used it to create a web service and client in java using ws-secuirty. I also connected a .net web service to it. They have pretty good documentation too. I had more luck with it than axis. [1]: http://cwiki.apache.org/CXF20DOC/ws-support.html
I'd use the String.Format, but I would also have the format string in the resource files so it can be localised for other languages. Using a simple string concat doesn't allow you to do that. Obviously if you wont ever need to localise that string, this isn't a reason to think about. It really depends on what the string is for. If it's going to be showed to the user, I'd use String.Format so I can localize if I need to - and [FxCop][1] will spell check it for me, just in case :) If it contains numbers or any other non-string things (e.g. dates), I'd use String.Format because it gives me more [control over the formatting][2]. If it's for building a query like SQL, I'd use [Linq][3]. If for concatenating strings inside a loop, I'd use [StringBuilder][4] to avoid performance problems. If it's for some output the user wont see, and isn't going to effect performance I'd use String.Format because I'm in the habit of using it anyway and I'm just used to it :) [1]: http://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspx [2]: http://www.sellsbrothers.com/tools/#FormatDesigner [3]: http://msdn.microsoft.com/en-us/netframework/aa904594.aspx [4]: http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx
Preprocessor Directives can be nifty if you want different behavior between Debug and Release modes. [http://msdn.microsoft.com/en-us/library/ed8yd1ha.aspx][1] [1]: http://msdn.microsoft.com/en-us/library/ed8yd1ha.aspx
Yes, save it to a variable and unhook it. DelegateType evt = (o, e) => { firedCount++; Console.Write(firedCount); }; foo.AnEvent += evt; foo.MethodThatFiresAnEvent(); foo.AnEvent -= evt; And yes, if you don't, you'll *leak* memory, as you'll hook up a new delegate object each time. You'll also notice this because each time you call this method, it'll dump to the console an increasing number of lines (not just an increasing number, but for one call to MethodThatFiresAnEvent it'll dump any number of items, once for each hooked up anonymous method).
I like the fact writing WCF services makes it easy to separate your service from the implementation. You can write your service and then host it in IIS, a console app, or a windows service; you can also talk to it via http, net tcp, etc.
What is a "regular old fashioned web service?" An ASMX service, or a WSE service? ASMX services are not naturally interoperable, don't support WS-* specs, and ASMX is a technology that is aging very quickly. WSE (Web Service Enhancement) services DO support WS-* and can be made to be interoperable, but WCF is meant to replace WSE, so you should take the time to learn it. I would say that unless your application is a quick an dirty one-off, you will gain immense flexibility and end up with a better design if you choose WCF. WCF *does* have a learning curve beyond a [WebMethod] attribute, but it is exponentially more powerful and future proof than legacy ASMX services.
What is a "regular old fashioned web service?" An ASMX service, or are you using WSE as well? ASMX services are not naturally interoperable, don't support WS-* specs, and ASMX is a technology that is aging very quickly. WSE (Web Service Enhancements) services DO add support for WS-* and can be made to be interoperable, but WCF is meant to replace WSE, so you should take the time to learn it. I would say that unless your application is a quick an dirty one-off, you will gain immense flexibility and end up with a better design if you choose WCF. WCF *does* have a learning curve beyond a [WebMethod] attribute, but the learning curve is over-exaggerated in my opinion, and it is exponentially more powerful and future proof than legacy ASMX services. Unless your time line simply cannot tolerate the learning curve, you would be doing yourself a huge favor learning WCF instead of just sticking with ASP.NET Web Services. Applications will only continue to become more and more distributed and interconnected, and WCF is the future of distributed computing on the Microsoft platform. [Here is a comparison][1] between the two. [1]: http://msdn.microsoft.com/en-us/library/aa738737.aspx
Joel Lucsy: That implementation of SQLite is a mixed-mode assembly which is not supported by Silverlight. Only a pure managed implementation would work under the Silverlight CLR.
There's also [Valentina][1]. I cam e across this product when I was working on some Real Basic project. The RB version is very good. [1]: http://www.paradigmasoft.com/en/products/developer/adk/VNET
I think you would need to consider leap years. I didn't do the math, but I think during a leap year, with a hard code of 28 days for feb, a comparison of noon on 2/29 and noon on 3/1 would result in the same duplicate time stamp as before. Although it looks like you didn't implement it like that. They way you implemented it, I think you still have the problem but it's between dates on 12/31 of $leapyear and 1/1 of $leapyear+1. I think you might also have some collisions during time changes if your code has to handle time zones that handle them. The file doesn't really seem to be sorted in any useful way. I'm guessing that field $1 is some sort of status (the "OK" you're checking for). So it's sorted by record status, then by DAY, then MONTH, YEAR, HOURS, MINUTES, SECONDS. If it was year,month,day I think there could be some optimizations there. Still might be but my brain's going in a different direction right now. If there are a small number of duplicate keys in proportion to total number of lines, I think your best bet is to reduce the file your awk script works over to just duplicate keys (as [David said][1]). You could also preprocess the file so the only lines present are the /OK/ lines. I think I would do this with a pipeline where the first awk script only prints the lines with duplicate IDs and the second awk script is basically the one above but optimized to not look for /OK/ and with the knowledge that any key present is a duplicate key. If you know ahead of time that all or most lines will have repeated keys, it's probably not worth messing with. [1]: http://stackoverflow.com/questions/6475/faster-way-to-find-duplicates-conditioned-by-time#6813
|interviewquestion|madscientist|evilgenius|amusement|sorting|
|interview-question|mad-scientist|evil-genius|amusement|sorting|
I wrote an O(n!) sort for my amusement that can't be trivially optimized to run faster without replacing it entirely. [And no, I didn't just randomize the items until they were sorted]. How might I write an even worse Big-O sort, without just adding extraneous junk that could be pulled out to reduce the time complexity? [http://en.wikipedia.org/wiki/Big_O_notation][1] has various time complexities sorted in growing order. Edit: I found the code, here is my O(n!) deterministic sort with amusing hack to generate list of all combinations of a list. I have a slightly longer version of get_all_combinations that returns an iterable of combinations, but unfortunately I couldn't make it a single statement. [Hopefully I haven't introduced bugs by fixing typos and removing underscores in the below code] def mysort(somelist): for combination in getallcombinations(somelist): if issorted(combination): return combination def issorted(somelist): # note: this could be merged into return... something like return len(foo) <= 1 or reduce(barf) if (len(somelist) <= 1): return True return 1 > reduce(lambda x,y: max(x,y),map(cmp, somelist[:-1], somelist[1:])) def getallcombinations(lst): return [[itm] + cbo for idx, itm in enumerate(lst) for cbo in getallcombinations(lst[:idx] + lst[idx+1:])] or [lst] [1]: http://en.wikipedia.org/wiki/Big_O_notation#Orders_of_common_functions
|sorting|fun|amusement|
|sorting|fun|
I wrote an O(n!) sort for my amusement that can't be trivially optimized to run faster without replacing it entirely. [And no, I didn't just randomize the items until they were sorted]. How might I write an even worse Big-O sort, without just adding extraneous junk that could be pulled out to reduce the time complexity? [http://en.wikipedia.org/wiki/Big_O_notation][1] has various time complexities sorted in growing order. Edit: I found the code, here is my O(n!) deterministic sort with amusing hack to generate list of all combinations of a list. I have a slightly longer version of get_all_combinations that returns an iterable of combinations, but unfortunately I couldn't make it a single statement. [Hopefully I haven't introduced bugs by fixing typos and removing underscores in the below code] def mysort(somelist): for permutation in get_all_permutations(somelist): if is_sorted(permutation): return permutation def is_sorted(somelist): # note: this could be merged into return... something like return len(foo) <= 1 or reduce(barf) if (len(somelist) <= 1): return True return 1 > reduce(lambda x,y: max(x,y),map(cmp, somelist[:-1], somelist[1:])) def get_all_permutations(lst): return [[itm] + cbo for idx, itm in enumerate(lst) for cbo in get_all_permutations(lst[:idx] + lst[idx+1:])] or [lst] [1]: http://en.wikipedia.org/wiki/Big_O_notation#Orders_of_common_functions
Yes in the same way that normal event handlers can cause leaks. Because the lambda is actually changed to: someobject.SomeEvent += () => ...; someobject.SomeEvent += delegate () { ... }; // unhook var del = () => ...; someobject.SomeEvent += del; someobject.SomeEvent -= del; So basically it is just short hand for what we have been using in 2.0 all these years.
How can I deploy artifacts from a Maven build to the SourceForge File Release System?
|java|maven-2|sourceforge|
I am using SourceForge for some Open Source projects and I want to automate the deployment of releases to the SourceForge File Release System. I use Maven for my builds and the standard SFTP deployment mechanism doesn't seem to work unless you do some manual preparation work. I have come across some old postings on other forums suggesting that the only approach is to write a Wagon specifically for SourceForge. Has anybody had any recent experience with this?
You wont just leak memory, you will also get your lambda called multiple times. Each call of 'PotentialMemoryLeaker' will add another copy of the lambda to the event list, and every copy will be called when 'AnEvent' is fired.
HTTPS requests are not cached so sending an **If-Modified-Since** doesn't make any sense. The not caching is a security precaution.
Unless the method provides a "limit" parameter (which it doesn't) your best option is to go with a ismple loop that removes the items that match, breaking when your incremented "match counter" hits your limit. That's pretty much how the internal function works anyway, but in a more optimized way.
Unless the method provides a "limit" parameter (which it doesn't) your best option is to go with a simple loop that removes the items that match, breaking when your incremented "match counter" hits your limit. That's pretty much how the internal function works anyway, but in a more optimized way.
Printers not available unless shared.
|c#|asp|printing|
We are using classic asp to call a C# dll and in the C# dll we are using System.Drawing.Printing.PrinterSettings.InstalledPrinters to get a list of availabe printers. If the printers are not shared they will not show up when a user trys to print. The Local System account can see and print to them from a VB6 dll and Administrators can print just fine from the C# dll as you might expect. Is there some sort of permissions we need to grant the user so these printers will be available?
|c#|asp|printing|windows-server-2003|
Anonymous delegates are useful here. A simple example to remove the first *limit* even numbers from a list. List<int> myList = new List<int>; for (int i = 0; i < 20; i++) myList.add(i); int total = 0; int limit = 5; myList.RemoveAll(delegate(int i) { if (i % 2 == 0 && total < limit) { total++; return true; } return false; }); myList.ForEach(i => Console.Write(i + " ")); Gives 1 3 5 7 9 10 11 12 13 14 15 16 17 18 19, as we want. Easy enough to wrap that up in a function, suitable for use as a lambda expression, taking the real test as a parameter.
Are you using ValidationGroups? Try assigning each control with a validation group as well as the validator that you want to use. Something like: <asp:TextBox ID="txt1" ValidationGroup="Group1" ruant="server" /> <asp:RequiredFieldValidator ID="rfv1" ... ValidationGroup="Group1" /> Note, if a button doesn't specify a validation groupo it will validate all controls that aren't assigned to a validation group.
Are you using ValidationGroups? Try assigning each control with a validation group as well as the validator that you want to use. Something like: <asp:TextBox ID="txt1" ValidationGroup="Group1" ruant="server" /> <asp:RequiredFieldValidator ID="rfv1" ... ValidationGroup="Group1" /> Note, if a button doesn't specify a validation group it will validate all controls that aren't assigned to a validation group.
One reason for rewriting at one of my previous jobs was an inability to find developers with enough experience to work on the original code base. The decision was made to first clean up the underlying database structure, then rewrite in something that would make it easier to find full-time employees and/or contractors. I haven't heard yet how it worked out :) I think people have a tendency to go for rewrites because it seems more fun on the surface. We get to rebuild from scratch! We'll do it right **this time**! etc.
Essentially this is the same issue as people had with WebForms and trying to compile their UserControl ASCX files into a DLL. I found this <http://www.codeproject.com/KB/aspnet/ASP2UserControlLibrary.aspx> that might work for you too.
Managing multiple identical databases efficiently?
|database|
In Podcast #19, Joel fails to answer the question posed to him by Ryan from San Diego; how, if you have a database per client of a web application instead of one database used by all clients, do you "go about providing updates and enhancements to all databases efficiently?" I'm particularly interested in the answer to this. Does anyone out there have any thoughts on the matter? Did you structure a web application this way and how do you roll out changes to schema and code in such a scenario?
See Joel Spolsky's essay [Things You Should Never Do][1]. In summary, when you rewrite you lose all the lessons you learned to make your current code work the way it needs to work. See also [Big Ball of Mud][2] [1]: http://www.joelonsoftware.com/articles/fog0000000069.html [2]: http://www.laputan.org/mud/
See Joel Spolsky's essay [Things You Should Never Do][1]. In summary, when you rewrite you lose all the lessons you learned to make your current code work the way it needs to work. See also: [Big Ball of Mud][2] [1]: http://www.joelonsoftware.com/articles/fog0000000069.html [2]: http://www.laputan.org/mud/
Please don't use ActiveX... I am so sick of sites that are only viewable in IE. My actual preference, as a user, in these situations is to download a lightweight .exe file that downloads the file for you.
Strange boo language syntax
|boo|
I've run into some strange syntax in [Boo Language Guide][1] : setter = { value | a = value } What | operator means? [1]: http://boo.codehaus.org/Closures