instruction
stringlengths
0
30k
I have been in your shoes, but I saw the light after I read this book (a few times!) http://www.apress.com/book/view/9781590599099 After I read this, I really "got" it and I haven't looked back. You'll get it on Amazon. I hope you persist, get it, and love it. When it comes together, it will make you smile. Compo...
The Python/C API manual is longer than the _whole_ Lua manual (including the Lua/C API). ( Why do people write Lua in upper case so much on SO? It's "Lua" (see [here][1]). ) [1]: http://www.lua.org/about.html
The Python/C API manual is longer than the _whole_ Lua manual (including the Lua/C API). Another reason for Lua is the built-in support for coroutines (co-operative multitasking within the one OS thread). It allows one to have like 1000's of seemingly individual scripts running very fast alongside each other. Like ...
Simplest way to do this is to copy all the FK info into a simple, 2-column (parent,child) table, and then use the following algorithm: while (rows left in that table) list = rows where table name exists in child but not in parent print list remove list from rows that's all. Basically, you...
If you're looking for a good start, you can use the foundation of code supplied by the [SharpMap][1] project and build out from there. If I recall there were a few people already working on a WPF renderer for SharpMap, so you may also have some code to begin with. I've personally used SharpMap in a C# 2.0 applicatio...
[How do you get a list of all the installed fonts?][1] var fontsCollection = new InstalledFontCollection(); foreach (var fontFamiliy in fontsCollection.Families) { if (fontFamiliy.Name == fontName) ... \\ installed } See [InstalledFontCollection class][2] for details. MSDN: [En...
I'm not sure but it should be easy for you to find out. Just create a small program with a statement that prints out the truth value of: (true || false && true) If the result is true, then the || has higher precedence than &&, if it is falase, it's the other way around.
<h2>Virtual calls are not inlined</h2> There is one kind of penalty for virtual functions which is easy to forget about: virtual calls are not inlined. If your function is small and suitable for inlining, this penalty may be very significant, are you are not only adding a call overhead, but the compiler is also limite...
Don't use a bazooka to kill a fly. Use something simple just like SQLite. There are all the tools you need for every modern languages and you can just do : "SELECT word FROM dict WHERE word LIKE "user_entry%" It's lightning fast and a baby could do it. What's more it's portable, persistent and so easy to main...
string fontName = "Consolas"; float fontSize = 12; Font fontTester = new Font( fontName, fontSize, FontStyle.Regular, GraphicsUnit.Pixel ); if ( fontTester.Name == fontName ) { // Font exists } else { // Font do...
Take a look at [MSDEPLOY][1] or [Web Deployment Projects][2]. There is a question that will provide [more detail here][3] [1]: http://blogs.iis.net/msdeploy/archive/2008/01/22/welcome-to-the-web-deployment-team-blog.aspx [2]: http://weblogs.asp.net/scottgu/archive/2008/01/28/vs-2008-web-deployment-project-sup...
See official write-up here: [http://msdn.microsoft.com/en-us/library/ms165392.aspx][1] [1]: http://msdn.microsoft.com/en-us/library/ms165392.aspx
Not to nitpick, but you mean "integer overflow" rather than "buffer overflow". I don't know C#, so there may be another way, but you could mimic an unsigned shift by just masking off the top bit: (x >> 1) & 0x80000000
The easy answer is Subversion along with Tortoise SVN. I've used Subversion with visual studio, and I've implemented it with an existing project. There is a free Visual Studio plugin called Ankh, which I used with some success. However, I have had some issues where Ankh refuses to stay in sync with the real state ...
My experience is that sometimes you know more about your dataset then SQL Server does. In that case you should use query hints. In other words: You help the optimizer decide. I once build a datawarehouse where SQL Server did not use the optimal index. By giving an index hint in my query I managed to make a query go ...
My experience is that sometimes you know more about your dataset then SQL Server does. In that case you should use query hints. In other words: You help the optimizer decide. I once build a datawarehouse where SQL Server did not use the optimal index on a complex query. By giving an index hint in my query I managed ...
You can have extermly complex DRMs (custom player, activation each time something is played/loaded), but it still won't be 100% hacker proof. And honestly, it's just not worth the trouble, Try to just keep the honest people honest; either have no DRM at all, or just some simple ones that's easy to implement and wil...
I don't think there is a clever way. owpython doesn't support that telling from the API documentation. I guess `/proc` is your safest bet. Maybe have a look at the source of the owpython module and check if you can find out how it works.
I strongly recommend working with a reporting tool that provides native support for exporting to PDF, it is much easier for management purposes if you can start with a single format and report to handle both the printing and archiving of information. If you are truly doing batch processing, I wouldn't see WPF as a n...
There only two real solutions for (the technical aspect of) this problem. Assuming it's only the application itself that needs access the key... 1. Hardware Security Module (HSM) - usually pretty expensive, and not simple to implement. Can be dedicated appliance (e.g. nCipher) or specific token (e.g. Alladin eTok...
There only two real solutions for (the technical aspect of) this problem. Assuming it's only the application itself that needs access the key... 1. Hardware Security Module (HSM) - usually pretty expensive, and not simple to implement. Can be dedicated appliance (e.g. nCipher) or specific token (e.g. Alladin eTok...
Testing is the comparison of implementation with intent/expections.
You should understand that by using TRUNCATE the data will be cleared but nothing will be logged to the transaction log. Writing to the log is why DELETE will take forever on 5 million rows. I use TRUNCATE often during development, but you should be wary about using it on a production database because you will not be...
I am revising my earlier statement: > You should understand that by using > TRUNCATE the data will be cleared but > nothing will be logged to the > transaction log. Writing to the log > is why DELETE will take forever on 5 > million rows. I use TRUNCATE often > during development, but you should be > wary a...
Are the service and the application running as the same user with different integrity levels, or are they running as different users? If it is the former, then this article from MSDN [which talks about integrity levels might help][1]. They have some sample code for lowering the integrity level of a file. I'm not sur...
At one point you will have to abandon whaterver coding/encypting you are using to circumvent th emaking illegal copyies and show the conent to the user in plain sight. The latest, at that point the user can simply capture the content and make copies. Which means that if you cannot control who your users are (or how t...
At one point you will have to abandon whatever coding/encrypting you are using to circumvent the making of illegal copies and show the content to the user in plain sight. The latest, at that point the user can simply capture the content and make copies. Which means that if you cannot control who your users are (or ho...
Sort of, yes. This is a core part of the [agile philosophy][1]. Basically, favour flexibility and speed of response over big design up front and unwieldy specifications. One of the best ways of doing that is to only build enough to meet your current requirements, because you never know when they're going to change. ...
Dynamically importing a C++ class from a DLL
|c++|dll|import|
What is the correct way to import a C++ class from a DLL? We're using Visual C++. There's the dllexport/exports.def+LoadLibrary+GetProcAddress trifecta, but it doesn't work on C++ classes, only C functions. Is this due to C++ name-mangling? How do I make this work?
|c++|windows|dll|import|
There is a cool framework called [Acovea (Analysis of Compiler Options via Evolutionary Algorithm)][1], by Scott Rober Ladd, one of the GCC hackers. It's a genetic/evolutionary algorithm framework that tries to optimize GCC optimization flags for a specific piece of code via natural selection. It works something lik...
I've found jQuery to be indispensable when writing just about any useful bit of javascript. That said, one site I was working on wanted to do animations. I suggested NOT using flash, but performing the relatively "simple" animations that jQuery packages so well with jQuery. We used fades and slides and the like. In...
Ended up moving everything to mod_rails. Works like a champ!
You seem to have two (or three) separate problems here.<p> 1. You don't really understand Kalman filters and/or the mathematics behind them. That is going to make it very difficult to correctly implement and use one.<p> 2. You don't seem to understand the basic physics involved in the problem. (Basic physics means ...
LINQ requires .NET v3.5 An excellent tool for getting to know and practice LINQ is [Joseph Albahari's LINQPad][1] [1]: http://www.linqpad.net/
Why am I loosing data when using a vxWorks pipe?
|vxworks|
I am using pipes to transfer information between two vxWorks tasks. Here is an almost code sample: <pre><code> Init() { fd = open("/pipe/mydev", O_RDWR, 0777); ... } taskRx() { ... len = read(fd, rxbuf, MAX_RX_LEN); ... } taskTx() { ... len = write(fd, txbuf, txLen); ... } </c...
Why am I losing data when using a vxWorks pipe?
I am using pipes to transfer information between two vxWorks tasks. Here is a code sample: <pre><code> Init() { fd = open("/pipe/mydev", O_RDWR, 0777); ... } taskRx() { ... len = read(fd, rxbuf, MAX_RX_LEN); ... } taskTx() { ... len = write(fd, txbuf, txLen); ... } </code></...
I am using pipes to transfer information between two vxWorks tasks. Here is a code sample: <pre><code> Init() { fd = open("/pipe/mydev", O_RDWR, 0777); ... } taskRx() { ... len = read(fd, rxbuf, MAX_RX_LEN); ... } taskTx() { ... len = write(fd, txbuf, txLen); ... } </code></...
just a bit note: string/String is not the only couple of aliases: eg. Integer,Int32, int are all aliases. @mliesen: it doesn't happend in C#, it's not like C. this because from C# you don't create executable but a per-compiled code, as java.
Install NTP if you don't already have it. <tt>ntpdate</tt> will set the clock correctly, then <tt>ntpd</tt> can keep the clock accurate. The <a href="http://www.pool.ntp.org/">NTP pool project</a> provides a large pool of NTP servers to pick from. <b>Edit</b> just noticed you said you think NTP is not a good s...
This was just released too: http://codeplex.com/SnippetDesigner
`wmemset(3)` is the wide (16-bit) version of memset. I think that's the closest you're going to get in C.
`wmemset(3)` is the wide (16-bit) version of memset. I think that's the closest you're going to get in C, without a loop.
Check your OS documentation for a local version, then consider just using the loop. The compiler probably knows more about optimizing memory access on any particular architecture than you do, so let it do the work. Wrap it up as a library and compile it with all the speed improving optimizations the compiler allo...
Here's the answer to the second one in C# with a test method. Shuffle looks O(n) to me. public enum CardValue { A, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, J, Q, K } public enum Suit { Spades, Hearts, Diamonds, Clubs } public class Card { public Card(CardValue value, Suit suit) ...
Here's the answer to the second one in C# with a test method. Shuffle looks O(n) to me. **Edit:** Actually it would be O(n^2) worst case because list.Remove() is O(n). Damn! public enum CardValue { A, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, J, Q, K } public enum Suit { Spades, Hearts, Diamo...
There's actually a much better solution than enumerating all the possible translations of a number and looking them up: Simply do the reverse computation on every word in your dictionary, and store the string of digits in another field. So if your mapping is: 0 = N, 1 = L, 2 = T, 3 = D, 4 = R, 5 = V or F, 6 = B or P...
I would say that for any given language, experience is the key thing. It just takes time to learn a language and learn the APIs and 'idioms' that the language uses. Whether someone is an expert in anything or not is something that should be asked of ones peers. To paraphrase Jeff Foxworthy, "If you answer more question...
Turns out I needed to use the "Pre Win2000" id not the regular one.
When I interviewed with Google, the interviewer told me to think about it this way. On a scale of 1-10 for C proficiency, to say you're a "10" means you've written papers and/or books or been a speaker in a conference on programming in C. Based on this, very few people are 10s. FWIW, I have been programming in C f...
I think a fair answer would be understanding all of the intracies of ISO C. The reality, as any comp.lang.c regular will tell you, is that almost nothing that people need to do can be done in pure ISO C, as you generally need to interact with your environment in a more well defined way. That's where POSIX comes abo...
**Best option**: I would instead recommend to use a standard date picker. **Alternative**: every time the content of the edit control changes, parse it and display (in a separate control?) the long format of the date (ie: input "03/04/09" display "Your input: March 4, 2009")
check out the [gd library][1] and [imagemagick][2] [1]: http://us2.php.net/gd [2]: http://us2.php.net/manual/en/book.imagick.php
Is there a way to get FlexBuilder 3 to treat a project as an Application and a LIbrary?
|apache-flex|flexbuilder|
My team builds reusable libraries for other (internal) software development teams. We use FlexBuilder 3 as our development environment. Our SCM standards state that these projects must include test harnesses and a unit test runner, and (of course) we want to be able to use the debugger. For that reason, all the proje...
How do I get the current size of a matrix stack in OpenGL?
|c|graphics|opengl|matrix|
How do I get the current size of a matrix stack (GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE) in OpenGL? I want this so that I can do some error checking to ensure that in certain parts of the code I can check that the matrix stacks have been left in the original condition.
You can use the Shape properties .TopLeftCell and .BottomRightCell to return the extents of the rectangular range that the shape overlaps. In your example, YourShape.TopLeftCell.Address should return $B$17
Read the items off the top of the heap one by one. Basically what you have then is heap sort.
Seems like the problem was due to how the BufferedImage was created. When using: BufferedImage hello = bufferedImage.getSubimage(0,0, getWidth(), getHeight()); Instead it worked. I also had to change switch from paintComponent to paint to render the children. Problem solved, but if anyone knows. Why did my...
I'm not sure if this will help, exactly, but here is some code to de-select text: // onselectstart is IE-only if ('undefined' !== typeof this.onselectstart) { this.onselectstart = function () { return false; }; } else { this.onmousedown = function () { return false; }; this...
I'm a bit like you, I've coded PHP for over 8 years. I had to take a .NET/C# course about a year ago and I really enjoyed the C# language (hated ASP.NET) but it made me a better PHP developer. PHP as a language is pretty poor, but, I'm extremely quick with it and the LAMP stack is awesome. The end product far outwei...
Dynamic LINQ and Dynamic Lambda expressions?
|linq|.net-3.5|lambda|dynamic|
What is the best way of dynamically writing LINQ queries and Lambda expressions? I am thinking of applications where the end user can design business logic rules, which then must be executed. I am sorry if this is a newbie question, but it would be great to get best practices out of experience.
[*Here*][1] you can see an animated diagram which "explodes" the box. [1]: http://redmelon.net/tstme/box_model/
Why not inherit from [Control][1] to define a custom control that has properties like Text and Image? [1]: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.aspx
The short answer is that it's not possible to construct a single regex to satisfy your problem. Ruby 1.8 does not have lookaround assertions (the (?&lt;! stuff in your example regex) which is why your regex doesn't work. This leaves you with two options. 1) Use more than one regex to do it. def is_first_rar(...
If you have tortoise SVN you can use SubWCRev.exe Create a file called: RevisionInfo.tmpl SvnRevision = $WCREV$; Then execute this command: SubWCRev.exe . RevisionInfo.tmpl RevisionInfo.txt It will create a file ReivisonInfo.txt with your revision number as follows: SvnRevision =...
"What not to test when it comes to Unit Testing?" * Beans with just getters and setters. Reasoning: Usually a waste of time that could be better spent testing something else.
What you assume is right, in a single target/thread environment there's little difference. However if you look at the cache providers there is a bit going on even in a multi-threaded scenario. How an object is re-cached from it's modified state is different in the non-strict. For example, if your object is much h...
There is no such tool that I know of. Generally, you simply copy the tbox and abox definitions from one ontology to another, and write a transform tool. I think this is the first ontology question I've seen on this site. I hope more people use the tag.
As others have already pointed out, there are various bignum/arbitrary precision libraries in C++ that you would likely find useful. If speed isn't necessary, I'm under the impression that Python and Lisp both use bignums by default.
You can do it this way: x = largeValue1; y = largeValue2; return (x&y)+((x^y)/2); That's a bit-twiddling way to get the average of two integers without overflow. If you want you can replace the division by two with a bit-shift, but the compiler will do that for you anyways.
[Sphinx](http://sphinx.pocoo.org/) is a documentation generator using reStructuredText. It's quite nice, although I haven't used it personally. The website [Hazel Tree](http://sphinx.pocoo.org/), which compiles python texts uses Sphinx, as well as the new Python documentation.
1) Create a new repository - you can create it on the test server and later transfer it to a dedicated server/NAS if it makes things simple for you. 2) Import all your existing source code into the repository. 3) You can create using the 'svn' command line tool (and its related tools, like svnadmin) a batch file whic...
You could also look at itextSharp. Its a .net pdf writing tool and is a port of the Java itext. The limited playing I did with it made pdf writing simple and fun.
I would seriously consider looking at using Strawberry Perl. [http://strawberryperl.com][1] [1]: http://strawberryperl.com
Implement a type converter, here is one, warning : quick&dirty, not for production use, etc : <pre> public class IntsConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } public overri...
Implement a type converter, here is one, warning : quick&dirty, not for production use, etc : public class IntArrayConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, Type sourceType) { return sourceTy...
Here's the answer to the second one in C# with a test method. Shuffle looks O(n) to me. **Edit:** Having looked at the Fisher-Yates shuffle, I discovered that I'd re-invented that algorithm without knowing about it :-) it is obvious, however. I implemented the Durstenfeld approach which takes us from O(n^2) -> O(n),...
Here's the answer to the second one in C# with a test method. Shuffle looks O(n) to me. **Edit:** Having looked at the Fisher-Yates shuffle, I discovered that I'd re-invented that algorithm without knowing about it :-) it is obvious, however. I implemented the Durstenfeld approach which takes us from O(n^2) -> O(n),...
This is a good approach. But be aware that you shouldn't over-do logging. Otherwise you couldn't find the interesting informations in all the noise, and it reduces the overall performance (e.g. anonymous object creation, depending on the language).
It is old news a little. It's often called "You ain't gonna need it" ( "You Arent' Going to Need It" in non-idomatic English), and abbreviated [YAGNI][1]. Problems associated with implementing a feature when you don't need it: * the implementation takes time away from developing features that are needed * the fe...
You can break lines in between parenthesises and braces. Additionally, you can append the backslash character `\` to a line to explicitly break it: x = (tuples_first_value, second_value) y = 1 + \ 2
basics/general: - Do not optimize when you have no problem. - Know your platform/CPU... - ...know it thoroughly - know your ABI - Let the compiler do the optimization, just help it with the job. some things that have actually helped: Opt for size/memory: - Use bitfields for storing bools ...
For information about [PHPUnit][1], be sure to read the [documentation][2]. It does not look too bad IMO. There is a blog entry about [automatically testing MVC applications with Zend Framework][3] which looks quite good, too. :) [1]: http://www.phpunit.de/ [2]: http://www.phpunit.de/manual/3.3/en/ [3]: ht...
PHP parse configuration ini files
|php|apache|
Is there a way to read a module's configuration ini file? For example I installed php-eaccelerator (<http://eaccelerator.net>) and it put a eaccelerator.ini file in /etc/php.d My PHP installation wont read this INI file because the "--with-config-file-scan-dir" option wasn't used when compiling PHP **Is there a wa...
I would suggest a small modification, if the method has been proven to work properly (performance/maintenance/security/etc.), THEN use that every time. The trick is the "proven to work", and also the "properly". So basically, unless there is a problem with the current method, don't change it for the sake of chan...
Add svn:keywords to the SVN properties of the source file: svn:keywords Revision Then in the source file include: private const string REVISION = "$Revision$"; The revision will be updated with the revision number at the next commit to (e.g.) `"$Revision: 4455$"`. You can parse this string to extrac...
Take a look the the [sql game][1], it is very stable and actually pushed traffic limits at one point so that it was getting throttled by Google. I have seen nothing but good news about App Engine, other than hosting you app on servers someone else controls completely. [1]: http://mysqlgame.appspot.com/