instruction
stringlengths
0
30k
A lot of the universities will actually publish their lecture materials online. So all you really need to do is find a suitable subject and then read the lecture materials and do the associated work. If you were really sneaky you could probably also go to the tutorials to get help :P
Ok, here is my atempt in C++ <pre><code> #include &ltiostream&gt #include &ltalgorithm&gt struct mycomparison { bool operator() (int* lhs, int* rhs) {return (*lhs) < (*rhs);} }; int main(int argc, char* argv[]) { int myarray[] = {1, 3, 6, 2, 4, 9, 5, 12, 10}; const size_t size = sizeof(myar...
Ok, here is my atempt in C++ #include <iostream> #include <algorithm> struct mycomparison { bool operator() (int* lhs, int* rhs) {return (*lhs) < (*rhs);} }; int main(int argc, char* argv[]) { int myarray[] = {1, 3, 6, 2, 4, 9, 5, 12, 10}; co...
Running scripts inside C#
|c#|scripting|
I want to run javascript/Python/Ruby inside my application. I have an application that creates process automatically based on user's definition. The process is generated in C#. I want to enable advanced users to inject script in predefined locations. Those scripts should be run from the C# process. For example, th...
I use the free and open source SharpMimeTools in my application, BugTracker.NET. It has been very dependable: [http://anmar.eu.org/projects/sharpmimetools/][1] [1]: http://anmar.eu.org/projects/sharpmimetools/ See the files POP3Client.cs, POP3Main.cs, and insert_bug.aspx
You should use [CharsetEncoder][1], the simple getBytes() + copy as many as you can can cut UTF-8 charcters in half. [1]: http://java.sun.com/javase/6/docs/api/java/nio/charset/CharsetEncoder.html#encode(java.nio.CharBuffer, java.nio.ByteBuffer, boolean)
You should use [CharsetEncoder][1], the simple getBytes() + copy as many as you can can cut UTF-8 charcters in half. [1]: http://java.sun.com/javase/6/docs/api/java/nio/charset/CharsetEncoder.html#encode(java.nio.CharBuffer, java.nio.ByteBuffer, boolean) Something like this: public static int tr...
I have a stateless bean something like: @Stateless public class MyStatelessBean implements MyStatelessLocal, MyStatelessRemote { @PersistenceContext(unitName="myPC") private EntityManager mgr; @TransationAttribute(TransactionAttributeType.SUPPORTED) public void processO...
I believe most of this sort of thing is usually done over SNMP (for professional system) is the usual way to make this sort of information available in a standards-based manner. JMX is also available over SNMP. The question then becomes, which are the better SNMP libraries for Java (and does your system support it)?
data structure for assembly code [TOP SECRET]
data structure for assembly code
data structure for assembly code [research]
|c++|c|dynamic|compilation|
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 ...
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 ...
The object would only be automatically disposed when garbage collection runs. If you want the dispose to run as soon as it went out of scope, you should use a `using` block: using (MyThirdClass mc = inputObject.CreateHelper()) { // do something with mc }
The object would only be automatically disposed when garbage collection runs. If you want the dispose to run as soon as it went out of scope, you should use a `using` block: using (MyThirdClass mc = inputObject.CreateHelper()) { // do something with mc } This is really more of an issue with s...
What is a smart pointer and when should I use one?
|c++|c|pointers|memory|object|
What is a smart pointer and when should I use one?
|c++|pointers|
|c++|smart-pointers|pointers|
Secure DLL with license file
I keep most of my config in IoC container, e.g. Spring.Net.
Selectors in key/keyref allow only a very restricted xpath syntax. Short, but not completely accurate: The selector must point to a subnode of the element declared. The full definition of the restricted syntax is [-> here][1]. So, no I don't see a better way, sorry. BTW: The W3C states that this restriction wa...
This is a hint rather than a proper answer: A cursory glance at Google results seems to suggest that the exception is usually caused by the code forcing the use of a default SSL socket factory that on purpose throws the exception when createSocket() is invoked on it. What some of the results seem to suggest is that the...
"When we add values to the table we have to do a look up everytime to see if it needs to insert the value or just grab the id." We used to call this the "upsert" operation. try: UPDATE log SET blah blah blah WHERE key = key; except Missing Key: INSERT INTO log(...) VALUES(...); We ...
Best Way To Add Version Control To Existing Project
|version-control|svn|
Hey guys, I am currently working on a project and it's grown to a decent size, but I am the only developer. We currently don't use any version control, but I definitely need to start. I wanted to use Subversion but I was wondering what would be the best way to transfer an existing project to it. I have a test server...
[This site](http://bytes.com/forum/thread554529.html) has a problem similar to yours in IE6. To summarize: > session_start() by default sends a cache control header including "no-store". Internet Explorer takes this a bit too literally, but doesn't have appropriate error handling for the case, and as a result expl...
Pretty simple if you use mod_rewrite, as we all do ;) This is part of the .htaccess from my live website: RewriteEngine on # Catches www.infinite-labs.net and redirects to the # same page on infinite-labs.net to normalize things. RewriteCond %{HTTP_HOST} ^www\.infinite-labs\.net$ ...
I believe this problem is coming from the .svn file. It's either incorrect in the old parent, the new parent or the old one. I would try reverting back to your starting point. Use an export to get a clean copy of the folder. Move the clean copy to the new location, and use an add and delete to do the move. That's manua...
It's as easy as: <VirtualHost 10.0.0.1:80> ServerName www.example.com Redirect permanent / http://example.com/ </VirtualHost> Adapt host names and IPs as needed :)
You seem to forget the endianness transcends processor architectures. There are plenty of algorithms and protocols that demand a particular byte order. For example, I spent two weeks trying to get an MD5 hashing algorithm to work, only to realize that I had assumed network byte order (Big Endian) while Ronald Rivest ha...
Since you mentioned using mod_rewrite, I'd suggest a simple rule in your .htaccess - doesn't seem monstrous to me :) RewriteCond %{HTTP_HOST} ^www\.foobar\.com$ [NC] RewriteRule ^(.*)$ http://foobar.com/$1 [L,R=301]
I've found that CMS Matrix (refer:iAn) can sometimes be a bit out of date but it is definitely a good starting place. Open Source CMS is a good resource (refer:mrinject). I'd lean towards something you can tinker with - closed source could back you into a corner. If you're looking into .NET then MojoPortal is anothe...
If you're wanting to log the client-side errors back to the server you're going to have to do some kind of server processing. Best bet would be to have a web service which you can access via JavaScript (AJAX) and you pass your error log info to it. Doesn't 100% solve the problem cuz if the problem is with the web se...
It's really up to you, *as long as you're consistent*. One good reason to put it in your database layer: if you are fairly sure that your clients will never ever change their database back-end. One good reason to put it in the application layer: if you are targeting multiple persistence technologies for your app...
You can launch the "[wc][1].exe" executable (comes with [UnixUtils][2] and does not need installation) run as an external process. It supports different line count methods (like unix vs mac vs windows). [1]: http://unixhelp.ed.ac.uk/CGI/man-cgi?wc [2]: http://unxutils.sourceforge.net/
Just a note on the versionning of libraries in your version control system: - it is a good solution _but_ it **implies packaging** (i.e. reducing the number of files of that library to a minimum) - it does not solves the 'configuration aspect' (that is "what specific set of libraries does my '3.2' projects need ?")...
Trouble with all the approached tried so far is that multiple threads can enter the code. That is multiple threads try to acquire and use the file handler - hence the errors - you need a single thread outside of the worker threads to do the work - with a single file handle held open. Probably easiest thing to do wo...
If you want quite sexy charts, easy to generate, and you can enable Flash, then you should definitely have a look at [maani.us xml/swf charts][1]. Some XML builder behind it and you're ready to go. [1]: http://www.maani.us/xml_charts/
java.lang.ClassCastException: javax.swing.KeyStroke
|java|
I'm getting a random unreproducible Error when initializing a JSplitPane in with JDK 1.5.0_08. Note that this does not occur every time, but about 80% of the time: Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.KeyStroke at java.util.TreeMap.compare(TreeMap.java:1093) at jav...
Getting java.lang.ClassCastException: javax.swing.KeyStroke when creating a JSplitPane
I'm getting a random unreproducible Error when initializing a JSplitPane in with JDK 1.5.0_08. Note that this does not occur every time, but about 80% of the time: Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.KeyStroke at java.util.TreeMap.compare(TreeMap.java:1093) at jav...
**Command-Line Warning D9025** If two options specify contradictory or incompatible directives, the directive specified or implied in the option farthest to the right on the command line is used. If you get this warning when compiling from the development environment, and are not sure where the conflicting option...
In terms of wording your error messages, I recommend referring to a style guide such as: - [Windows Vista User Experience Guidelines](http://msdn.microsoft.com/en-us/library/aa511258.aspx) - [Microsoft Manual of Style for Technical Publications](http://www.amazon.com/gp/product/0735617465)
In terms of wording your error messages, I recommend referring to the following style guides for Windows applications: - [Windows Vista User Experience Guidelines](http://msdn.microsoft.com/en-us/library/aa511258.aspx), and specifically the section on error messages [here](http://msdn.microsoft.com/en-us/library/a...
Import your existing base into a SVN repository, check it back out and begin working again.
Boost.DateTime has millisecond and nanosecond representations **IF** the underlying platform supports them. While it is using platform specific code, it is keeping those details out of your code. If that is a big deal, they do have another way of doing platform independent subsecond resolution. [This page](http:...
Is there a DRM scheme that works?
|drm|
We help our clients to manage and publish their media online - images, video, audio, whatever. They always ask my boss whether they can stop users from copying their media, and he asks me, and I always tell him the same thing: no. If the users can view the media, then a sufficiently determined user will always be abl...
|drm|management-management|
|drm|rights-management|management-management|
|drm|rights|rights-management|management-management|
Try [Fiddler][1]! It is a free, HTTP debugging proxy, that among other things provides insight on what's loading in your site, what may slow it down, etc. It has advanced features like decoding compressed resources, providing pre-canned responses for certain URL's, etc. Learning Fiddler is a must for any web developer....
Don't check-in/commit any changes that break a build.
Others have given excellent answers, so what remains for me is to explain what "dynamic" languages actually mean. In the context of a virtual machine it means that the type of a variable is not known at compile time. In "static" languages the type (or at least a parent class of it) is known at compile time, and many...
You don't say how your web service is hosted, so I'll assume it's in IIS. I don't think the file should be accessed by multiple processes unless your service runs in multiple application pools. Nevertheless, I guess you could get this error when multiple threads in one process are trying to write. I think I'd go f...
To know what I am trying to do in my code, following is the singletone class I have implemented in C# public sealed class FileWriteTest { private static volatile FileWriteTest instance; private static object syncRoot = new Object(); private static Queue logMessages = new Queue(); pri...
simple token solutions suffer from a design flaw: you will have some sort of secret that can be reverse-engineered if wanted. this can be avoided entirely if dome correct. i would propose a challenge-response algorithm. *) user loggs in to rich client with pw *) from salt+password a sha256 or similar hash is c...
How to enter Javascript into a wiki page?
|wiki|javascript|
How can I enter scripting (Javascript) into a wiki page?<br><br> I would like to enter a title and, when clicking on that, having displayed under it a small explanation. I usually have done that with javascript, any other idea?
How can I, as the wiki admin, enter scripting (Javascript) into a Sharepoint wiki page?<br><br> I would like to enter a title and, when clicking on that, having displayed under it a small explanation. I usually have done that with javascript, any other idea?
|wiki|javascript|sharepoint|
|javascript|html|sharepoint|wiki|
Pesky x86's dirtying up my memory registers with their segment pointers! ;) I believe you don't need to flip words between PCs and Macs anymore, assuming you're eschewing backwards-compatibility with PowerPC.
Whatever you come up with to disable the back button might not stop the back button in future browsers. If its late in the development cycle I suggest you try some suggestions above but when you get time you should structure your flow so that the back button does not interfere with the logic of your site, it simpl...
Well, actually there are plenty of big endian CPUs left over. Actually the PPC is not dead. You are aware, that the Xbox360 uses PPC CPUs (and it is a good example, that these CPUs are not as bad as their reputation - the Xbox360 is anything but slow). Okay, this one may not count as a PC. But does a server count...
`hcitool` is a command that comes with [BlueZ][1], which is specific to the Linux kernel. Unfortunately, I don't have Mac OSX, so I can't test this, but as far as I know, [Darwin][2] shares a lot with BSD, so they both use [Netgraph framework][3] for bluetooth drivers. There's some information on how to use [Bluetoo...
Inline functions! Inspired by the profiling fans here I profiled an application of mine and found a small function that does some bitshifting on MP3 frames. It makes about 90% of all function calls in my applcation, so I made it inline and voila - the program now uses half of the CPU time it did before.
Exception is already serializable, but you need to override the `GetObjectData` method to store your variables and provide a constructor which can be called when re-hydrating your object. So your example becomes: public class MyException : Exception { private readonly string resourceName; ...
Exception is already serializable, but you need to override the `GetObjectData` method to store your variables and provide a constructor which can be called when re-hydrating your object. So your example becomes: [Serializable()] public class MyException : Exception { private readonly strin...
British English to American English (and vice versa) Converter
|language-agnostic|language|converters|lazyweb|
Does anyone know of a library or bit of code that converts British English to American English and vice versa? I don't imagine there's too many differences (some examples that come to mind are doughnut/donut, colour/color, grey/gray, localised/localized) but it would be nice to be able to provide localised site cont...
Some ?? weirdness :) Delegate target = (target0 = target as CallTargetWithContext0) ?? (target1 = target as CallTargetWithContext1) ?? (target2 = target as CallTargetWithContext2) ?? (target3 = target as CallTargetWithContext3) ?? (target4 = target as CallTargetWithContext4) ?...
My open source application [BugTracker.NET][1] includes a POP3 client that can parse MIME. Both the POP3 code and the MIME code are from other authors, but you can see how it all fits together in my app. [1]: http://ifdefined.com/bugtrackernet.html
My open source application [BugTracker.NET][1] includes a POP3 client that can parse MIME. Both the POP3 code and the MIME code are from other authors, but you can see how it all fits together in my app. For the MIME parsing, I use [http://anmar.eu.org/projects/sharpmimetools/][2]. See the file POP3Main.cs, P...
Some of the stuff you can do with an XSLT you can also do with some form of 'search & replace'. It all depends on how complex your problem is and how 'generic' you want to implement the solution. To make your own example slightly more generic: xml.replaceFirst("<Mobiltlf>[^<]*</Mobiltlf>", '<Mobiltlf>32165487</M...
Find matching sequences in two binary files
|python|diff|binary|antivirus|
Let me start off with a bit of background. This morning one of our users reported that Testuff's setup file has been reported as infected with a virus by the CA antivirus. Confident that this was a false positive, I looked on the web and found that users of another program (SpyBot) have reported the same problem. ...
Not only that works, but it's even a best practice. You definitively want to separate the data format (xHTML) from the design (CSS) and the behaviour (javascript). So it's far better to just add and remove classes in JS according to event while the esthetic concerns are delegated to css styles. E.G : Coloring ...
No, their is no way to prevent a user to use its camera to take a screenshot of the screen, or its recorder to record a movie, a song or anything else. And if you're talking about preventing making "exact" copy of a digitalized content, the answer is still the same: NO.
Since your requirement is a windows based application i would suggest that you go with sql server 2005 express edition which is a free tool, but with certain small limitations. you can upgrade to a bigger version when you go with a paid version. There are other DB engines like SQL Lite or FireBird, choose them if...
To me the actual copy & search & replace seems like the perfect job for an XSLT stylesheet. In an XSLT you have no problem at all to just copy everything (including the items you're having problems with) and simply insert your data where it is required. You can pass the specific value of your data in via an XSL paramet...
Locking File using Appache Server and TortoiseSVN
|locking|
I am seeting up Appache server with TortoiseSVN for local source code repository. Currently on trial purpose I am setting only two users. Is it possible for administrator to set up some thing so that file get compulsory locked once its checkout (copy to working directory) by some one. Abhijit Dhopate
Locking File using Apache Server and TortoiseSVN
I am seeting up Apache server with TortoiseSVN for local source code repository. Currently on trial purpose I am setting only two users. Is it possible for administrator to set up some thing so that file get compulsory locked once its checkout (copy to working directory) by some one. Abhijit Dhopate
|svn|apache|tortoisesvn|locking|