instruction stringlengths 0 30k ⌀ |
|---|
The userwidgetid in the first table is not needed, as like you said the uniqueness comes from the combination of the widgetid and the userid.
I would use the second table, keep the foriegn keys and add a unique index on widgetid and userid.
So:
<pre>
userwidgets( widgetid(fk), userid(fk),
unique_... |
I'm assuming you deal with files in the same directory:
<?php
if (isset($_GET['page']) && !empty($_GET['page'])) {
$page = urldecode($_GET['page']);
$page = basename($page);
$file = dirname(__FILE__) . "/{$page}.php";
if (!file_exists($file)) {
$file = dirname(__FILE__) ... |
The #1 rule when accepting user input is always sanitize it. Here, you're not sanitizing your page GET variable before you're passing it into include. You should perform a basic check to see if the file exists on your server before you include it. |
Use a whitelist and make sure the page is in the whitelist:
$whitelist = array('home', 'page');
if (in_array($_GET['page'], $whitelist)) {
include($_GET['page'].'.php');
} else {
include('home.php');
} |
What is the benefit of a primary key in this scenario? Consider the option of no primary key:
UserWidgets3: WidgetID (FK), UserID (FK)
If you want uniqueness then use either the compound key (UserWidgets2) or a uniqueness constraint.
The usual performance advantage of having a primary key is that you often que... |
Gregg Miskely has a [blog post][1] on this. You might get it to work if both local accounts have the same user name and password. You might also try dropping your good box from it's domain so that you are going from a workgroup to a domain rather than domain to domain.
[1]: http://blogs.msdn.com/greggm/archive... |
I would say the definition of real time would depend on the context. As with the music example real time would need to be milliseconds, but possibly with your example real time could be within 30 seconds or so. It's all relative. |
What constitutes 'real time' |
|real-time|near-real-time|glossary| |
I am having trouble deciding on whether to classify my application as 'real time' or 'near real time', or perhaps even something else.
The software receives data immediately as it is generated from the source, then based on certain rules, raises an alert when certain conditions are met. It takes the approach of chec... |
|glossary|real-time|near-real-time| |
I am having trouble deciding on whether to classify my application as 'real time' or 'near real time', or perhaps even something else.
The software receives data immediately as it is generated from the source, then based on certain rules, raises an alert when certain conditions are met. It takes the approach of chec... |
Typically, for a site with resources of any value to protect, you need a 3-pronged approach:
- Throttle responses from authenticated users only, disallow anonymous posts.
- Minimize (not prevent) the few trash posts from authenticated users - e.g. reputation-based.
- Use server-side heuristic logic to ident... |
Are you clearing the destination tables each time and then starting again? That will make a big difference to the solution you need to implement. If you are doing a complete re-import each time then you could do something like the following:
Create a temporary table or table variable to record the old and new primar... |
Tables make sense only when you're trying to display tabular data and that's it. For layouts, you should always use DIVs and play with CSS positionings. |
Have feature requests handled in a formal process, normally through the project manager and whoever analyzed the requirements originally. Its always better to palm those sorts of decisions off to someone that isn't the developer, assuming that whoever is going to do that job is actually capable of it.
If you're fre... |
In VB6 you could change the array to start with 0 or 1, so I think VBScript can do the same. For C#, it's not possible but you can simply add NULL value in the first [0] and start real value at [1]. Of course, this is a little dangerous... |
Mocking is used very extensively in my case. Mocks are usually for the classes that has external dependencies, e.g. network, database, filesystem. Any of these can introduce flakiness in the tests if mocks are not used.
If the mocks that you find costly to write because there are a lot of fake data to populate, you... |
Not simply. But you can certainly write your own class. It would have an array as a private variable, and the user would think his array starts at 1, but really it starts at zero and you're subtracting 1 from all of his array accesses. |
<table>
<tr><td>Title<td><td>Author<td></tr>
{
let $authordoc := fn:doc("author.xml")
for $book in fn:doc("book.xml")/books/book
return
<tr>
<td>{ $book/title }</td>
<td>{ $authordoc/authors/author/[@id eq $book/authorid] }</td>
</tr>
}
</table>
ps: haven't tested/executed it, b... |
Hang on, the encapsulation point is a valid one but flash can execute JS functions, and Seldaek is right that an HTML element with a higher z-index should float on the flash movie. So if you did all the drag handling in JS and had the flash read its own dimensions and the position of the pointer in the app it could sig... |
SELECT name
FROM locations
ORDER BY CASE WHEN name = 'Montreal'
THEN 0
ELSE 1
END
, name |
I've run into this at $DAYJOB. In my case I wanted to implement SSL signon then redirect to a non SSL page. The core problem in tomcat is the method (from memory) SessionManager.configureSessionCookie which hard codes all the variables you would like to get access to.
I came up with a few ideas, including a particu... |
http://www.google.com/search?q=google.com |
Some versions of libc contain functions that deal with stack traces; you might be able to use them:
[http://www.gnu.org/software/libc/manual/html_node/Backtraces.html][1]
I remember using [libunwind][2] a long time ago to get stack traces, but it may not be supported on your platform.
[1]: http://www.gnu.org/s... |
Take a look at [YAML][1].
[1]: http://www.yaml.de/en/home.html |
.NET DOM API doesn't support modifying element's namespace which is what you are essentially trying to do. So, in order to solve your problem you have to construct a new document one way or another. You can use the same .NET DOM API and create a new element without specifying its namespace. Alternatively, you can creat... |
If you can, use boost shared_ptr and standard C++ auto_ptr. Those convey ownership semantics.
When you return an auto_ptr, you are telling the caller that you are giving them ownership of the memory.
When you return a shared_ptr, you are telling the caller that you have a reference to it and they take part of th... |
If you can, use boost shared_ptr and standard C++ auto_ptr. Those convey ownership semantics.
When you return an auto_ptr, you are telling the caller that you are giving them ownership of the memory.
When you return a shared_ptr, you are telling the caller that you have a reference to it and they take part of th... |
What is the easiest way to adjust EXIF timestamps on photos from multiple cameras in Windows Vista? |
|exif|photo-management| |
**Scenario:** Several people go on holiday together, armed with digital cameras, and snap away. Some people remembered to adjust their camera clocks to local time, some left them at their home time, some left them at local time of the country they were born in, and some left their cameras on factory time.
**The Pro... |
App referencing Microsoft.SqlServer.Smo requires additional assemblies to be included on Target Machine? |
|.net|reference| |
I have a small app which references the Microsoft.SqlServer.Smo assembly (so I can display to the user a list of servers & databases to which they can connect).
My application originally referenced Microsoft.SqlServer.Smo and Microsoft.SqlServer.ConnectionInfo. Things worked as expected on my dev box.
When I inst... |
Design patterns are supposed to provide a structure _in which_ problems can be solved. When solving a real problem, you have to consider _many_ tiny variations of a solution to that problem to see whether any fits a design pattern. In particular, you will probably need to generalise your problem, or its solution, in ... |
Both Python and PERL have excellent string processing capabilities.
I'd suggest using something like ctags to parse the program, and just create a script to read the ctags file and output in txt/html.
The file format used by ctags is well-defined so that other programs can read it. See [http://ctags.sourceforge.n... |
How do you structure a development sprint? |
|sprint|agile|team|teamwork| |
So I have a backlog of features and we are about to get started on a sizable project. I am working on defining the structure of our sprints and I'm interested in the communities feedback.
What I'm thinking is:
- One day sprint planning
- Fill the backlog and figure out what each dev will go after this spri... |
|agile|team|teamwork|sprint| |
So I have a backlog of features and we are about to get started on a sizable project. I am working on defining the structure of our sprints and I'm interested in the communities feedback.
What I'm thinking is:
- One day sprint planning
- Fill the backlog and figure out what each dev will go after this spri... |
In general, when you know an object exists because it's been used in a query, and you can't find it in the object tree in Management Studio, you can do this to find it.
select *
from sys.objects
where name = 'THE_NAME_YOU_WANT'
I just checked, and it works with Synonyms. |
I think your best bet is to remove the explicit constraint and add a [cursor][1] for inserts, so you can perform your checking there and raise an error if the constraint is violated.
[1]: http://msdn.microsoft.com/en-us/library/ms180169.aspx |
Although it costs, I highly recommend [Visual Build][1]. It works with MSBuild, and old tools like Visual Basic. It is scriptable, and can do everything from making installers to simple Continuous Integration.
[1]: http://www.kinook.com/VisBuildPro/ |
The real questions are:
- What are the business rules and user stories behind a user?
- What are the business rules and user stories behind an employee?
- What are the business rules and user stories behind a member?
These can be three completely unrelated entities or not, and that will determine whethe... |
You might try a log viewer; this basically just lets you look at the transactions in the transaction log, so you should be able to find the statement that updated the row in question. I wouldn't recommend this as a production-level auditing strategy, but I've found it to be useful in a pinch.
Here's one I've used; ... |
I recommend the Apache License (specifically, version 2). It is not a “copy left” license and it addresses several matters that are important to established companies and their lawyers.
“Copy left” is the philosophy of the free software foundation requiring anything incorporating the licensed opens source code to a... |
I don't think composition is always better than inheritance (just usually). If Employee and Member really are Users, and they are mutually exclusive, then the first design is better. Consider the scenario where you need to access the UserName of an Employee. Using the second design you would have:
myEmployee.Us... |
Validation Groups were not added to ASP.NET until version 2.0. This is a 1.1 question.
Double check your setting and make sure you are not overwriting it in the code behind. |
You can use Array.CreateInstance.
See [Array Types in .NET][1]
[1]: http://msdn.microsoft.com/en-us/magazine/cc301755.aspx |
The most likely scenario for running a CPAN mirror is so that your network of 50 machines can all be updated from it locally, instead of hitting the network 50 times.
I'd argue that using CPAN in the traditional manner is a poor way to keep a network of servers up to date.
I run a network of RedHat machines. I p... |
I don't think if it's possible to modify the starting index of arrays.
I would create my own array using generics and handle it inside. |
Windows CD Burning API |
|c++|windows|c|cd-burning| |
We need to programatically burn files to CD in a C\C++ Windows XP/Vista application we are developing using Borlands Turbo C++.
What is the simplest and best way to do this? We would prefer a native windows API (that doesnt rely on MFC) so as not to rely on any third party software/drivers if one is available.
An... |
Just keep of const int named 'offset' with a value of one, and always add that to your subscripts in your code. |
Ideally requests like this should be handled by the person in charge of the Functional Design. Wether you like it or not, changes will happen (from the first letter in the functional design to the last byte of code and beyond) and there will always be requests for extra features. So make sure your design is up for such... |
Well the braking space is just a space, you know a " " without the quotes... |
I haven't wrote my own pixel shaders, mostly modified samples from the net, what you would do is you would increase the value of the R,G,B components in the pixel respectively as long as they're under 255, this would gradually shift the color of the sprite towards white. Hey that rhymes. |
I think you need to look at the specific solution or part of the solution in where you need the response to be real-time. A real time response is one which is perceived by the receiver (the application or basically the end-user) as being real-time. |
Perl Regex Match and Removal |
|regex|perl| |
I have a string which starts with //#... goes upto the newline characater. I have figured out the regex for the which is this ..#([^\n]*).
My question is how do you remove this line from a file if the following condition matches |
Well, that could be more of a marketing question than a technical one.
Real-time, in terms of embedded hardware, involves a known fixed maximum time for handling incoming information (interrupts and the like).
You can certainly claim 30 seconds delay as real-time especially if the delivery of said information is ... |
Real Time deals with microseconds...mainly around robotics. Think 'move arm 30 microseconds; weld 1000 microseconds;', like in automobile assembly.
Is your 30 seconds based on a Thread sleep or a timer in a non-real time OS? If so, then you have a potential varience. Will you consider it a failure if you're outsi... |
As GAE builds on how data is managed in Django there is a lot of info on how to address similar questions in the Django documentation (for example see [here](http://www.djangobook.com/en/1.0/chapter05/), scroll down to 'Your first model').
In short you design you db model as a regular object model and let GAE sort o... |
If tweaking the web server configuration is not an option, consider PHP's standard [readfile() function](http://us3.php.net/manual/en/function.readfile.php). It won't be quite as fast as sendfiling, but it will be more widely compatible. Also note that when doing this, you should also send a Content-Type header at the ... |
If you are looking to remove unnecessary `#include` files in order to decrease build times, your time and money might be better spent parallelizing your build process using [cl.exe /MP][1], [make -j][2], [Xoreax IncrediBuild][4], distcc/[icecream][3], etc.
Of course, if you already have a parallel build process and ... |
Designing a bigtable schema is an open process, and basically requires you to think about:
- The access patterns you will be using and how often each will be used
- The relationships between your types
- What indices you are going to need
- The write patterns you will be using (in order to effectively spr... |
I echo the answer by Dmitriy - very well put.
For those who are worried about the performance overhead FK's often bring, there's a way (in Oracle) you can get the query optimiser advantage of the FK constraint without the cost overhead of constraint validation during insert, delete or update. That is to create the F... |
Trying not to get you to rip off your hair with frustration (well, Baraff's/Witkin great math articles with the multi-dimensional matrices would do that sometimes), you can look at the easier online articles such as the ones published in Gamasutra.
Here are two of them:
1. http://www.gamasutra.com/resource_guide/2... |
Look here: <http://msdn.microsoft.com/en-us/library/bb384202.aspx>
You can tell the garbage collector that you're doing something critical at the moment, and it will try to be nice to you. |
In C# -- like c/c++/java -- braces denote a scope. This dictates the lifetime of a variable. As the closing brace is reached, the variable becomes immediately available for a garbage collection. In c++, it would cause a class's destructor to be called if the var represented an instance.
As for usage, the only possi... |
Handleing and storing eslapsed time |
|c#|timespan|datetime|database| |
Im having problems deciding on what is the best way is to handle and store time measurements.
I have an app that has a textbox that allows the users to input time in either hh:mm:ss or mm:ss format.
So I was planning on parsing this string, tokenizing it on the colons and creating TimeSpan (or using TimeSpan.Par... |
The only way I was able to do this was to use Windows Environment Variables. You can specify things like connection strings and user preferences in environment variables, and then pick up those environment variables from your SSIS Task. |
You could create an INSERT TRIGGER that checks that the conditions are met. That way all updates/inserts will go straight through.
CREATE TRIGGER employee_insupd
ON employee
FOR INSERT
AS
/* Get the range of level for this job type from the jobs table. */
DECLARE @min_lvl tinyint,
... |
You could create an INSERT TRIGGER that checks that the conditions are met. That way all updates will go straight through.
CREATE TRIGGER employee_insupd
ON employee
FOR INSERT
AS
/* Get the range of level for this job type from the jobs table. */
DECLARE @min_lvl tinyint,
@max_l... |
Is this in low memory conditions? If so it might be that new is returning NULL rather than throwing std::bad_alloc. Older VC++ compilers didn't properly implement this. There is an article about [Legacy memory allocation failures][1] crashing STL apps built with VC6.
[1]: http://msdn.microsoft.com/en-us/magaz... |
You have a $1000 operating system license and you're going to put it on ~$1100 worth of hardware purchased at Fry's and presumably put together by yourself? |
Please check your routes.
Not all routes are created equally. Routes have priority defined by the order of appearance of the routes in the config/routes.rb file. The priority goes from top to bottom. The last route in that file is at the lowest priority and will be applied last. If no route matches, **404** is retur... |
How do you find out which NIC is connected to the internet? |
|windows|networking|iphelper| |
SELECT SUM( CASE WHEN Stop = '31 dec 9999'
THEN DateDiff(mi, Start, Stop)
ELSE DateDiff(mi, Start, GetDate())
END ) AS TotalMinutes
FROM task
However, a better solution would be to make the <code>Stop<code> field nullable, and make it ... |
If you want a dictionary type collection but you need to maintain the insertion order you can look into the KeyedCollection<TKey,TItem>
[here][1]
It is a merger between a dictionary and a list. That way you can access elements in the collection via the key or the insertion index.
The only gotcha is if your elem... |
You can use a macro like this:
http://www.codeguru.com/cpp/v-s/devstudio_macros/article.php/c3203/
<hr>
**ASIDE NOTE:** *I also think that VS is far from Eclipse for example with regard with save actions and plugin integration. But that is a fundamental problem regarding the underlying infrastructure and archite... |
This has been discussed at length on previous questions.
[http://stackoverflow.com/questions/15142/what-are-the-pros-and-cons-to-keeping-sql-in-stored-procs-versus-code#15153][1]
[1]: http://stackoverflow.com/questions/15142/what-are-the-pros-and-cons-to-keeping-sql-in-stored-procs-versus-code#15153 |
What's the best/fastest/easiest way to collapse all projects in Visual Studio? |
|visual-studio| |
I'm currently using [DPack][1] as this adds a "Collapse All Projects" option to the Solution node in Solution Explorer. It works pretty well but can take a while to execute and doesn't always collapse everything fully.
Are there any better alternatives? Preferably free and easy to install/setup. There are lots out t... |
Jean's advice is sound. Assuming your models look like this:
class Contact < ActiveRecord::Base
belongs_to :account
end
class Account < ActiveRecord::Base
has_many :contacts
end
You should be using the `contacts` association of the current account to ensure that you're only ... |
Assuming you want to match ###token2### as well...
/###.+###/ |
What in your opinion is the best free library for hadling SMS with a gsm modem? |
|gsm|sms|modem|responses| |
I have tried to develop my own gsm modem library for hadling sms built around system.io.ports.serialport. it does not handle unsolicited responses very well, in particular incomming calls(some customers just dont get it...sms lines are for sms only). i resort to sending ATH(AT hangup command) for each incoming call rec... |
How do you handle unsolicited responses (like incoming calls) when handling sms with a gsm modem |
|sms|modem|gsm|responses| |
I have tried to develop a gsm modem library for handling sms built around system.io.ports.serialport. it does not handle unsolicited responses very well, in particular incomming calls. i resort to sending AT hangup commands for each incoming call, however the unsolicited responses can popup even while you are doing oth... |