instruction stringlengths 0 30k ⌀ |
|---|
Is there anything out there (for Java specifically) that allow you to automatically test the behavior of an interface? As an example, let's say I have a bunch of tests for the Comparable interface, that should apply to anything that implements Comparable. What I'd like is to be able to include "ComparableTests" automat... |
Is there anything out there (for Java specifically) that allow you to automatically test the behavior of an interface? As an example, let's say I have a bunch of tests for the Comparable interface, that should apply to anything that implements Comparable. What I'd like is to be able to include "ComparableTests" automat... |
Create an abstract class that contains concrete versions of the tests and a abstract GetRepository method which returns IFooRepository.
Create three classes that derive from the abstract class, each of which implement GetRepository in a way returns the appropriate IFooRepository implementation.
Add all three classes ... |
Create an abstract class that contains concrete versions of the tests and a abstract GetRepository method which returns IFooRepository.
Create three classes that derive from the abstract class, each of which implement GetRepository in a way returns the appropriate IFooRepository implementation.
Add all three classes ... |
Create an abstract class that contains concrete versions of the tests and an abstract GetRepository method which returns IFooRepository.
Create three classes that derive from the abstract class, each of which implements GetRepository in a way that returns the appropriate IFooRepository implementation.
Add all three c... |
Something I've noticed - in the INFORMATION\_SCHEMA.COLUMNS view, CHARACTER\_MAXIMUM\_LENGTH gives a size of 2147483647 (2^31-1) for field types such as image, text and, I assume though I have not gotten around to checking, ntext.
This size is included in the output from this query, but it is invalid for these data ... |
Something I've noticed - in the INFORMATION\_SCHEMA.COLUMNS view, CHARACTER\_MAXIMUM\_LENGTH gives a size of 2147483647 (2^31-1) for field types such as image and text. ntext is 2^30-1 (being double-byte unicode and all).
This size is included in the output from this query, but it is invalid for these data types in ... |
Storing serialized data in a cookie is a very, very bad idea. Since users have complete control over cookie data, it's just too easy for them to use this mechanism to feed you malicious data. In other words: <i>any</i> weakness in your deserialization code becomes instantly exploitable (or at least a way to crash somet... |
Storing serialized data in a cookie is a very, very bad idea. Since users have complete control over cookie data, it's just too easy for them to use this mechanism to feed you malicious data. In other words: <i>any</i> weakness in your deserialization code becomes instantly exploitable (or at least a way to crash somet... |
Storing serialized data in a cookie is a very, very bad idea. Since users have complete control over cookie data, it's just too easy for them to use this mechanism to feed you malicious data. In other words: <i>any</i> weakness in your deserialization code becomes instantly exploitable (or at least a way to crash somet... |
Interfaces describe a contract for behavior. If you need to address some set of objects according to a behavioral pattern, interfaces are useful, not so much if you're simply describing the structure of objects. I think you need to have a good reason to use them, such as using a factory that creates behaviorally relate... |
[CssTidy](http://csstidy.sourceforge.net/) is the best CSS optimizer of which I am aware. It (configurably) strips comments, eliminates whitespaces, rewrites to use the many shorthand rules [nickf mentioned](http://stackoverflow.com/questions/65491/what-is-the-best-method-to-reduce-the-size-of-my-javascript-and-css-fil... |
You need to be careful when using this method. This may not affect you now, for this query, but please keep this in mind for future applications of this method.
The problem occurs when you have a NULL value in your list. When this happens, you will get incorrect results.
For example, if your original table look... |
How do I remove the passphrase for the SSH key without having to create a new key? |
|ssh|openssh|unix|passphrase|passwords| |
I set a passphrase when creating a new SSH key on my laptop. But, as I realise now, this is quite a PITA when you are trying to commit(git,svn) to a remote location over SSH many times in an hour.
One way I can think of is, delete my SSH keys and create new. Is there a way to remove the passphrase, while still keep... |
|unix|passwords|ssh|openssh|passphrase| |
I set a passphrase when creating a new SSH key on my laptop. But, as I realise now, this is quite a PITA when you are trying to commit(git,svn) to a remote location over SSH many times in an hour.
One way I can think of is, delete my SSH keys and create new. Is there a way to remove the passphrase, while still keep... |
Use both hands (and all ten fingers).
To maximize your typing speed, you need to use the opposite pinky to shift/ctrl etc. and you want to minimize the amount of time you have to "reacquire" the home position. My biggest increase in typing when coding was to really learn my IDE's keyboard shortcuts, since that elim... |
string foo = Convert.ToString(myint,base);
http://msdn.microsoft.com/en-us/library/14kwkz77.aspx
**EDIT**: My bad, this will throw an argument exception unless you pass in the specified bases (2, 8, 10, and 16)
Your probably SOL if you want to use a different base (but why???).
|
Where is the best place to store user related data in asp.net? |
|c#|asp.net| |
When a customer logs in to my site, I need to know their account id and their menu id. This lets me know what data they can see on a page and what menu they get. I don't want to have to read this data over and over. Should I store this in a session variable or customize the membership user and membership provider to... |
The cost of a function call depends on the architecture. x86 is considerably slower (a few clocks plus a clock or so per function argument) while 64-bit is much less because most function arguments are passed in registers instead of on the stack. |
Google is your friend. Search for "java socket programming tutorial" or something like that and you'll get lots of results, including the one suggested by zxcv as well as these:
[http://www.javaworld.com/javaworld/jw-12-1996/jw-12-sockets.html][1]
[http://www.cafeaulait.org/books/jnp/javanetexamples/index.html][... |
Rememebr if you change the trigger order, someone else could come by later and rearrange it again. And where would you document what the trigger order should be so a maintenance developer knows not to mess with the order or things will break? If two trigger tasks definitely must be performed in a specific order, the o... |
Break your code up into 2 processes. Run the first, then run your "long running process", then run the second process. |
1. iGoogle: News, RSS, Wether, New Films, E-Mail widgets
2. ToDoList: every day work aspects
3. Local MediaWiki, for local company knowleges
4. Smartphone MS Excel for personal finances. |
The profile system would probably suit your needs. |
While in your example it is weird that it does not work, take this similar one:
try
{
//Code 1
String s = "1|2";
//Code 2
}
catch
{
Console.WriteLine(s.Split('|')[1]);
}
This would cause th... |
Seanyboy's `IsCharAlphaA` answer is close. The best method is to use the W version like so:
Private Declare Function IsCharAlphaW Lib "user32" (ByVal cChar As Long) As Long
Public Property Get IsLetter(character As String) As Boolean
IsLetter = IsCharAlphaW(CLng(AscW(character)) And &HFFFF)
En... |
stat()
Much like a system stat, but in PHP. What you want to check is the mode value, much like you would out of any other call to stat in other languages (I.E. C/C++).
[http://us2.php.net/stat][1]
[1]: http://us2.php.net/stat |
@Jeremy,
I don't have enough rep to comment... but,
>>> print vars.__doc__
vars([object]) -> dictionary
Without arguments, equivalent to locals().
With an argument, equivalent to object.__dict__.
In otherwords, it essentially just wraps \_\_dict__ |
PHP GD, imagecreatefromstring( ); how to get the image dimensions? |
|php|image|upload|gd| |
Normally I used imagecreatefromjpeg and then getimagesize(), but with firefox 3 I need to go round this different. So now im using imagecreatefromstring( ), but how do I retreive the images dimesions now ? |
One hot title is _[Effective Prototyping for Software Makers][1]_. The issue is that there are several schools of thought.
- Rapid Prototyping. Use fancy tools; get
something done soon.
- Evolutionary Prototyping. Evolve from prototype to production.
Some of this is legacy thinking, based... |
**Database** MySQL<br/>
**Defect** Server will start up with damaged tables<br/>
**Description**<br/>
<br/>
If MySQL has a damaged table - from either being killed during a write or some other failure - it will quite happily start up and allow the user to carry on as if the problem does not exist. Granted it will p... |
**Database** Microsoft SQL Server 2005
**Defect** Lack of array type parameters
**Description**
Useful in searches, a lot of times you need to pass a series of values to be matched against. In SQL 2005 you can do a workaround by using CLR inside SQLServer. Given the usefulness it would make more sense to have ... |
The diff command has a -r option to recursively compare directories:
diff -r /develop /main |
[I read somewhere that answering your own questions is OK, so here goes :) ]
I tried this, and it worked pretty well
[/]$ cd /develop/
[/develop/]$ find | while read line; do diff -ruN "/main/$line" $line; done |less
You can choose to compare only specific files [e.g., only the .php ones] by editing t... |
NHibernate transaction and race condition |
|sql-server|sql|nhibernate| |
I've got an ASP.NET app using NHibernate to transactionally update a few tables upon a user action. There is a date range involved whereby only one entry to a table 'Booking' can be made such that exclusive dates are specified.
My problem is how to prevent a race condition whereby two user actions occur almost simul... |
|sql|sql-server|nhibernate| |
I've got an ASP.NET app using NHibernate to transactionally update a few tables upon a user action. There is a date range involved whereby only one entry to a table 'Booking' can be made such that exclusive dates are specified.
My problem is how to prevent a race condition whereby two user actions occur almost simul... |
On the 'easy to translate' theme, there's also [Lua][1].
It's somewhat similar to Javascript, but more 'orthogonal' (closer to functional roots).
The heavy orientation to 'pure' programming theory has made it really small and fast. It's the fastest scripting language around, and the JIT runs circles around the n... |
Surprisingly enough, my all-time favorite, of ones I've encountered in the wild, is Dell's, on their **[IdeaStorm][1]**.
If you click on a control that requires a login (to vote up an idea, for example), it automatically refocuses on the login element. If you don't already have an account you can hit the 'register' ... |
Surprisingly enough, my all-time favorite, of ones I've encountered in the wild, is Dell's, on their **[IdeaStorm][1]**.
If you click on a control that requires a login (to vote up an idea, for example), it automatically refocuses on the login element. If you don't already have an account you can hit the 'register' ... |
Not without swapping widget trees in and out, which I don't think can be done cleanly with Tk. Other toolkits can do this a little more elegantly.
- COM/VB/MFC can do this with an ActiveX control - you can hide/show multiple ActiveX controls in the same region. Any of the containers will let you do this by chang... |
I believe that Bryan's answer is probably the best general solution. However, you may also want to look at the **place** geometry manager. The **place** geometry manager lets you specify the exact size and position of the widget... which can get tedious quickly, but will get the job done.
|
I believe that Bryan's answer is probably the best general solution. However, you may also want to look at the <a>[place][1] geometry manager. The **place** geometry manager lets you specify the exact size and position of the widget... which can get tedious quickly, but will get the job done.
[1]: http://www.p... |
Andrew Connell's latest book (Professional SharePoint 2007 Web Content Management Development) has an entire chapter dedicated to imporving performance of SharePoint sites.
Key topics it covers are Caching, Limiting page load (particularly how to remove CORE.js if it's not needed), working with Disposable objects an... |
I believe that the future development model for "Web" applications will more akin to the current model of desktop application development. By which I mean that tomorrow's Web apps won't be HTML/AJAX monstrosities that are difficult and expensive to maintain, debug and test, they'll instead be developed with real langua... |
I believe that the future development model for "Web" applications will more akin to the current model of desktop application development. By which I mean that tomorrow's Web apps won't be HTML/AJAX efforts that are difficult and expensive to maintain, debug and test, they'll instead be developed with compiled language... |
Out-of-band communication is the way to go.
For instance, sending a temporary password in SMS may be acceptable (depending on the system). I've seen this implemented often by telecoms, where SMS is cheap/free/part of business, and the user's cellphone number is pre-registered...
Banks often require a phone call t... |
What is the best online book service for software development references? |
|reference|ebook| |
I'm a member of ACM, and I have limited access to both Books 24x7 and Safari Books Online, however if I was interested in moving up to a full account for greater access to other books what online book service would you recommend? |
What is the best way to paginate results in MS SQLServer |
|sql-server|pagination|paging| |
What is the best way (performance wise) to paginate results in SQL Server 2000, 2005, 2008 if you also want to get the total number of results (before paginating)? |
VSS has a pretty comprehensive set of command line arguments. The best way I know is to write a batch file to:
1 - Get Latest to the local system (presumably a clean build machine)
2 - Push the newly-updated local files to your FTP site. |
jQuery has several plugins available for doing graphics. Raphael is a plugin that uses SVG (for Firefox and other browsers that support SVG), and VML for the IE products. In addition, jQuery provides a great architecture for javascript projects with plenty of support and plug-ins.
Raphael is available here: [http:... |
Transform .HBM model to annotated pojos |
|java|hibernate|domain-driven-design|hbm|mda| |
We have our domain model declared in rusty old hbm files, we wish to move to POJOs annotated with the javax.persistence.* annotations.
Has anyone had experience doing so?
Are there tools that we could employ? |
This seems to work:
`
select your_column
from your_table
order by
case when isnumeric(your_column) = 1 then your_column else 999999999 end,
your_column
`
|
how to override Ctrl+V in TinyMCE |
|overriding|tinymce|keypress| |
I need to cleanup the HTML of pasted text into TinyMCE by passing it to a webservice and then getting it back into the textarea.
So I need to override the Ctrl+V in TinyMCE to caputre the text, do a background request, and on return continue with whatever the paste handler was for TinyMCE.
First off, where is TinyMCE... |
Awesome C# scripting language - [Script.Net][1]
[1]: http://www.codeplex.com/scriptdotnet |
And you can use
:cmap WQ wq
as well.
E.g. I have
cmap h tab help
in my `.vimrc` which means opening help pages in a new tab. |
Are you setting the Mime type to "text/html"? You should have something like this:
BodyPart bp = new MimeBodyPart();
bp.setContent(message,"text/html");
|
Using **kwargs with SimpleXMLRPCServer in python |
|python|simplexmlrpcserver|xmlrpclib| |
I have a class that I wish to expose as a remote service using pythons SimpleXMLRPCServer. The server startup looks like this:
server = SimpleXMLRPCServer((serverSettings.LISTEN_IP,serverSettings.LISTEN_PORT))
service = Service()
server.register_instance(service)
server.serve_forever()
I th... |
I have a class that I wish to expose as a remote service using pythons SimpleXMLRPCServer. The server startup looks like this:
server = SimpleXMLRPCServer((serverSettings.LISTEN_IP,serverSettings.LISTEN_PORT))
service = Service()
server.register_instance(service)
server.serve_forever()
I th... |
To test the front-end then YSlow is great for getting statistics for how long your pages take to load from a user perspective. It breaks down into stats for each specfic HTTP request, the time it took, etc. Get it at <http://developer.yahoo.com/yslow/>
Firebug, of course, also is essential. You can profile your JS e... |
You need to look at what you are trying to do, and if RTTI will satisfy your requirements. I've implemented by own pseudo-reflection for very specific purposed. One was to be able to flexibly configure what was output from a simulation. It required adding some boilerplate to the classes that would be output:
... |
It's pretty easy really. Let's assume you're editing a blog post.
Here's your 2 actions for new/edit:
public class BlogController : Controller
{
public ActionResult New()
{
var post = new Post();
return View("Edit", post);
}
public ActionResult... |
Is SQL Server Bulk Insert Transactional? |
|sql-server|transactions|bulkinsert| |
If I run the following query in SQL Server 2000 Query Analyzer:
BULK INSERT OurTable
FROM 'c:\OurTable.txt'
WITH (CODEPAGE = 'RAW', DATAFILETYPE = 'char', FIELDTERMINATOR = '\t', ROWS_PER_BATCH = 10000, TABLOCK)
On a text file that conforms to OurTable's schema for 40 lines, but then changes fo... |
How does jstl's sql tag work? |
|java|jsp|web-applications|jstl| |
I'm using the following code to query a database from my jsp, but I'd like to know more about what's happening behind the scenes.
These are my two primary questions.
Does the tag access the ResultSet directly, or is the query result being stored in a datastructure in memory?
When is the connection closed?
... |
Run your long-running process in the middle of your current process and wait for it to complete. |
@burkhard has the question as to why answered properly, but as a note I wanted to add, while your recommended solution example is good 99.9999+% of time, it is not good practice, it is far safer to either check for null before using something instantiate within the try block, or initialize the variable to something ins... |
wget seems to manage it with the --limit-rate option. Here's from the man page:
> Note that Wget implements the limiting
> by sleeping the appropriate amount of
> time after a network read that took
> less time than specified by the
> rate. Eventually this strategy causes
> the TCP transfer to slow down to
> ... |
This could be improved, but it seems to do the job (Python):
import math, random
def get_pool(items, y, z):
slots = y*z
use_each_times = slots/len(items)
exceptions = slots - use_each_times*len(items)
if (use_each_times > y or
... |
This isn't solely a .NET thing, the same problem occurs in Java quite often.
Unless it's a completely obvious requirement, I vote for not using interfaces and simply refactoring when the need becomes clear.
The pragmatic approach says to just do the *simplest thing that could possibly work*, and don't get caught ... |
Some posts mention memory concerns. That might be a good reason to shun std::string, but char* probably is not the best replacement. It's still an OO language. Your own string class is probably better than a char*. It may even be more efficient - you can apply the Small String Optimization, for instance.
In my case... |
Try this - overload new.
struct MY_STRUCT
{
int n1;
int n2;
};
class CMyStruct : public MY_STRUCT
{
public:
CMyStruct()
{
// whatever
}
void* new(size_t size)
{
// dangerous
return... |
Try this - overload new.
EDIT: I should add - This is safe because the memory is zeroed before *any* constructors are called.
struct MY_STRUCT
{
int n1;
int n2;
};
class CMyStruct : public MY_STRUCT
{
public:
CMyStruct()
{
// whate... |
Try this - overload new.
EDIT: I should add - This is safe because the memory is zeroed before *any* constructors are called. Big flaw - only works if object is dynamically allocated.
struct MY_STRUCT
{
int n1;
int n2;
};
class CMyStruct : public MY_STRUCT
{
pu... |
Can you elaborate on what you don't like about Apache POI? I've been using POI for years now and haven't found anything that it couldn't do with a tweak here or there or taking an creative approach. IMHO, it's the best open-source (and free) Excel generation/reporting framework out there.
If you are willing to p... |
I have Books 24x7, it has a great range of books and the search functionality works well. It also gives you recommendations from other users, and if other people from your organization join then it tells you about books they have recommended. |
Why isn't there a standard memswap function. |
|c| |