instruction
stringlengths
0
30k
If your program validates the XML against the DTD during normal execution, then you should just get the DTD from wherever your program will get it. If not and the DTD is extremely short (only a few lines), then storing it as a string in your code is probably okay. Otherwise, I'd put it in an external file and hav...
I would say your test scheme is not really useful. To fulfill the db query, the db server goes through several steps: 1. parse the SQL 2. work up a query plan, i. e. decide on which indices to use (if any), optimize etc. 3. if used, search the index for the pointers to the actual data 4. load the data from di...
I would say your test scheme is not really useful. To fulfill the db query, the db server goes through several steps: 1. parse the SQL 2. work up a query plan, i. e. decide on which indices to use (if any), optimize etc. 3. if an index is used, search it for the pointers to the actual data, then go to the appro...
Secure all folders containing any sensitive info with the location tag. Encrypt any connection strings with [DPAPI][1]. [1]: http://msdn.microsoft.com/en-us/library/ms998280.aspx
If your only intent is to get calling code to not make a mistake, and modify the collection when it should only be reading all that is necessary is to return an interface which doesn't support Add, Remove, etc.. Why not return IEnumerable<string>? Calling code would have to cast, which they are unlikely to do without...
Our company (and others) use the open source <a href="http://www.icu-project.org/">Internation Components for Unicode</a> (ICU) library originally developed by Taligent. It handles strings, locales, conversions, date/times, collation, transformations, et. al. Start with the <a href="http://www.icu-project.org/us...
@CodingTheWheel: There is one slight problem with your approach. Consider a call such as XTRACE("x=%d", x); This works fine in the debug build, but in the release build it will expand to: ("x=%d", x); Which is perfectly legitimate C and will compile and usually run without side-effects but genera...
You can use shared memory or named pipe to facilitate IPC as well. Conceptually this is similar to TCP/IP, but you don't have to worry about finding an unused port. You have to make sure that the named objects you create are prefixed with "Global\" to allow them to be accessed by all sessions as described [here][1]....
One should not that [aku][1]'s answer will only protect the list as being read only. Elements in the list are still very writable. I don't know if there is any way of protecting non-atomic elements without cloning them before placing them in the read only list. [1]: http://stackoverflow.com/questions/55502/r...
One should note that [aku][1]'s answer will only protect the list as being read only. Elements in the list are still very writable. I don't know if there is any way of protecting non-atomic elements without cloning them before placing them in the read only list. [1]: http://stackoverflow.com/questions/55502/...
Before you check the code in.
When hacking something together for myself, I test at the end. Bad practice, but these are usually small things that I'll use a few times and that's it. On a larger project, I write tests before I write a class and I run the tests after every change to that class.
The [Beagle search engine][1] had code to parse Mork files. It's not the most memory efficient solution, but it worked and could be a useful starting point. Here's a link to the file: [http://svn.gnome.org/viewvc/beagle/tags/BEAGLE_0_2_18/Util/Mork.cs?view=markup][2] (These days Beagle doesn't use this parser a...
Open Calais probably use language parsing technology and language statics to guess which words or phrases are Names, Places, Companies, etc. Then, it is just another step to do some kind of search for those entities and return meta data. Zementa probably does something similar, but matches the phrases against meta-d...
This is going to be a long answer, because I want to make sure you are fully aware of all the ways you can accomplish what you want to do. The routing engine that powers the ASP.NET MVC Framework will work with the traditional ASP.NET Framework. You can take advantage of using the RouteTable and assigning routes, j...
|.net|asp.net|.net-3.5|crystal-reports|
While not related to .net, I would consider obfuscation in Javascript, and possibly other interpeted languages. Javascript benefits well from obfuscation because it reduces the bandwith needed, and the tokens the parser has to read. But obfuscating compiled bytecode doesn't really seem that usefull to me. I mean wha...
The main reason to use obfuscation is to protect intellectual property as you have indicated. It is generally much more cost effective to a business to purchase an obfuscation product like .NET Reactor than it is to try and legally enforce your copyrights. Obfuscation can also provide other more incidental benefits...
Another system (not mentioned in the accepted answer yet) is PyInstaller, which worked for a PyQt project of mine when py2exe would not. I found it easier to use. http://pyinstaller.python-hosting.com/
Another system (not mentioned in the accepted answer yet) is PyInstaller, which worked for a PyQt project of mine when py2exe would not. I found it easier to use. http://pyinstaller.python-hosting.com/ Pyinstaller is based on Gordon McMillan's Python Installer. Which is no longer available.
You asked for engineering reasons, so this is not strictly speaking an answer to the question. But I think it's a valid clarification. As you say, obfuscation is intended to address a social problem. And social (or business) problems, unlike technical ones, rarely have a complete solution. There are only degrees of ...
Best strategy to write hooks for subversion in Windows
|subversion|hook|
What is the best approach to write **hooks** for **Subversion** in **Windows**? As far as I know, only executable files can used. So what is the best choice? - Plain batch files (very limited but perhaps OK for very simple solutions) - Dedicated compiled executable applications (sledgehammer to crack a nutshel...
I attempted to use the Entity Framework on an existing project (~60 tables, 3 with inheritance) just to see what it was all about. My experience boiled down to: The designer surface is kludgy. The mapping isn’t intuitive and someone must have thought that having several tool windows open at the same time is acceptab...
Why is it considered bad practice to use cursors in SQL Server?
|sql-server|
I knew of some performance reasons back in the SQL 7 days, but do the same issues still exist in SQL Server 2005? If I have a resultset in a stored procedure that I want to act upon individually, are cursors still a bad choice? If so, why?
The following will do it: for i in `seq 1 N` ; do mv foo$i `printf foo%05d $i` ; done (Although technically `seq` isn't part of `bash`, it's in [gnu coreutils][1], and I just found out it's not in OS X!) [1]: http://www.gnu.org/software/coreutils/
The following will do it: for i in ((i=1; i<=N; i++)) ; do mv foo$i `printf foo%05d $i` ; done **EDIT:** changed to use ((i=1,...)), thanks [mweerden][1]! [1]: http://stackoverflow.com/users/4285/mweerden
How do I position one image on top of another in HTML?
|html|rails|
I'm a beginning rails programmer, attempting to show many images on a page. Some images are to lay on top of others. To make it simple, say I want a blue square, with a red square in the upper right corner of the blue square (but not tight in the corner). I am trying to avoid compositing (with ImageMagick and simila...
|html|css|
|html|css|graphics|
Hierarchical Data In ASP.NET MVC
|asp.net|asp.net-mvc|
I am trying to come up with the best way to render some hierarchical data in to a nested unordered list using ASP.NET MVC. Does anyone have any tips on how to do this?
This is going to be a long answer, because I want to make sure you are fully aware of all the ways you can accomplish what you want to do. The routing engine that powers the ASP.NET MVC Framework will work with the traditional ASP.NET Framework. You can take advantage of using the RouteTable and assigning routes, j...
This is going to be a long answer, because I want to make sure you are fully aware of all the ways you can accomplish what you want to do. The routing engine that powers the ASP.NET MVC Framework will work with the traditional ASP.NET Framework. You can take advantage of using the RouteTable and assigning routes, j...
You can do it, but the downside is that it can't be part of the prototype: function Restaurant() { var private_stuff = function() // Only visible inside Restaurant() { } this.use_restroom = function() // use_restroom is visible to all { privat...
You can do it, but the downside is that it can't be part of the prototype: function Restaurant() { var myPrivateVar; var private_stuff = function() // Only visible inside Restaurant() { myPrivateVar = "I can set this here!"; } this.use_restroo...
I assume with shards we're talking about horizontal partitioning and not vertical partitioning ([here are the differences on Wikipedia][1]). First off, **stretch vertical partitioning** as far as you can take it before you consider horizontal partitioning. It's easy in Rails to have different models point to differ...
Indeed, for security reasons it is no longer possible to communicate directly with the "desktop". What exactly is the "desktop" anyway, when you live in a machine with multiple active users + remote sessions? The general way to solve the problem is to use service apps which communicate via some RPC mechanism (TCP/I...
SharePoint Permissions
|sharepoint|permissions|
I would like to create a folder that users who do not have privileges to view the rest of the site can see. This user group would be granted access to the site, but I only want them to be able to view one particular page. Is this possible to do without going to every single page and removing the new user group's acc...
This is going to be a long answer, because I want to make sure you are fully aware of all the ways you can accomplish what you want to do. The routing engine that powers the ASP.NET MVC Framework will work with the traditional ASP.NET Framework. You can take advantage of using the RouteTable and assigning routes, j...
I have trouble wrapping my head around lambda expressions because I work in Visual FoxPro, which has Macro substitution and the ExecScript{} and Evaluate() functions, which seem to serve much the same purpose. ? Calculator(10, 23, "a + b") ? Calculator(10, 23, "a - b"); FUNCTION Calculator(a, b, ...
I've had good success using [Mockito][1]. When I tried learning about JMock and EasyMock, I found the learning curve to be a bit steep (though maybe that's just me). I like Mockito because of its simple and clean syntax that I was able to grasp pretty quickly. The minimal syntax is designed to support the common ...
I would say your test scheme is not really useful. To fulfill the db query, the db server goes through several steps: 1. parse the SQL 2. work up a query plan, i. e. decide on which indices to use (if any), optimize etc. 3. if an index is used, search it for the pointers to the actual data, then go to the appro...
How to serialize a graph structure?
|serialization|graph|
Flat files and relational databases give us a mechanism to serialize structured data. XML is superb for serializing un-structured tree-like data. But many problems are best represented by graphs. A thermal simulation program will, for instance, work with temperature nodes connected to each others through resistive e...
@[modesty](): > I wish there was a Mac version. You can install the font on a Mac. I use it all the time, everywhere, without any problem. The only thing to pay attention for is to set `nomacatsui` when working with GVIM, or better yet, switch to [MacVim](http://code.google.com/p/macvim/).
I test constantly. After I finish even a loop inside of a function, I run the program and hit a breakpoint at the top of the loop, then run through it. This is all just to make sure that the process is doing exactly what I want it to. Then, once a function is finished, you test it in it's entirety. You probably want...
I've only recently added unit testing to my regular work flow but I write unit tests: * to express the requirements for each new code module (right after I write the interface but before writing the implementation) * every time I think "it had better ... by the time I'm done" * when something breaks, to quantif...
[YSlow][1] can give you a quick analysis of different metrics. [1]: http://developer.yahoo.com/yslow/
It sounds like in the console situation you are running with your current user credentials, which have access to the PSI. When running from the web, it's running with the creds of the IIS application instance. I think you'd either need to set up delegation to pass the session creds to the IIS application, or use some s...
Store procedures should be used as much as possible, if your writing SQL into code your already setting yourself up for headaches in the futures. It takes about the same time to write a SPROC as it does to write it in code. Consider a query that runs great under a medium load but once it goes into fulltime productio...
Store procedures should be used as much as possible, if your writing SQL into code your already setting yourself up for headaches in the futures. It takes about the same time to write a SPROC as it does to write it in code. Consider a query that runs great under a medium load but once it goes into fulltime productio...
Ubuntu 32 bit maximum address space
|memory|ubuntu|operating-system|
Jeff covered this a while back [on his blog][1] in terms of 32 bit Vista. Does the same 32 bit 4 GB memory cap that applies in 32 bit Vista apply to 32 bit Ubuntu? Are there any 32 bit operating systems that have creatively solved this problem? [1]: http://www.codinghorror.com/blog/archives/000811.html
I would try running the tests from the command line using [MSTest.exe][1]. This might help isolate the problem to Visual Studio, and at least give you some method of running the tests successfully. [1]: http://msdn.microsoft.com/en-us/library/ms182486(VS.80).aspx
Modifying a spreadsheet using a VB macro
|excel|vba|macros|
I have two spreadsheets... when one gets modified in a certain way I want to have a macro run that modifies the second in an appropriate manner. I've already isolated the event I need to act on (the modification of any cell in a particular column), I just can't seem to find any concrete information on accessing and mo...
There's a lot to the whole process. The single easiest way to do it is to use services similar to paypal, so that you never actually handle any credit card data. Apart from that, there's a quite a bit of stuff to go through to get approved to offer credit card services on your website. You should probably talk with y...
In theory, all 32-bit OSes have that problem. You have 32 bits to do addressing. 2^32 bits / 2^10 (bits per kb) / 2^10 (kb per mb) / 2^10 (mb per gb) = 2^2 = 4gb. Although there are some ways around it. (Look up the jump from 16-bit computing to 32-bit computing. They hit the same problem.)
This is my understanding of your question: You have a plugin object that may have to listen for events on x data objects - you don't want to subscribe to the event on each data object though. I'm assuming that several plugins may want to listen to events on the same data object. You could create a session type objec...
Well, with windows, there's something called [PAE][1], which means you can access up to 64 GB of memory on a windows machine. The downside is that most apps don't support actually using more than 4 GB of RAM. Only a small number of apps, like SQL Server are programmed to actually take advantage of all the extra memo...
|svn|subversion|hook|
|svn|hook|
What is the best approach to write **hooks** for **Subversion** in **Windows**? As far as I know, only executable files can used. So what is the best choice? - Plain batch files (very limited but perhaps OK for very simple solutions) - Dedicated compiled executable applications (sledgehammer to crack a nutshel...
What is the best approach to write **hooks** for **Subversion** in **Windows**? As far as I know, only executable files can be used. So what is the best choice? - Plain batch files (very limited but perhaps OK for very simple solutions) - Dedicated compiled executable applications (sledgehammer to crack a nuts...
Example 1 **dissociates** the $query variable from the MySQL result. The MySQL result still exists in memory, and will continue to exist and waste memory until garbage collection occurs. Example 2 **frees** the MySQL result immediately, releasing the used resources. However, since PHP pages are generally short-li...
How to efficiently archive older parts of a big (multi-GB) SQL Server database?
|sql|sql-server|
Right now I am working on a solution to archive older data from a big working database to a separate archive database with the same schema. I move the data using SQL scripts and SQL Server Management Objects (SMO) from a .Net executable written in C#. The archived data should still be accessible and even (occassiona...
> Consolidate them. Create a timer > service and ask that for the timers. > It will only need to keep 1 active > timer (for the next due call)... For this to be an improvement over just creating lots of Threading.Timer objects, you have to assume that it isn't exactly what Threading.Timer is already doing interna...
I hope this helps. I'm just doing the trick of `float`ing the buttons on the right - like in normal wizard :-) This way the Prev button is left of the Next button but the Next comes first in the HTML code: <html> <head> <style> .f { float: right; } ...
No, from MSDN on HttpContext.Current: "Gets or sets the HttpContext object for the current HTTP request." In other words it is a HttpContext object, not a Page.
No, from MSDN on HttpContext.Current: "Gets or sets the HttpContext object for the current HTTP request." In other words it is a HttpContext object, not a Page. You can get to the Page via HttpContext using: Page page = HttpContext.Current.Handler as Page; if (page != null) { // Use...
Do you mean that you need the values sorted by the value of the key? In that case, this should do it: for key in sorted(d.keys()): print d[key]
Do you mean that you need the values sorted by the value of the key? In that case, this should do it: for key in sorted(d): print d[key] **EDIT:** changed to use sorted(d) instead of sorted(d.keys()), thanks [Eli][1]! [1]: http://stackoverflow.com/users/1694/eli-courtwright
I think cursors get a bad name because SQL newbies discover them and think "Hey a for loop! I know how to use those!" and then they continue to use them for everything. If you use them for what they're designed for, I can't find fault with that.
SQL is a set based language--that's what it does best. I think cursors are still a bad choice unless you understand enough about them to justify their use in limited circumstances. Another reason I don't like cursors is clarity. The cursor block is so ugly that it's difficult to use in a clear and effective way. ...
The basic issue, I think, is that databases are designed and tuned for set-based operations -- selects, updates, and deletes of large amounts of data in a single quick step based on relations in the data. In-memory software, on the other hand, is designed for individual operations, so looping over a set of data and ...
Because cursors take up memory and create locks. What you are really doing is attempting to force set-based technology into non-set based functionality. And, in all fairness, I should point out that cursors *do* have a use, but they are frowned upon because many folks who are not used to using set-based solutions us...
I found this site called [Visual Studio Gallery][1] - it has a lot of visual studio add-ins. I'm browsing it right now and I recommend everyone to visit it. [1]: http://www.visualstudiogallery.com/
I don't understand why people start debates like this. It really serves no purpose than to start flame wars at then end of which nothing is gained. Now if the C# team was trying to phase out one style in favor of the other, I can see the reason to argue over the merits of each style. But since both are going to remain ...
You could try [NDOC][1] or [SandCastle][2] if you dont mind using 3rd party tools. [1]: http://ndoc.sourceforge.net/ [2]: http://www.codeplex.com/Sandcastle
Actually it's in the project properties. Build tab, Output section, XML documentation file, and enter the filename. It will be built on every build of the project. After that you can build the actual help with [Sandcastle][1]. [1]: http://www.microsoft.com/downloads/details.aspx?FamilyId=E82EA71D-DA89-42EE-A7...
You can use [Lint][1] to do that. Unusually there isn't a free OS version of the tool available. [1]: http://www.gimpel.com/
You can use [Lint][1] to do that. Unusually there isn't a free OS version of the tool available. You can remove #includes by passing by reference instead of passing by value and forward declaring. This is because the compiler doesn't need to know the size of the object at compile time. This will require a large a...
XML is very verbose. Whenever I do it, I roll my own. Here's an example of a 3 node directed acyclic graph. It's pretty compact and does everything I need it to do: 0: foo 1: bar 2: bat ---- 0 1 0 2 1 2
haXe can't iterate over Dynamic variables (as the compiler says). You can make it work in several ways, where this one is probably easiest (depending on your situation): var d : {a:Array<Dynamic>} = getDynamic(); for(t in d.a) { ... } You could also change Dynamic to the type of the contents of the ar...
On a less academic, more practical note, in [CubicTest][1] we use [Xstream][2] (Java) to serialize tests to and from xml. Xstream handles graph-structured object relations, so you might learn a thing or two from looking at it's source and the resulting xml. You're right about the *ugly* part though, the generated xml f...
One example you might be familiar is Java serialization. This effectively serializes by graph, with each object instance being a node, and each reference being an edge. The algorithm used is recursive, but skipping duplicates. So the pseudo code would be: serialize(x): done - a set of serialized objects...