instruction stringlengths 0 30k ⌀ |
|---|
I would avoid serialization, IMHO, we implemented this for one of our applications in MFC back in 1995, we were smart enough to use independent object versioning, and file versioning, but you end up with a lot of old messy code around after time.
Imagine certain scenarios, deprecating classes, deprecating members, e... |
When you use LIKE without specifying any search criteria, it behaves like an = comparison. In your example, I would expect it to work properly. In your real data, you probably have a hidden (non-printable) character in your data (think about Carriage Return, Line Feed, Tab, etc....).
Take a look at this example...... |
When you use LIKE without specifying any search criteria, it behaves like an = comparison. In your example, I would expect it to work properly. In your real data, you probably have a hidden (non-printable) character in your data (think about Carriage Return, Line Feed, Tab, etc....).
Take a look at this example...... |
If you have .NET 3.0 available, I find the XamlReader/XamlWriter very handy for storing settings. They can write/read any .NET object to XAML if:
* The object has a parameterless constructor
* The properties to read/write have public getters and setters
It is especially nice that you don't have to decorate your... |
You might want to have a look to [gmplib](http://gmplib.org/), an arbitrary precision number handling library for C and C++ |
One of the feature which prevents me from using Studio Express is the ability to import and export data via the SSIS (SQL Server Integration Services). It is hard to be a true DBA with just Studio Express. From a developer's standpoint, Studio Express would typically be sufficient. |
For .net 1/2:
IEnumerator e;
try
{
e = enumerable.GetEnumerator();
return e.MoveNext();
}
finally
{
if (e is IDisposable)
e.Dispose();
}
Or, with generics:
using (IEnumerator<T> e = enumerable.GetEnumerator())
{
return e... |
Saving information in "sub" model in CakePHP |
|php|cakephp| |
I've got a simple CakePHP site (1.2). I've got a page where you can edit and save a Person. So I have a Person model and controller.
Each Person has none or more comments, in the comment table. So I have a Comment model, and I have a hasMany association on my Person model to the Comment model. View is working great.... |
Heapy is quite simple to use. At some point in your code, you have to write the following:
from guppy import hpy
h = hpy()
print h.heap()
This gives you some output like this:
Partition of a set of 132527 objects. Total size = 8301532 bytes.
Index Count % Size % Cumulative % ... |
You will need some GUI library with Python bindings. (working on list) |
You will need some GUI library with Python bindings.
**Cross-platform (Windows, Linux, Mac)**
Of course, there are many, but the most popular that I've seen in wild are:
- [WxPython][1] - based on [WxWidgets][2] (very popular, free to also for commercial projects)
- [PyQt][3] - based on [Qt][4] (also very... |
Your question has really two parts...
First you will need some GUI library with Python bindings and then (if you want) some program that will convert your python scripts into standalone executables.
**Cross-platform GUI libraries with Python bindings (Windows, Linux, Mac)**
Of course, there are many, but the m... |
It is not possible to delete the link and then relink? |
Your desire to create a WPF mapping tool is similar to mine, which lead me to ask [this question][1] about DeepZoom (aka MultiScaleImage) from Silverlight. I want a WPF version. The accepted answer provides a link to a very good starting point (similar to your described thought process).
[1]: http://stacko... |
None of the above. For the smoothest gameplay possible, your game should be time-based, not frame-locked. Frame-locking works for simple games where you can tweak the logic and lock down the framerate. It doesn't do so well with modern 3D titles where the framerate jumps all over the board and the screen may not be VSy... |
I don't know if this is what you need, because it's sqlserver based, but have you tried taking a look to [SSIS][1] and or [DTS][2]?
[1]: http://en.wikipedia.org/wiki/SQL_Server_Integration_Services
[2]: http://en.wikipedia.org/wiki/Data_Transformation_Services |
Is it safe to generally assume that toString() has a low cost? |
|java| |
Do you generally assume that toString() on any given object has a low cost? I do. Is that assumption valid? If it has a high cost should that normally be changed? What are valid reasons to make a toString() method with a high cost? The only time that I get concerned about toString costs is when I know that it is o... |
Do you generally assume that toString() on any given object has a low cost? I do. Is that assumption valid? If it has a high cost should that normally be changed? What are valid reasons to make a toString() method with a high cost? The only time that I get concerned about toString costs is when I know that it is o... |
Do you generally assume that toString() on any given object has a low cost (i.e. for logging)? I do. Is that assumption valid? If it has a high cost should that normally be changed? What are valid reasons to make a toString() method with a high cost? The only time that I get concerned about toString costs is when ... |
You need to add an HTTP Handler in your web config for gif files:
<system.web>
<httpHandlers>
<add path="*.gif" verb="GET,HEAD" type="System.Web.StaticFileHandler" validate="true"/>
</httpHandlers>
</system.web>
That forces .Net to handle the file, then you'll get the .Ne... |
It's about how much type-safety you want to impose.
When you write `(foo) bar` (which is equivalent to `reinterpret_cast<bar> foo` in C++) you are telling the compiler to ignore type safety, and just do as it's told.
When you write `static_cast<bar> foo` you are asking the compiler to at least check that the type... |
It's about how much type-safety you want to impose.
When you write `(bar) foo` (which is equivalent to `reinterpret_cast<bar> foo` if you haven't provided a type conversion operator) you are telling the compiler to ignore type safety, and just do as it's told.
When you write `static_cast<bar> foo` you are asking ... |
I'd be tempted to suggest that whether you use concrete types or not shouldn't matter, as if your using dependency injection (castle?) to create the repositories (so you can wrap them with different caches etc) then your codebase will be none the wiser whichever way you've done it.
Then just ask your DI for a reposi... |
I think performance is a pretty good reason. If you consider every instruction in a typical program that increments an integer, and if instead of the simple op to add 1, it had to check every time if adding 1 would overflow the type, then the cost in extra cycles would be pretty severe. |
The main reason you might want to do this on subversion is for binary files (i.e. images, etc.) that are difficult or impossible to 'merge'. In those cases, each user can request a lock on a file. There is also a svn property (needs-lock) that can be applied to files that makes them read-only on checkout, and read-writ... |
Red Hat has a program which detects which (if any) virtualization product it's being run under: <A HREF="http://et.redhat.com/~rjones/virt-what/">virt-what</A>. |
Red Hat has a program which detects which (if any) virtualization product it's being run under: <A HREF="http://et.redhat.com/~rjones/virt-what/">virt-what</A>.
Using a third-party-maintained tool such is this is a better strategy long-term than trying to roll your own detection logic: more eyes (testing against mor... |
Considering that an “int” is different in some languages depending on 16bit/32bit system, a "string" could in the future evolve to not be the same as System.String.
But for now it is.
|
SVN Versioning |
|svn|version-control| |
Just a small SVN "problem" here.
I setup my own SVN server [http://www.codinghorror.com/blog/archives/001093.html][1]
Now I made a rep in which all my projects will go.
Now, I checked the rep out in a folder called "Projects".
Now If I make a project and check it in, that project is revision 1. If I make a ... |
> Supposedly updating regularly via ntp
> is not a good solution
That's the solution I would recommend, though. Why is it not considered good at your location? |
The key point that I believe everyone here is pointing to is that with VERY careful consideration the usage of index hints can improve the preformance of your queries, IF AND ONLY IF, multiple indexes exist that could be used to retreive the data, AND if SQL Server is not using the correct one.
In my experience I ha... |
How can I best create a SharePoint list view that shows only root folder contents? |
|sharepoint|list-definition| |
I have a custom SharePoint list definition that is based on the Document content type. My library instance that I create from this contains many HTML documents, and each of those documents has some images saved into a subfolder inside this library. What's the best way to create a view that will show all of those top-... |
const is pointless when the argument is passed by value since you will not be modifying the caller's object.
const should be preferred when passing by reference, unless the purpose of the function is to modify the passed value.
Finally, a function which does not modify current object (this) can, and probably shou... |
The folks at Head First have come out with a book. Going by how good their other books are, I'd recommend this one. Haven't read it yet though. ([LINK][1])
[1]: http://headfirstlabs.com/books/hfsql/ |
You are correct, SQLite is a great place to start because it is free, lightweight, and available on many platforms. This is only a start though. SQLite is very liberal on SQL syntax and lacks an intneral programming language like DBMS systems have. Still, if you want to start and learn with minimal overhead, SQLite ... |
LINQ to SQL only supports 1 to 1 mapping of database tables, views, sprocs and functions available in Microsoft SQL Server. It's a great API to use for quick data access construction to relatively well designed SQL Server databases. LINQ2SQL was first released with C# 3.0 and .Net Framework 3.5.
LINQ to Entities (... |
SQLite is nice and they have really nice documentation, however you should be aware that it is not a full featured SQL database like MySQL, Postgres or the commercial variants. SQLite's API relies on callbacks which is a fine model, but not all database APIs work that way. If you are familiar with Perl, then DBI is a... |
At first glance, this does not make intuitive sense. But it does. Look at this code:
List<Person> people = new List<Person>();
List<object> things = people; // this is not allowed
// ...
Mouse gerald = new Mouse();
things.add(gerald);
Now we suddenly have a <code>List</code> of <code>Perso... |
If you want to write the front and back end in JAVA, and want to do complex ajax type thing, then GWT is a great way to go.
The easiest way to think about it is that building a GWT app is kind of like building a JAVA swing application that hooks into a server. Just like a swing app that uses a server you can make i... |
As far I know, every concatenation implies a memory reallocation. So the problem is not the operator used to do it, the solution is to reduce the number of concatenations. For example do the concatenations outside of the iteration structures when you can. |
What is the best way to return multiple tags from a Rails Helper? |
|ruby|ruby-on-rails|helper| |
I want to create a hidden field and create a link in one helper and then output both to my erb.
<%= my_cool_helper "something", form %>
Should out put the results of
link_to "something", a_path
form.hidden_field "something".tableize, :value => "something"
What would the definition of the help... |
I don't really understand what you're trying to do with this huge amount of XML, but I get the impression that
- using XML was wrong for the data stored
- you are buffering way beyond what you should do (and you are giving up all advantages of SAX parsing by doing so)
Apart from that: XML is not ancient and in m... |
Please remember to make your solution accessible to those not using conventional browsers. The iPhone crowd are not to be ignored, and those with vision and cognitive problems should not be excluded either. |
Use Mail::factory in the Mail PEAR package. [Example.][1]
[1]: http://email.about.com/od/emailprogrammingtips/qt/et073006.htm |
I completely agree with the previous posters... don't forget your team's workload also. Just because you estimated a project would take 3 months, it doesn't mean it'll be done anywhere near that.
I work on a smaller team (5 devs, 1 lead), many of us work on several projects at a time - some big, some small. Dependin... |
I believe Joel has wrote an article on this: What you can do, is ask each developer on team to lay out his task in detail (what are all the steps that need to be done) and ask them to estimate time needed for each step. Later, when project is done, compare the real time to estimated time, and you'll get the bias for ea... |
Something that doesn't change within a block of code |
I would suggest to first import your massive XML file into **a native XML database** (such as [eXist](http://exist.sourceforge.net/) if you are looking for open source stuff, never tested it myself), and then perform **iterative paged queries** to process your data small chunks at a time. |
|c#|java| |
You mention that :
> but both .net and php web applications are on different servers
Are both applications running under the same domain name? (ie: www.mydomain.com) or are they on different domains?
If they're on the same domain, then you can do what you're trying to do in PHP by using the $_COOKIE variable. ... |
I'm not really an old hand at Python, but here's an XPath solution using libxml2.
import libxml2
DOC = """<elements>
<parent name="CategoryA">
<child value="a1"/>
<child value="a2"/>
<child value="a3"/>
</parent>
<parent name="CategoryB... |
I'm not really an old hand at Python, but here's an XPath solution using libxml2.
import libxml2
DOC = """<elements>
<parent name="CategoryA">
<child value="a1"/>
<child value="a2"/>
<child value="a3"/>
</parent>
<parent name="CategoryB... |
I'm not really an old hand at Python, but here's an XPath solution using libxml2.
import libxml2
DOC = """<elements>
<parent name="CategoryA">
<child value="a1"/>
<child value="a2"/>
<child value="a3"/>
</parent>
<parent name="CategoryB... |
Without knowing what your rules are it's hard to say for sure, but assuming they are something like "the password must be at least 8 characters with at least one upper case letter, one lower case letter, one number and one special character" then it's impossible even with brute force to check sufficient quantities of g... |
Your question has really two parts...
First you will need some GUI library with Python bindings and then (if you want) some program that will convert your python scripts into standalone executables.
**Cross-platform GUI libraries with Python bindings (Windows, Linux, Mac)**
Of course, there are many, but the m... |
Your question has really two parts...
First you will need some GUI library with Python bindings and then (if you want) some program that will convert your python scripts into standalone executables.
**Cross-platform GUI libraries with Python bindings (Windows, Linux, Mac)**
Of course, there are many, but the m... |
Your question has really two parts...
First you will need some GUI library with Python bindings and then (if you want) some program that will convert your python scripts into standalone executables.
**Cross-platform GUI libraries with Python bindings (Windows, Linux, Mac)**
Of course, there are many, but the m... |
It is likely 99% performance. On x86 would have to check the overflow flag on every operation which would be a huge performance hit.
The other 1% would cover those cases where people are doing fancy bit manipulations or being 'imprecise' in mixing signed and unsigned operations and want the overflow semantics. |
I think you'll have to write it in C++, compile that to a DLL and then call the DLL from your managed code. |
You get the same opening the file for appending
<?php
$file=fopen(date("Y-m-d").".txt","a+") or exit("Unable to open file!");
if ($_POST["lastname"] <> "")
{
fwrite($file,$_POST["lastname"]."\n");
}
fclose($file);
?> |
The question code got me a little confused.
In general with Ruby, if that happens it's a good sign that I am trying to do things the wrong way.
It might be better to ask a question related to your actual intended outcome, rather than the specifics of a particular 'attack' on your problem. They we can say 'nonono,... |
What is a javascript hash table implementation that avoids object namespace collisions? |
|javascript|diff|hash|adobe-indesign| |
First off: I'm using a rather obscure implementation of javascript embedded as a scripting engine for Adobe InDesign CS3. This implementation sometimes diverges from "standard" javascript, hence my problem.
I'm using [John Resig's jsdiff library][1] ([source here][2]) to compare selections of text between two docume... |
Or you could just take advantage of Seam. All you need to do is enable the SeamFilter in web.xml. See [Blog Example][1] for an example RESTful application using Seam.
[1]: http://docs.jboss.com/seam/2.0.2.SP1/reference/en-US/html_single/#blog |
Or you could just take advantage of Seam. All you need to do is enable the SeamFilter in web.xml. See [Blog Example][1] for an example RESTful application using Seam. The key is to use a Seam page parameter, defined in WEB-INF/pages.xml
[1]: http://docs.jboss.com/seam/2.0.2.SP1/reference/en-US/html_single/#b... |
All you need to do is enable the SeamFilter in web.xml. See [Blog Example][1] for an example RESTful application using Seam. The key is to use a Seam page parameter, defined in WEB-INF/pages.xml
[1]: http://docs.jboss.com/seam/2.0.2.SP1/reference/en-US/html_single/#blog |
The linq workaround is a good one. Another workaround, since you are using type object, is to pass the list as IEnumerable (not the generic version). |
Structure Query Language (SQL) is the language used to talk to database management systems (DBMS). While it's a good thing to learn, it's probably best to do it with a project in mind that you'd like to do. It's funny you say you've never had a need, because I'm the opposite, almost every program I've ever written has ... |
How do I save a model with this dynamically generated field? |
|ruby-on-rails| |
I have a rails model that looks something like this:
class Recipe < ActiveRecord::Base
has_many :ingredients
attr_accessor :ingredients_string
attr_accessible :title, :directions, :ingredients, :ingredients_string
before_save :set_ingredients
def ingredients_string
... |
Your question has really two parts...
First you will need some GUI library with Python bindings and then (if you want) some program that will convert your python scripts into standalone executables.
**Cross-platform GUI libraries with Python bindings (Windows, Linux, Mac)**
Of course, there are many, but the m... |
First you will need some GUI library with Python bindings and then (if you want) some program that will convert your python scripts into standalone executables.
**Cross-platform GUI libraries with Python bindings (Windows, Linux, Mac)**
Of course, there are many, but the most popular that I've seen in wild are:
... |
First you will need some GUI library with Python bindings and then (if you want) some program that will convert your python scripts into standalone executables.
**Cross-platform GUI libraries with Python bindings (Windows, Linux, Mac)**
Of course, there are many, but the most popular that I've seen in wild are:
... |
In (c++ like) pseudocode these two are what I used in industrial image processing applications that had to process images from a set of externally triggered camera's. Variations in "frame rate" had a different source (slower or faster production on the belt) but the problem is the same. (I assume that you have a simple... |
I usually use 30 or 33. It's often enough for the user to feel the flow and rare enough not to hog the CPU too much. |
There are APis available:
Yahoo --> [http://developer.yahoo.com/addressbook/][1]
Google --> [http://code.google.com/apis/contacts/][2]
None for AOL (yet).
[1]: http://developer.yahoo.com/addressbook/
[2]: http://code.google.com/apis/contacts/ |
Any other tools/plugins like VisualAssist that will change my life (MSVS)? |
|visual-assist| |
I was introduced to VisualAssist a few years ago and for me there's no going back. Are there any other tools I'm missing out on? |
When using an ORM, how to safely send loaded entities across the tiers |
|architecture|orm| |
When a system has N tiers, and when using an ORM, how do you send loaded entities across the tiers ?
Do you use DTO ?
When DTO are not used and the entities are directly sent, how do you protect againt the uninitialized lazy loaded relationship errors ?
Note : this is not a "should N tiers be used ?" question.... |
Setting Environment Variables for Mercurial Hook |
|python|shell|mercurial| |
I am trying to call a shell script that sets a bunch of environment variables on our server from a mercurial hook. The shell script gets called fine when a new changegroup comes in, but the environment variables aren't carrying over past the call to the shell script.
My hgrc file on the respository looks like this:
... |
Not sure it is programming-related... but:
firefox -safe-mode
Reset toolbar and control
More at [Firefox support][1]
[1]: http://support.mozilla.com/fr/kb/Firefox+window+is+too+large+or+opens+off+screen |
I usually use `sys.platform` to get the platform. `sys.platform` will distinguish between linux, other unixes, and OS X while `os.name` is "`posix`" for all of them.
For much more detailed information, use the [platform module][1]. This has cross-platform functions that will give you information on the machine archi... |
Note on the "It would be best if i didn't have to add any extra fields to the model, but if i really have to i can."
Sorry, but order of information in a database is determined by the information itself: you always have to add a column for ordering. There's really no choice about that.
Further, to retrieve ... |