instruction
stringlengths
0
30k
|c++|file|
Is there a (cross-platform) way to get a C FILE* handle from a C++ std::fstream ?
Is there a (cross-platform) way to get a C FILE* handle from a C++ std::fstream ? The reason I ask is because my C++ library accepts fstreams and in one particular function I'd like to use a C library that accepts a FILE*.
|c++|c|file|file-io|fstream|
Look at Configatron: http://github.com/markbates/configatron/tree/master I have yet to use it, but he's actively developing it now, and looks quite nice.
data structure for assembly code, interesting problem.
|hard-problem|c|c++|compilation|dynamic|
I'm planning to create a data structure optimized to hold assembly code. That way I can be totally responsible for the optimization algorithms that will be working on this structure. If I can compile while running. It will be kind of dynamic execution. Is this possible? Have any one seen something like this? Should ...
|c|c++|compilation|dynamic|c#|
I'm planning to create a data structure optimized to hold assembly code. That way I can be totally responsible for the optimization algorithms that will be working on this structure. If I can compile while running. It will be kind of dynamic execution. Is this possible? Have any one seen something like this? Should ...
data structure for assembly code
I'm planning to create a data structure optimized to hold assembly code. That way I can be totally responsible for the optimization algorithms that will be working on this structure. If I can compile while running. It will be kind of dynamic execution. Is this possible? Have any one seen something like this? Should ...
A **service** in Microsoft Windows is a program that runs whenever the computer is running the operating system. It does not require a user to be logged on. Services are needed to perform user-independent tasks such as directory replication, process monitoring, or services to other machines on a network, such as suppor...
A **service** in Microsoft Windows is a program that runs whenever the computer is running the operating system. It does not require a user to be logged on. Services are needed to perform user-independent tasks such as directory replication, process monitoring, or services to other machines on a network, such as suppor...
You could push the results onto an MSMQ Queue and have a windows service pick the items off of the queue and log them. It's a little heavy, but it should work.
Google did not treat underscore as a word separator in the past, which I thought was pretty crazy, but apparently it does now. Because of this history, dashes are preferred. Even though underscores are now permissible from an SEO point of view, I still think that dashes are best. One benefit is that your average s...
You could quickly read it in, and increment a counter, just use a loop to increment, doing nothing with the text.
We put a lot of business logic in stored procedures - it's not ideal, but quite often it's a good balance between performance and reliability. And we know where it is without having to search through acres of solutions and codebase!
I tend to do the last of those ideas, "start by designing your domain models, with minimal looks, and apply a preetier design later on" I like to make my application, of any kind, does what I want it to do before I spend time on making it look pretty.
Another way (for 2000 / 2005): IF ((SELECT OBJECTPROPERTY( OBJECT_ID(N'table_name_here'), 'TableHasIdentity')) = 1) PRINT 'Yes' ELSE PRINT 'No'
I would think you would be able to do it. You would have to access the javascript DOM. A couple links that may steer you down the correct path.. [http://homepage.ntlworld.com/kayseycarvey/document2.html][1] [http://www.permadi.com/tutorial/flashjscommand/][2] [1]: http://homepage.ntlworld.com/kaysey...
Dave Anderson, a co-worker of mine, wrote this server control that could help you get started. Note that we're targeting .NET 3.5. [AspNetHostingPermission( SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, ...
As I said in my previous post, here's some code in C# that implements an O(1) matrix rotation for any size matrix. For brevity and readability there's no error checking or range checking. The code: static void Main (string [] args) { int [,] // create an arbitrary matrix m = {{...
As I said in my previous post, here's some code in C# that implements an O(1) matrix rotation for any size matrix. For brevity and readability there's no error checking or range checking. The code: static void Main (string [] args) { int [,] // create an arbitrary matrix m = {{...
You should be able to do this without any IF or CASE WHERE (IsNumeric(@OrderNumber) AND (CAST OrderNumber AS VARCHAR) = (CAST @OrderNumber AS VARCHAR) OR (NOT IsNumeric(@OrderNumber) AND OrderNumber LIKE ('%' + @OrderNumber)) Depending on the flavour of SQL you m...
Another potential way to do this for SQL Server, which has less reliance on the system tables (which are subject to change, version to version) is to use the INFORMATION_SCHEMA views: select COLUMN_NAME, TABLE_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_SCHEMA = 'dbo' and COLUMNPROPERTY(obje...
If you could give us more to go on than just trouble making it compile; we might be better able to help you with your issues.
It works out better than you'd believe. Recently I did a large reverse-engineering job on a hideous old collection of C code. Function by function I reallocated the features that were still relevant into classes, wrote unit tests for the classes, and built up what looked like a replacement application. It had som...
How do I checkout files under Perforce from within Emacs?
|version-control|emacs|file|perforce|
I use Perforce for source control at work and I want to 'open for edit' files that under source control from within Emacs. How can that be done? What do I need to setup in Emacs? Is there a plug in? I also want to perform other p4 operations such as submitting my changes, etc.
Most of the High-Availability options are missing from the Express Edition. The Express *editions* are great for development purposes. Here's the comparison facts: http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx
This would generally be a bad idea, as System.Threading.Timer uses threads from the ThreadPool, the same as ASP.Net. If for what ever reason your timer delegate blocks or stops, the timer will simply begin a new Thread after the timeout period, which eats in to the Threads available for ASP.net. If they all begin...
The index hint will only come into play where your query involves joining tables, and where the columns being used to join to the other table matches more than one index. In that case the database engine may choose to use one index to make the join, and from investigation you may know that if it uses another index the ...
I had a similar problem and found this solution [here][1]: > When you do something like this: > > $('p').click( function() { alert('blah'); } ) > > All the _currently existing_ 'p' > elements will have a click handler > attached. Now if you go on to add > other 'p' elements to the page they > _will no...
When you catch the exception, you can log/output it's details to help identify what the problem was and the offending line of code. Then it is smart to fix the code to handle that exception in the future. You should generally never plan on an unknown exception being thrown in a normal use case. You should try to h...
Disabling Warnings generated via _CRT_SECURE_NO_DEPRECATE
|c++|visual-studio|visual-c++|
What is the best way to disable the warnings generated via `_CRT_SECURE_NO_DEPRECATE` that allows them to be reinstated with ease and will work across Visual Studio versions?
The easiest: int lines = File.ReadAllLines("myfile").Length;
1. Have CC.net label the successful builds 2. have each project in the solution link to a common solutioninfo.cs file which contains assembly and file version attributes (remove from each projects assemblyinfo.cs) 3. Before the build have cruise control run an msbuild regex replace (from msbuild community tasks) to u...
If by easy you mean a lines of code that are easy to decipher but per chance inefficient? string[] lines = System.IO.File.RealAllLines($filename); int cnt = lines.Count(); That's prolly the quickest way to know how many lines. You could also do (depending on if you are buffering it in) #for large files w...
Figure out how the users need to interact with your site first. What are they needing to achieve? Let this define you ERD and the database model will quickly follow. Then, when you actually start coding you'll be heading in the right direction. Many will also say, write your Unit Tests first. It's hard to do ...
You start by deciding which way you start. No but really, it depends on too much factors to have a general answer. Do you develop using concepts of agile development, are there specified functional designs, did the client give you strict requirements, what is your own experience etc.. Generally we start by developin...
[styles explorer][1] Haven't tried it myself yet but worth a try [1]: http://blogs.windowsclient.net/ricciolocristian/archive/2008/04/05/styles-explorer-baml-decompiler.aspx
Maintainability of your code is always a big concern when determining where business logic should go. Integrated debugging tools and more powerful IDEs generally make maintaining middle tier code easier than the same code in a stored procedure. Unless there is a real reason otherwise, you should start with busine...
|c#|winforms|desktop|window|
I want to create a c# application with multiple windows that are all transparent with some text on. The tricky part is making these forms sit on top of the desktop but under the desktop icons. Is this possible?
You could rely on wget which usualy handles ftp get properly (at least in my own experience). I think it goes this way: wget -r ftp://user:pass@server.com/ Hope this helps!
ncftp -u <user> -p <pass> <server> ncftp> mget directory
I strongly suggest [savant](http://phpsavant.com/) instead of smarty, - you don't have to learn a new templating "language" in order to create templates, savant templates are written in php - if you don't want to use php you can define your own template "language" with a compiler - it's easily extendable by your ...
If you can, I strongly suggest you `tar` and `bzip` (or `gzip`, whatever floats your boat) the directory on the remote machine—for a directory of any significant size, the bandwidth savings will probably be worth the time to zip/unzip.
Which GUI toolkit would you use for a touchscreen interface?
|windows|gui|api|
The only experience I have so far with a touchscreen interface was one where everything was custom drawn, and I get the feeling it's not the most efficient way of doing it (even the most basic layout change is hell to make). I know plenty of GUI toolkits intended at keyboard & mouse interfaces, but can you advise somet...
If you call getImage too early, your component will not have been displayed yet and will still have a 0 width and height. Have you made sure you're calling it at a sufficient late time? Try printing the component's size to stdout and see what its dimensions are.
SELECT testColumn FROM testTable WHERE testColumn COLLATE Latin1_General_CS_AS = 'example' SELECT testColumn FROM testTable WHERE testColumn COLLATE Latin1_General_CS_AS = 'EXAMPLE' SELECT testColumn FROM testTable WHERE testColumn COLLATE Latin1_General_CS_AS...
Use WGet instead. It supports HTTP and FTP protocols. wget -r ftp://mydomain.com/mystuff Good Luck! reference: [http://linux.about.com/od/commands/l/blcmdl1_wget.htm][1] [1]: http://linux.about.com/od/commands/l/blcmdl1_wget.htm
There is 'ncftp' which is available for installation in linux. This works on the FTP protocol and can be used to download files and folders recursively. works on linux. Has been used and is working fine for recursive folder/file transfer. Check this link... http://www.ncftp.com/
We run our daemons by piping the output to mail. php daemon.php | mail -s "daemon stopped" foo@example.org That way, when/if the daemon stops, it will send a mail, and we will be notified that way. It still means manual restart of the daemons of course, but we'll know right away. Usually, if the daemons st...
In model class you would probably have to add "order" field, to maintain specific order (eg. item with order = 10 is the last one and order = 1 is the first one). Then you can add a JS code in admin change_list template (see [this][1]) to maintain drag&drop feature. Finally change ordering in Meta of model to something...
Script.aculo.us Autocompleter problem in IE
|internet-explorer|script.aculo.us|prototype|
I'm struggleing with a problem with the Script.aculo.us Autocompleter control in IE (I've tried it in IE6 & 7). The suggestions fail to appear for the first character is entered into the text box after the page has been loaded. After that initial failure, the control works as it should. I've verified that the sugges...
|internet-explorer|prototype|script.aculo.us|
I'm struggleing with a problem with the Script.aculo.us Autocompleter control in IE (I've tried it in IE6 & 7). The suggestions fail to appear for the first character is entered into the text box after the page has been loaded. After that initial failure, the control works as it should. I've verified that the sugges...
Since this method will always return the result of numericUpDown.Value you have no cause for the value to be converted to anything other than Decimal. Are you trying to solve a problem you don't have?
I think Magnus' answer will be exactly what you need but why are you storing to many content types and document types in one library? Wouldn't it make more sense to have more than one document library? this would make it much more easily managed.
I think it depends on how you want your app/solution to *interpret* said NULLs in your data.<br><br>Do you want to simply "ignore" them in a report... i.e. have them print out as blank spaces or newlines? In that case you can use the handy IsNull function along with the "immediate if" iif() in either the SQL builder o...
This code (C# DotNet 1.0 onwards) works quite well to serialize most objects to XML. (and back) It does not work for objects containing ArrayLists, and if possible stick to using only Arrays using System; using System.IO; using System.Text; using System.Runtime.Serialization; using System.Runtime.Serializatio...
I'm particularly fond of the bytecode outliner plugin, although it won't suit all tastes since looking at Java bytecode isn't for everyone. Sometimes it's really useful to see the underlying bytecode for your Java class. Update site: [http://download.forge.objectweb.org/eclipse-update/][1] Description: [http://as...
Enter some valid values for the stored procedure parameters so it runs and returns some data (or even no data, you just need the columns). Then you should be able to do the mapping/etc.. Then do a disconnected edit and change to the actual parameter values (I assume you are getting them from a global variable). DE...
Ignoring all the reasons you'd want to avoid doing this....... If it were simply a need to keep # of lines down, you could try something like: <pre> int totalMethodCount = xxx; for(int counter = 0; counter &lt; totalMethodCount; counter++) { try { if (counter == 0) WidgetMaker.SetAlignment(57); if (coun...
Const parameter is useful only when the parameter is passed by reference i.e., either reference or pointer. When compiler sees a const parameter, it make sure that the variable used in the parameter is not modified within the body of the function. Why would anyone want to make a by-value parameter as constant? :-)
If the parameter is passed by value (and is not a reference), usually there is not much difference whether the parameter is declared as const or not (unless it contains a reference member -- not a problem for built-in types). If the parameter is a reference or pointer, it is usually better to protect the referenced/po...
I am *really* grooving to [Stripes][1]. Total setup includes some cut-and-paste XML into your app's web.xml, and then you're off. No configuration is required, since Stripes is a convention-over-configuration framework. Overriding the default behavior is accomplished via Java 1.5 annotations. Documentation is great. I ...
As Adam said, homebrew is pretty much the only way to do what it sounds like you want to do. A lot of times, using homebrew kits also involves modifying the console in some manner. There is a Linux-based portable game device called the [GP2X][1] that might interest you, but I think that open source game development ...
UI and DB, but it depends which one is really first. The UI is a very important thing because your customer has to work with it in the end (some say there might be developers who sometimes forget...). The database design is a very good way to put (some) structure in all the business needs which aren't always specified ...
I start with the functional UI, moving from there to the business layer and db (usually in tandem to start with). Design is normally provided in some respect by the client, so I try to apply that early on, without letting it get in the way. I like to get the domain sorted out in one step (minor changes are acceptable l...
This would use less memory, but probably take longer int count = 0; string line; TextReader reader = new StreamReader("file.txt"); while ((line = reader.ReadLine()) != null) { count++; } reader.Close();
count the line feeds/carriage returns. I believe in unicode they are still 0x000D and 0x000A respectively
count the carriage returns/line feeds. I believe in unicode they are still 0x000D and 0x000A respectively. that way you can be as efficient or as inefficient as you want, and decide if you have to deal with both characters or not
Joel and charles. That was quick! :) Joel: When you say "queue line" do you mean creating a separate thread that runs in a loop to keep checking the queue as well as write to a file when it is not locked? Charles: I know about MSMQ and windows service combination, but like I said I have no choice other than writi...
First off let me say that I don't think that the subtle differences between Java bytecode and MSIL is something that should bother a novice .NET developer. They both serve the same purpose of defining an abstract target machine which is a layer above the physical machine being used in the end. MSIL and Java bytecod...
Unit test for randomized data
|unit-testing|random|
I ran across this situation this afternoon, so I thought I'd ask what you guys do. We have a randomized password generator for user password resets and while fixing a problem with it, I decided to move the routine into my (slowly growing) test harness. I want to test that passwords generated conform to the rules ...
JavaScript API methods are almost all called with [lowerCamelCase][1] names, and JavaScript is case-sensitive [1]: http://en.wikipedia.org/wiki/LowerCamelCase
How can you overcome the svn 'out of date' error?
|svn|
I've been attempting move a directory structure from one location to another in Subversion and I've run up against a brick wall which is the `Item '*' is out of date` commit error. I have the latest version checked out (so far as I can tell), svn st -u turns up no differences other than the mv commands, I have no ...
How do you overcome the svn 'out of date' error?
|svn|
Make apache automatically strip off the www.?
|apache|http-redirect|
For various reasons, such as cookies, SEO, and to keep things simple, I would like to make apache automatically redirect any requests for http://www.foobar.com/anything to http://foobar.com/anything. The best I could come up with is a mod_rewrite-based monstrosity, is there some easy simple way to tell it "Redirect all...
^([^.\s]+)\\.([^.\s]+)(?:\\.([^.\s]+))?$
Array list has ctor which accepts ICollection, which is implemented by the Array class. object[] myArray = new new object[] {1,2,3,"string1","string2"); ArrayList myArrayList = new ArrayList(myArray);
Depending on the version of C# you are using, you have different options. C# 3.0 has collection initializers, detail at [Scott Gu's Blog][1] Here is an example of your problem. ArrayList list = new ArrayList {1,2,3}; And if you are initializing a collection object, most have constructors that take simil...
As Adam said, homebrew is pretty much the only way to do what it sounds like you want to do. A lot of times, using homebrew kits also involves modifying the console in some manner. There is a Linux-based portable game device called the [GP2X][1] that might interest you, but I think that open source game development ...