instruction stringlengths 0 30k ⌀ |
|---|
I have this view set:
glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective
glLoadIdentity(); //Reset the drawing perspective
and I get a screen position (sx, sy) from a mouse click.
Given a value of z, how can I calculate x and y in 3d-space from sx and sy? |
PostgreSQL works great as a backend for MS Access, there are a couple of support functions you should use to make things easier. See here for more info on this:
http://www.amsoftwaredesign.com/smf/index.php?board=8.0
|
I really got a great intro from Flexible Rails:
http://www.flexiblerails.com/
|
Iteration length is primarily related to the teams ability to communicate and complete a working version of the software. More team members equals more communication channels ([Brooks's Law][1]) which will likely increase your iteration time.
I think that 2 week iterations, whether you deliver to the client or not... |
`rmdir /S /Q %DIRNAME%` |
Another benefit of AppDomains (as you mentioned in your question) is code that you load into it can run with different security permissions. For example, I wrote an app that dynamically loaded DLLs. I was an instructor and these were student DLLs I was loading. I didn't want some disgruntled student to wipe out my h... |
I use <br>
<code>
if (x)<br>
{<br>
...statements...<br>
}<br>
</code>
for multiple lines, but I prefer bracketless one liners:<br>
<code>
if (x)<br>
...statement...<br>
else<br>
...statement...<br>
</code>
I find the extraneous brackets visually offensive, and I've never made
one of the ab... |
I use <br>
<pre>
if (x)
{
DoSomething();
}
</pre>
for multiple lines, but I prefer bracketless one liners:<br>
<pre>
if (x)
DoSomething();
else
DoSomethingElse();
</pre>
I find the extraneous brackets visually offensive, and I've never made
one of the above-mentioned mistakes not adding bra... |
Quick and Dirty Usability testing tips? |
|testing|usability|user-experience|hci| |
What are your best usability testing tips?
I need quick & cheap.
|
I use NTP throughout the whole network at my company and it works rather well. The key is to have one authoritative server on a local network and have every machine on the network synchronize with it. The best is to have a radio clock installed on that server. NTP is great because it does not just correct the clock onc... |
For a co-located team nothing beats a big wall and a whole bunch of index cards as far as I'm concerned. Maybe with whiteboard or two for burnup/down charts.
|
Seriously, when's the last time you had a bug in any code anywhere that was cause someone did:
if (a)
foo();
bar();
Yeah, never...* The only real 'pro' here is to just match the style of the surrounding code and leave the aesthetic battles to the kids that just got outta college.
*(caveat bein... |
I tend only to single line when I'm testing for break conditions at the beginning of a function, because I like to keep this code as simple and uncluttered as possible
public void MyFunction(object param)
{
if (param == null) return;
...
}
Also, if I find I do want to avoid... |
PostgreSQL has a version() function you can call.
SELECT version();
It will return something like this:
version
-----------------------------------------------------------------------------------------------
PostgreSQL 8.3.3 on i486-pc-linux-gnu, co... |
This is DB dependent, and in case this function exists in another dbms, this says PostgreSQL in the output
select version() |
If the counter is to be used as an index to a container, I use `i`, `j`, `k`.
If it is to be used to iterate over a range (or perform a set number of iterations), I often use `n`. Though, if nesting is required I'll usually revert to `i`, `j`, `k`.
In languages which provide a `foreach`-style construct, I usually... |
Is the answers here that you can't escape quotes using JavaScript and that you need to start with escaped strings.
Therefore. There's no way of JavaScript being able to handle the string 'Marge said "I'd look that was" to Peter' and you need your data be cleaned before offering it to the script? |
What is the unit testing strategy for method call forwarding? |
|unit-testing| |
I have the following scenario:
<pre>
public long AddCar(Car car)
{
try
{
string username = _authorizationManager.GetUsername();
...
long id = _carAccessor.AddCar(username, car.Id, car.Name, ....);
if(id == 0)
{
throw new Exception("Car was not added");
... |
I have the following scenario:
<pre>
public class CarManager
{
..
public long AddCar(Car car)
{
try
{
string username = _authorizationManager.GetUsername();
...
long id = _carAccessor.AddCar(username, car.Id, car.Name, ....);
if(id == 0)
{
... |
A privileged instruction is an IA-32 instruction that is only allowed to be executed in Ring-0 (i.e. kernel mode). If you're hitting this in userspace, you've either got a really old EXE, or a corrupted binary. |
If you are storing function pointers only (and not other functors that match the signature required), this is easy (see code below). But in general, the answer, like other posters have said, is no.
The code below demonstrates how to get the functor/pointer object that is to be called. To use it, you must know the ex... |
If you are storing function pointers only (and not other functors that match the signature required), this is easy (see code below). But in general, the answer, like other posters have said, is no.
The code below demonstrates how to get the functor/pointer object that is to be called. To use it, you must know the ex... |
If you are storing function pointers only (and not other functors that match the signature required), this is easy (see code below). But in general, the answer, like other posters have said, is no. In that case, you probably want to store your functors in a hash, as values, with keys being something the user supplies o... |
You need to firstly stop all connections to the database, change the ownership of the tables that are 'db_owner' by running the command sp_MSforeachtable @command1="sp_changeobjectowner ""?"",'dbo'" where ? is the table name. |
[SpaceBlock][1] also makes it simple to delete s3 buckets - right click bucket, delete, wait for job to complete in transfers view, done.
This is the free and open source windows s3 front-end that I maintain, so shameless plug alert etc.
[1]: http://www.codeplex.com/spaceblock |
Automating interaction with a HTML game using C#? |
|c#|botting| |
There are some HTML based games (ie bootleggers.us) that have a simple login form and after that your entire game experience revolves around submitting various forms and reading information from the website itself.
My Question is, **what is the best way to go about writing a bot / automate the html-based game using ... |
Try using database-backed sessions. |
VB.Net "There is a naming violation" Error with open ldap for creating user |
|ldap| |
I am trying to use directory services to add a directory entry to an openldap server. The examples I have seen look pretty simple, but I keep getting the error "There is an naming violation". What does this message mean? How do I resolve it?
I have included the code, ldif file used to create the person container.
... |
|ldap|vb.net| |
|vb.net|ldap| |
I am trying to use directory services to add a directory entry to an openldap server. The examples I have seen look pretty simple, but I keep getting the error "There is an naming violation". What does this message mean? How do I resolve it?
I have included the code, ldif file used to create the person container.
... |
I dont know if this will help, but you cn try this:
http://www.jsunit.net/
EDIT:Sorry i reread your Q and realized you meant spoecific to VS. I dont know if you are familiar with Script#, but i had read some talk a little while back that someone was building a testing framework to use with that, and Script# can b... |
You can sign the assembly and the executable with the same key and then put a check in the constructor of the classes you want to protect:
public class NotForAnyoneElse {
public NotForAnyoneElse() {
if (typeof(NotForAnyoneElse).Assembly.GetName().GetPublicKeyToken() != Assembly.GetEntryAssembly()... |
After the handshake is complete, you can get the client certificate. While the client certificate is also available in the verify callback (verify_cb), there's not really any reason to try to do anything aside from verify the certificate in that callback. Setting up an application-specific mapping is better done afte... |
There was a RAD tool called [JADE ][1]written a few years ago that has a built-in OODBMS. Earlier incarnations of the DB engine also supported Digitalk Smalltalk. If you want to sample application building using a non-RDBMS paradigm this might be a start.
Other OODBMS products include [Objectivity][2], [GemStone... |
You could also use DTS or SSIS. |
Personally for this test, I wouldn't use Shoulda.
You can easily remove duplication by using dynamic method creation as follows:
class DefineMethodTest < Test::Unit::TestCase
[{:string => '1 cups butter', :unit => 'cups', :amount => 1.0, :name => 'butter'},{:string => '1 (18.25 ounce) package devil's f... |
Not a direct answer to your question, but food for thought:
http://en.wikipedia.org/wiki/Dining_philosophers_problem
The "Dining philosophers problem" is an old thought experiment for examining the deadlock problem. Reading about it might help you find a solution to your particular circumstance. |
One of the main drivers for short iterations, is easing integration between modules/features/programmers. Obviously, the bigger your team, the more integration you will have. It's a tradeoff: short iterations mean you're integrating often, which is good - BUT if its a big team you'll be spending a LOT of team on integr... |
How do you get the Eclipse Package Explorer to show files whose names begins with a . (period)? |
|eclipse|package-explorer| |
When a folder in the Eclipse Package Explorer (one which is linked to a directory somewhere in the filesystem) contains files whose names begin with a . (period), those files do not appear. Can Eclipse be configured to show these files, and if so, how? |
You need to use one of the procedural languages such as PL/pgSQL not the SQL proc language.
In PL/pgSQL you can use vars right in SQL statements.
For single quotes you can use the quote literal function. |
<p>My experience is that the length of the iterations are somewhat dependent on team size,</p>
<p>External dependencies, like in cases where we had to integrate with in house systems that was not using a iteration based development cycle (read waterfall) where another factor we observed.</p>
<p>Our team were real n... |
org.eclipse.swt.SWTError: Item not added |
|eclipse|swt| |
Dows somebody know how to recover a never-starting eclipse when the error "org.eclipse.swt.SWTError: Item not added" is raising againg and again? |
|eclipse|swt| |
Does somebody know how to recover a never-starting eclipse when the error "org.eclipse.swt.SWTError: Item not added" is raising againg and again?
I'm using WebSphere Studio Site Developer (Windows) 5.1.0
The only stack trace in the .metadata/log file is:
`SESSION -----------------------------------------------... |
If your PoJos contain logic that's important to your business, then yes, of course test them.
If they don't, then don't bother. Sometimes leaving a class without tests is important since it gives you freedom to refactor it away later. |
Of course, what else would you do test cases on?
I like to do Test Driven Development and it is much about testing your pojos (well, actually its about designing your pojos). |
Of course, what else would you do test cases on?
I like to do [Test Driven Development][1] and it is much about testing your pojos (well, actually its about designing your pojos).
[1]: http://en.wikipedia.org/wiki/Test-driven_development |
simple answer
sp_changeobjectowner [ @objname = ] 'object' , [ @newowner = ] 'owner'
you don't need to stop all connections to the database, this can be done on the fly.
|
Detect "Clone Mode" display setup |
|displays| |
How can I determine if my displays are in "Clone Mode" without using either COPP (Computer Output Protection Protocol) or OPM (Output Protection Protocol) on Windows? |
How can I determine if my displays are in "Clone Mode" without using either COPP (Computer Output Protection Protocol) or OPM (Output Protection Protocol) on Windows?
Vista solution:
hMonitor = MonitorFromWindow (HWND_DESKTOP, MONITOR_DEFAULTTOPRIMARY);
bSuccess = GetNumberOfPhysicalMonitorsFromHMONITOR (h... |
Another solution to this would be to avoid writing a calculator like that altogether. Writing an RPN parser is much simpler, and doesn't have any of the ambiguity inherent in writing math with infix notation.
import operator, math
calc_operands = {
'+': (2, operator.add),
'-': (2, operator... |
A symbol table is added to the executable maps function/variable names to data locations, so that debuggers can report back meaningful information, rather than just pointers. This doesn't effect the speed of your program, and you can remove the symbol table with the 'strip' command. |
Based on [KISS][1], [high cohesion and low coupling][2], ask these questions -
- Who needs to know? my class, my library, other classes, other libraries, 3rd parties
- What level of abstraction do I need to provide? Does the consumer understand bit operations.
- Will I have have to interface from VB/C# etc?
The... |
I can't think of any projects where we needed to create our own code generators from scratch but there are several where we used preexisting generators. (I have used both Antlr and the Eclipse Modeling Framework for building parsers and models in java for enterprise software.) The beauty of using a code generator that ... |
If you actually are holding non-managed resources that will not be automatically cleaned up by the garbage collector and cleaning those up in your Dispose(), then yes, you should do the same in Finalize().
If you're implementing IDisposable for some other reason, implementing Finalize() isn't required.
The basic ... |
If I understood you correctly, then the answer is: You can't.
intelligence should be an attribute of WizardPageSimple, if you'd want both classes to inherit it.
Depending on your situation, you might try to extract intelligence and related attributes into another baseclass. Then you could inherit from both:
... |
Character Limit in HTML |
|html|character-limit| |
How do you impliment a character limit on a textbox in HTML? I know it's a basic question, but I don't really use HTML too much, so I don't know. |
Multiple services from the same executable |
|winapi|service| |
I've written a small service (plain Win32) and I'd like to know if it's possible to run multiple instances of it when multiple users are logged on.
Basically, let's say we've got UserA and UserB for UserA the service would log on as "domain\UserA" and for UserB the service would log on as "domain\UserB" - this is fr... |
We currently use inline documentation parsed by an external application (PHP + PhpDocumenter) plus various internal wikis. At times it's painful at best (mainly because only one person update the wikis or the docs...)
However, I've been looking at using [ikiwiki][1] to do internal docs. It integrate with your source... |
Does several levels of base classes slow down a class/struct in c++? |
|c++|oop| |
Does having several levels of base classes slow down a class? A derives B derives C derives D derives F derives G, ...
Does multiple inheritance slow down a class? |
Yes, that would be useful. Especially if you have a mechanism where the error message (exception.getMessage()) is displayed on-screen but the actual stacktrace gets hidden away in log files which you can't access immediately. |
The Visual Studio C# debugger's call stack window includes a stack trace with all the argument values displayed. |
There are also other algorithms that are time-based, not frequency based.
Autocorrelation is a relatively simple algorithm for pitch detection.
Reference: http://cnx.org/content/m11714/latest/
I have written c# implementations of autocorrelation and other algorithms that are readable. Check out http://code.google.... |
Absolutely. Knowledge without regular using is useless. Talking about technologies, languages, methods, development processes, books etc. greatly improves overall experience and points possible ways of professional evolution. |
If there are no virtual functions, then it shouldn't. If there are then there is a performance impact in calling the virtual functions as these are called via function pointers or other indirect methods (depends on the situation). However, I do not think that the impact is related to the depth of the inheritance hierar... |
I think refactoring and keeping your code up to date is a very important process to avoid code rot/smell. A lot of developers suffer from either being married to their code or just not confident enough in their unit tests to be able to rip things apart and clean it up and do it right.
If you don't take the time to c... |
Once you know your path you can use IO.Directory.GetFiles() method.
IO.Directory.GetFiles("\translated\path","27_*.jpg").Count()
will give you what you're looking for. |
You can not rely on find bugs so much , it is just an expert system that tells you that something **may** be wrong with your program during runtime. Personally I have seen a lot of warning generated by findbugs because it was not able to figure out the correctness of code (in fact).
One example when you open a strea... |
If you intend to read csv from excel, then there are some interesting corner cases. I can't remember them all, but the apache commons csv was not capable of handling it correctly (with, for example, urls).
Be sure to test excel output with quotes and commas and slashes all over the place. |
I use "counter" or "loop" as the variable name. Modern IDEs usually do the word completion , so longer variable names are not as tedious to use. Besides , to name the variable to its functionality makes it clear to the programmer who is going to maintain your code as to what your intentions were. |
PostgreSQL "DESCRIBE TABLE" |
|postgresql| |
I am trying to learn PostgreSQL after already having used MySQL and Oracle for some time now. It seems that using psql is a step backwards...
How do you perform the psql equivalent of a "DESCRIBE TABLE"? |
I think all vulnerabilities are based off of programmers not thinking, either momentary lapses of judgement, or something they haven't thought of. One big vulnerability that was in an application that I was tasked to "fix up", was the fact that they had returned 0 (Zero) from the authentication method when the user th... |
The psql equivalent of "DESCRIBE TABLE" is "\d table".
See the psql portion of the PostgreSQL manual for more details.
|
It looks like you can do that with a psql slash command:
\d table describe table (or view, index, sequence)
From http://www.faqs.org/docs/ppbook/c4890.htm |
STL strings are certainly far easier to use, and I don't see any reason to not use them.
If you need to interact with a library that only takes C-style strings as arguments, you can always call the c_str() method of the string class. |
We virtualise a copy of a test client and server, so we can deploy to them before sending the files to the customer. They also gets used to test bug reports.
We find this is the biggest benefit to virtualisation as we can keep lots of per-customer versions around.
We also VM our web server, and corporate division... |
I occasionally use macros so I can define information in one place, but use it in different ways in different parts of the code. It's only slightly evil :)
For example, in "field_list.h":
/*
* List of fields, names and values.
*/
FIELD(EXAMPLE1, "first example", 10)
FIELD(EXAMPLE2, "sec... |