instruction
stringlengths
0
30k
Print variable type in C++
|c++|variables|typeof|
Is it possible in standard C++ to print a variable type. I think this is being addressed in C++0x but not sure it already exists. I would like something like this: int a = 12; cout << typeof(a) << endl; That would print: int
The class declaration says it all pretty much,as you cannot inherit it becouse it's final. You can ofcourse implement your own string-class, but that is probaby just a hassle. public final class String C# (.net 3.5) have the functionality to use extender metods but sadly java does not. There is some java ext...
Requery the combo box in the form's after update event and the delete event. Your combo box will be up to date whenever the user makes changes to the recordset, whether it's a new record, and change, or a deletion. Unless users must have everybody else's changes as soon as they're made, don't requery the combo box ...
Most big software companies have their own practices. For example Motorola has detailed documentation for every aspect of software development process. There are standard templates for each type of documents. Having strict standards allows effectively maintain huge number of documents and integrate it with different to...
Use grep to find content in files and move them if they match
|linux|shell|scripting|grep|
I'm using grep to generate a list of files I need to move: grep -L -r 'Subject: \[SPAM\]' . How can I pass this list to the mv command and move the files somewhere else?
D-Editor with debugging
|editor|d|
i've been programming a while in D [(http://www.digitalmars.com/d/)][1] now. I prefer it to Java because it is faster. However, i have not found an Editor that supports Code-Completion and Debugging (Step-Over, Step-Into, Breakpoints,...). Do you have any suggestions? [1]: http://www.digitalmars.com/d/
|editor|d|
i've been programming a while in D [(http://www.digitalmars.com/d/)][1] now. I prefer it to Java because it is faster. However, i have not found an Editor that supports Code-Completion and Debugging (Step-Over, Step-Into, Breakpoints,...). Do you have any suggestions? P.S: gdb did not work. [1]: http://www...
You can pass the result to the next command by using grep ... | xargs mv {} destination Check man xargs for more info.
SQL in general, like others said, does not handle well such relations. Typically, a surrogate 'relations' table is needed (id, parent_id, unique key on (id, parent_id)), where: - every time you add a record in 'table', you: `INSERT INTO relations (id, parent_id) VALUES ([current_id], [current_id]);` ...
mailto add urgent priority
|untagged|
I want to add a mailto link on our web page. I want to add a urgent priority to this mail. If you can help me that would be great. Thanks for your help, Donald
We do keep stored procedures in source control. The way we (or at least I) do it is add a folder to my project, add a file for each SP and manually copy, paste the code into it. So when I change the SP, I manually need to change the file the source control. I'd be interested to hear if people can do this automatical...
On Linux/unix/MacOSX use core files (you can enable them with ulimit or [compatible system call][1]). On Windows use Microsoft error reporting (you can become a partner and get access to your application crash data). [1]: http://www.opengroup.org/onlinepubs/009695399/functions/setrlimit.html
In general you want to throw an exception for anything that can happen in your application that is "Exceptional" In your example, both of those exceptions look like you are calling them via a password / username validation. In that case it can be argued that it isn't really exceptional that someone would mistype a ...
Actually, two books stand out. The first was Code Complete. Despite its age, this is still a very useful book, and the chapter on the dangers of premature optimisation is worth the price of the book on its own. The second one was The Psychology of Everyday Things (now called The Design of Everyday Things, I think),...
Refactoring you should do all the time.... so you shouldn't have to justify it. Cleaning up big messes / Redesign may include refactoring in order to get it under control, however its not "Refactoring" Refactoring should be a matter of moments...or if you have no tool support, minutes.
When it comes to storing images in a database I try to avoid it. In your case from what I can gather of your question there is a possibilty for a subsantial number of fairly large images, so I would probably strong oppose it. If this is a web application I would use a database for quick searching and indexing of ima...
Yes, there is a benefit of using multiple threads (or processes) on a single CPU - if one thread is busy waiting for something, others can continue doing useful work. However this can be offset by the overhead of task switching. You'll have to benchmark and/or profile *your* application on production grade hardware ...
Others have mentioned ways of avoiding memory leaks in the first place (like smart pointers). But a profiling and memory-analysis tool is often the only way to track down memory problems once you have them. [Valgrind memcheck][1] is an excellent free one. [1]: http://valgrind.org/info/tools.html#memcheck
If you just want the printer name no advantage at all. But WMI is capable of returning a whole bunch of other printer properties: using System; using System.Management; namespace Test { class Program { static void Main(string[] args) { O...
I needed LSB this for the following scenario: - Imagine you're building a "mail processor" daemon that downloads the message from an email server, classifies it, parses it, saves it, and then does something, depending on the type of the message. - Class hierarchy: you have a base Message class, with children "Bou...
I'd recommend raising the connection timeout time before getting the output stream, like so: urlConnection.setConnectTimeout(1000); Where 1000 is in milliseconds (1000 milliseconds = 1 second).
Do you want to do it programatically? Otherwise I believe there is a setting for max conncurrent connections from an ip address for IIS.
They tend to be numbered in the order the capturing parens start, left to right. Therefore, option b.
Here's another solution that uses some of VBA's built in date functions and stores all the date data in an array for comparison, which may give better performance if you get a lot of data: Public Sub MoveData(MonthNum As Integer, FromSheet As Worksheet, ToSheet As Worksheet) Const DateCol = "A" 'colum...
|sap|css|
|css|sap|
I am overriding a lot of SAP's Portal functionality in my current project. I have to create a custom fixed width framework, custom iView trays, custom KM API functionality, and more. With all of these custom parts, I will not be using a lot of the style functionality implemented by SAP's Theme editor. What I would...
|css|sap|portal|
There are a few tools, depending on what you want to do. I'm not sure what you mean by "report", things like <a href="http://lxr.linux.no/">lxr</a> will do html etc. cross referenced links. But for a person to use to help understand some code, then <a href="http://students.ceid.upatras.gr/~sxanth/ncc/">ncc</a> or <a hr...
The NullReferenceException was actually thrown within a catch block so the stack trace couldn't display that line of code so instead it stopped at the caller. It was indeeed one of the properties of the l_Monitor instance.
This is originally from Sara's [blog][1]. It also works with almost any version of Visual Studio, you just need to change the "8.0" in the registry key to the appropriate version number for your version of Visual Studio. The guide line shows up in the Output window too. You can also have the guide in multiple ...
This is originally from Sara's [blog][1]. It also works with almost any version of Visual Studio, you just need to change the "8.0" in the registry key to the appropriate version number for your version of Visual Studio. The guide line shows up in the Output window too. You can also have the guide in multiple ...
Microsoft guidelines as checked by FxCop discourage use of List&lt;T&gt; in public APIs - prefer IList&lt;T&gt;. Incidentally, I now almost always declare one-dimensional arrays as IList&lt;T&gt;, which means I can consistently use the IList&lt;T&gt;.Count property rather than Array.Length. For example: publ...
You may want to check the [architecture](http://www.archiveopteryx.org/architecture) and the [DB schema](http://www.archiveopteryx.org/schema) of "Archiveopteryx".
You will also see wierd issues if the Thread class is ever further subclassed. In that case, you'll end up with the thread running already once the super() exits, and anything the subclass might do in its constructor could be invalid. @bill barksdale If the thread is already running, calling start again gets you...
Is there a reason to use Word? If you start with a PDF with Form fields, you can either allow the user to fill out the fields, or do it programatically with iTextSharp's PDF stamper. If you need to use MSOffice 2000/2003 components programmatically, you can try Office Web Components. They do need to be installed on...
SQL Server 2005 Linked Server to DB2 Performance issue
|sql-server|db2|
I have a SQL Server 2005 machine with a JDE DB2 set up as a linked server. For some reason the performance of any queries from this box to the db2 box are horrible. For example. The following takes 7 mins to run from Management Studio SELECT * FROM F42119 WHERE SDUPMJ >= 107256 Whereas it t...
Python - time.clock() vs. time.time() - accuracy?
|python|
Which is better to use for timing in Python? time.clock() or time.time()? Which one provides more accuracy? for example: start = time.clock() ... do something elapsed = (time.clock() - start) vs. start = time.time() ... do something elapsed = (time.time() - start)
I've developed on numerous multi-platform C++ apps (the largest being 1.5M lines of code and running on 7 platforms -- AIX, HP-UX PA-RISC, HP-UX Itanium, Solaris, Linux, Windows, OS X). You actually have two entirely different issues in your post. 1. Instability. Your code is not stable. Fix it. * Use unit tests...
|xml|validation|xsd|aiml|
In file Atomic.aiml, part of the [annotated ALICE AIML files][1], there are a lot of categories like this: <category> <pattern>ANSWER MY QUESTION</pattern> <template> Please try asking <set name="it">your question</set> another way. </template> ...
for (prop in obj) { alert(prop + ' = ' + obj[prop]); }
There are compiler validation suits available.<br> The one I remember is ["Perennial"](http://www.peren.com/pages/cvsa_set.htm). When I worked on a C compiler for a embedded SOC processor we had to validate the compiler against this and two other validation suits (that I forget the name of). Validating the compil...
Try to make changes at the database level in the least number of possible instructions. The general rule is to lock a resourse the lest possible time. Using T-SQL, PLSQL, Java on Oracle or any similar way you can reduce the time that each transaction locks a shared resource. I fact transactions in the database are o...
Yes it does translate to SQL, it generates a standard IN statement like this: SELECT [t0].[col1] FROM [table] [t0] WHERE [col1] IN ( 'Value 1', 'Value 2')
getting a DrawingContext for a wpf WriteableBitmap
|wpf|drawing|bitmaps|
Is there a way to get a `DrawingContext` (or something similar) for a `WriteableBitmap`? I.e. something to allow you to call simple `DrawLine`/`DrawRectangle`/etc kinds of methods, rather than manipulate the raw pixels directly.
Proving correctness of multithread algorithms
|algorithm|theory|multithreading|proof|correctness|
Does anyone have a good reference (books, articles) for this? Thanks!
|algorithm|multithreading|theory|correctness|proof|
Multithread algorithms are notably hard to design/debug/prove. Dekker's algorithm is a prime example of how hard it can be to design a correct synchronized algorithm. Tanenbaum's Modern operating systems is filled with examples in its IPC section. Does anyone have a good reference (books, articles) for this? Thanks!
Can I pass a JavaScript variable to another browser window?
|javascript|browser|
I have a page which spawns a popup browser window. I have a JavaScript variable in the parent browser window and I would like to pass it to the popped-up browser window. Is there a way to do this? I know this can be done across frames in the same browser window but I'm not sure if it can be done across browser windo...
I recently worked on a project were the "protected" member was a very good idea. The class hiearchy was something like: [+] Base | +--[+] BaseMap | | | +--[+] Map | | | +--[+] HashMap | +--[+] // something else ? The Base implemented a std::list but noth...
How should exceptions be planned at the architectural level?
|java|exception|architecture|
Are there any good resources for planning how exceptions will be used from an architecture perspective? (Or provide your suggestions directly here.) In projects on which I have worked I find that a few common Exceptions are used over and over again and tend to lose their meaning. From: [http://jamesjava.blogspot.com...
Check your User Agent string. This same thing happened to me one time and I realized it was because I was testing out some pages as "googlebot". The JavaScript that is generated depends on knowing what the user agent is. From [http://support.mozilla.com/tiki-view_forum_thread.php?locale=tr&comments_parentId=160492&f...
Firstly, if the users of your API aren't interested in specific, fine-grained failures, then having specific exceptions for them isn't of any value. Since it's often not possible to know what may be useful to your users, a better approach is to have the specific exceptions, but ensure they inherit from a common clas...
I like the answer given in "Refactoring" by Martin Fowler. Tell your boss that you are going to develop software the fastest way that you know how. It happens that in most cases the fastest way to develop software is to refactor as you go. The other thing to tell your boss is you are reducing the cost to make fu...
Take a look at the [ucfirst][1] function. $line = join " ", map {ucfirst} split " ", $line; [1]: http://perldoc.perl.org/functions/ucfirst.html
The solution we used at my last job was to number the scripts as they were added to source control: 01.CreateUserTable.sql 02.PopulateUserTable 03.AlterUserTable.sql 04.CreateOrderTable.sql The idea was that we always knew which order to run the scripts, and we could avoid having to manage data integrity issue...
All these answers and no Befunge? I'd wager a fair amount it's shortest solution of them all: 1 Not kidding. Try it yourself: http://www.quirkster.com/js/befunge.html
All these answers and no Befunge? I'd wager a fair amount it's shortest solution of them all: 1 Not kidding. Try it yourself: http://www.quirkster.com/js/befunge.html EDIT: I guess I need to explain this one. The 1 operand pushes a 1 onto Befunge's internal stack. Using the interpreter provided, you will e...
All these answers and no Befunge? I'd wager a fair amount it's shortest solution of them all: 1 Not kidding. Try it yourself: http://www.quirkster.com/js/befunge.html EDIT: I guess I need to explain this one. The 1 operand pushes a 1 onto Befunge's internal stack and the lack of anything else puts it in a ...
Tell him 80% of the costs associated with a software project comes in the maintenance phase of the lifecycle. Any refactoring done now to alleviate future problems, and have some examples, will net substantial cost benefits later on when the need arises to maintaining that code. This is assuming you are refactoring ...
Think of it this way: your stored procedures are about the data that's under them, and shouldn't really know about the applications above them. It's possible that one application will need to read or update data in a way that another doesn't, and so one would use SPs that the other wouldn't. If it were my applicatio...
As mentioned, purely functional languages are inherently parallelizable. However, imperative languages are much more intuitive for many people, and we are deeply entrenched in imperative legacy code. The fundamental issue is that pure functional languages express side-effects explicitly, while side effects are expresse...
If session is stored in-proc then worker process recycle will remove it. Otherwise it will be there even after wp recycles.
If session is stored in-proc then YES worker process recycle will remove it. Use Out-of-proc model or sql server to store session value if you want to keep it stored.
C99 is [available online][2]. Quoted from [www.open-std.org][1]: > The lastest publically available version of the standard is the combined C99 + TC1 + TC2, [WG14 N1124][2], dated 2005-05-06. This is a WG14 working paper, but it reflects the consolidated standard at the time of issue. In 2007, TC3 has been published...
I assume that you want to do this to make your code less verbose; instead of saying Thread t = new CustomThread(); t.start(); activeThreads.add(t); you can just say activeThreads.add( new CustomThread() ); I also like having less verbosity, but I agree with the other respondents that you s...
As 'sharding' is part of the architecture principles for large websites, you may be interested in listening to 'eBay's Architecture Principles with Randy Shoup' [here](http://www.se-radio.net/podcast/2008-09/episode-109-ebay039s-architecture-principles-randy-shoup).
Fitnesse has support for Delphi. See the [FitServers][1] page at fitnesse.org. [1]: http://www.fitnesse.org/FitServers
Try: p.model_properties()[s].get_value_for_datastore(p) See <a href="http://code.google.com/appengine/docs/datastore/propertyclass.html#Property_get_value_for_datastore">the documentation</a>.
Back in the VB6/COM/DCOM times we used the suite [J-Integra][1] to accomblish this task. I have no experience with the .NET version though. [1]: http://j-integra.intrinsyc.com/
I certainly have. Historically and on recent projects. Years ago I worked in organisations where templates were everything. Then I worked other places where the templates were looser or non-existent or didn't fit the projects I was working on. Now the content of the software design is pretty much governed by wha...
I would suppose that most people who write SDD documents and use terminology like CSCI have to be using a specific software development methodology and most likely are working for some serious government customer. They usually tend to take their preparations quite seriously and the documents are ready and approved befo...
Calling DLL functions from VB6.
|c++|c|vb6|
I've got a Windows DLL that I wrote, written in C/C++ (all exported functions are 'C'). The DLL works fine for me in VC++. I've given the DLL to another company who do all their development in VB. They seem to be having a problem linking to the functions. I haven't used VB in ten years and I don't even have it installe...
I've got a Windows DLL that I wrote, written in C/C++ (all exported functions are 'C'). The DLL works fine for me in VC++. I've given the DLL to another company who do all their development in VB. They seem to be having a problem linking to the functions. I haven't used VB in ten years and I don't even have it installe...
PowerShell's select-string is similar, it's not the same options and semantics, but it's still powerful.
My understanding of spooling is that it's a bit of a red herring on your execution plan. Yes, it accounts for a lot of your query cost, but it's actually an optimization that SQL Server undertakes automatically so that it can avoid costly rescanning. If you were to avoid spooling, the cost of the execution tree it si...