instruction
stringlengths
0
30k
It seems fitting I post an answer, since I left the comment :P Basically, if you forget to include `stdlib.h` the compiler will assume `malloc` returns an `int`. Without casting, you will get a warning. With casting you won't. So by casting you get nothing, and run the risk of suppressing legitimate warnings. ...
It seems fitting I post an answer, since I left the comment :P Basically, if you forget to include `stdlib.h` the compiler will assume `malloc` returns an `int`. Without casting, you will get a warning. With casting you won't. So by casting you get nothing, and run the risk of suppressing legitimate warnings. ...
It seems fitting I post an answer, since I left the comment :P Basically, if you forget to include `stdlib.h` the compiler will assume `malloc` returns an `int`. Without casting, you will get a warning. With casting you won't. So by casting you get nothing, and run the risk of suppressing legitimate warnings. ...
|asp.net|asp|legacy|code-converter|
We have a large ASP (classic ASP) application and we would like to convert it to .NET in order to work on further releases. It makes no sense continuing to use ASP as it is obsolete, and we don't want to rewrite it from scratch (Joel Spolsky tells you [why][1]). Are there any tools for converting from ASP to ASP.NET...
What is the reasoning behind the recommended layout for Subversion repositories?
|svn|
[*Version Control with Subversion*][1] recommends the following layout for (single-project) repositories (complemented by [*this question*][2]): /trunk /tags /rel.1 (approximately) ... /branches /rel1fixes What are the relative merits of this arrangement when compared with a (pe...
|svn|
Anna, Here is a great page that discusses the performance difference between tradition scientific programming languages (fortran, C++) and c#. [http://msdn.microsoft.com/en-us/magazine/cc163995.aspx][1] According to the article C#, when using rectangular arrays (2d) can be a very good performer. Here is a gra...
I pretty much spend most of my time in [Eclipse][1] and at the command line. With Eclipse I usually modify the keyboard bindings so I have features such as Open Type/Resource, Quick Outline, Show Refactor Menu and so on at the tip of my fingers. I also install [Q for Eclipse][q] to enable good Maven-integration allo...
What's the Name of the Python Module that Formats arbitrary Text to nicely looking HTML?
|python|formatting|markup|
A while ago I came across a Python library that formats regular text to HTML similar to Markdown, reStructuredText and Textile, just that it had no syntax at all. It detected indentatations, quotes, links and newlines/paragraphs only. Unfortunately I lost the name of the library and was unable to Google it. Anyone...
A while ago I came across a Python library that formats regular text to HTML similar to Markdown, reStructuredText and Textile, just that it had no syntax at all. It detected indentatations, quotes, links and newlines/paragraphs only. Unfortunately I lost the name of the library and was unable to Google it. Anyone...
OK, first about the .NET 3.5 thing. The runtime(CLR) of 3.5 is still the same as in .NET 2.0. There are a bunch of new libraries plus (among other things) a new C#-Compiler. So to **run** LINQ in theory you just need to have .NET 2.0 installed and throw a few additional assemblies into the GAC. If you want to know w...
OK, first about the .NET 3.5 thing. The runtime(CLR) of 3.5 is still the same as in .NET 2.0. There are a bunch of new libraries plus (among other things) a new C#-Compiler. So to **run** LINQ in theory you just need to have .NET 2.0 installed and throw a few additional assemblies into the GAC. If you want to know w...
#include <time.h> #include <stdio.h> // tobase36() returns a pointer to static storage which is overwritten by // the next call to this function. // // This implementation presumes ASCII or Latin1. char * tobase36(time_t n) { static char text[32]; char ...
@p3t0r is right,MemCached is probably the best option, but you could also use the sqlite database that comes with Rails. That won't work over multiple machines though, where MemCached will. Also, sqlite will persist to disk, though I think you can set it up not to if you want. Rails itself has no application-scoped sto...
@p3t0r- is right,MemCached is probably the best option, but you could also use the sqlite database that comes with Rails. That won't work over multiple machines though, where MemCached will. Also, sqlite will persist to disk, though I think you can set it up not to if you want. Rails itself has no application-scoped st...
Dealing with errors Vs. warnings first: An error should be for something which violates the standard. A warning should be for something which is allowed, but quite likely isn't what the author intended. For example, the W3C Markup Validator will warn about the use of the syntax <br /> in an HTML document. In XHTML t...
I'm playing with the wonderful [FindBugs plugin][1] for [Hudson][2]. Ideally, I'd like to have the build fail if FindBugs finds any problems. Is this possible? Please, don't try and tell me that "0 warnings" is unrealistic with FindBugs. We've been using FindBugs from Ant for a while and we usually do maintain 0 war...
Rather than rolling your own, why not just use the SC built-in command?
Interesting ... version() is a function! I wonder why? Version is not going to change or return different values under different inputs/circumstances. Curious because I remember from old days that in Sybase it used to be a global variable and version could be found out by doing "select @@version"
Both are fine, but remember that sometimes access to the Iterator directly is useful (such as if you are removing elements that match a certain condition - you will get a ConcurrentModificationException if you do collection.remove(o) inside a for(T o : collection) loop). I prefer to write the for(blah : blah) [forea...
As Matt Cruikshank says, this is easily done by pulling a couple things from the boost libraries, like this: #include <boost/function.hpp> #include <boost/thread.hpp> class cMyClass { public: void Run(); } boost::thread* pThread = new boost::thread( boost::bin...
As Matt Cruikshank says, this is easily done by pulling a couple things from the boost libraries, like this: #include <boost/function.hpp> #include <boost/thread.hpp> class cMyClass { public: void Run(); } cMyClass theClass; // start new thread by invoking me...
This can be simply done by pulling a couple things from the boost libraries, like this: #include <boost/function.hpp> #include <boost/thread.hpp> class cMyClass { public: void Run(); } cMyClass theClass; // start new thread by invoking method run on theCl...
It depends what mode your database was in when it was detached, it's possible there are uncommitted/unwritten transactions in that log file that are needed to attach the database, otherwise there would be data loss. Do you know what recovery mode you were in when it was detached?
I use it everywhere. On the topic of the effort for marking methods, I let Eclipse do it for me so, it's no additional effort. I'm religious about continuous refactoring.... so, I'll use every little thing to make it go more smoothly.
Its difficult to understand what exactly you are doing with it, but it seems like [Boost Bimap][1] is what you want. It allows indexing from both ends of the map. Why are you looking up the location of an object in a map by its address? Use the abstraction and let it do all the work for you. Just a note: iteration over...
Its difficult to understand what exactly you are doing with it, but it seems like boost [bimap][1] is what you want. It's basically boost multi-index except a specific use case, and easier to use. It allows fast lookup based on the first element or the second element. Why are you looking up the location of an object in...
DNS resolution happens at the domain level. DNS doesn't have any knowledge of URLs or folders so your name will always point to the same server. You can make that server actually retrieve the information from another one or redirect to another one but that's not very satisfactory I'd say.
Our entire business unit telecommutes. Only us first years are required to be in the office, so our enterprise IM solution is vital to staying in touch and on task. Its how my manager lets me know what project I'm working on, if I need to bill my time to another customer, or if I need to bounce ideas around. So yes, I ...
See <a href="http://www.w3.org/TR/html5/offline.html#browser0">the HTML 5 draft specification</a>. You want `navigator.onLine`. Not all browsers support it yet. Firefox 3 and Opera 9.5 do. It sounds as though you are trying to cover up the problem rather than solve it. If a failed request causes your widgets to ...
If you don't want the full overhead of RMI, you could do direct socket communcation between the two by opening ports and talking to eachother. You'd have to have some way to have both processes agree on which ports to use, how to handshake/etc, but would be simpler than RMI. ETA: it looks like you can *use* named p...
Dealing with errors Vs. warnings first: An error should be for something which violates the standard. A warning should be for something which is allowed, but quite likely isn't what the author intended. For example, the W3C Markup Validator will warn about the use of the syntax &lt;br /> in an HTML document. In XHTM...
Testing grant me : - the serenity to accept the bug I can not change, - courage to fix the bug I can change, and - wisdom to know the difference (oops, I must have that confused with another pledge...)
So what you are asking is quite impossible in Rails because of the way it is designed. What you ask is a shared object and Rails is strictly single threaded. Memcached or similar tool for sharing data between distributed processes is the only way to go.
If you want to see the css defaults for firefox, look for a file called 'html.css' in the distribution. You could pick out the rules that want, and apply them after a reset.
If you want to see the css defaults for firefox, look for a file called 'html.css' in the distribution. You could pick out the rules that you want, and apply them after a reset.
If you want to see the css defaults for firefox, look for a file called 'html.css' in the distribution (there should be some other useful css files in the same directory). You could pick out the rules that you want, and apply them after a reset. Also, the CSS2 standard has a [sample stylesheet for html 4](http://www...
You can use the [corflags][1] utility to force an AnyCPU exe to load as an x86 or x64 executable, but that doesn't totally meet the file copy deployment requirement unless you choose which exe to copy based on the target. [1]: http://msdn.microsoft.com/en-us/library/ms164699(VS.80).aspx
How do I synchronize the address book in my app using MAPI?
|mapi|lazyweb|c++|
The system I'm working on contains an address book. I am looking for sample code that will synchronize addresses with the current users address book through MAPI. I need two-way sync. If you know of any open-source library with easy to use functions for this, I'd be glad to hear about it. If you know of a library th...
It's important to test multi-threaded code on a multi-processor machine. A dual-core machine may not be sufficient. I've seen deadlocks occur on a 4 processor machine that did not occur on a dual-core single processor. Then you need to create a stress test based on a client program that spawns many threads and makes mu...
If you're really wanting to control a browser from Java, you'll have to use a web-connector such as [Selenium][1] or [WebDriver][2]. Both of these let you control a browser directly from within Java and simulate a user typing text, clicking on links and submitting forms. One thing to keep in mind when doing this with...
Building a web search engine
|search|search-engine|
I've always been interested in developing a web search engine. What's a good place to start? I've heard of Lucene, but I'm not a big Java guy. Any other good resources or open source projects? I understand it's a huge under-taking, but that's part of the appeal. I'm not looking to create the next Google, just so...
Update VERY LARGE PostgresQL database table efficiently
|sql|database|postgresql|update|mvcc|
I have a very large database table in PostgresQL and a column like "copied". Every new row starts uncopied and will later be replicated to another thing by a background programm. There is an partial index on that table "btree(ID) WHERE replicated=0". The background programm does a select for at most 2000 entries (LIMIT...
It can't be done with DNS because the domain name is only the *.example.com of the address. It can be done by configuring a proxy on your www machine to pass all requests for /news to another server. It's very easy to do with apache but I don't remember all the details at this moment.
Three thoughts: 1) If you're going to do something different based on the types of the objects, it might make sense to move that behavior into those classes. Then instead of switch or if-else, you'd just call childNode.DoSomething(). 2) Comparing types will be much faster than string comparisons. 3) In the if...
Generics vs. Array Lists
|c#|generics|
The system I work on here was written before .net 2.0 and didn't have the benefit of generics. It was eventually updated to 2.0, but none of the code was refactored due to time constraints. There are a number of places where the code uses ArraysLists etc. that store things as objects. From performance perspectiv...
|c#|performance|generics|
Well, although I have not used TestComplete I have used a competing package called QA Wizard Pro. Since you are asking this question I am assuming that it isn't something that is natively supported by TestComplete. QA Wizard is the same way and they expect it to be run manually instead of automatically, though there ar...
The **only** real way to it is with a reverse proxy ( *Or a webserver acting as a reverse proxy* ) between you and the outside world that knows what IP address each folder is in. Its not possible to just make something, for example have google.com appear at http://foobar.com/google/ because the browser won't route...
I think he's looking for something similar with openMosix, some kind of a general cluster on top of which any application can run distributed among the nodes. AFAIK there's nothing like that available. MPI based clusters are the closest thing you can get, but I think you can only run MPI applications on them.
Inside the c++ object model by Stanley Lippman http://www.amazon.com/Inside-Object-Model-Stanley-Lippman/dp/0201834545
How to concatenate webcam FLVs
|linux|flash|webcam|ffmpeg|mencoder|
I want my website to concatenate some webcam recordings in FLV files (like this one). This needs to be done on Linux without user input. How do I do this? For simplicity's sake, I'll use the same flv as both inputs in hope of getting a flv that plays the same thing twice in a row. That should be easy enough, right? ...
How to join webcam FLVs
I want my website to join some webcam recordings in FLV files (like this one). This needs to be done on Linux without user input. How do I do this? For simplicity's sake, I'll use the same flv as both inputs in hope of getting a flv that plays the same thing twice in a row. That should be easy enough, right? There's...
I don't know what you're really trying to accomplish, but you could put a singleton constructor in each derived class's implementation file that adds the name to a list, along with a pointer to a factory. Then the list is always up to date and can create all the compiled in classes.
I use this approach a fair bit, I don't see any problem with it. Unlike cookies, the data isn't stored at the client-side, which is often a big mistake. Like anything though, just be careful that you're always sanitising user input, especially if you're putting user input into the $_SESSION variable, then later usin...
Generally, relying on the run-time type information is a bad idea in C++. What you have described seems like the factory pattern. You may want to consider creating a special factory subclass for each platform, which would only know about classes that exist on that platform.
You could most likely do this with a collection of user controls and the ModalPopupExtender that is available in the AJAX Control Toolkit.
Perhaps SQLAlchemy SQL Expression support is suitable. See the [documentation][1]. [1]: http://www.sqlalchemy.org/docs/05/sqlexpression.html
For each application, you could write a little cache-dump.aspx script to kill the cache/application data. Copy it to all your applications and write a hub script to manage the calling. For security, you could add all sorts of authentication-lookups or IP-checking. Here the way I do the actual app-dumping: ...
You can read here a good and illustrated article: [http://kpumuk.info/ruby-on-rails/colorizing-console-ruby-script-output/][1] I think setting console text color is pretty language-specific. Here is an example in C# from MSDN: for (int x = 0; x < colorNames.Length; x++) { Console.Write("{0,2}: ",...
They are enhanced variable substitutions. They modify the %N variables used in batch files. Type "FOR /?" in a command prompt for more information. They are quite useful if you're into batch programming in Windows.
They are enhanced variable substitutions. They modify the %N variables used in batch files. Quite useful if you're into batch programming in Windows. %~I - expands %I removing any surrounding quotes ("") %~fI - expands %I to a fully qualified path name %~dI - expands %I to a drive...
You may want to try [Stax][1] instead of SAX, I hear it's better for that sort of thing (I haven't used it myself). [1]: http://stax.codehaus.org/
There are ports of Lucene. Zend have one freely available. Have a look at this quick tutorial: http://devzone.zend.com/node/view/id/91
It is best to simply time yourself, record your estimates and determine the average % you're off. Given that, as long as you are consistent, you can appropriately estimate actual times based on when you believed you'd get it done. It's not simply to determine how bad you are at estimating, but rather to take into accou...
It is best to simply time yourself, record your estimates and determine the average % you're off. Given that, as long as you are consistent, you can appropriately estimate actual times based on when you believed you'd get it done. It's not simply to determine how bad you are at estimating, but rather to take into accou...
It is best to simply time yourself, record your estimates and determine the average percent you're off. Given that, as long as you are consistent, you can appropriately estimate actual times based on when you believed you'd get it done. It's not simply to determine how bad you are at estimating, but rather to take into...
|c++|mapi|lazyweb|
The system I'm working on contains an address book. I am looking for sample code that will synchronize addresses with the current users address book through MAPI. I need two-way sync. If you know of any open-source library with easy to use functions for this, I'd be glad to hear about it. If you know of a library th...
Create your own malloc wrapper which will randomly return null instead of a valid pointer. Well, or which fails consistently if you want to unit test.
You can write your own mock library with the same interface as your 3rd party library instead of it. You can also use LD_PRELOAD to override selected functions of the 3rd party library. /Allan
Django's development server has a file change monitor that watches for modifications and automatically reloads itself. You could re-use this code to launch unit tests on file modification.
How to simulate memory allocation errors
|memory-management|c|unit-testing|
My C application uses 3rd libraries, which do their own memory management. In order to be robust, my application has code to deal with failures of library functions due to lack of free memory. I would like to test this code, and for this, I need to simulate failures due to lack of memory. What tool/s are recomme...
|c|linux|unit-testing|gcc|memory-management|
No one here really has it right, or has stated it in a clear way. I'll describe probably the most common usage scenario of branches and tags, and give an example scenario of how they are used. * **Trunk**: Main development area. This is where your next major release of the code lives, and generally has all the newe...
The only way to know for sure is to profile your code using a tool like dotTrace. http://www.jetbrains.com/profiler/ It's possible that the boxing/unboxing is trivial in your particular application and wouldn't be worth refactoring. Going forward, you should still consider using generics due to the compile-time ...
How can I load xml from a url instead of a file path in .NET?
|.net|xml|
We currently have code like this: Dim xDoc = XDocument.Load(myXMLFilePath) The only way we know how to do it currently is by using a file path and impersonation (since this file is on a secured network path). I've looked at [XDocument.Load on MSDN][1], but I don't see anything. [1]: http://msdn.micr...
Here's another way, with test data create table #table1 (colWithDupes1 int, colWithDupes2 int) insert into #table1 (colWithDupes1, colWithDupes2) Select 1, 2 union all Select 1, 2 union all Select 2, 2 union all Select 3, 4 union all Select 3, 4 union all Select 3, 4 union...
I would look into the preferences > applications list. What application is targeted for "application/*" ? Apart from that, are you using FireBug? Absolutely essential, since you can look at the headers and response content within the network view.
I would suggest using a WebRequest to get a stream and load the stream into the document.