instruction stringlengths 0 30k ⌀ |
|---|
[This post][1] by John Resig says that there are shells for [Tamarin (Firefox 4?)][4] and [JavaScriptCore (Safari 3)][5]. I'm not sure if they have auto completion though.
[1]: http://ejohn.org/blog/javascript-engine-speeds/
[4]: http://www.mozilla.org/projects/tamarin/
[5]: http://webkit.org/projects/javasc... |
That's exactly what we're doing. We have a Utility project which has some non project specific usefull functions. We increase the version manually (minor), build the project in Release version, sign it and put it to a shared location.
People then use the specific version of the library.
If some usefull methods ar... |
Asking a Generic Method to Throw Specific Exception Type on FAIL |
|exception|generics| |
Right, I know I am totally going to look an idiot with this one, but my brain is just _not_ kicking in to gear this morning.
I want to have a method where I can say "if it goes bad, come back with this type of Exception", right?
For example, something like (**and this doesn't work**):
static ExType Tes... |
|exception|generics|c#| |
|c#|exception|generics| |
Right, I know I am totally going to look an idiot with this one, but my brain is just _not_ kicking in to gear this morning.
I want to have a method where I can say "if it goes bad, come back with this type of Exception", right?
For example, something like (**and this doesn't work**):
static ExType Tes... |
In my work I deal mostly with C# code nowadays, with a sprinkle of java from time to time. What I absolutely love about Eclipse (and I know people using it daily love it even more) is a sophisticated code formatter, able to mould code into any coding standard one might imagine. Is there such a tool for C#? Visual Studi... |
|c#|build-automation|formatting| |
|c#|formatting|build-automation| |
In my work I deal mostly with C# code nowadays, with a sprinkle of java from time to time. What I absolutely love about Eclipse (and I know people using it daily love it even more) is a sophisticated code formatter, able to mould code into any coding standard one might imagine. Is there such a tool for C#? Visual Studi... |
Most efficient code for the first 10000 prime numbers? |
|efficiency|puzzle|number|challenge|prime| |
I want to print the first 10000 prime numbers.
Can anyone give me the most efficient code for this?
Clarifications:
1. It does not matter if your code is inefficient for n >10000.
2. The size of the code does not matter.
3. You cannot just hard code the values in any manner. |
|efficiency|puzzle|numbers|challenge|prime| |
|puzzle|efficiency|numbers|challenge|primes| |
|puzzle|efficiency|codes|numbers|challenge|primes| |
DELETE Statement hangs on SQL Server for no apparent reason |
|sql-server-2005|sql|delete|hang| |
We have a simple delete statement that looks like this:
DELETE FROM tablename WHERE pk = 12345
This just hangs, no timeout, no nothing.
We've looked at the execution plan, and it consists of many lookups on related tables to ensure no foreign keys would trip up the delete, but we've verified that none of t... |
Here is how to to it in powershell , from [hanselman][1]:
$userToFind = $args[0]
$administratorsAccount = Get-WmiObject Win32_Group -filter "LocalAccount=True AND SID='S-1-5-32-544'"
$administratorQuery = "GroupComponent = `"Win32_Group.Domain='" + $administratorsAccount.Domain + "',NAME='" + $admini... |
You could loop the groups like i did in this answer:
<http://stackoverflow.com/questions/45437/determining-members-of-local-groups-via-c#45458>
After reading some more, the easiest thing would be to use the `System.DirectoryServices.AccountManagement` namespace. Here is how it can be used:
<http://www.leastpri... |
They took forever to load up and get going in the browser, and then for a lot of people they didn't work. When they finally did load, the interfaces were ugly and clunky. I think the poor user experience was a big step towards making applets obsolete.
So to answer the original question I have a question of my own - ... |
Here are mine (developer centric):
1. [FireBug][1] - a myriad of productivity enhancing tools, includes javascript debugger, DOM inspector, allows you to edit the CSS/HTML on the fly which is highly valuable for troubleshooing layout and display problems.
2. [Web Developer][2] - again another great developer pr... |
In my opinion, the bias should be in favour of CSS over IE6 - i.e. unless there's an insanely good reason (e.g. your site is only targetted at people using IE6, which would be *weird*), it's better to 'alienate' people using IE6 rather than people with poor vision and/or automated user agents. Usage of IE6 is decreasin... |
This may be a silly answer, but are you sure the code is running on a machine with .NET Framework 3.5? |
On windows parsing the output of IPConfig will get you the default gateway, without waiting for a trace. |
I do my profiles by creating two class: cProfile and cProfileManager.
cProfileManager will hold all the data that resulted from cProfile.
cProfile with have the following requirements:
- cProfile have a constructor which initializes the current time.
- cProfile have a deconstructor which sends the total time... |
I do my profiles by creating two class: cProfile and cProfileManager.
cProfileManager will hold all the data that resulted from cProfile.
cProfile with have the following requirements:
- cProfile have a constructor which initializes the current time.
- cProfile have a deconstructor which sends the total time... |
there's always System.Web.Security.Membership.GeneratePassword(int length, int numberOfNonAlphanumericCharacters)
|
Can you "ignore" a file in Perforce? |
|svn|version-control|perforce| |
I sometimes use the feature 'Reconcile Offline Work...' found in Perforce's P4V IDE to sync up any files that I have been working on while disconnected from the P4 depot. It launches another window that performs a 'Folder Diff'.
I have files I never want to check in to source control (like ones found in bin folder s... |
I've tried several Application Blocks of Entrerprise Lib 3.1 (May 2007) and here are somme comments :
Caching Application Block : Less interesting than System.Web.Caching in simple scenarios (like In-Memory caching)
Exception Handling & Logging : Overcomplicated. NLog or Log4Net are better solutions.
I looked at... |
First I would say, don't rewrite all your tests just to suit the latest fad. Junit3 works perfectly well, and the introduction of annotations in 4 doesn't buy you very much (in my opinion). It is much more important that you guys *write* tests, and it sounds like you do.
Use whatever seems most natural and helps... |
First I would say, don't rewrite all your tests just to suit the latest fad. Junit3 works perfectly well, and the introduction of annotations in 4 doesn't buy you very much (in my opinion). It is much more important that you guys *write* tests, and it sounds like you do.
Use whatever seems most natural and helps... |
First I would say, don't rewrite all your tests just to suit the latest fad. Junit3 works perfectly well, and the introduction of annotations in 4 doesn't buy you very much (in my opinion). It is much more important that you guys *write* tests, and it sounds like you do.
Use whatever seems most natural and helps... |
Actually, the best add-on for developers to IE would be [Fiddler](http://www.fiddlertool.com/fiddler/version.asp). It has a number of features that the other browsers possess. |
You could try something like this.
It's taken from sun's page on [Character Sets and Encodings][1].
I think this has to be the very first line in your jsp.
<%@ page contentType="text/html; charset=UTF-8" %>
[1]: http://java.sun.com/j2ee/1.4/docs/tutorial/doc/WebI18N5.html |
We maintain a library for use with a very large codebase (tens of millions of loc). We use both asserts and if-conditions, often like follows:
function foo(int index)
{
if (index > MAX_INDEX) {
assert(FALSE);
return (STATUS_INVALID_ARG);
}
...
}
... |
For internal functions, ones that only you will use, use **asserts** only. The asserts will help catch bugs during your testing, but won't hamper performance in production.
Check inputs that originate externally with **if-conditions**. By externally, that's anywhere outside the code that you/your team control and ... |
Here's one simple check that you can perform. It uses generated random numbers to estimate Pi. It's not proof of randomness, but poor RNGs typically don't do well on it (they will return something like 2.5 or 3.8 rather ~3.14).
Ideally this would be just one of many tests that you would run to check randomness.
... |
I think it depends on your focus. A few years ago I purchased the set of Art of Computer Programming by Donald Knuth. After looking at the books I realized pretty much everything is calculus proofs. If you're interested in developing your own generic algorithms and proofs for them, then I recommend being able to unders... |
I don't have an answer to the tool question, but I will say it is fairly easy in any text processing language (perl/python/etc) to randomly generate sentences from a BNF grammar, and slightly more verbose in a bigger language (Java/C/etc), but it shouldn't be too hard to roll your own.
The problem with this, of cour... |
I can think of three options:
Implement RFC 2217
------------------
[RFC 2217][1] covers a com port to TCP/IP standard that allows a client on one system to emulate a serial port to the local programs, while transparently sending and receiving data and control signals to a server on another system which actually... |
wrap it in a tran use an holdlock + updlock in the select
example
begin tran
select * from
SomeTable (holdlock,updlock)
where ....
processing here
commit
|
I do my profiles by creating two class: cProfile and cProfileManager.
cProfileManager will hold all the data that resulted from cProfile.
cProfile with have the following requirements:
- cProfile have a constructor which initializes the current time.
- cProfile have a deconstructor which sends the total time... |
I've done something similar with a SourceSafe dialog, which I posted on my blog. Basically, I used either Spy++ or Winspector to find out the window class name, and make Win32 calls to do stuff with the window. I've put the source on my blog: [http://harriyott.com/2006/07/sourcesafe-cant-leave-well-alone.aspx][1]
... |
Are you trying to [activate][1] the word app? If you want full control, you need to automate word from your vb.net app. Check here for some samples: [1][2], [2][3]
[1]: http://msdn.microsoft.com/en-us/library/dyz95fhy(VS.80).aspx
[2]: http://support.microsoft.com/?kbid=303294
[3]: http://support.microsoft.... |
It depends on what you want to do. If you have some specific tasks that you are interested in accomplishing then look at languages that are best for those types of tasks. The best way to learn a language is to actually use it.
|
I think that most convenient way is to add App blocks\EntLib as a solution items. That way they will not be recompiled each time you build your project (they will not participate in build process at all) and you can easily access their source code\set breakpoint etc. |
There is no project template that will do this for you. You might as well read up and start with a usercontrol. |
I think it's important to schedule time for dealing technical debt if you are trying to make up for old sins, but I also think you should not make this a habit. Once you clean up the mess you should avoid putting your project into more debt, unless you have good reasons for doing so.
Actively managing it like Mike ... |
What is the possible mimetype hierachy of an email message? |
|email|mime-types| |
I'm working with a snippet of code that recursively calls itself and tries to pull out a mime type part of "text/html" from an email (if it exists) for further processing. The "text/html" could exist inside other content such as "multipart/alternative" so I'm trying to find out if there is a defined hierarchy for email... |
It's verbose, but you can do it like this:
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_base_of.hpp>
struct base {};
struct derived : base {};
struct not_derived {};
template <typename ImplementationClass, class Enable = void>
class WrapperClass;
... |
It's verbose, but you can do it like this:
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_base_of.hpp>
struct base {};
struct derived : base {};
struct not_derived {};
template <typename ImplementationClass, class Enable = void>
class WrapperClass;
... |
I'd recommend a [Safari Books Online][1] subscription as well.
Oh, and gallons of coffee.
[1]: http://safari.oreilly.com/ |
This is the shortcut method:
$myPerson = "" | Select-Object First,Last,Phone |
In the UK and in US there is a legal requirement for favouring CSS layouts over Tables. Both Section 508 (US) and the Disability Discrimination Act (UK) cover accessibility standards for users with limited vision.
In the UK the legislation extends so far as to actually make it illegal to commercially produce a si... |
Based up Scott's links, the information about the current CF version can be found in the registry of the device at:
HKEY_LOCAL_MACHINE\Software\Microsoft\.NETCompactFramework
Versions for CF 2.0 are:
CompactFrameworks 2.0 RTM - 2.0.5238.00
CompactFrameworks 2.0 SP1 - 2.0.6129.00
CompactFram... |
IIS is a destination. The configuration issue is in whatever is doing the call (acting like a client). If you are using the built-in .Net communication methods you will need to make the adjustment inside of ... Wait for it ... Internet Explorer.
Yep! That little bugger has bitten me more times than I care to re... |
IIS is a destination. The configuration issue is in whatever is doing the call (acting like a client). If you are using the built-in .Net communication methods you will need to make the adjustment inside of ... Wait for it ... Internet Explorer.
Yep! That little bugger has bitten me more times than I care to re... |
SVN plugins for Eclipse - Subclipse vs. Subversive |
|svn|eclipse|subclipse|subversive| |
SVN in Eclipse is spread into 2 camps. The SVN people have developed a plugin called [Subclipse][1]. The Eclipse people have a plugin called [Subversive][2]. Broadly speaking they both do the same things. What are the advantages and disadvantages of each?
[1]: http://subclipse.tigris.org/
[2]: http://www.eclips... |
Here's one simple check that you can perform. It uses generated random numbers to estimate Pi. It's not proof of randomness, but poor RNGs typically don't do well on it (they will return something like 2.5 or 3.8 rather ~3.14).
Ideally this would be just one of many tests that you would run to check randomness.
... |
`SimpleDateFormat` already does this with the `parse()` method. |
`SimpleDateFormat` already does this with the `parse()` method.
If you need to parse multiple dates from a single string, start with a regex (even if it matches too leniently), and use `parse()` on all the potential matches found by the regex. |
You could encode the binary data using base64 and put it into a CDATA section; the below article is a pretty good one on the subject.
[Handling Binary Data in XML Documents][1]
[1]: http://www.xml.com/pub/a/98/07/binary/binary.html |
I installed .NET 3.5 SP1 and it corrected the problem |
Determine size of page via HttpModule |
|asp.net| |
Here's an easy one for you:
I'm currently logging request duration via an HttpModule and I'd like to find out the number of bytes each page is as well.
HttpContext.Current.Response.OutputStream.Length throws a NotSupportedException.
What's an easy way to do this? |
VB6 Runtime Type Retrival |
|vb6|runtime| |
How can you obtain the Type (the name as a string is sufficient) of an Object in VB6 at runtime?
i.e. something like:
If Typeof(foobar) = "CommandButton" Then ... |
How can you obtain the Type (the name as a string is sufficient) of an Object in VB6 at runtime?
i.e. something like:
If Typeof(foobar) = "CommandButton" Then ...
**/EDIT:** to clarify, I need to check on Dynamic objects, so using TypeName, will (in my case) always return "Object". What I am looking for is... |
How can you obtain the Type (the name as a string is sufficient) of an Object in VB6 at runtime?
i.e. something like:
If Typeof(foobar) = "CommandButton" Then ...
**/EDIT:** to clarify, I need to check on Dynamically Typed objects. An example:
Dim y As Object
Set y = CreateObject("So... |
T-SQL trim   (and other non-alphanumeric characters) |
|sql|sql-server| |
We have some input data that sometimes appears with   characters on the end.
The data comes in from the source system as varchar() and our attempts to cast as decimal fail b/c of these characters.
Ltrim and Rtrim don't remove the characters, so we're forced to do something like:
UPDATE myTable
SET... |
You can buy templates from ieee and other places, but I have always ended up making my own.
For a technical spec, "[Code Complete][1]" by Steve McDonnell has a good checklist, you can draw some info from that. At my last job, I just made a template out of his section headers, and tweaked it from there.
As far as... |
Not a template, but Joel has written a [couple of articles][1] on writing a functional spec. He also has [sample here][2].
[1]: http://www.joelonsoftware.com/articles/fog0000000036.html
[2]: http://www.joelonsoftware.com/articles/WhatTimeIsIt.html |
It's verbose, but you can do it like this:
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_base_of.hpp>
struct base {};
template <typename ImplementationClass, class Enable = void>
class WrapperClass;
template <typename ImplementationClass>
class WrapperC... |
You would have to consider the target application that will host the control. If it is a line of business application I've [heard][1] that WPF doesn't offer great advantages over Forms. According to [this][2] blog entry however, the author believes that the killer WPF is a LOB application that leverages the graphical p... |
After posting this question I spoke with a coworker who suggested I read article:
http://www.codinghorror.com/blog/archives/000968.html
In short, it advocates that programmers be more aware of branching. It helped me to see there is no right way to go about it. For our team we will have a trunk and two long term... |
After posting this question I spoke with a coworker who suggested I read the article:
http://www.codinghorror.com/blog/archives/000968.html
In short, it advocates that programmers be more aware of branching. It helped me to see there is no right way to go about organizing our repository. For our team we will hav... |
I'm not sure this is what you're looking for, but there's an old program called [ELIZA][1] which could hold a conversation by taking what you said and spitting it back at you after performing some simple textual transformations.
If I remember correctly, many people were convinced that they were "talking" to a real p... |
You could encode the binary data using base64 and put it into a Base64 element; the below article is a pretty good one on the subject.
[Handling Binary Data in XML Documents][1]
[1]: http://www.xml.com/pub/a/98/07/binary/binary.html |
You can do a lot without going nuts on 3rd-party products and mshtml (i.e. interop). use the System.Windows.Forms.WebBrowser. From there, you can do such things as "GetElementById" on an HtmlDocument or "GetElementsByTagName" on HtmlElements. If you want to actually inteface with the browser (simulate button clicks ... |
How can I get a fixed-position menu like slashdot's comment filtration menu |
|javascript|css| |
Slashdot has a little widget that allows you to tweak your comment threshold to filter out down-modded comments. It will be in one place if you scroll to the top of the page, and as you scroll down, at some point, where its original home is about to scroll off the page, it will switch to fixed position, and stay on yo... |
The great thing about using the Rails ActiveRecord as a model in MVC is that it gives you an automatic ORM (Object Relational Mapper) and easy way to create associations between models. As you have pointed out, MVC can sometimes be lacking.
Therefore, for some complex transaction involving many models, I'd suggest t... |
Sorry, I have myself found the answer on Google (literaly):
http://code.google.com/p/xml2json-xslt/
|
I have also used [Debug Bar](http://www.debugbar.com/). |
* **HttpContent.Current** will always give you access to the current context's Request/Response/etc., even when you don't have access to the Page's properties (e.g., from a loosley-coupled helper class).
* You can continue executing code on the same page after redirecting the user to another one by calling **Response.... |