instruction
stringlengths
0
30k
A few objects is IE aren't always case-sensitive, including some/most/all ActiveX -- why both **XHR.onReadyStateChange** and **XHR.onreadystatechange** would work fine in IE5 or IE6, but only the latter would work with the native **XMLHttpRequest** object in IE7, FF, etc. But, a quick reference for "<i>standard</i>"...
From [perlvar][1]: >Use of $* is deprecated in modern Perl, <u>supplanted by the /s and /m modifiers</u> on pattern matching. If you have access to the place where it's being matched just add it to the end: $haystack =~ m/.../sm; If you only have access to the string, you can surround the expression with...
Perl: why is the if statement slower than "and"?
|performance|perl|
In Perl, a conditional can be expressed either as if (condition) { do something } or as (condition) and do { do something } Interestingly, the second way seems to be about 10% faster. Does anyone know why?
Use the central limit theorem [wikipedia entry][1] [mathworld entry][2] to your advantage. Generate n of the uniformly distributed numbers, sum them, subtract n*0.5 and you have the output of an approximately normal distribution with mean equal to 0 and variance equal to `(1/12) * (1/sqrt(N))` (see [wikipedia on uni...
When is a browser considered "Dead"?
|browser|
Since it's been a while since my last web job, I decided to do this latest site up from scratch. Now I have to decide *again* what to support in terms of browsers. Certainly I have a list of what I'd like to support, but the decisions that went into that list seem to be a little arbitrary to me. Where can I go to get a...
The way to get the return value is to use a SqlParameter on the SqlCommand object which has its Direction set to ParameterDirection.ReturnValue. You should check the SelectCommand property of the TableAdapter after calling Fill.
WPF is surprisingly different from Windows Forms. This means a lot of training for your team.
As far as I know, you cannot access these parts of the browser due to security issues. But you can load new browser windows without toolbars as such. I don't know exactly how (hopefully other users will help yout out), but maybe start here: http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20782379.html ...
This might be a step too far, but have you considered using WCF and the callback element of WCF? Callback effectively turns the what was client into a server. To be honest, I don't know a great deal about callback and have only experimented. Perhaps worth a 10 minute google though.
I think the following might work: RewriteEngine on RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$ RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L] When it comes to mod_rewrite I can never be sure without testing though...
I think the following might work: RewriteEngine on RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$ RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L] When it comes to mod_rewrite I can never be sure without testing though...
--you can play with the datediff using mi for minutes -- this give you second of each task select Start, Stop, CASE WHEN Stop = '9999-12-31' THEN datediff(ss, start,getdate()) ELSE datediff(ss, start,stop) END duration_in_seconds from mytable -- sum Select Sum(duration_in_seconds...
Also, you mentioned cut & paste, this is not the best way to be copying large amounts of data within windows. At least use xcopy, robocopy is even faster.
To filter out all the lines in a file that match a certain regex: perl -n -i.orig -e 'print unless /^#/' file1 file2 file3 The -i switch creates a backup of the file with the given extension (.orig). You can skip it if you don't need a backup. The -n switch causes perl to execute your instructions (-e ' .....
To filter out all the lines in a file that match a certain regex: perl -n -i.orig -e 'print unless /^#/' file1 file2 file3 The '.orig' after the -i switch creates a backup of the file with the given extension (.orig). You can skip it if you don't need a backup (just use -i). The -n switch causes perl to ex...
The following example works as well when your PK is just a subset of all table columns. First find the duplicate rows: SELECT col1, col2, count(*) FROM t1 GROUP BY col1, col2 HAVING count(*) > 1 If there are only few, you can delete them manually: set rowcount 1 delete from t1 ...
The following example works as well when your PK is just a subset of all table columns. (Note: I like the approach with inserting another surrogate id column more. But maybe this solution comes handy as well.) First find the duplicate rows: SELECT col1, col2, count(*) FROM t1 GROUP BY col1, col2...
If stoptime data type is string, you can use .Contains() function, and also .StartsWith() and .EndsWith().
In single-threaded code, I find adding some statements like this: System.out.println("A: "+ System.currentTimeMillis()); is simpler and as effective as using a profiler. You can soon narrow down the part of the code causing the problem.
You can do this by converting to PostScript and back. PostScript files can be concatenated trivially. For example, here's a Bash script that uses the Ghostscript tools ps2pdf and pdf2ps: <pre> #!/bin/bash for file in 01_foo.pdf 02_bar.pdf 03_baz.pdf; do pdf2ps $file - >> temp.ps done ps2pdf temp.ps outp...
A really good text editor with syntax highlighting (e.g. Textpad from www.textpad.com) and SQL Plus.
**[DNA][1]** -- or does it have to involve silicon computers? ;-) [1]: http://en.wikipedia.org/wiki/DNA_replication
JavaFx is not a new runtime. It is the same JRE but a new language/compiler with some a few new APIs to make it all works.... Using Netbeans, you can build applications on any platform. As of today, the APIs are beta. Classfiles produced by the compiler are JRE 6 compatible.
[Others][1] have answered re: time.time() vs. time.clock(). However, if you're timing the execution of a block of code for benchmarking/profiling purposes, you should take a look at the [`timeit` module][2]. [1]: http://stackoverflow.com/questions/85451/python-timeclock-vs-timetime-accuracy#85489 [2]: htt...
[Others][1] have answered re: time.time() vs. time.clock(). However, if you're timing the execution of a block of code for benchmarking/profiling purposes, you should take a look at the [`timeit` module][2]. [1]: http://stackoverflow.com/questions/85451#85511 [2]: http://docs.python.org/lib/module-timeit....
What version are you using? Design view is for human-readable elements, you wouldn't be editing code there and therefore wouldn't need intellisense. If you are not using code-behind, you should only have one <script runat="server"> tag on the page, and you would edit this in Source view. To enable intellisense, add ...
On Unix time.clock() measures the amount of CPU time that has been used by the current process, so it's no good for measuring elapsed time from some point in the past. On Windows it will measure wall-clock seconds elapsed since the first call to the function. On either system time.time() will return seconds passed sinc...
FindControl() method throws ArithmeticException?
|c#|asp.net|
As far as I know, the search window tab depend of the open file you're on when calling the search function. So, for example if your on a web.xml file, it will open the "plug-in search" instead of the "java-search". Edit: there is a way to force the default open tab, by assigning a shortcut to the "File Search" actio...
You could always use ADO to write the results out to the worksheet cells from a recordset object
If I understand your scenerio correctly you'll probably want to set it's visible property during the databound event
Is there a simple tool to convert mysql to postgresql syntax?
|database|mysql|postgresql|
I've tried the tools listed [here][1], some with more success than others, but none gave me valid postgres syntax I could use (tinyint errors etc.) [1]: http://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL
Pointers are important! They "point" to a memory address, and many internal structures are represented as pointers, IE, An array of strings is actually a list of pointers to pointers! Pointers can also be used for updating variables passed to functions.
Straight from the [C# Language Specification][1], [§ 2.4.2 Identifiers (C#)][2] : > The prefix "@" enables the use of > keywords as identifiers, which is > useful when interfacing with other > programming languages. The character @ > is not actually part of the > identifier, so the identifier might be > seen ...
I suggest using a XmlSimple for a start. After you run the XmlSimple#xml_in on your input file, you get a hash. Then you can recurse into it (obj.instance_variables) and turn all internal hashes (element.is_a?(Hash)) to the objects of the same name, for example: obj.instance_variables.find {|v| obj.send(v.gsub(/...
Do they have to be real English words, or just strings that look like they could be English words? If they just need to look like *possible* English words you could do some statistical analysis on some real English texts and work out which combinations of letters occur frequently. Once you've done that you can thro...
I guess you have 2 choices If your use-cases never require updates to both databases within the same transaction, then you can use two JpaTransactionManagers, but I'm not sure you will be able to use the @Transactional approach? In this case, you would need to fallback on the older mechanism of using a simple [Trans...
On Windows, you can register other languages with the Scripting Host and have them available to IE. For example VBScript is supported out of the box (though it has never gained much popularity as it is for most purposes even worse than JavaScript). The Python win32 extensions allowed one to add Python to IE like thi...
This question is too broad. The only reasonable answer is P/Invoke, but that's kind of like saying that if you want to program for Windows you need to know the Win32 API. Pretty much entire books have been written about P/Invoke ([http://www.amazon.com/NET-COM-Complete-Interoperability-Guide/dp/067232170X][1]), and...
I'm of the opinion that one shouldn't escape anything during input, only on output. Since (most of the time) you can not assume that you know where that data is going. Example, if you have form that takes data that later on appears in an email that you send out, you need different escaping (otherwise a malicious user c...
Based on [marked23's](http://stackoverflow.com/questions/76223/get-last-friday-of-month-in-java#76437) suggestion: public Date getLastFriday( int month, int year ) { GregorianCalendar cal = new GregorianCalendar(); cal.set( year, month + 1, 1 ); cal.add( Calendar.DAY_OF_MONTH, -( cal.get(...
Based on [marked23's](http://stackoverflow.com/questions/76223/get-last-friday-of-month-in-java#76437) suggestion: public Date getLastFriday( int month, int year ) { Calendar cal = Calendar.getInstance(); cal.set( year, month + 1, 1 ); cal.add( Calendar.DAY_OF_MONTH, -( cal.get( Calendar....
I don't think this is possible. However, you could use the enum's valueOf(String name) method if you were going to use the enum value's name as your code.
I don't see much wrong with the code. Technically you're binding an instance of the Person class (ie it doesn't make sense to try and bind to an interface anyway) I don't know what your PolicyInjection.Wrap method does, but I'm assuming it returns a concrete Person class? Anyway, I just tried this on my end and it work...
You need to install the runtime redistributable files onto the machine you are trying to run the app on. The redistributable for 2008 is [here][1]. The redistributable for 2005 is [here][2]. They can be installed side-by-side, in case you need both. [1]: http://www.microsoft.com/downloads/details.aspx?F...
I assume they log into your email account, either by POP3, a public API or they know the html formatting of webmail systems and read the DOM. Then they find whoever you recieved and sent emails to and looks through it's own user database to find matches.
Cygwin includes grep. All the GNU tools amd Unix stuff works great on Windows if you install Cygwin. <http://www.cygwin.com/>
It's not possible, sadly. However, consider your applications navigation model. Are you using Post/Redirect/Get PRG Model? http://en.wikipedia.org/wiki/Post/Redirect/Get? This model is more back button friendly than the Postback model.
Note that the downside of garbage-collecting your repository is that, well, the garbage gets collected. As we all know as computer users, files we consider garbage right now might turn out to be very valuable three days in the future. The fact that git keeps most of its debris around has saved my bacon several times – ...
Since I generally only call toString() on methods and classes that I have written myself and overrode the base method, then I generally know what the cost is ahead of time. The only time I use toString() otherwise is error handling and or debugging when speed is not of the same importance.
PowerShell's Select-String cmdlet was fine in v1.0, but is [significantly better for v2.0][1]. > **New parameters added to Select-String**: Select-String cmdlet now supports new parameters, such as: > > - -Context: This allows you to see lines before and after the match line > - -AllMatches: which allows y...
Assuming you're going open source, strong considerations are: An active and knowledgeable community. <-- You don't want to be the only person able to support this CMS in 10 years time. regular and simple updating techniques. Your skill sets.
(defun maybe-kill-buffer () (if (and (not buffer-file-name) (buffer-modified-p)) ;; buffer is not visiting a file (y-or-n-p (format "Buffer %s has been edited. Kill it anyway? " (buffer-name))) t)) (add-to-list 'kill-buffer-query-functions 'maybe-ki...
When is a browser considered "dead"?
**Keep in mind that I'm not looking for a list of current browsers to support, I'm looking for logical ways to make that list, backed by some kind of hard statistics.** Since it's been a while since my last web job, I decided to do this latest site up from scratch. Now I have to decide *again* what to support in te...
If you need to explicity state the localisation you can use the CultureInfo and pass that to the string formatter.
In Python, how do you take tokenized input such as with the C++?
|c++|python|input|
In C++, I can have take input like this: cin >> a >> b >> c; And a can be int, b can be float, and c can be whatever... How do I do the same in python? input() and raw_input(), the way I'm using them, don't seem to be giving me the desired results.
Use GetPrice().ToString("C", CultureInfo.CreateSpecificCulture("en-GB"))
Another idea is to find another good developer to pair program with. It worked really well for me. I get to rest my hands without necessarily slowing down, end up producing better quality code - or at least not having to review as much of it.
How do I represent features v. tasks in FogBugz 6?
|fogbugz|
In FogBugz 6, how do I represent the concepts of a "feature" versus a "task"? As [defined by Joel Spolsky][1], the owner of Fog Creek Software (which makes FogBugz), a feature is essentially a user-visible capability. To estimate the time to implement a feature, the developer should break the implementation into shor...
In FogBugz 6, how do I represent the concepts of a "feature" versus a "task"? As [defined by Joel Spolsky][1], the owner of Fog Creek Software (which makes FogBugz), a feature is essentially a user-visible capability. To estimate the time to implement a feature, the developer should break the implementation into shor...
jQuery to replace broken images
|jquery|html|javascript|broken-image|
I have a web page that includes a bunch of images. Sometimes the image isn't available so a broken image is displayed in the clients browser. I want to use jQuery to get the set of images, filter it to broken images then replace the src.
|javascript|html|jquery|broken-image|
I have a web page that includes a bunch of images. Sometimes the image isn't available so a broken image is displayed in the clients browser. How do I use jQuery to get the set of images, filter it to broken images then replace the src?
My guess is that your DS does not point to your data-segment. Int21 Function 0x09 takes the string from DS:DX. try to replace your MOV DX, offset MSG by: LDS DX, MSG ; Check that, it's been ages since I've written 16 bit code. You can also load DX directly via a MOV from a general purpos...
My guess is that your DS does not point to your data-segment. Int21 Function 0x09 takes the string from DS:DX. Remember that DX is only a 16 bit register. To access data outside the 16 bit range you have to use segment registers. These are called DS and ES for data, CS for code and SS for the stack (there are FS ...
You can't make a service robust in this way - if the bank account is a single point of failure then when (not if) it fails, you lose. A bank account can't exist without a legal entity to own it, but that's just a detail here - other failures are that Amazon might pull SC2, or raise the price, or make an incompatible AP...
Java: How can I see what parts of my code are running the most?
|java|debugging|user-interface|
I am writing a simple checkers game in Java. When I mouse over the board my processor ramps up to 50% (100% on a core). I would like to find out what part of my code(assuming its my fault) is executing during this. I have tried debugging, but step-through debugging doesn't work very well in this case. Is ther...
I am writing a simple checkers game in Java. When I mouse over the board my processor ramps up to 50% (100% on a core). I would like to find out what part of my code(assuming its my fault) is executing during this. I have tried debugging, but step-through debugging doesn't work very well in this case. Is ther...
|java|user-interface|debugging|profiling|
The first method exists as a way to remind yourself not to do assignments in an IF statement, which could have disasterous consequences in some languages (C/C++). In C# you'll only get bitten by this if you're setting booleans.
The first method exists as a way to remind yourself not to do assignments in an IF statement, which could have disasterous consequences in some languages (C/C++). In C# you'll only get bitten by this if you're setting booleans. Potentially fatal C code: if (succeeded = TRUE) { // I could be in t...
You need them if you want to generate "objects" at runtime without pre allocate memory on the stack
session variable mixup in ASP.NET?
|asp.net|session|variables|
Is it possible for ASP.NET to mix up which user is associated with which session variable on the server? Are session variables immutably tied to the original user that created them across time, space & dimension?
Are you in Debug mode? I've had this problem when I was trying to do it in Release mode. It doesn't complain, it just doesn't hit the breakpoints.
It's all just indirection: The ability to not deal with data, but say "I'll direct you to some data, over there". You have the same concept in Java and C#, but only in reference format. The key differences are that references are effectively immutable signposts - they always point to something. This is useful, and e...
You know by testing. When you test, you're testing your both code and the compiler. You will find that the odds that you or the compiler writer have made an error are much smaller than the odds that you would make an error if you wrote the program in question in some assembly language.
You need to tell C++ what your base is going to be. Want to parse a hex number? Change your "is >> result" line to: is >> std::hex >> result; Putting a std::dec indicates decimal numbers, std::oct indicates octal.
include iomanip and then use std::setbase(0) is >> std::setbase(0) >> result;
Sometimes, it's just time to get a new job. There are certian poeple who just want you to "get it done". If you are ever in one of those situations, and I've been there, then just leave. But yeah, all that other stuff about future costs and such is good idea. I just think that most bosses lie to themselves becau...
Yes, they do need to be included. On the development machine you probably have SQL Server installed, which places those assemblies into the Global Assembly Cache. Whenever you build, Visual Studio just pulls from them from the GAC. It also assumes that the GAC of whatever computer it will be deployed on will also ha...
Try [PyMacs](http://pymacs.progiciels-bpi.ca/).
If you're having trouble loading the data from the DB to sort in C#, then I'm sure you'll be disappointed with any approach at doing it programmatically in the DB. When the server is going to sort, it's got to calculate the "perceived" order just as you would have -- every time. I'd suggest that you add an addition...