instruction stringlengths 0 30k ⌀ |
|---|
How about (something based on) the [Template method pattern][1]?
One superclass knows how to rip apart the class hierarchy, but relies on its subclasses to actually do something useful with it.
[1]: http://en.wikipedia.org/wiki/Template_method_pattern |
> Trying to get the size of a bitfield isn't legal, as you have seen. (sizeof returns the size in bytes, which wouldn't make much sense for a bitfield.)
So are you stating that the behavior is undefined, i.e. it has the same degree of legality as "*(int *)0 = 0;", and compilers can choose to fail to handle this sens... |
We have been trying the continuous replication solution on SQL SERVER 2005 and it appeared to be less efficient than a scheduled solution: as your process is continuous, you will not get all the info related to your passed replications (how many replications failed, how long did the process take, why was the process st... |
Not sure that you'll easily get this to work. Unlike basic where the 401 challenge happens in-band of the user request - such that the creds appear in the headers, NTLM handshakes are done on a separate port - then forced onto the thread context by unmanaged code.
You tried pulling apart the ASP.NET NTLM module in ... |
[Firebug][1] seems to be the most useful so far. When a page is running on firebug, it can be very handy to log messages into firebug via javascript calls to **console.log('your log message');** but don't execute that code in IE since the console object is only in scope when firebug is running.
For IE, other folks ... |
To judge whether it's really a conformant ZIP file, see PKZIP's [.ZIP File Format Specification][1].
For what it's worth I have had no trouble using SharpZipLib to create ZIPs on a Windows Mobile device and open them with WinZip or Windows XP's built-in Compressed Folders feature, and also no trouble producing ZIPs ... |
This really depends on what you are trying to do. Are you trying to do something special just in safari using some of the CSS3 features included or are you trying to make a site cross browser compliant?
If you are trying to make a site cross browser compliant I'd recommend writing the site to look good in safari/fir... |
You're probably best off benchmarking both and finding out. I've seen situations where just doing multiple queries (MySQL likes this) is faster than JOINs and one big slow query that takes a lot memory and causes the DB server to thrash. I say benchmark because it's going to depend on your database server, how much mem... |
Please clarify if you mean “delete all directories but the four newst ones” or “delete everything (files and directories) except for the four newest directories”.
Please also note that creation times are not known for directories. One can only tell when a directory was last modified, that is, had files added, remove... |
Unfortunately you will have to install both versions. Older version of the framework are not automatically bundled with newer versions. |
Accessing hidden embedded quicktime audio |
You have a few options, as already detailed, but in my experience, you're better off leaving delegates and BeginInvoke, and using BackgroundWorker instead (v2.0+), as it is easier to use and also allows you to interact with the main form on the thread's completion. All in all a very weel implemented solution, I have fo... |
[The Wiki Article][1] gives a good overview of Futures. The concept is generally used in concurrent systems, for scheduling computations over values that may or may not have been computed yet, and further, whose computation may or may not already be in progress.
From the article:
> A future is associated with a
... |
I agree with Patrick_O that the strto{l,ul,ull,ll,d} functions are the best way to go. There are a couple of points to watch though.
1. Set errno to zero before calling the functions; no function does that for you.
2. The Open Group page linked to (which I went to before noticing that Patrick had linked to it too)... |
[YAML][1]'s main advantages are human readability and compactness. Oh, and it's widely supported across various platforms and languages.
YAML is very popular in the Ruby community, where it's mainly used in preference to XML for configuration files in Rails and Merb for example.
[1]: http://www.yaml.org/ |
How do the equality (==) and identity (===) comparison operators differ? |
|php| |
Can you explain the difference between `==` and `===`, giving some useful examples? |
|javascript|php| |
We migrated our svn repository with a tool that we wrote, and just took the head revision of our starteam projects.
Watch out for differences between single-file checkins (CVS) and multi-file changesets (Perforce).
Watch out for branches is separate space (CVS) vs. branches in filepath-space (Perforce).
|
If you want to go from a string to binary data, **you must know what encoding was used to convert the binary data to a string in the first place**. Otherwise, you might not end up with the correct binary data. So, the most efficient way is likely GetBytes() on an Encoding subclass (such as UTF8Encoding), but you must k... |
Static methods in python are called [classmethod][1]s. Take a look at the following code
<pre><code>>>> class MyClass:
... def myInstanceMethod(self):
... print 'output from an instance method'
... @classmethod
... def myStaticMethod(cls):
... print 'output from a static method'
>>> MyCl... |
Static methods in python are called [classmethod][1]s. Take a look at the following code
<pre><code>>>> class MyClass:
... def myInstanceMethod(self):
... print 'output from an instance method'
... @classmethod
... def myStaticMethod(cls):
... print 'output from a static method'
... |
I don't have any completed sites written in ASP.NET MVC, but I have one in the works and a few others in mind that would be ideal in MVC.
The product is solid and you can expect to continue to see development in the coming months. The only concern you should be aware of is that the code is likely going to change. ... |
[Carnage Heart][1] for PlayStation was fun. It would let you program little mechs to do battle using a flow diagram.
![The Brain][2]
[1]: http://en.wikipedia.org/wiki/Carnage_Heart
[2]: http://upload.wikimedia.org/wikipedia/en/thumb/3/3f/CarnageHeartSoftware.PNG/180px-CarnageHeartSoftware.PNG |
[OWASP][1] is your friend. Their [Top Ten List][2] of web application security vulnerabilities includes a description of each problem and how to defend against it. The site is a good resource for learning more about web application security and is a wealth of tools and and testing techniques as well.
[1]: http:... |
Using DIV, you can easily switch things. For example, you could make this :
Menu | Content
Content | Menu
Menu
----
Content
It's easy to change it in CSS, not in HTML. You can also provide several styles (right handed, left handed, special for little screen).
In CSS, you can also hi... |
OO Design, open/closed principle question |
|language-agnostic|oop|ooad|openclosed-principle| |
I've been thinking about this object oriented design question for a while now and have unable to come up with a satisfactory solution, so thought I'd throw it open to the crowds here for some opinions.
I have a *Game* class that represents a turn based board game, we can assume it's similar to Monopoly for the purpo... |
In addition to yours I will put:
- Unit Test Strategy
- Integration Test Strategy
- Defined Process
- Release (delivery) strategy (like milestones, working packages and so on)
- Source control branching strategy |
If you care about interoperability, the man page for tmpnam suggests:
## tmpnam man page ##
BUGS
Never use this function. Use mkstemp(3) instead.
## mkstemp man page ##
SYNOPSIS
#include <stdlib.h>
int mkstemp(char *template);
DESCRIPTION
... |
Hosting a WCF endpoint with programatic settings in IIS |
|embed|quicktime| |
I'm trying to write a simple audio player for a website, and am using the EMBED... tag to embed the audio and setting HIDDEN="true" and using various javascript commands to control the audio playback. It works fine for realplayer and mplayer but the quicktime plugin doesn't respond to javascript if the hidden bit is se... |
As mentioned above, you'll need to create a custom membership provider which a fairly straightforward. You'll create a .NET class that inherits from System.Web.Security.MembershipProvider. There are several methods that need to be overriden in your class, but most are not even used by the MVC account controller. The ma... |
For the easy to teach Component Pascal language (a successor to Niklaus Wirth's Pascal and Oberon) try the free, open source [BlackBox IDE][1] and the book [Computing Fundamentals][2] by Stan Warford.
Regards,
tamberg
[1]: http://www.oberon.ch/blackbox.html
[2]: http://www.amazon.com/Computing-Fundamentals-... |
This Java code works for me:
selenium.keyDown(id, "\\13");
Notice the escape. You probably need something like chr(\13) |
If you install something that requires 3.5, then you will have to install it. The way that .Net works though, you can have 1.1, 2.x and 3.5 all installed at the same time. Programs specify the version of the framework they need, and that version is loaded for them. |
Rather that trying to figure out which characters to filter out, I'd stick to parametrized queries instead, and remove the problem entirely. |
If you are writing software targeted at a Windows platform then Visual Studio is more or less the standard IDE. Since you are teaching a graduate student I would recommend getting the academic license for the [professional edition][1] if they are going to be writing a lot of software, otherwise the [express editions][2... |
To answer your question: very poorly.
We're looking to standardize on public keys for password-less authentication and shared group/passwd files. Our testing looks good so far, but we're still trying to smooth over some rough edges. |
There is no *native* (e.g., System libraries) solution for this. That's the reason why [SharpUSBLib][2] exists as mentioned by [moobaa][3].
If you wish to roll your own handler for USB devices, you can check out the [SerialPort class of System.IO.Ports][1].
[1]: http://msdn.microsoft.com/en-us/library/syste... |
list() is useful here. With any but the first array element, you'll need to pad it with useless variables. For example:
list( $firstElement ) = functionThatReturnsAnArray();
list( $firstElement , $secondElement ) = functionThatReturnsAnArray();
And so on. |
One lesser known facet of **switch** in C# is that it relies on the **operator=** and since it can be overriden you could have something like this:
<pre><code>
string s = foo();
switch (s) {
case "abc": /*...*/ break;
case "def": /*...*/ break;
}
</code></pre> |
I think it is interesting that more asp.net is requiring code in the aspx pages. The listview in 3.5, and even the ASP.NET MVC. The MVC has basically no code behind, but code in the pages to render information. |
if your 3rd party code doesn't require that the javascript file has the .js extension, then you can create your HTTPHandler and map it to either .axd or .ashx extension in web.config only - no need to change IIS settings as these extensions are automatically configured by IIS to be handled by asp.net.
<system.we... |
How can I stop Visual Studio (both 2005 and 2008) from crashing (sometimes) when I select the "Close All But This" option? |
|visual-studio| |
It does not do it all the time. |
Steve's answer works. The problem with your attempt to reproduce it is that you're using `$input`, which is a reserved variable (it automatically collects multiple piped input into a single variable).
You should, however, use .Replace() unless you need the extra feature(s) of -replace (it handles regular expressions... |
If you want to go from a string to binary data, **you must know what encoding was used to convert the binary data to a string in the first place**. Otherwise, you might not end up with the correct binary data. So, the most efficient way is likely GetBytes() on an Encoding subclass (such as UTF8Encoding), but you must k... |
There's a very good article about the Sieve of Eratosthenes: [The Genuine Sieve of Eratosthenes][1]
It's in a functional setting, but most of the opimization do also apply to a procedural implementation in C#.
The two most important optimizations are to start crossing out at P^2 instead of 2*P and to use a wheel ... |
The most influential programming book for me was [*Enough Rope to Shoot Yourself in the Foot*][1] by [Allen Holub][2].
O, well, how long ago it was.
[1]: http://www.amazon.com/Enough-Rope-Shoot-Yourself-Foot/dp/0070296898/ref=sr_1_1?ie=UTF8&s=books&qid=1221634801&sr=1-1
[2]: http://holub.com/ |
The most influential programming book for me was [*Enough Rope to Shoot Yourself in the Foot*][1] by [Allen Holub][2].
![Cover of the book][3]
O, well, how long ago it was.
[1]: http://www.amazon.com/Enough-Rope-Shoot-Yourself-Foot/dp/0070296898/ref=sr_1_1?ie=UTF8&s=books&qid=1221634801&sr=1-1
[2]: http... |
The most "important" shortcut is the [Secure Attention Sequence][1], Ctrl+Alt+Del.
On XP you usually have to [enable it][2] otherwise it just runs Task Manager.
While logged in, SAS brings up the Windows Security dialog on its own [Desktop][3], which will get you out of almost anything (such as a hung full-screen... |
What are you trying to accomplish?
I found the [System.ServiceModel.Syndication][1] classes very helpful when working with feeds.
[1]: http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.aspx |
I suggest reading the synaptics touchpad specs (most of the touchpads installed on notebooks are synaptics') available here http://www.synaptics.com/decaf/utilities/ACF126.pdf
I believe on page 18 you'll find the feature you are looking for. At least you'll know what to expect.
So, very likely, the touchpad driver ... |
There's a nice collection of "Bit Twiddling Hacks", including a variety of simple and not-so simple bit reversing algorithms coded in C at http://graphics.stanford.edu/~seander/bithacks.html.
I personally like the "Obvious" algorigthm (http://graphics.stanford.edu/~seander/bithacks.html#BitReverseObvious) because, w... |
As others have noted, worst case of Quicksort is O(n^2), while mergesort and heapsort stay at O(nlogn). On the average case, however, all three are O(nlogn); so they're for the vast majority of cases comparable.
What makes Quicksort better on average is that the inner loop implies comparing several values with a si... |
I use DDD a lot, and it's pretty powerful once you learn to use it. One thing I would say is don't use it over X over the WAN because it seems to do a lot of unnecessary screen updates.
Also, if you're not mated to GDB and don't mind ponying up a little cash, then I would try TotalView. It has a bit of a steep lea... |
Some useful things to think about when deciding whether an exception is appropriate:
1. what level of code you want to have run after the exception candidate occurs - that is, how many layers of the call stack should unwind. You generally want to handle an exception as close as possible to where it occurs. For usern... |
[Cleanly Migrate Your Subversion Repository To a GIT Repository][1].
[1]: http://www.simplisticcomplexity.com/2008/03/05/cleanly-migrate-your-subversion-repository-to-a-git-repository/ |
I think you are searching how to create a "Dynamic" Linq Query, [Here][1] is an example about how to do it with a library of extension methods. Those methods take string arguments instead of type-safe language operators.
[1]: http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dy... |
Combining two SyndicationFeeds |
<a href="http://stackoverflow.com/questions/61692/how-do-i-get-my-java-application-to-shutdown-nicely-in-windows">how-do-i-get-my-java-application-to-shutdown-nicely-in-windows</a>
That might be of help |
*[First][1]* link from google points to MSDN page:
[contains Function (XQuery)][2]
> In order to get case-insensitive
> comparisons, the [upper-case][3] or
> lower-case functions can be used.
[1]: http://www.google.ru/search?complete=1&hl=en&newwindow=1&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial... |
Why do we use extra expression? |
|ansi-c| |
Actually, I'm new at C-programming, so there is the sample from Kernighan & Ritchie's "The C Programming Language":
int getline(char s[], int lim)
{
int c, i;
i=0;
while (--lim > 0; && (c=getchar()) !=EOF && c !='\n')
s[i++] = c;
if (c =='\n')
s[i++] = ... |
I use SQL Server, not PostgreSQL, so I'm not sure if this will work for you or not, but Pop Rivett had a great article on creating an audit trail here:
[Pop rivett's SQL Server FAQ No.5: Pop on the Audit Trail][1]
Build an audit table, then create a trigger for each table you want to audit.
Hint: use [Codesmith... |
[TreeSurgeon][1] is a tool that will set up a directory tree for you, with all the required dependencies and a skeleton nant file. At that link, you can also find a series of blog posts by its original creator, Mike Roberts, explaining some of the deliberate choices behind the structure that TreeSurgeon gives you, e.g.... |
How do I get the text size of a string on a WPF canvas? |
|.net|wpf| |
I'm trying to find the amount of space/width that a string would take when its drawn on a WPF canvas? |
The above seems to be the better answer.
I can't find any good information on detecting window shutdown events. I guess the best possible method would be to detect weather your application is trying to close, using a window closing event or the like then ask the question.
http://www.javalobby.org/java/forums/t179... |
Look for signal handling in java. when Windows closes it will send a signal to the application asking it to terminate most likely a sigterm
see [here][1] for more about this (I am not the owner of the website)
[1]: http://twit88.com/blog/2008/02/06/java-signal-handling/ |
|iis|wcf| |
I need to host a WCF service in IIS that exposes a wsHttpBinding. That part is working nicely using the settings of system.serviceModel in my web.config.
What i need now is to setup the configuration (like maxReceivedMessageSize and other options) through a configuration assembly that is also used by the client(s).
... |
Am i right in thinking this is the Haversine formula? |
Hope this mapping table do the job.
http://www.carlprothman.net/Default.aspx?tabid=97
|
I would choose JBoss or Glassfish for a start. However I'm not sure what you mean by J2EE "Hello World". If you just want to deploy some JSP you could use this tutorial (for JBoss):
http://www.centerkey.com/jboss/
If you want to get further and do the EJB stack and/or deploy an ear-file, you could read the very g... |
Mysql stored procedure |
|mysql| |
How to create optional parameter in mysql stored procedure? |
Custom style with Qt |
|qt|custom|style| |
Has anybody experience in building a custom style in Qt? What I have in my mind is a complete new style that affects all kind of widgets. I have seen some examples in the web for a custom combo box. But I have no idea how much time and code it takes to build a "complete" new custom style ... maybe someone can give me a... |
Has anybody experience in building a custom style in Qt? What I have in my mind is a complete new style that affects all kind of widgets. I have seen some examples in the web for a custom combo box. But I have no idea how much time and code it takes to build a "complete" new custom style ... maybe someone can give me a... |
Multi-user Snippet Manager |
|collaboration|code-snippets| |
Currently, we're using a wiki at work to share insights, tips and information. But somehow, people aren't sharing snippets that way. It's probably too inconvenient to write and too difficult to find snippets there.
So, is there a multi-user/collaborative snippets manager around? Something like [Snippely][1]. (Has an... |
The answer to your follow-up question is here:
> operands of type byte and short are automatically promoted to int before being handed to the operators
So, in your example, `a` and `b` are both converted to an `int` before being handed to the + operator. The result of adding two `int`s together is also an `int`.... |
You will need to add a listener since the URLRequest is not instantaneous. It will be **very** fast if you're loading from disk, but you will still need the Event-listener.
There's a good example of how to set this up (Complete with IOErrorEvent handling) in the [livedocs][1].
[1]: http://livedocs.adobe.com/fl... |
setlogsock('inet') didn't do it for me (it looks for host "syslog") but building and installing Sys::Syslog from CPAN did. The Sys::Syslog that comes with Solaris 10 is ancient. |
In response to mopoke, for IE6 you definitely want to use Visual Studio for debugging if you can get it. For all intents and purposes, the MS script debugger is useless. You're better off using some form of tracing (not alerts) than using the MS script debugger. Dojo Toolkit, for instance, provides a debug console for ... |
How best to approach this for your problem depends on several factors that you have not described:
- Will the same hypersphere arrangement be used for many particle collision calculations?
- Are the hyperspheres uniform size?
- What is the movement of the particle (e.g. straight line/curve) and is that movement affe... |
The
(f.x = 1)
is not an expression, it is an assignment and thus returns the assigned value. In this case, the size of that value depends on the variable, it has been assigned to.
unsigned x:1
has 1 Bit and its sizeof returns 1 byte (8 bit alignment)
If you would use
unsigned x:12
th... |
I agree with Sergio; YAML provides a format which is easily editable by humans, but also a good way to cleanly represent data structures.
YAML tends to be much more human-readable, IMO.
YAML is more of a data serialisation technique, rather than a markup language. |
To maximize a window: Alt+Space, X
To restore a window: Alt+Space, R
To minimize a window: Alt+Space, N |