instruction stringlengths 0 30k ⌀ |
|---|
Statistics is hard :-). After a year of reading and re-reading books and papers and can only say with confidence that I understand the very basics of it.
You might wish to investigate ready-made libraries for whichever programming language you are using, because they are many gotcha's in math in general and statisti... |
Here is the code. It is basicly a copy of BindingUtils.bindProperty that is setup for a ComboBox so that both the combo box and the model are updated when either of the two change.
public static function bindProperty2(site:Object, prop:String, host:Object, chain:Object, commitOnly:Boolean = false):ChangeWatcher
... |
It can be done but only if the return value when the node does exist is *the string value of the node, not the node itself*. The XPath
substring(concat("N/A", /foo/baz), 4 * number(boolean(/foo/baz)))
will return the string value of the `baz` element if it exists, otherwise the string "N/A".
|
It can be done but only if the return value when the node does exist is *the string value of the node, not the node itself*. The XPath
substring(concat("N/A", /foo/baz), 4 * number(boolean(/foo/baz)))
will return the string value of the `baz` element if it exists, otherwise the string "N/A".
To generalize ... |
It can be done but only if the return value when the node does exist is *the string value of the node, not the node itself*. The XPath
substring(concat("N/A", /foo/baz), 4 * number(boolean(/foo/baz)))
will return the string value of the `baz` element if it exists, otherwise the string "N/A".
To generalize ... |
There were new interfaces added, like INotifyPropertyChanging, so there were new types added. The question is valid. |
Should I use window.onload or script block? |
|javascript|dom| |
I have a javascript function that manipulates the DOM when it is called (adds CSS classes, etc). This is invoked when the user changes some values in a form. When the document is first loading, I want to invoke this function to prepare the initial state (which is simpler in this case than setting up the DOM from the ... |
I have a javascript function that manipulates the DOM when it is called (adds CSS classes, etc). This is invoked when the user changes some values in a form. When the document is first loading, I want to invoke this function to prepare the initial state (which is simpler in this case than setting up the DOM from the ... |
# Product of everything except current in C
void product_except_current(int input[], int index[], int out[],
size_t len) {
// compute product of all non-zero `input` elements
int prod = 1, nzero = 0;
for (int* i = input; i != &input[len]; ++i)
... |
# Product of everything except current in C
void product_except_current(int input[], int index[], int out[],
size_t len) {
// compute product of all non-zero `input` elements
int prod = 1, nzeros = 0;
for (int* i = input; i != &input[len]; ++i)
... |
# Product of everything except current in C
void product_except_current(int input[], int index[], int out[],
int len) {
int prod = 1, nzeros = 0, izero = -1;
for (int i = 0; i < len; ++i)
if (input[i])
prod *= input[i]; // ignore possibl... |
# Product of everything except current in C
void product_except_current(int input[], int index[], int out[],
int len) {
int prod = 1, nzeros = 0, izero = -1;
for (int i = 0; i < len; ++i)
if (input[i])
prod *= input[i]; // ignore possibl... |
# Product of everything except current in C
void product_except_current(int input[], int index[], int out[],
int len) {
int prod = 1, nzeros = 0, izero = -1;
for (int i = 0; i < len; ++i)
if ((out[i] = input[index[i]]) != 0)
// compute pr... |
It should respond to ActionListeners, like this:
combo.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
doSomething();
}
});
|
It should respond to ActionListeners, like this:
combo.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
doSomething();
}
});
@John Calsbeek rightly points out that addItemListener() will work, too. You may get 2 ItemEvents, though, on... |
I use references unless I need either of these:
- Null Pointers can be used as a
sentinel value, often a cheap way to
avoid function overloading or use of
a bool.
- You can do arithmetic on a pointer.
For example, p += offset; |
@Pat: I get the same error here for your query. My query is just a little bit more complicated than what I originally posted. I'm working on a reproducible simple example now. |
Enforce SSL in code in an ashx handler |
|asp.net|ssl| |
I have a site, which contains several ashx handlers, on a couple of the handlers I want to reject non-SSL requests. Is there a way that I can do this in code? |
I'm not sure why you need nested transactions here. You only need one actual transaction:
BEGIN TRAN
DELETE FROM Employee
FROM Employee
INNER JOIN Department ON Employee.DepartmentID = Department.DepartmentID
INNER JOIN Company ON Department.CompanyID = Company.CompanyID
... |
I'm not sure why you need nested transactions here. You only need one actual transaction:
BEGIN TRAN
DELETE FROM Employee
FROM Employee
INNER JOIN Department ON Employee.DepartmentID = Department.DepartmentID
INNER JOIN Company ON Department.CompanyID = Company.CompanyID
... |
It's likely throwing an error because you're never initializing _nextId to anything. It needs to have an initial value before you can safely add 1 to it. |
http://us2.php.net/date
echo date('Y'); |
On the server side, you have three alternatives:
1. [Adobe's Flash Media Server][1]
2. [Red5][2], an open source version
3. [Wowza Media Server Pro][3], a commercial alternative
You can either run any of these on your own server or else go for a web provider (I found [this list][4] to be helpful)
On the c... |
'Reliable' SMS Unicode Encoding in PHP |
|php|unicode|internationalization|sms|gsm| |
I'm not very experienced with internationalisation using PHP, it must be said, and a deal of searching didn't really provide the answers I was looking for.
I'm in need of working out a reliable way to convert only 'relevant' text to Unicode to send in an SMS message, using PHP (just temporarily, whilst a service is ... |
I'm not very experienced with internationalisation using PHP, it must be said, and a deal of searching didn't really provide the answers I was looking for.
I'm in need of working out a reliable way to convert only 'relevant' text to Unicode to send in an SMS message, using PHP (just temporarily, whilst a service is ... |
'Reliable' SMS Unicode & GSM Encoding in PHP |
|php|unicode|sms|internationalization|gsm| |
|php|i18n|unicode|sms|gsm| |
|php|unicode|sms|gsm| |
How to escape a # in velocity |
|velocity| |
I would like to know how can i escape a # in velocity. Backslash seems to escape it but it prints itself as well
This:
\#\#
prints:
\#\#
I would like:
## |
Maybe, the following site helps?
[http://velocity.apache.org/tools/releases/1.4/generic/EscapeTool.html][1]
[1]: http://velocity.apache.org/tools/releases/1.4/generic/EscapeTool.html |
The pythonic way to do it is from the [style guide](http://www.python.org/dev/peps/pep-0008/):
For sequences, (strings, lists, tuples), use the fact that empty sequences are false.
**Yes:**
if not seq:
if seq:
**No:**
if len(seq)
if not len(seq)
|
IMO such micro-optimization is not necessary unless you work with some exotic compiler. I would put readability on the first place. |
It does depend on the compiler you are actually using, but very probably they translate to the same code.
You can check it by yourself by creating a small test program and checking its disassembly. |
Most compilers are smart enough to decompose an integer multiplication into a series of bit shifts and adds. I don't know about Windows compilers, but at least with gcc you can get it to spit out the assembler, and if you look at that you can probably see identical assembler for both ways of writing it.
|
Compilers are good at optimising code such as yours. Any modern compiler would produce the same code for both cases and additionally replace `* 2` by a left shift. |
As long as you are using tests that produce TAP (Test Anything Protocol) output you might find this to be useful: http://sourceforge.net/projects/smolder |
This would depend on the compiler, its configuration and the surrounding code.
You should not try and guess whether things are 'faster' without taking measurements.
*In general* you should not worry about this kind of nanoscale optimisation stuff nowadays - it's almost always a complete irrelevance, and if you... |
Not really an answer, but more asking for clarification what is different for Blackberry dev versus other J2ME devices...
I see its a [MIDP J2ME][1] device, and so the standard [Intellij J2ME][2] support would seem to give most of what is needed.
I guess the emulator side of things might be different... but maybe... |
Daily Build |
|build|dailybuilds| |
OK, so we all know the daily build is the heart beat of a project, but whats the single best way of automating it?
We have perl scripts wrapping our pipeline which includes ClearCase, VS2005 (C++), Intel FORTRAN, Inno setup. We use cron jobs on UNIX to schedule the build, and host a simple Apache web server to view... |
The datawrangling blog posted a nice list a while back:
http://www.datawrangling.com/some-datasets-available-on-the-web
Includes financial, government data (labor, housing, etc.), and too many more to list here. |
Not very clean, but you can use DeviceIoControl() |
Not very clean, but you can use DeviceIoControl()
Open volume as a file, pass resulting handle to DeviceIoControl() together with control code. Check MSDN for control codes, there is something like "read journal record". |
You can probably find the Northwind sample database for SQLServer
It might be overkill but you can [install OracleXE][1], I think it comes with some sample schemas or you can find the old Scott schema online.
Also, in stephen bohlen's [Summer of NHibernate][2] screen-cast series he creates a sample database, the ... |
Unfortunately you can't declare two indexers with the same parameter list. The following paragraph is taken from here <a href="http://msdn.microsoft.com/en-us/library/2549tw02.aspx#languageReferenceRemarksToggle" title="C# Programming Guide - Using Indexers">C# Programming Guide - Using Indexers "Remarks" section</a>:... |
[UnData][1] and [Swivel][2] are both good sources for data. Any database should be able to import CSV files.
[1]: http://data.un.org/
[2]: http://www.swivel.com/
|
As far as I can tell, there isn't one. Sorry.
I take it you're trying to validate the tracking number entered to make sure it was entered properly?
-- Kevin Fairchild |
How do you send and receive UDP packets in Java on a multihomed machine? |
|java| |
I have a machine with VmWare installed which added two extra network interfaces. The OS is Vista. I have two Java applications, one which broadcasts datagrams, and one which receives those datagrams. The problem I'm having is that unless I disable both VmWare network interfaces, the receiver can't receive the datagr... |
|java|sockets| |
import org.restlet.Client;
import org.restlet.data.Protocol;
import org.restlet.data.Reference;
import org.restlet.data.Response;
import org.restlet.resource.DomRepresentation;
import org.w3c.dom.Node;
/**
* Uses YAHOO!'s RESTful web service with XML.
*/
public class... |
LSP concerns invariants. Your board example is broken at the outset because the interfaces simply don't match.
A better example would be the following (implementations omitted):
class Rectangle {
int getHeight() const;
void setHeight(int value);
int getWidth() const;
void s... |
How do I use a start commit hook in TortoiseSVN to setup a custom log entry? |
|tortoisesvn| |
I'd like to automate TortoiseSVN as part of a commit process.
Specifically I'd like to dynamically create a log entry for the commit dialog.
I know that I can launch the commit dialog either from the commandline or by right clicking on a folder and selecting svncommit.
I'd like to use the start commit hook to se... |
You might like to try the [improved Javascript syntax highlighter][1] than the one that ships
[1]: http://www.vim.org/scripts/script.php?script_id=1491 |
You might like to try this [improved Javascript syntax highlighter][1] rather than the one that ships with VIMRUNTIME.
[1]: http://www.vim.org/scripts/script.php?script_id=1491 |
Access to Result sets from within Stored procedures Transact-SQL SQL Server |
|sql-server|t-sql|sql| |
I'm using SQL Server 2005, and I would like to know how to access different result sets from within transact-sql. The following stored procedure returns two result sets, how do I access them from, for example, another stored procedure?
CREATE PROCEDURE foobar () AS
BEGIN
select foo_column1, foo_co... |
|sql|sql-server|t-sql| |
I'm using SQL Server 2005, and I would like to know how to access different result sets from within transact-sql. The following stored procedure returns two result sets, how do I access them from, for example, another stored procedure?
CREATE PROCEDURE getOrder (@orderId as numeric) AS
BEGIN
selec... |
Every time I create a new project I copy the last project's ant file to the new one and make the appropriate changes (trying at the same time to make it more flexible for the next project). But since I didn't really thought about it at the begging, the file started to look really ugly.
Do you have an Ant template th... |
G'day,
Most places where I have worked have folowed this practice. I've actually written coding standards for BAE (Aust.) along with the reasons why instead of just carving something in stone with no real justification.
Concerning your question about source files, it's not so much time to compile but more an issu... |
> How about writing a cursor to loop through the contents, attempting the cast for each entry?When an error occurs, output the primary key or other identifying details for the problem record.
I can't think of a set-based way to do this.
Not totally setbased but if only 3 rows out of 1 million are bad it will sa... |
The ISDATE() would take care of the rows which were not formatted properly if it were indeed being executed first. However, if you look at the execution plan you'll probably find that the DATEDIFF predicate is being applied first - thus the cause of your pain.
If you're using SQL Server Management Studio hit CTRL-L... |
I will have to agree with Greg: make up an attribute for it.
And if you're really serious, maybe find a way to figure out if the constructor is being accessed by anything other than XMLSerializer and throw an exception if it is. |
> Are you initially loading the data only when !Page.IsPostBack? Also, is view state enabled for the text box?
I had almost forgotten to check the ViewState, but ended up remembering to verify that it wasn't disabled before making my post here on SO. I even set EnableViewState="true" to make sure.
I did find the... |
(**Updated a little**)
I'm not very experienced with internationalisation using PHP, it must be said, and a deal of searching didn't really provide the answers I was looking for.
I'm in need of working out a reliable way to convert only 'relevant' text to Unicode to send in an SMS message, using PHP (just tempora... |
We can store the results of reversing all possible 1 byte sequences in an array (256 distinct entries), then use a combination of lookups into this table and some oring logic to get the reverse of integer. |
Try using a different colour. I'm not sure IE understands 'grey' (instead, use 'gray'). |
Game Programming and Event Handlers |
|c#|xna|camera| |
I haven't programmed games for about 10 years (My last experience was DJGPP + Allegro), but I thought I'd check out XNA over the weekend to see how it was shaping up.
I am fairly impressed, however as I continue to piece together a game engine, I have a (probably) basic question.
How much should you rely on C#'s ... |
|continuous-integration|build| |
We're in the process of implementing CC.Net. So far it seems like it would fit your model pretty well.
Out of the box it offers automated building, results tracking and notification. I'm not sure how detailed the build-in-progress monitoring is though. |
A new one to me that I've heard is quite slick is [hudson][1] - also with MSBuild support.
[1]: http://hudson.gotdns.com/wiki/display/HUDSON/Plugins |
After some testing, I found a way to do this.
1. Add the App.Config file to the test project. Use "Add as a link" option.
2. Use `System.Configuration.ConfigurationManager.AppSettings["myKey"]` to access the value.
|
I never considered changing my font, I have always been happy with Courier. This thread has truely opened my eyes, if only I could upvote it!
Went with Droid Sans Mono. |
first create the column if it doesn't exist:
ALTER TABLE database2..targetTable
ADD targetColumn int null -- or whatever column definition is needed
and since you're using Sql Server 2005 you can use the new [MERGE][1] statement. Example:
MERGE database2..targetTable AS t
USING (SELECT source... |
first create the column if it doesn't exist:
ALTER TABLE database2..targetTable
ADD targetColumn int null -- or whatever column definition is needed
and since you're using Sql Server 2005 you can use the new [MERGE][1] statement.
**The [MERGE][1] statement has the advantage of being able to treat all si... |
It is possible to determine which process starts my .Net application? |
Change your generic implementation to...
T IList<T>.this[int index] { get; set; }
This explicitly says which 'this' is which. |
How can I programmatically run the ASP.Net Development Server using C#? |
|c#|asp.net| |
I have ASP.NET web pages for which I want to build automated tests (using WatiN & MBUnit). How do I start the ASP.Net Development Server from my code? I do not want to use IIS. |
In Subversion, every .svn folder has whatever is necessary for the containing folder. And since all local paths are stored as relative, you are safe while copying whole or partial trees outside the original checkout tree. They will continue to function in their new homes.
I frequently copy subtrees from my trunk out... |
Without wider context, it's hard to figure out the right answer, but I sew three possibilities here:
- stay with normal switch statement, no need to do anything. This is the most likely solution
- use pointers to member function in conjunction with an array, as @Simon says, or may be with a map. For a case statem... |
From what I know, you can fire up the dev server from the command prompt with the following path/syntax:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\Webdev.WebServer.exe /port:[PORT NUMBER] /path: [PATH TO ROOT]
...so I could imagine you could easily use Process.Start() to launch the particulars you need th... |