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,... |
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/eaaCatalo... |
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;
... |
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... |
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 comp... |
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... |
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
-... |
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... |
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.
Usin... |
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.
... |
|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 des... |
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 docu... |
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]... |
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-... |
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 S... |
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 rec... |
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.Cre... |
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 j... |
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 cont... |
# 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.micros... |
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... |
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-ba... |
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 tim... |
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 fir... |
#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 strin... |
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 ... |
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 ... |
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,... |
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 implem... |
|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 comp... |
|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 comp... |
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 -= ... |
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 oth... |
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 Adm... |
|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... |
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 d... |
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 d... |
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 contract... |
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 ... |
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 |