instruction stringlengths 0 30k ⌀ |
|---|
|c++|api|error-handling|error-logging|api-design| |
I've encountered the following problem pattern frequently over the years:
* I'm writing complex code for a package comprised of a standalone application and also a library version of the core that people can use from inside other apps.
* Both our own app and presumably ones that users create with the core library... |
[AngelScript](http://www.angelcode.com/angelscript/)
> lets you call standard C functions and C++ methods with no need for proxy functions. The application simply registers the functions, objects, and methods that the scripts should be able to work with and nothing more has to be done with your code. The same funct... |
If you're using a winforms app you could try using [UserProperties][1] to store this info. Another possible solution could be [custom configuration sections][2].
[1]: http://msdn.microsoft.com/en-us/library/aa221771(office.11).aspx
[2]: http://msdn.microsoft.com/en-us/library/2tw134k3.aspx |
You didn't provide a budget or other considerations like sound footprint. You also didn't say if you actually can use more than a few cores at one time with the applications you are developing. So, everything below is a guess.
If you have the budget, the Mac Pro with Bootcamp(or a vm if you are so inclinded) might be... |
Is this valid YAML? |
|yaml| |
So for my text parsing in C# [question][1], I got directed at YAML. I'm hitting a wall with this library I was recommended, so this is a quickie.
heading:
name: A name
taco: Yes
age: 32
heading:
name: Another name
taco: No
age: 27
And so on. Is that valid?
[1]:htt... |
I do it the other way around. I find that doing it database-schema-first gets the system stuck in a data-driven-design that is difficult to abstract from persistence. We try to do domain model designs first *and then* base the database schema on those.
And then there's the infrastructure design: the team should sett... |
Add a [pre-commit hook][1] which parses the file content and performs the munging of CRLF/LF/CR/etc for you before it's written to SVN.
[1]: http://wordaligned.org/articles/a-subversion-pre-commit-hook |
There were some excellent suggestions already, but I just wanted to mention that Perl can also be called / can call to C/C++. |
If you right-click on your "Computer" (or "My Computer") icon and select "Manage" from the pop-up menu, that'll take you to the Computer Management console.
In there, under System Tools\Shared Folders, you'll find "Open Files". This is probably close to what you want, but if the file is on a network share then you'd... |
I *think* that an unordered_map and hash_map are more or less the same thing. The difference is that the STL doesn't officially have a hash_map (what you're using is probably a compiler specific thing), so unordered_map is the fix for that omission.
unordered_map is just that... unordered. You can't depend on it pre... |
MSSQL Full Text Searching |
|mssql|search| |
I am currently working on an application where we have a mssql database and I need to get a full text search working that allows us to search people's names.
Currently the user can enter a into a name field that searches 3 different varchar cols. First, Last, Middle names
So say I have 3 rows with the following i... |
|mssql|search|fulltextsearch| |
|search|fulltextsearch| |
|search|full-text-search| |
|search|fulltextsearch| |
|search|full-text-search| |
|sql-server|search|full-text-search| |
@wesc: STL has std::map... so what's the difference with unordered_map? I don't think STL would implement twice the same thing and call it differently. |
I can think of a couple of reasons:
- A modicum of security by obscurity - it's slightly more work to tamper with POST submissions than GET
- Caching and resubmit rules are more restrictive for POST than GET. I'm not entirely sure this would matter for the OpenID use case, though.
- Bots wouldn't follow the ... |
[xxd](http://gd.tuwien.ac.at/linuxcommand.org/man_pages/xxd1.html) is the 'standard' hex dump util and looks like it should solve your problems |
XML => HTML with Hpricot and Rails |
|hpricot|rubyonrails|ruby|ruby-on-rails|open-uri| |
I've never worked with web services and rails, and obviously this is something I need to learn.
I've chosen to use hpricot because it looks great.
Anyway, _why's been nice enough to provide the following example on the [hpricot website][1]:
#!ruby
require 'hpricot'
require 'open-uri'
# load ... |
|ruby|xml|ruby-on-rails|hpricot|open-uri| |
Is there a rake task for backing up the data in your database? |
|rake|database| |
Is there a rake task for backing up the data in your database?
I already have my schema backed up, but I want to make a backup of the data. It's a small database. |
|rake|database|sql| |
Is there a rake task for backing up the data in your database?
I already have my schema backed up, but I want to make a backup of the data. It's a small MySQL database. |
|rake|database|mysql|ruby|ruby-on-rails| |
|database|ruby|mysql|ruby-on-rails|rake| |
Defensive programming |
|security|quality| |
When writing code do you consciously program defensively to ensure high program quality and to avoid the possibility of your code being exploited maliciously, e.g. through buffer overflow exploits or code injection ?
What's the "minimum" level of quality you'll always apply to your code ? |
|security|quality|defensive-programming| |
Shift operator in C |
|c| |
Is the shift operator (<<, >>) in C arithmetic shift or logical shift? |
|c| |
Looks like Jeff is using [CruiseControl.NET][1] based on some leafing through the podcast transcripts. This seems to have automated deployment capabilities from source control to production. Might this be where the insertion is happening?
[1]: http://confluence.public.thoughtworks.org/display/CCNET/What+is+Cruis... |
Annotating YouTube videos programatically |
|web|youtube| |
I want to be able to display a normal youtube video with overlaid annotations. This consists of colored rectangles for each frame. The only requirement is that this be done programatically. Youtube has annotations now, but require you use their front end to create them by hand. I want to be able to generate them. What'... |
Apache/PHP: error_log per Virtual Host? |
|php|apache| |
On one Linux Server running Apache and PHP 5, we got multiple Virtual Hosts with separate logfiles and everything. The only thing we cannot seem to separate between virtual hosts is the php error_log. Overriding this setting in the <Location> of the httpd.conf does not seem to do anything.
Did I overlook somet... |
Maybe this might help:
http://jsefa.sourceforge.net/quick-tutorial.html
Read csv file with this tool and serialize to xml :) |
Adobe air - SQLStatement.execute() - Multiple queries in one statement |
|actionscript-3|apache-flex|air| |
I've written a database generation script in sql, and want to execute it in my Adobe air application:
Create Table tRole (
roleID integer Primary Key
,roleName varchar(40)
);
Create Table tFile (
fileID integer Primary Key
,fileName varchar(50)
,fileDescription varchar(500)
,th... |
>I don't use VS2008 for C++, only VB & C#, but I find that when intellisense stops working (true for VS2003/2005/2008) it's because something in the project/file is broken - usually a bad reference or code.
VB and C# have much better intellisense support due to the ability to reflect on the referenced assemblies to ... |
ASP.NET MVC and IIS6 |
|asp.net-mvc|iis-6| |
Where can I find some good pointers on best practices for running ASP.NET MVC on IIS6?
I haven't seen any realistic options for web-hosts who provide IIS7-hosting yet. Mostly because I don't live in the U.S.
So I was wondering on how you best build applications in ASP.NET MVC and make it easily available to deplo... |
ASP.NET MVC on IIS6 |
Where can I find some good pointers on best practices for running ASP.NET MVC on IIS6?
I haven't seen any realistic options for web-hosts who provide IIS7-hosting yet. Mostly because I don't live in the U.S.
So I was wondering on how you best build applications in ASP.NET MVC and make it easily available to deplo... |
|.net|asp.net-mvc|iis-6| |
|.net|asp.net-mvc|deployment|iis-6| |
Your logic seems sound, but you might want to consider adding some code to prevent the insert if you had passed in a specific primary key.
Otherwise, if you're always doing an insert if the update didn't affect any records, what happens when someone deletes the record before you "UPSERT" runs? Now the record you we... |
How to identify that you're running under a VM? |
|virtualization| |
Is there a way to identify, from within a VM, that your code is running inside a VM?
I guess there are more or less easy ways to identify specific VM systems, especially if the VM has the provider's extensions installed (such as for VirtualBox or VMWare). But is there a general way to identify that you are not runni... |
If you don't want it saved, you do not need to execute the cfg.Save command.
The Configuration object will store your changes until it isn't needed anymore. |
@lomaxx I also learned the other day (the same time I learned your tip) is that you can now have disparate access levels on the same property:
public string Name { get; private set;}
That way only the class itself can set the Name property.
public Name(string name) { Name = name; } |
Just so I'm clear, you've done something like this, right?
public ListView MyListView { get { return this.listView1; } }
So then you are accessing (at design time) the MyListView property on your UserControl?
I think if you want proper design-time support you're better off changing the "Modifier" property ... |
Try [Handle][1]. [Filemon][2] & [Regmon][3] are also great for trying to figure out what the duce program foo is doing to your system.
[1]: http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx
[2]: http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx
[3]: http://technet.microsoft.com/en-... |
> If you can I'd be horrified.
Why would you be horrified?
Air is a desktop platform, and having access to the OS's APIs (such as registry access) makes plenty of sense.
That being said, it isn't supported now (and as Adobe seem to be very Mac-centric, I doubt it will ever be added).
> I have settled on grab... |
Use [Process Explorer][1] from the Sysinternals Suite, the Find Handle or DLL function will let you search for the process with that file open.
[1]: http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx "Process Explorer" |
There appears to be a YAML validator called [Kwalify][1] which should give you the answer. You shoulda just gone with the String tokenizing, man. Writing parsers is fun :)
[1]: http://www.kuwata-lab.com/kwalify/ |
Why not just add a dependency to the "startup" project for each of the plugins? This will force the project to be rebuilt if any of the others change, and you won't have to mess with any other pre/post-build events. |
Partially. YAML supports the notion of multiple consecutive "documents". If this is what you are trying to do here, then yes, it is correct - you have two documents (or document fragments). To make it more explicit, you should separate them with three dashes, like this:
---
heading:
name: A name
... |
You will almost certainly want to use a database for flexible, record based access and to take advantage of the database's ability to handle concurrent data access. If you need to track information that may need to be undone, having it in a structured format is a benefit, as is having the ability to update a row indica... |
[Boost documentation of unordered containers][1]
The difference is in the method of how you generate the look up.
In the map/set containers the `operator<` is used to generate an ordered tree.
In the unordered containers, an `operator( key ) => index` is used.
See hashing for a description of how that wor... |
You sure that std::hash_map exists in *all* STL implementations? SGI STL implements it, however GNU g++ doesn't have it (it's located in the __gnu_cxx namespace) as of 4.3.1 anyway. As far as I know, hash_map has always been non-standard, and now tr1 is fixing that.
|
It all depends on your skill level and how much load you are getting on your servers.
If you have spare (physical) resources and have the technical skills and experience to maintain production machines running different operating systems, I'd recommend going running lighttpd on either Linux or FreeBSD. A light OS in... |
If you're serving files over the Internet, you might also consider [Amazon's S3 service][1]. I've found the rates and reliability to be better than anything I could do (or find) on my own.
[1]: http://www.amazon.com/gp/browse.html?node=16427261 |
In C++ I use this [example code][1] to do natural sorting. The code requires the boost library.
[1]: http://www.boostcookbook.com/Recipe:/1235053 |
I have tried both methods with a large commercial C++ application.
**The better method: The trunk should be always stable.**
Here are some guidelines and benefits of this method:
- Code each task (or related set of tasks) in its own branch, then you will have the flexibility of when you would like to merge ... |
For 3.5, you must install this tool:
- [http://www.microsoft.com/downloads/details.aspx?FamilyID=4377f86d-c913-4b5c-b87e-ef72e5b4e065&displaylang=en][1]
And for 3.0 you must use the 2.0 config tool.
[Source of Answer][2].
[1]: http://www.microsoft.com/downloads/details.aspx?FamilyID=4377f86d-c913-4b5c... |
yes. If you mark a method as Sealed then it can not be overriden in a derived class.
|
Normally DestroyHandle is called in Dispose method. So you need to make sure that all controls are disposed to avoid handles leaks. |
Normally DestroyHandle is being called in Dispose method. So you need to make sure that all controls are disposed to avoid resource leaks. |
Yes, you can use the sealed keyword in the B class's implementation of Render:
class B : A
{
public sealed override void Render()
{
// Prepare the object for rendering
SpecialRender();
// Do some cleanup
}
protected virtual void Sp... |
How sophisticated should be my Ajax code? |
|ajax| |
I have seen simple example Ajax source codes in many online tutorials. What I want to know is whether using the source code in the examples are perfectly alright or not?
Is there anything more to be added to the code that goes into a real world application?
What all steps are to be taken to make the application m... |
I have seen simple example Ajax source codes in many online tutorials. What I want to know is whether using the source code in the examples are perfectly alright or not?
Is there anything more to be added to the code that goes into a real world application?
What all steps are to be taken to make the application m... |
Danny is mostly right.
a. unsigned decimal, minimum 4 characters, space padded<br>
b. floating point, minimum 16 digits before the decimal (0 padded), 1 digit after the decimal<br>
c. hex, minimum 4 characters, 0 padded, letters are printed in upper case<br>
d. same as above, but minimum 2 characters<br>
e. e is... |
Danny is mostly right.
a. unsigned decimal, minimum 4 characters, space padded<br>
b. floating point, minimum 16 digits before the decimal (0 padded), 1 digit after the decimal<br>
c. hex, minimum 4 characters, 0 padded, letters are printed in upper case<br>
d. same as above, but minimum 2 characters<br>
e. e is... |
If, while writing your code, you expect this object to be in the collection, and then during runtime you find that it isn't, I would call that an exceptional case, and it is proper to use an exception.
However, if you're simply testing for the existence of an object, and you find that it is not there, this is not ex... |
The latter is an acceptable solution. Although I would definitely catch on the specific exception (ElementNotFound?) that the collection throws in that case.
Speedwise, it depends on the common case. If you're more likely to find the element than not, the exception solution will be faster. If you're more likely to f... |
> I just confrim, Replicating between
> SqlServer 2005 and Compact Edition is
> something that can be done?
Yes it can definately be done using either Merge Replication or Sync Services |
I would have to think about it more as to how much I like it... my gut instinct is, eh, not so much...
EDIT: Ryan Fox's comments on the exceptional case is perfect, I concur
As for performance, it depends on the indexer on the collection. C# lets you override the indexer operator, so if it is doing a for loop li... |
What are some web-based knowledge-base solutions? |
|language-agnostic|planning| |