instruction stringlengths 0 30k ⌀ |
|---|
@Lance: the first one is also executing. Compare it with a named constructor:
function Blah() {
alert('blah');
}
new Bla();
this is actually also executing code. The same goes for the anonymous constructor...
But that was not the question ;-) |
On an Intel based Mac you can run Windows within a virtual machine. You will need one virtual machine for each version of IE you want to test against.
The instructions below include **free** and **legal** virtualisation software and Windows disk images.
1. Download some virtual machine software. The developer dis... |
On an Intel based Mac you can run Windows within a virtual machine. You will need one virtual machine for each version of IE you want to test against.
The instructions below include **free** and **legal** virtualisation software and Windows disk images.
1. Download some virtual machine software. The developer dis... |
Help me construct a complex SQL query (or queries). |
|php|cakephp| |
As part of a larger web-app (using CakePHP), I'm putting together a simple blog system. The relationships are exceedingly simple: each User has a Blog, which has many Entries, which have many Comments.
An element I'd like to incorporate is a list of "Popular Entries." Popular Entries have been defined as those with ... |
Since subversion doesn't actually think of branches as anything special other than more directories, you can always just create the directory tree you want (with svn mkdir) then copy the code you want into the tree location.
Or just use the --parents flag @BlairC mentioned. |
It's worth subscribing to the <a href="[Google Tech Talk YouTube channel][1], which is a video podcast with a bunch of really interesting, wide-ranging talks given to Google but (usually) outside speakers. Past presentaters include Linus Torvals, Guido van Rossum, Merlin Mann and Larry Wall. The video is usually just t... |
Hummm, thanks for putting me on the right track guys...this was odd but it turns out that if I change the case to lower case, everything starting working just fine...
Finished Result:
var newDiv = document.createElement("DIV");
newDiv.setAttribute("id", "obj_1000");
document.appendChild(newDiv);
alert(... |
1. Win-[type name of program] to launch a program in Vista
2. Win-E for explorer
3. Win-F for find
4. Alt-Tab to swap between programs
5. Ctrl-Tab to swawp between tabs
Not really a 'Windows' shortcut, but the Ctrl-Alt-numpad and Ctrl-Alt-arrows to move and windows and move them to another monitor using [Wi... |
1. Win-[type name of program] to launch a program in Vista
2. Win-E for explorer
3. Win-F for find
4. Alt-Tab to swap between programs
5. Ctrl-Tab to swawp between tabs
Not really a 'Windows' shortcut, but the Ctrl-Alt-numpad and Ctrl-Alt-arrows to move and resize windows and move them to another monitor us... |
I always use this [module][1] from Jeff for unhandled exceptions, sending me an email with stacktrace etc.
[1]: http://www.codeproject.com/KB/exception/ExceptionHandling.aspx |
On the VSS side, there are conversion tools that are available to help with migration. They can mostly maintain version history (there are caveats that are explained in the readme and docs). I have migrated well over 50 VSS projcts into perforce using the VSS to perforce tool. Getting the data out of VSS can be a b... |
What Oracle version are you using? Check this page which refers to Oracle 10:
http://www.acs.ilstu.edu/docs/Oracle/server.101/b10752/stats.htm
It says:
> The recommended approach to gathering statistics is to allow Oracle to automatically gather the statistics. Oracle gathers statistics on all database objec... |
You could create a simple script which runs uptime and dumps it to a file.
uptime >> uptime.log
Then set up a cron job for it. |
forms and jquery |
|jquery|webforms| |
I'm creating a simple form for a site I manage. I use JQuery for my javascript. I noticed a large amount of plugins for JQuery and forms. Does anybody have any favorites that they find especially useful? In particular, plugins to help with validation would be the most useful. |
backup data for reporting |
|database| |
StringBuilder will perform better, from a memory stand point. As for processing, the difference in time of execution may be negligible. |
We're using http://hyperestraier.sourceforge.net/, which was inherited. Haven't looked into other engines, but hyperestraier provides all the hooks necessary. Setting up the search index is complicated though. Probably easier options available. |
[This article at A List Apart][1] has a solution resulting in a 3-column layout that will :
* have a fluid center with fixed width sidebars,
* allow the center column to appear first in the source,
* allow any column to be the tallest,
* require only a single extra div of markup, and
* require very simpl... |
You can use a For Each to iterate through all the cells in a defined range.
Public Sub IterateThroughRange()
Dim wb As Workbook
Dim ws As Worksheet
Dim rng As Range
Dim cell As Range
Set wb = Application.Workbooks(1)
Set ws = wb.Sheets(1)
Set rng = ws.Range("A1", "C... |
You can also check IsSpecialName is true. this will be true in a property (amongst other things)
At the il level the methods are exposed as follows (using Environment.ExitCode as example):
.method public hidebysig specialname static int32 get_ExitCode() cil managed
.method public hidebysig specialname st... |
>How do you react when you find yourself being the only one who listenes, while other team members just sit there and maybe even fall asleep?
If I have already heard what the others have said I would ask a question of someone who is not paying attention about how it might affect thier jobs. Very school teacher like,... |
>How do you react when you find yourself being the only one who listenes, while other team members just sit there and maybe even fall asleep?
If I have already heard what the others have said I would ask a question of someone who is not paying attention about how it this might affect what they are working on. Very s... |
require 'net/smtp'
SMTP_SERVER = 'mailserver01' #change to your server
def send_emails(sender_address, recipients, subject, message_body)
recipients.each do |recipient_address|
message_header =''
message_header << "From: <#{sender_address}>\r\n"
message_header << "To: <#{recipient_add... |
`<asp:Button>` is the ASP.NET equivalent to the HTML.Button. It will by default generate an `<input type="button">`. (This is the System.Web.UI.WebControls.Button class) |
We're moving to an MSI for our installs, so far with mixed results. I'm a control freak so I would personally prefer a series of scripts that I had more direct control over. I've used ANT in the past with good results. |
Michael Feathers has an insightful blog post about this titled [The Flawed Theory Behind Unit Testing][1]. Seriously, go read it. The punch line is
> All of these techniques have been shown to increase quality. And, if we look closely we can see why: all of them force us to reflect on our code.
but you should... |
Do you have the ability to run commands remotely? The [PsExec][1] utility from [Systinternals][2] would let run a command line unzip program on the remote machine. If you have a script that copies the build as a .zip file to the remote site, you would just need one more line for the PsExec call to unzip the files.
... |
Yes, that is the downside of testing with mocks. There is a lot of work that you need to put in that it feels brutal. But that is the essence of unit testing. How can you test something in isolation if you don't mock external resources?
On the other hand, you're mocking away slow functionality (such as databases and... |
How do you stop IIS SMTP Server from sending bounce emails? |
|iis|smtp|pop| |
How do you stop the "Default SMTP Virtual Server" from sending bounce messages for email addresses that you don't have?
i.e. I'm using IIS' SMTP server to handle my email and if an email is sent unknown at mydomain.com a bounce email with 'address not known' (or something like that) is sent back to the sender. I wan... |
I would like my website to record flvs using webcams. These flvs need to play smoothly so I can play with them afterwards, for example transcoding them to avis.
I've tried many different servers to handle the flv recording. The resulting flvs play OK in Wimpy FLV Player, for example, except that the progress indicat... |
As far as I recall, the code for getting the viewport position differs between browsers, so it would be easier to use some kind of framework, for example, [Prototype][1] has a function document.viewport.getScrollOffsets (which, I believe, is the one you're after).
However, getting the coordinates is only one part, t... |
Shouldn't be too bad, you just need a group by (this is off the type of my head, so forgive syntax errors):
SELECT entry-id, count(id) AS c
FROM comment
WHERE comment.createdate >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH)
GROUP BY entry-id
ORDER BY c DESC |
How to import a DBF file in SQL Server |
|sql-server|foxpro|dbf| |
How can you import a foxpro DBF file in SQL Server?
|
I'd make use of the event log. Take a look here:
http://support.microsoft.com/kb/307024 |
You are on the right track. You need to create a tracking module which logs actions/exceptions locally.
You can then have a button or a menu option that the user can click to either automatically email you this information the moment the issue occurs, or they can have the option to get hold of the file so that they ... |
One option is to generate a (mini-)dump file as close to the point where the exception is thrown as possible. This [article][1] talks about how to do this from managed code.
You could then load the dump file into Visual Studio or WinDbg and examine it with the aid of [SOS][2]
[1]: http://blogs.microsoft.co.i... |
Use a linked server or use openrowset, example
SELECT * into SomeTable
FROM OPENROWSET('MSDASQL', 'Driver=Microsoft Visual FoxPro Driver;
SourceDB=\\SomeServer\SomePath\;
SourceType=DBF',
'SELECT * FROM SomeDBF')
|
C#: How do I get the path of the assembly the code is in? |
|c#|stl| |
Is there a way to get the path for the assembly in which the current code resides? I do not want the path of the calling assembly, just the one containing the code.
Basically my unit test needs to read some xml test files which are located relative to the dll. I want the path to always resolve correctly regardle... |
|c#|.net| |
Is there a way to get the path for the assembly in which the current code resides? I do not want the path of the calling assembly, just the one containing the code.
Basically my unit test needs to read some xml test files which are located relative to the dll. I want the path to always resolve correctly regardle... |
Is there a console for Windows Mobile devices? |
|windows-mobile|console| |
I would like to write small console based applications on Windows Mobile. What console applications might I use? |
There are pros and cons to both. These days I use and recommend Module::Build and Module::Starter.
Frank Wiles, Revolution Systems, <a href="http://www.revsys.com">www.revsys.com</a> |
If you only need to look at the cells that are in use you can use:
sub IterateCells()
For Each Cell in ActiveSheet.UsedRange.Cells
'do some stuff
Next
End Sub
that will hit everything in the range from A1 to the last cell with data (the one on the bottom right-most ... |
If you're starting from scratch. I'd have to say [Google Web Toolkit](http://code.google.com/webtoolkit/). I have to say it is incredibly powerful. You get keep using most of your Java tools. Plus, you don't have to duplicate code that exists on both the server and the client, it just gets compiled differently for ... |
As far as I know, the only way to do that is to enter something (anything) on that line, then delete it. Or hit space and you'll never see it there until you return to that line.
Once VS determines that you've edited a line of text, it won't automatically modify it for you (at least, not in that way that you've des... |
Using preview 5, Html.RenderPartial is your man, you can render sub-controls, and pass them your viewdata, or an arbitrary model, and new viewdata combo. |
I believe StringBuilder is faster if you have more than 4 strings you need to append together. Plus it can do some cool things like AppendLine. |
Sometimes I'll change the function, so it can optionally return an element instead of the entire array:
<?php
function functionThatReturnsAnArray($n = NULL) {
return ($n === NULL ? $myArray : $myArray[$n]);
}
$firstElement = functionThatReturnsAnArray(0); |
Is this a case of the output screen just flashing and then dissapearing? if so you can keep it open by using cin as your last statement. |
Is this a case of the output screen just flashing and then dissapearing? if so you can keep it open by using cin as your last statement before return. |
Although Subversion tries to [automatically detect][1] whether a file is binary or not, you can override the mime-type using [svn propset][2].
For example, `svn propset svn:mime-type application/octet-stream example.txt`. This will make your file act as a collection of bytes rather than a text file. See also, the svn ... |
In .NET, StringBuilder is still faster than appending strings. I'm pretty sure that in Java, they just create a StringBuffer under the hood when you append strings, so there's isn't really a difference. I'm not sure why they haven't done this in .NET yet. |
What is the best method to transfer data from sales table to sales history table in sql server 2005. sales history table will be used for reporting. |
|sql-server|database| |
I like Consolas myself, but when it comes to monospaced fonts there are quite a few [other options][1] to choose from:
[1]: http://www.zeusedit.com/forum/viewtopic.php?t=301
|
ddd is a graphical front-end to gdb that is pretty nice. One of the down sides is a classic X interface, but I seem to recall it being pretty intuitive. |
The best way to do this IMO is to make a Web Part. As a Web Part the UI will be automatically rendered to be the same as the theme the site is using (unless you override it) and it will be able to be placed anywhere by anyone with admin privileges.
- [Tutorial on making a Web Part][1]
- [Tutorial on packaging ... |
Some suggestions here:
[Standard score][1] (z-value, z-score, normal score)
but "sigma" or "stdev_distance" would probably be clearer
[1]: http://en.wikipedia.org/wiki/Standard_score |
The Scanner class is new in Java 5. I do not know what Hardy's default Java environment is, but it is not Sun's and therefore may be outdated.
I recommend installing the package sun-java6-jdk to get the most up-to-date version, then telling Eclipse to use it. |
We use varchar(15) and certainly index on that field.
The reason being is that International standards can support up to 15 digits
[link text][1]
If you do support International numbers, I recommend the separate storage of a World Zone Code or Country Code to better filter queries by so that you do not find yo... |
We use varchar(15) and certainly index on that field.
The reason being is that International standards can support up to 15 digits
[Wikipedia - Telephone Number Formats][1]
If you do support International numbers, I recommend the separate storage of a World Zone Code or Country Code to better filter queries by... |
I will second Thomas Owens's ImageMagick suggestion. It is mind-boggling just how comprehensive the library is, and how much time it saves you in the end. |
[Form Validation][1] is one that comes to my mind. I think is being used here in SO.
[1]: http://plugins.jquery.com/project/validate |
Given the traversing of the DOM that is actually happening with an update panel it's generally not the content that is hindering performance.. it is the PC/Browser.
I know this is exactly what you aren't looking for but unless your panel contains a significant amount of data then compression and caching isn't going ... |
WCF problem passing complex types |
|.net|wcf|wsdl| |
I have a service contract that defines a method with a parameter of type System.Object (xs:anyType in the WSDL). I want to be able to pass simple types as well as complex types in this parameter. Simple types work fine, but when I try to pass a complex type that is defined in my WSDL, I get this error:
Element 'ht... |
My super lazy version that stays updated:
`© <?php
$copyYear = 2008;
$curYear = date('Y');
echo $copyYear.(($copyYear!=$curYear)?'-'.$curYear);
?> Me, Inc.`
This year (2008), it will say:
> © 2008 Me, Inc.
Next year, it will say:
> © 2008-2009 Me, Inc.
|
Unfortunately LINQ to SQL does not support Full Text Search.
There are a bunch of products out there that I think could: Lucene.NET, NHibernate Search comes to mind. LINQ for NHibernate combined with NHibernate Search would probably give that functionality, but both are still way deep in beta. |
All very good tip here... but I just want to add something..
Ive seen some sites that gives you a http login page and only redirect you to https after you post your username/pass.. This means the username is transmitted in the clear before the https connection is established..
In short make the page where you lo... |
If you have the cell name or position, you can do:
With ActiveSheet
.Shapes.AddTextbox msoTextOrientationHorizontal, .Cells(3,2).Left, .Cells(3,2).Top, .Cells(3,2).Width, .Cells(3,2).Height
End With
This will add a textbox over cell B3. When B3 is resized, the textbox is also. |
const int __N = 100;
const int __start = 9;
const int __divisibleBy = 3;
var yourList = Enumerable.Range(__start, __N).Where(x => x % __divisibleBy == 0).ToList().ToArray(); |
const int __N = 100;
const int __start = 9;
const int __divisibleBy = 3;
var yourList = Enumerable.Range(__start, __N).Where(x => x % __divisibleBy == 0).ToArray(); |
const int __N = 100;
const int __start = 9;
const int __divisibleBy = 3;
var array = Enumerable.Range(__start, __N * __divisibleBy).Where(x => x % __divisibleBy == 0).Take(__N).ToArray(); |
Have you checked out [NAnt][1] and [CruiseControl][2]?
Combined, they can provide an easy and automated way to build and deploy your web apps.
[1]: http://nant.sourceforge.net/
[2]: http://cruisecontrol.sourceforge.net/ |
What is the best way to rollout web applications? |
|deployment| |
I'm trying to create a standard way of rolling out web applications for our company. Currently we do it with zip files, vbscript/javascript, and manual some steps.
For thick client installs we generate MSI installers using Wise/Wix. We don't create installers currently for websites as in general they are just xc... |
|asp.net|deployment| |
Wrap an Oracle schema update in a transaction |
|oracle-database|transactions| |
I've got a program that periodically updates its database schema. Sometimes, one of the DDL statements might fail and if it does, I want to roll back all the changes. I wrap the update in a transaction like so:
BEGIN TRAN;
CREATE TABLE A (PKey int NOT NULL IDENTITY, NewFieldKey int NULL, CONSTRAINT ... |
If you are storing the credit card information because you don't want the user to have to re-enter it then hashing of any form isn't going to help.
When do you need to act on the credit card number?
You could store the credit card numbers in a more secure database, and in the main db just store enough information... |
Clustering Algorithm for Mapping Application |
|algorithm|maps| |
I'm looking into clustering points on a map (lat/longs). Are there any recommendations as to a suitable algorithm that is fast and scalable? |
Yes, the performance difference is significant. See the KB article "[How to improve string concatenation performance in Visual C#][1]".
I have always tried to code for clarity first, and then optimize for performance later. That's much easier than doing it the other way around! However, having seen the enormous p... |