instruction
stringlengths
0
30k
⌀
Lacking a more specific prototype, the compiler will assume that the function returns int and takes whatever number of arguments you provide. Depending on the CPU architecture arguments can be passed in registers (for example, a0 through a3 on MIPS) or by pushing them onto the stack as the original x86 called conven...
Lacking a more specific prototype, the compiler will assume that the function returns int and takes whatever number of arguments you provide. Depending on the CPU architecture arguments can be passed in registers (for example, a0 through a3 on MIPS) or by pushing them onto the stack as in the original x86 calling co...
Perforce is free for up to 2 users. I'm not 100% certain about what you expect can/should be automated, but perforce is very high quality. You can easily create and maintain branches, and you can merge easily. It's quite easy to cherry pick specific changes you made in one branch, and merge them into another b...
I believe that is a supported, but unrecommended configuration. You should be able to get help from microsoft :)
Did you ever ask yourself why you have so many branch/merge operations? Is there a way to simplify your development process? Subversion, IMHO, is a good application of the KISS (Keep it simple, stupid) principle. Translation: In my experience you will get a far greater productivity boost from streamlining your dev...
`join()` in Perl: use List::Util qw(reduce); sub mjoin($@) {$sep = shift; reduce {"$a$sep$b"} @_ or ''} say mjoin(', ', qw(Alpha Beta Gamma)); # Alpha, Beta, Gamma Or without `reduce`: sub mjoin($@) { my ($sep, $sum) = (shift, shift); $sum .= "$sep$_" for...
`join()` in Perl: use List::Util qw(reduce); sub mjoin($@) {$sep = shift; reduce {$a.$sep.$b} @_ or ''} say mjoin(', ', qw(Alpha Beta Gamma)); # Alpha, Beta, Gamma Or without `reduce`: sub mjoin($@) { my ($sep, $sum) = (shift, shift); $sum .= $sep.$_ for ...
@Fire Lancer: Right! I forgot about exception, but I would like to see them mentioned, especially the unchecked 'runtime' exception that this public method could throw @Mike Stone: > you have to be diligent also to update the docs when you change the semantics of the method. Mmmm I sure hope that the _public ...
Windows API Dialogs without using resource files
|c++|winapi|dialog|windows-api|
I'm trying to create a dialog box using C++ and the windows API, but I don't want the dialog defined in a resource file. I can't find anything good on this on the web, none of the examples I've read seem to define the dialog programmatically. Anyone know how to do this? A simple example is fine, I'm not doing anythi...
To get a copy, use the clone method: new_record = old_record.clone Then you can change whichever fields you want
To get a copy, use the clone method: new_record = old_record.clone Then you can change whichever fields you want. [ActiveRecord overrides the built-in Object#clone](http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M001363) to give you a new (not saved to the DB) record with an unassigned ID. No...
I'm selecting the “best answer” after this post. But first, I'd like to acknowledge some very original contributions: 1. aku's ones. Each one explores a new and original way of causing stack overflow. The idea of doing [f(x) ⇒ f(f(x))](#63061) is one I'll explore in my next entry, below. :-) 2. [Cody's one](#62321)...
I'm selecting the “best answer” after this post. But first, I'd like to acknowledge some very original contributions: 1. aku's ones. Each one explores a new and original way of causing stack overflow. The idea of doing [f(x) ⇒ f(f(x))](#63061) is one I'll explore in my next entry, below. :-) 2. [Cody's one](#62321)...
We also use TreeSurgeon and are quite happy with it. Our structure looks like: Branch - build - lib - src - < various src directories for apps, tests, db migrations, etc.) - tools Trunk - Same as above
c++ overload resolution
|c++|function|overloading|resolution|
Given the following example, why do I have to explicitly use the statement b->A::DoSomething() rather than just b->DoSomething()? Shouldn't the compiler's overload resolution figure out which method I'm talking about? I'm using Microsoft VS 2005. class A { public: int DoSomething() {re...
|dns|cname|webhosting|
I have 2 hosts and I would like to point a subdomain on host one to a subdomain on host two: subdomain.hostone.com --> subdomain.hosttwo.com I added a CNAME record to host one that points to subdomain.hosttwo.com but all I get is a '**400 Bad Request**' Error. Can anyone see what I'm doing wrong?
|dns|web-hosting|cname|
You can try using the [HttpResponse.Cache property][1] if that would help: Response.Cache.SetExpires(DateTime.Now.AddSeconds(60)); Response.Cache.SetCacheability(HttpCacheability.Public); Response.Cache.SetValidUntilExpires(false); Response.Cache.VaryByParams["Category"] = true; if (Res...
You can try using the [HttpResponse.Cache property][1] if that would help: Response.Cache.SetExpires(DateTime.Now.AddSeconds(60)); Response.Cache.SetCacheability(HttpCacheability.Public); Response.Cache.SetValidUntilExpires(false); Response.Cache.VaryByParams["Category"] = true; if (Res...
> HANDLEs (and the rest of the WinAPI) is OOP! Are they, though? They're not inheritable, they're certainly not substitutable, they lack well-defined classes... I think they fall a long way short of "OOP".
What's the best way to configure my Ruby compilation in Debian?
|debian|ruby|compilation|
When compiling from source, I never know which configure flags to use to optimize the compilation for my environment. Assume the following hardware/OS: - Single Core, 2 GHz Intel - 512MB Ram - Debian 4 I usually just go with `./configure --prefix=/usr/local` Should I be doing anything else?
For what it's worth, you can use Subversion & TortoiseSVN without a server using file:/// URLs to connect to you repository. I've done this to create repositories on USB thumb drives that I can move from machine to machine. Here's a nice write-up: [http://www.fredshack.com/docs/tortoisesvn.html][1] [1]: http...
In reply to the update in the question, I would say that the 'label' option should be selectable but either make it do nothing on submission or via JavaScript, don't allow the form to be submitted without a value being selected (assuming it's a required field). From a usablilty point of view I'd suggest doing both, ...
I have created a thread devoted to these kind of questions for *any* programming languages [here][1]. [Java is also mentioned][2]. Here is the short summary: - Java passes it parameters by value - "by value" is the only way in java to pass a parameter to a method - using methods from the object given as ...
I haven't seen anyone mention Perforce. Perforce allows you to use their software for up-to 2 users for free. You can run the server and clients in the same machine, which will give you the environment that you want.
> *...This is a fairly core piece of the* > *project I'm working on though...* Is it really? It's tempting to just abstract it and provide a basic implementation with the intention of refactoring later on. Then you can get on with what matters: the game. Just a thought &lt;bb /&gt;
This is a great free resource by Joseph Albahari I read all the time. [Threading in C#][1] [1]: http://www.albahari.com/threading/
Simpler interface for SQL Server analysis services cubes for end users
|sql-server|olap|cubes|
Is there a simpler interface for end users to run "queries" on pre-existing SqlServer Analysis Service cubes? I'm looking for a way to deploy the cubes and allow the users to work with the data through a simpler interface than BIDS. Is this even possible?
If you're talking GoF, the [Memento][1] pattern specifically addresses undo. [1]: http://en.wikipedia.org/wiki/Memento_pattern
I understand threading in theory but not in practice in .net
|.net|multithreading|reference|
I have a basic cs-major understanding of multi-threading but have never had to do anything beyond simple timers in an application. Does anyone know of a good resource that will give me a tour how to work with multi-threaded applications, explaining the basics and maybe posing some of the more difficult stuff?
if your assingnments have `has_many :students` or `has_and_belongs_to_many :students`, then you can change the id of the multi-select box to assignment_student_ids[], and it should work.
Alternative to PHP QuickForm?
|php|
I'm currently playing around with [HTML_QuickForm](http://pear.php.net/package/HTML_QuickForm) for generating forms in PHP. It seems kind of limited in that it's hard to insert my own javascript or customizing the display and grouping of certain elements. Are there any alternatives to QuickForm that might provide m...
Justify any "fun" features you insert by regarding them as marketable eye-candy. Unless, of course, they're not visible ;)
If you find it hard to insert Javascript into the form elements, consider using a JavaScript framework such as [Prototype](http://www.prototypejs.org/) or [jQuery](http://jquery.com/). There, you can centralize the task of injecting event handling into form controls. By that, I mean that you won't need to insert eve...
AJAX Library Strategies
|ajax|jquery|yui|prototype|scriptaculous|
What experience can you share about using multiple AJAX libraries? There are useful features in Prototype, some in jQuery, the Yahoo library, etc. Is it possible to include all libraries and use what you want from each, do they generally all play nicely together with name spaces, etc. For the sake of speed is there ...
What are the best strategies for using multiple AJAX libraries?
|jquery|ajax|prototype|yui|scriptaculous|
I'm a big fan of option 3. Pretend for a minute you were going to set up transaction infrastructure anyways where: 1. Whenever a call to the datastore was about to be made if an existing transaction hadn't been started then one was created. 2. If a transaction is already in place then calls to the data store h...
The example you give is actually a python builtin function, called `divmod`. So someone, at some point in time, thought that it was pythonic enough to include in the core functionality. To me, if it makes the code cleaner, it is pythonic. Compare these two code blocks: seconds = 1234 minutes, seconds = d...
I used to work in a development team that happily wiped their asses with any naming (and for that matter any other coding) conventions. Believe it or not, having to cope with ä's and ö's in the code was a contributing factor of me resigning. Though I'm Finnish, I prefer writing code with US keyboard settings because cu...
Is there a specific problem you are trying to handle with dates? If the existing date API in .NET can handle your problem cleanly, I see no reason to consider a 3rd party library to do it. When I was in .NET, we had to deal with dates quite a bit, and the standard libraries provided a fair amount of functionality to ...
According to the MSDN documentation: *When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.* Public Overridable Function GetBaseException() As Exception Dim innerException As Exception = Me.InnerException Dim excep...
Often unit tests are based on mock object or mock data. I like to write three kind of unit tests: - "transient" unit tests: they create their own mock objects/data and test their function with it, but destroy everything and leave no trace (like no data in a test database) - "persistent" unit test: they test func...
|c++|function|resolution|overloading|
Given the following example, why do I have to explicitly use the statement b->A::DoSomething() rather than just b->DoSomething()? Shouldn't the compiler's overload resolution figure out which method I'm talking about? I'm using Microsoft VS 2005. (Note: using virtual doesn't help in this case) class A { ...
I primarily use ActivePerl, but I really like where Strawberry Perl is headed. I love that the cpan shell "just works" and I don't have to jump through a bunch of hoops to install XS modules. (e.g. ExtUtils::FakeConfig, though that's less necessary in more recent ActivePerl builds.) I'm also excited about the possibili...
The people above have already pretty much explained the issue, but one thing that might make things clear is that, though people use '&lt;br/>' and such all the time in HTML documents, this is not actually HTML, and only works because all half-decent HTML parsers *ignore* the '/' in such a position (and know that BR 'c...
The people above have already pretty much explained the issue, but one thing that might make things clear is that, though people use '&lt;br/>' and such all the time in HTML documents, any '/' in such a position is basically ignored, and only used when trying to make something both parseable as XML and HTML. Try '&lt;p...
Here are three more pages that have examples and code: http://leeontech.wordpress.com/2008/04/11/drag-and-drop-in-silverlight/ http://simplesilverlight.wordpress.com/2008/08/13/drag-and-drop-silverlight-example/ http://blogs.msdn.com/mgrayson/archive/2008/08/18/silverlight-2-samples-dragging-docking-expanding-...
Not answering your question, but I'll write some comments anyway: I don't remember all K&R rules, but the function you've listed will fail if lim is equal to one. Then you won't run the loop which leaves c unintialised, but you'll still use the variable in the if (c == '\n') check. Also the while (--lm > 0; ...) ...
Problem with SET FMTONLY ON
|sql-server|
I'm executing stored procedures using SET FMTONLY ON, in order to emulate what our code generator does. However, it seems that the results are cached when executed like this, as I'm still getting a *Conversion failed* error from a proc that I have just dropped! This happens even when I execute the proc without SET FMT...
There are at least four options when using PHP5 to parse XML files. The best option depends on the complexity and size of the XML file. There’s a very good 3-part article series titled ‘[XML for PHP developers][1]’ at IBM developerWorks. “Parsing with the DOM, now fully compliant with the W3C standard, is a famil...
Ruby has a somewhat unique syntax and style that you'll pick up more quickly by working with other people's ruby code. You could certainly learn this while using IronRuby just as well as in any other implementation of the ruby language. (Although, you may run into trouble with some more obscure syntax or libraries with...
Why don't we get a compile time error even if we donot include stdio.h in a C program?
|c|compiler-construction|
How does the compiler know the prototype of sleep function or even printf function, when I did not include any header file in the first place. Moreover, if I specify sleep(1,1,"xyz") or any arbitrary number of arguments, the compiler still compiles it. But the strange thing is that gcc is able to find the definitio...
Why don't we get a compile time error even if we don't include stdio.h in a C program?
A context-sensitive language? This one's non-indented: Protium (http://www.protiumble.com)
I started to use a really cool cross-platform SDK called EdgeLib. It allows you to use a simple API and you can compile your projects to a variety of platforms: Windows Mobile Pocket PC, Windows Mobile Smartphone, Symbian Series 60, Series 80, Series 90, Symbian UIQ, Gamepark Holdings GP2X, Gizmondo and Windows desktop...
There is the classic 'ab' (apachebench) program. More power comes from [JMmeter][1]. For server health, I recommend Munin, which can painlessly capture data from several systems and aggregate it on one page. [1]: http://http://jakarta.apache.org/jmeter/
There is the classic 'ab' (apachebench) program. More power comes from [JMmeter][1]. For server health, I recommend Munin, which can painlessly capture data from several systems and aggregate it on one page. [1]: http://jakarta.apache.org/jmeter/
I'm using a Finnish host called [Nebula](http://www.nebula.fi) that happily runs my NHibernate-leveraging applications. I had an issue once with trust levels; the machine.config on the host was configured to deny reflection but I successfully overrode it in the web.config.
Can an iPhone App Be Run as Root?
|iphone|setuid|permissions|
I am thinking about the design of an iPhone app I'd like to create. One possible problem is that this application will have to run as root (to access certain network ports). In a typical UNIX app, I'd just get the app to run with setuid, but I'm wondering if that is possible with an iPhone app. I've read this ques...
|iphone|permissions|setuid|
I am thinking about the design of an iPhone app I'd like to create. One possible problem is that this application will have to run as root (to access certain network ports). In a typical UNIX app, I'd just get the app to run with setuid, but I'm wondering if that is possible with an iPhone app. I've read this ques...
|iphone|permissions|no-can-do|setuid|
|iphone|permissions|setuid|
You'd have to manually write some javascript. Rails' generators won't do something this complex for you. Prototype.js will do almost all of the heavy lifting for you though. Off the top of my head, the code would look like this: (UNTESTED) <%= javascript_include_tag 'prototype' %> <form id="my-fo...
I agree with Vinko [BeautifulSoup][1] is the way to go. However I suggest using <code>fooId['value']</code> to [get the attribute][2] rather than relying on value being the third attribute. from BeautifulSoup import BeautifulSoup #Or retrieve it from the web, etc. html_data = open('/yourwebsite/page.ht...
Start to write a lot of comments -- but use that as an opportunity to refactor the code so that it's self explanatory. ie: for(int i=0; i<=arr.length; i++) { arr[i].conf() //confirm that every username doesn't contain invalid characters } Should've been something more like for(int i=0;...
In C++ you can do: <pre><code> bool is_signed = std::numeric_limits&lt;typeof(some_integer_variable)>::is_signed; </code></pre> numeric_limits is defined in the &lt;limits> header.
The new C# language features are compelling for me: automatic properties, object initializers, collection initializers, extension methods, lambda expressions. For a quick overview from the guy responsible, see: <http://weblogs.asp.net/scottgu/archive/2007/03/08/new-c-orcas-language-features-automatic-properties-...
In C, you can't write a macro that works on as-yet unknown typedef's of fundamental integer types. In C++, you can as long as your type is a fundamental integer type or a typedef of a fundamental integer type. Here's what you'd do in C++: template <typename T> struct is_signed_integer { st...
JVM Thread dumps containing monitors without locking threads
|java|multithreading|
What could be the cause of JVM thread dumps that show threads waiting to lock on a monitor, but the monitors do not have corresponding locking threads? Java 1.5_14 on Windows 2003
|ruby|installation|debian|
You could also try http://motionandcolor.com/ > Wrapper is a cross-browser compliant HTML/CSS rendering engine written in ActionScript that sits on top of your standards compliant HTML page. Javascript might be tricker though.
I just installed <a href="http://www.helicontech.com/isapi_rewrite/">Helicon's ISAPI Rewrite 3</a>. Works exactly like htaccess. I'm diggin it so far.
>> HANDLEs (and the rest of the WinAPI) is OOP! > Are they, though? They're not inheritable, they're certainly not substitutable, they lack well-defined classes... I think they fall a long way short of "OOP". Have you ever created a window using WinAPI? Then you should know that you define a class (`RegisterClass...
> All too often, the class is used > simply for its syntactic sugar; it > puts the functions for a record type > into their own little namespace. Yes, I find this to be too prevalent as well. This is not Object Oriented Programming. It's Object Based Programming and data centric programing. In my 10 years of ...