instruction stringlengths 0 30k ⌀ |
|---|
Unless you are 100% sure that the code being evaluated is from a trusted source (usually your own application) then it's a surefire way of exposing your system to a cross-site scripting attack. |
If you are already doing databinding:
<asp:Calendar ID="Calendar1" runat="server" SelectedDate="<%# DateTime.Now %>" />
Will do it. This does require that somewhere you are doing a Page.DataBind() call (or a databind call on a parent control). If you are not doing that and you absolutely do not want any c... |
Is there a JavaScript PNG fix for IE6 that allows CSS background positioning? |
|javascript|css|internet-explorer-6|png|transparency| |
I've seen a few fixes for allowing PNG images to have transparency in Internet Explorer 6, but I've yet to find one that also allows you to set the background position in CSS. If you use sprites, it's a deal-breaker. I've resorted to using GIF's (which are not as high quality), not using transparent images at all, or s... |
CVS does not provide this capability. You can, however, get it by buying a license for [FishEye][1] or possibly by using [CVSTrac][2] (note: I have not tried CVS Trac).
Or you could migrate to SVN, which does provide this capability via atomic commits. You can check in a group of files and have it count as a single ... |
How to remove xmlns attribute with .NET XML API |
|.net|xml|api|xmlns| |
XmlElement.Attributes.Remove* methods are working fine for arbitrary attributes resulting in the removed attributes being removed from XmlDocument.OuterXml property. Xmlns attribute however is different. Here is an example:
XmlDocument doc = new XmlDocument();
doc.InnerXml = @"<Element1 attr1=""value1"" xml... |
Asa graphics designer, I've used Flash (on and off) over the last few years, and Silverlight (and its big brother WPF) over the last 1.5 years. Based on what I've heard from my team (all of whom are developers or former developers, if your .Net developers will be doing all the programming, go with Silverlight. I love F... |
[This link][1] gives two approaches that should help.
It looks like this is the most straightforward method:
vmware-vdiskmanager -x 12GB path\to\disk.vmdk
where 12GB is the desired size of the expanded volume.
[1]: http://www.seandeasy.com/expanding-a-drive-within-a-vmware-image/ |
You pass the pointer by value, not by reference, so whatever you do with arr inside foo will not make a difference outside the foo-function. As m_pGladiator wrote one way is to declare a reference to pointer like this (only possible in C++ btw. C does not know about references):
int main(int argc, char ** argv) ... |
Are you launching via "Run As Administrator"? It's possible the permissions on your .Net framework directories aren't what they should be. |
Try pointing connect() to the same host:port where your SSH command works. Also, keep in mind that some firewalls can apply different rules for different user accounts (and sometimes for different executables). Therefore, make sure you run ssh and your test app under the same user account and that SUID isn't set for SS... |
[Capistrano](http://capify.org/) is pretty handy for that. There's a few people using it ([1](http://www.simplisticcomplexity.com/2006/8/16/automated-php-deployment-with-capistrano/), [2](http://www.contentwithstyle.co.uk/Blog/178), [3](http://laurentbois.com/2008/08/05/use-capistrano-in-enterprise-for-php-and-ruby-on-... |
I'm just about to start doing Javascript TDD on a new project I am working on. My current plan is to use [qunit][1] to do the unit testing. While developing the tests can be run by simply refreshing the test page in a browser.
For continuous integration (and ensuring the tests run in all browsers), I will use [Selen... |
If you're not embedding the font then you're at the mercy of the player, and Arial is a Windows-only font. If all you want is the system's sans-serif font, try setting the font name to _sans |
You can use obfuscation.
That will turn:
int MySecretPrimeDetectionAlgorithm(int lastPrimeNumber);
Into something unreadable like:
int Asdfasdfasdfasdfasdfasdfasdf(int qwerqwerqwerqwerqwerqwer);
Others will still be able to use your assembly, but it will be difficult to make any sensible. |
If you are defining your own context menu via a <code>ContextMenuStrip</code> in Windows Forms, use the *Font* property.
If you are defining your own context menu via a <code>ContextMenu</code> in WPF, use the various *Fontxxx* properties such as *FontFamily* and *FontSize*.
You cannot change the default context ... |
[You *can* embed fonts in Flash.][1]
[1]: http://www.adobe.com/devnet/flash/quickstart/embedding_fonts/ |
If you want to pull source without affecting remote branches and without any changes in your local copy, it's best to use git pull.
I believe if you have a working branch that you have made changes to, use git rebase to change the base of that branch to be latest remote master, you will keep all of your branch chang... |
I agree with Justin. To elaborate, overly long lines of code are harder to read by humans and some people might have console widths that only accommodate 80 characters per line.
The style recommendation is there to ensure that the code you write can be read by as many people as possible on as many platforms as p... |
You can also try running devenv.exe with the /ResetSettings argument (which will reset any custom settings you have) or with the /SafeMode flag.
/SafeMode won't help you fix your problem but it will at least narrow down the issue to the things that are different between safe and regular mode. |
The keyword you're after is "compacting garbage collector". JVMs are permitted to use one, meaning that objects can be relocated. Consult your JVM's manual to find out whether yours does, and to see whether there are any command-line options which affect it.
The conceptually simplest way to explain compaction is to ... |
Not your original question, but still...
Your class declaration can be written as:
public class Person
{
public string FirstName { get; set; }
public string LastName {get; set; }
}
and if it were my code, I'd probably have an object for Name with fields First and Last.
|
I'm not sure how much luck you will have with this without a lot of messing around.
No matter how DRY and OO and easy your framework makes things ( which is in this case - alot =) you've still got to remember it's running in front of a bog-standard relational database, which has atomic commits as one of it's *defin... |
A slightly more elegant version of the DB check on every page would be to do the check in the Global.asax file or to create a master page that all the other pages inherit from.
The suggestion of having an online site and an offline site is really good, but only really applicable if you have a limited number of sites... |
I've been using Joda exclusively for three years now and would definitely recommend it - it has the whole area covered with an interface that 'does what it says'.
Joda can look complex when you start, as eg it has concepts of periods, duration and intervals which look sort of similar, but you can start off simply b... |
Sure any ORM is better than hand-writting SQL for CRUD operations... the thing is: I'm think there is no reason to use JPA instead pure Hibernate because I'm mixing both a lot. If I'm not getting a hidden provider why use JPA anyway? |
Well, there are only so many ways to aggregate information from multiple tables. You can join, like you mentioned in your example, or you can run multiple queries and union them together as in borjab's answer. I don't know if some idea of creating a table that intersects all the module tables would be useful to you, ... |
If you need stats to support a decision for Flash, you can grab it's install stats here:
http://www.adobe.com/products/player_census/flashplayer/version_penetration.html
About 97% install rate. That's pretty sweet. |
Use jQuery to replace my XMLHttpRequest |
|javascript|jquery|ajax| |
I am kind of new to JavaScript library's. I wanted to replace my current code with a JS lib jQuery. My current code looks like this.
var req;
function createRequest(){
var key = document.getElementById("key");
var keypressed = document.getElementById("keypressed");
keypres... |
Why are you using `preg_split` if what you really want is what matches inside the parentheses? Seems like it would be simpler to just use `preg_match`.
It's often an issue with regex that parens are used both for grouping your logic and for capturing patterns.
According to the PHP doc on regex syntax,
> The fact... |
The 0 / non-0 thing your coworker is confused about is probably referring to when people use numeric values as return value indicating success, not truth (i.e. in bash scripts and some styles of C/C++).
Using 0 = success allows for a much greater precision in specifying causes of failure (e.g. 1 = missing file, 2 =... |
You pass the pointer by value, not by reference, so whatever you do with arr inside foo will not make a difference outside the foo-function.
As m_pGladiator wrote one way is to declare a reference to pointer like this (only possible in C++ btw. C does not know about references):
int main(int argc, char ** argv... |
Debugging the latter is going to be harder if you want to see the intermediate state, and single step through the stages.
I would go for readability over the amount of screen real estate used here since performance is a wash. |
To answer your question `logout` is the view name obtained from the ModelAndView object returned by the controller. If your are having problems you many need the following additional configuration.
You need to add a servlet mapping for `*.htm` in your `web.xml`:
<pre><code lang="xml">
<web-app>
... |
Sort on a string that may contain a number |
|java|algorithm|string|comparison| |
I need to write a Java Comparator class that compares Strings, however with one twist. If the two strings it is comparing are the same at the beginning and end of the string are the same, and the middle part that differs is an integer, then compare based on the numeric values of those integers. For example, I want th... |
PRADO would have been my choice for a framework if I hadn't run across QCodo. I like the event-driven approach -- QCodo just suits me more. |
You mention .NET 3.5 - are you writing in WPF? If so, you can specify font size for the TextBlock.FontSize attached property
<Whatever.ContextMenu TextBlock.FontSize="12">
<MenuItem ... /> <!-- Will get the font size from parent -->
</Whatever.ContextMenu>
Or, you could specify it in a style that ... |
From a practical perspective, I generally consider any SELECT that ends up taking more than 10 lines to write (putting each clause/condition on a separate line) to be too long to easily maintain. At this point, it should probably be done as a stored procedure of some sort, or I should try to find a better way to expres... |
I think, it will take time, till the tools get more refined, more people gain experience with MDD. At the moment if you want to get something out of MDD you have to invest quite a lot, so its use remains limited.
Looking at openArchitectureWare for example: While it is quite robust and basic documentation exists, do... |
having had to make the call between silverlight and flash recently for a very intense interactive component, i had to go with flash. and for one reason:
online support.
If i have a problem building something in flash, chances are pretty good that I'll find help somewhere online from someone thats overcome the same is... |
Try this
/**
* Return an int containing the wrapped line index at the given position
* @param component JTextPane
* @param int pos
* @return int
*/
public int getLineNumber(JTextPane component, int pos)
{
int posLine;
int y = 0;
V... |
Try this
/**
* Return an int containing the wrapped line index at the given position
* @param component JTextPane
* @param int pos
* @return int
*/
public int getLineNumber(JTextPane component, int pos)
{
int posLine;
int y = 0;
... |
I've added a few extra test cases. You can change your duplicate handling by changing the way you use distinct keywords in your aggregates. Basically, I'm getting a count of matches and comparing it to a count of required matches in each @a and @b.
declare @a table
(
pkid int,
value int
... |
XmlElement.Attributes.Remove* methods are working fine for arbitrary attributes resulting in the removed attributes being removed from XmlDocument.OuterXml property. Xmlns attribute however is different. Here is an example:
XmlDocument doc = new XmlDocument();
doc.InnerXml = @"<Element1 attr1=""value1"" xml... |
CVS doesn't group change sets like other version control systems do; each file has its own, independent version number and history. This is one of the deficiencies in CVS that prompts people to move to a newer VC.
That said, there are ways you could accomplish your goal. The easiest might be to add a post-commit hoo... |
Besides the possible security issues if you are executing user-submitted code, most of the time there's a better way that doesn't involve re-parsing the code every time it's executed. Anonymous functions or object properties can replace most uses of eval and are much safer and faster. |
You could setup a converter with that pattern, but that sounds like the exact opposite to what you want. |
While Javascript is the only well-supported scripting language you can control the page directly from, Flash has some very nice features for bigger programs. Lately it has a JIT and can also generate bytecode on the fly (check out [runtime expression evaluation][1] for an example where they use flash to compile user-in... |
Inlining C++ code |
|c++|inline| |
Is there any difference to the following code:
class Foo
{
inline int SomeFunc() { return 42; }
int AnotherFunc() { return 42; }
};
Will both functions gets inlined? Does inline actually make any difference? Are there any rules on when you should or shouldn't inline code? I often us... |
Quoting:
[Infrastructure Update for Microsoft Office Servers (KB951297)][1]
<b>Other Relevant Updates</b> It is strongly recommended that you install the Infrastructure Update for Windows SharePoint Services 3.0 (KB951695) before installing this update on any of the Office Servers listed in the system requirements ... |
SQL Bulk import from CSV |
|sql|bulkinsert| |
I need to import a large CSV file into an SQL server. I'm using this :
BULK
INSERT CSVTest
FROM 'c:\csvfile.txt'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
problem is all my fields are surrounded... |
|sql|bulkinsert|sql-server|t-sql| |
|sql|sql-server|t-sql|bulkinsert| |
I need to import a large CSV file into an SQL server. I'm using this :
BULK
INSERT CSVTest
FROM 'c:\csvfile.txt'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
problem is all my fields are surrounded... |
| = bitwise or, || = logic or |
100% completely impossible without jumping through some hoops.
One of the perks of using the .NET is the ability to use reflection, that is load up an assembly and inspect it, dynamically call methods, etc. This is what makes interop between VB.NET and F# possible.
However, since your code is in a managed assembl... |
I need to write a Java Comparator class that compares Strings, however with one twist. If the two strings it is comparing are the same at the beginning and end of the string are the same, and the middle part that differs is an integer, then compare based on the numeric values of those integers. For example, I want th... |
|java|algorithm|string|sorting|comparison| |
I think this is a basic conflict between people who must maintain the database and people who develop the user interfaces.
As a data person, I would not consider working with a database that is accessed through adhoc queries because they are difficult to effectively tune or manage. How can I know what affect a chan... |
'->' is not an operator. It appears in the F# syntax in a number of places, and its meaning depends on how it is used as part of a larger construct.
Inside a type, '->' describes function types as people have described above. For example
let f : int -> int = ...
says that 'f' is a function that takes an ... |
Performance of try-catch in php |
|php|performance|exception|try-catch| |
What kind of performance implications are there to consider when using try-catch statements in php 5?
I've read some old and seemingly conflicting information on this subject on the web before. A lot of the framework I currently have to work with was created on php 4 and lacks many of the niceties of php 5. So, I d... |
If you have installed it yourself you should be able to remove it by going to Settings -> System -> Remove Programs (could be a slightly different path on the smartphone OS, I'm used to Pocket PCs). |
I do not have VC6 any more, so I cannot try it. I do not know if it works, but maybe you can enter
(char*)textArray;
in the watch window.
**The bettter solution maybe**: VS2008 automatically displays the text the way you want. And there is a Express Edition for VS2008 free of change, which can, as far as I... |
you'll have to go into the SharePoint admin console and explicitely allow that web application to run on on the same web site as SharePoint.
I believe it is under defined managed paths.
Central Administration > Application Management > Define Managed Paths |
how can I use debugbreak() in C#. |
|debugging|debugbreak.| |
What is the syntax and which namespace/class to be imported? Give me a sample code if possible taht will be of great help. |
|c#|debugging|debugbreak| |
How do I match one letter or many in a PHP preg_split style regex |
|regex|php| |
I'm having an issue with my regex.
I want to capture <% some stuff %> and i need what's inside the <% and the %>
This regex works quite well for that.
$matches = preg_split("/<%[\s]*(.*?)[\s]*%>/i",$markup,-1,(PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE));
I also want to catch &% some stuff %... |
|php|regex| |
I'm having an issue with my regex.
I want to capture <% some stuff %> and i need what's inside the <% and the %>
This regex works quite well for that.
$matches = preg_split("/<%[\s]*(.*?)[\s]*%>/i",$markup,-1,(PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE));
I also want to catch &% some stuff %... |
Why would you ship anything more than you need to? |
It's been awhile since I worked in c/c++ but IIRC, the same shortcut can be used for arrays as well. |
I would say it's potentially a bad practice, depending on what happens when the query fails. For example, if your database could throw an error that was intelligently handled by an application, then you might be ok.
On the other hand, if you don't put any validation in your app, you might not have any bad data, but... |
Validate at input time. Validate again before you put it in the database. And have database constraints to prevent bad input. And you can bet in spite of all that, bad data will still get into your database, so validate it again when you use it.
It seems like every day some web app gets hacked because they did al... |
Class variables are just like classes: global and unique for the application. |
Apart from the fact that they are extremely heavy in any serious project? No, there´s no reason if you don't mind people reverse engineering your software. |
Produce conditional compile time error in Java |
|java|c++|compiler-construction|templates| |
I do not mean the compile errors because I made a syntax mistake or whatever. In C++ we can create compile time errors based on conditions as in the following example:
template<int> struct CompileTimeError;
template<> struct CompileTimeError<true> {};
#define STATIC_CHECK(expr, msg) { CompileTime... |
Implement as much data validation as you can at the database end without compromising other goals. For example, if speed is an issue, you may want to consider _not_ using foreign keys, etc. Furthermore, some data validation can only be performed on the application side, e.g., ensuring that email addresses have valid do... |
I am a programmer who has to deal with a lot of code on a daily basis. Open source and what has been developed in house.
As a programmer, I find it useful to have many source files open at once, and often organise my desktop on my (widescreen) monitor so that two source files are side by side. I might be programming... |
I don't know about 6.0.5, but in former versions there used to be a program called vmware-vdiskmanager in VMWare's program directory. You can use this one to extend the virtual disk container.
After you expanded the container, you need to expand the partitions in the guest, you have to do this from "the inside", whi... |
>How do I query for all the values in @a that completely match up with @b?
I'm afraid this definition is not quite perfectly clear. It seems from your additional example that you want all pairs of a.pkid, b.otherID for which every b.value for the given b.otherID is also an a.value for the given a.pkid.
In other ... |
If you want to watch more than one element at the same time, you can append a comma and the number of elements as so:
<code>(v._Myfirst)[startIndex], count</code>
However, note that count must be a constant, it cannot be the result of another expression. |