instruction stringlengths 0 30k ⌀ |
|---|
|python|metaclass| |
How do I add an instance method to a class using a metaclass (yes I do need to use a metaclass)? The following kind of works, but the func_name will still be "foo":
def bar(self):
print "bar"
class MetaFoo(type):
__new__(cls, name, bases, dict):
dict["foobar"] = bar
... |
The AWT code in IKVM is fairly easy to read and edit. I'd recommend you look for the methods that you are using that throw that exception, and then implement them. I've done this several times before with IKVM's AWT implementation and found it easy to do for background/server related functions. Its much less usable ... |
How do I estimate the size of a Lucene index? |
|lucene| |
|sql|mysql|duplicate| |
How to efficiently SQL select newest entries from a MySQL database? |
|sql|mysql| |
I have a database containing stock price history. I want to select most recent prices for every stock that is listed. I know PostreSQL has a <a href="http://stackoverflow.com/questions/25224/joining-latest-of-various-usermetadata-tags-to-user-rows#27159">DISTINCT ON</a> statement that would suit ideally here.
Table ... |
[NDepend][1] for .net
[1]: http://www.ndepend.com/ |
Make separate serializer classes (a-la XmlSerializer) for each mode, inherit or incapsulate to avoid duplication.
Use attributes on properties to mark whether and how they should be serialised in specific mode |
using your webservice get your XML and create an XML Document from it, You can then set the Source of your xmlDataProvider to the XMLDocument you got from the service.
I'm not at a pc with visual studio to test it but it should be possible for you to do this.
The steps are as you mentioned in your question:
<pre... |
The KB article linked in [Joe's post][1] is great for determining which service packs have been installed for any version. Along those same lines, [this KB article][2] maps version numbers to specific hotfixes and cumulative updates, but it only applies to SQL05 SP2 and up.
[1]: http://stackoverflow.com/questio... |
>Is there a way that would allow you to add buttons or forms to the browser UI, since this is not possible with an Input manager or Service menu?
Actually, with an InputManager, it *would* be possible. SIMBL, the common technique for Safari extensions, is simply a wrapper around InputManagers — it stands for **S**ma... |
As python is in kind of an transition phase towards python 3 with breaking backward compatibility I don't think it is a good idea to go python 3 only. Based on the [time line][1] there will be at least one or two following releases of the 2.x series after 2.6/3.0 in october.
Beside not having python 3 available on y... |
It looks like I am going to have to write this myself. |
It looks like I am going to have to write this myself.
[https://sourceforge.net/projects/wagon-sf/][1]
[1]: https://sourceforge.net/projects/wagon-sf/ |
Using the same setup as yours (ie separate web and database server), I've seen it from time to time and it has always been a connection problem between the servers - typically when the database server is being rebooted but sometimes when there's a comms problem somewhere in the system. I've not seen it triggered by any... |
I think it's an XML based template system that outputs HTML. I think it's internal to MS only. |
How can I generate database tables from C# classes? |
|c#|code-generation|data-access| |
Does anyone know a way to auto-generate database tables for a given class? I'm not looking for an entire persistence layer - I already have a data access solution I'm using, but I suddenly have to store a lot of information from a large number of classes and I really don't want to have to create all these tables by ha... |
You appear to think that REST is a distinct protocol.
REST is not a protocol. It is a design style for HTTP-based applications.
So, your a writing an HTTP application. Are the headers encrypted? Yes, if you are using the HTTPS (HTTP over SSL) protocol instead of plain HTTP.
Having certificates on both sides is... |
In Firefox, you could do something like this:
javascript:alert(
document.getSelection().match(/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/g)
.join("\n"))
How this works:
- Gets the selection text from the browser ("document.getSelection()" in FF, in IE it would be "document.selection.createRang... |
Take a look at this article: [http://en.wikipedia.org/wiki/Floating_point][1]. Note that there is a sign bit, even if the value is zero.
[1]: http://en.wikipedia.org/wiki/Floating_point |
You need a Base64-encoded Type 1 message. <a href="http://curl.haxx.se/rfc/ntlm.html">Read this</a>. |
If you are not completely allergic to Perl, then [XML::Twig][1] comes with a tool named [xml_split][2] that can split a document, producing well-formed XML section. You can split on a level of the tree, by size or on an XPath expression.
[1]: http://search.cpan.org/dist/XML-Twig/ "CPAN page for the module"
[... |
In IEEE floating point 0 and -0 are both distinct values, from [here][1] under "Special Values":
> Note that -0 and +0 are distinct
> values, though they both compare as
> equal.
[1]: http://steve.hollasch.net/cgindex/coding/ieeefloat.html |
Cast to object in the overload method:
public static bool operator ==(Foo foo1, Foo foo2) {
if ((object) foo1 == null) return (object) foo2 == null;
return foo1.Equals(foo2);
}
|
If you're talking HTML you can use <input type="image" src="myfile.png" />
Specifications <a href="http://www.w3.org/TR/html401/interact/forms.html">here</a> |
Use ReferenceEquals:
Foo foo1 = null;
Foo foo2 = new Foo();
Assert.IsFalse(foo1 == foo2);
public static bool operator ==(Foo foo1, Foo foo2) {
if (object.ReferenceEquals(null, foo1))
return object.ReferenceEquals(null, foo2);
return foo1.Equals(foo2);
}
|
using pictures as buttons?is this possible? |
|user-interface| |
John Dyer is right on about the NET command for controlling Windows services. I would add that you can get the service name from the Services MMC snap-in (just run services.msc). If you installed a default instance of SQL Server 2005 that would be "SQL Server (MSSQLSERVER)". If you installed a named instance the nam... |
I would recommend opening the Services MMC snap-in (just run services.msc), finding the service and modifying the properties of the service to restart automatically when the service fails.
1. Open the Services MMC snap-in (run
services.msc)
2. Locate the service. If you
installed a default instance of ... |
[Perl](http://www.perl.org/about/style-guide.html) |
I feel the accepted answer was one of the weakest (http://stackoverflow.com/questions/64333/what-is-the-downside-to-test-driven-development#67184), and the most up-modded answer smells of someone who might be writing over specified tests.
> Big time investment: for the simple
> case you lose about 20% of the actual... |
Is there a known math formula that I can use to estimate the size of a new Lucene index? I know how many fields I want to have indexed, and the size of each field. And, I know how many items will be indexed. So, once these are processed by Lucene, how does it translate into bytes? |
Instead of using String.valueOf I'd use .toString(); it avoids some of the auto boxing described by @johnathan.holland
The javadoc says that valueOf returns the same thing as Integer.toString().
List<Integer> oldList = ...
List<String> newList = new List<String>(oldList.size());
for (Integer myI... |
Instead of using String.valueOf I'd use .toString(); it avoids some of the auto boxing described by @johnathan.holland
The javadoc says that valueOf returns the same thing as Integer.toString().
List<Integer> oldList = ...
List<String> newList = new ArrayList<String>(oldList.size());
for (Intege... |
Software Tools by by Brian W. Kernighan and P. J. Plauger
It had a profound influence on how I write software.
|
How do you get the logged in Windows domain account from an ASP.NET application? |
|authentication|asp.net| |
We have an ASP.NET application that manages it's own User, Roles and Permission database and we have recently added a field to the User table to hold the Windows domain account.
I would like to make it so that the user doesn't have to **physically** log in to our application, but rather would be automatically log... |
|authentication|asp.net|ntlm| |
We have an ASP.NET application that manages it's own User, Roles and Permission database and we have recently added a field to the User table to hold the Windows domain account.
I would like to make it so that the user doesn't have to **physically** log in to our application, but rather would be automatically log... |
|asp.net|ntlm|authentication| |
|asp.net|webforms|authentication|ntlm| |
We have an ASP.NET application that manages it's own User, Roles and Permission database and we have recently added a field to the User table to hold the Windows domain account.
I would like to make it so that the user doesn't have to **physically** log in to our application, but rather would be automatically log... |
You might want to supplement your current offline backup scheme with [MySQL replication][1].
Then if you have a hardware failure you can just swap machines. If you catch the failure quickly you're users won't even notice any downtime or data loss.
[1]: http://dev.mysql.com/doc/refman/5.0/en/replication.htm... |
I'd suggest that you emit the web resources as a dynamic javascript associative array.
Server side code:
StringBuilder script = new StringBuilder();
script.Append("var imgResources = {};");
script.AppendFormat("imgResources['{0}'] = '{1}';",
"drophint",
Page.ClientScript.GetWebRe... |
A few internet searches led me to http://www.microsoft.com/backstage/bkst_column_46.mspx, but it was a dead link. Fortunately, it was archived on the Wayback Machine and you can read it here: [http://web.archive.org/web/20040803120105/http://www.microsoft.com/backstage/bkst_column_46.mspx][2]
The .MSPX extension is ... |
A few internet searches led me to http://www.microsoft.com/backstage/bkst_column_46.mspx, but it was a dead link. Fortunately, it was archived on the Wayback Machine and you can read it here:
http://web.archive.org/web/20040803120105/http://www.microsoft.com/backstage/bkst_column_46.mspx
The .MSPX extension is p... |
Every post so far leaves the memory management for the programmer. This can and should be avoided. ReaperUnreal is darn close to what I'd do, except I'd use a vector rather than an array and also make the dimensions template parameters and change the access functions -- and oh just IMNSHO clean things up a bit:
... |
Every post so far leaves the memory management for the programmer. This can and should be avoided. ReaperUnreal is darn close to what I'd do, except I'd use a vector rather than an array and also make the dimensions template parameters and change the access functions -- and oh just IMNSHO clean things up a bit:
... |
Every post so far leaves the memory management for the programmer. This can and should be avoided. ReaperUnreal is darn close to what I'd do, except I'd use a vector rather than an array and also make the dimensions template parameters and change the access functions -- and oh just IMNSHO clean things up a bit:
... |
The future is definitely Strawberry Perl.
Whichever you chose though (and this problem is not unique to Windows), if you're distributing the end result to other machines, you're going to have to be careful as regards the installer/installation instructions you provide. |
You don't need to add these -- they contain per-user settings, and other developers won't want your copy. |
The CLR likes to optimize instructions, so when you access a field in code it might not always access the current value of the field (it might be from the stack, etc). Marking a field as `volatile` ensures that the current value of the field is accessed by the instruction. This is useful when the value can be modified ... |
Visual Studio will automatically create them. I don't recommend putting them in source control. There have been numerous times where a local developer's SOU file was causing VS to behave erratically on that developers box. Deleting the file and then letting VS recreate it always fixed the issues. |
You can create a base controller class via normal C# inheritance:
public abstract class BaseController : Controller
{
}
public class DerivedController : BaseController
{
}
You can use this base class only for controllers which require a department. You do not have to do anythi... |
So I googled [greasemonkey dom ready][1] and the [first result][2] seemed to say that the greasemonkey script is actually running at "DOM ready" so you just need to remove the onload call and run the script straight away.
I removed the *`window.addEventListener ("load", function() {`* and *`}, false);`* wrapping an... |
So I googled [greasemonkey dom ready][1] and the [first result][2] seemed to say that the greasemonkey script is actually running at "DOM ready" so you just need to remove the onload call and run the script straight away.
I removed the *`window.addEventListener ("load", function() {`* and *`}, false);`* wrapping an... |
You can try to use [Nightly Tester Tools][1] It overrides addons compatibility check. Using this tool I managed to bring all of my fav extensions from FF2 to FF3
[1]: https://addons.mozilla.org/addon/6543 |
For complex types, you can recursively convert each one that you come across into a table of its own and then attempt to manage foreign key relationships.
You may also want to pre-specify *which* classes will or won't be converted to tables. As for complex data that you want reflected in the database without bloati... |
You can use generics to implement that in C#:
abstract class Leg { }
interface IAnimal { Leg GetLeg(); }
abstract class Animal<TLeg> : IAnimal where TLeg : Leg
{ public abstract TLeg GetLeg();
Leg IAnimal.GetLeg() { return this.GetLeg(); }
}
class Dog : Animal<Dog.DogLeg>
{ public c... |
You can use generics and interfaces to implement that in C#:
abstract class Leg { }
interface IAnimal { Leg GetLeg(); }
abstract class Animal<TLeg> : IAnimal where TLeg : Leg
{ public abstract TLeg GetLeg();
Leg IAnimal.GetLeg() { return this.GetLeg(); }
}
class Dog : Animal<Dog.DogLeg... |
You could always try Firefug. It sounds like it does a similar thing, plus more :) |
The answer is here:
http://beta.stackoverflow.com/questions/40853/how-to-store-passwords-in-winforms-application#40867
|
You can use different versions of python on each machine.
Coding something new, I would not use anything less than python2.5. You can do `apt-get install python2.5` on stock debian stable.
For windows, don't really worry about it. It's very easy to install the python2.5 msi.
If the users can't be bothered t... |
There shouldn't be any need to use FastCGI. There exists a [ISAPI extension for WSGI](http://code.google.com/p/isapi-wsgi/). |
#include <boost/foreach.hpp>
const char* list[] = {"abc", "xyz"};
BOOST_FOREACH(const char* str, list)
{
cout << str << endl;
} |
I've seen both in action (though I'm a Java developer). The upsides from a pick and mix approach is that you can choose the best bits for everything (e.g. I'd check out Hudson for CI - its excellent for Java, works for .Net too and has *loads* of plugins and is really simple to use). The downside is that you have to ... |
Or you could try something like:
boost::shared_array<int> zbuffer(new int[width*height]);
You should still be able to do this too:
++zbuffer[0];
No more worries about managing the memory, no custom classes to take care of, and it's easy to throw around.
|
You can use a while loop:
While (Select Count(*) From #TempTable) > 0
Begin
Insert Into @Databases...
Delete From #TempTable Where x = x
End |
How can I lock down my MS-SQL DB from my users and yet still access it through ODBC? |
|ms-access|odbc|ms-sql| |
I've got an ms-access application that's accessing and ms-sql db through an ODBC connection. I'm trying to force my users to update the data _only_ through the application portion, but I don't care if they read the data directly or through their own custom ms-access db (they use it for creating ad hoc reports).
What... |
|sql-server|ms-access|odbc| |
I liked [Terai Atsuhiro san's DnDTabbedPane][1], but I wanted more from it. The original Terai implementation transfered tabs within the TabbedPane, but it would be nicer if I could drag from one TabbedPane to another.
Inspired by @[Tom](http://stackoverflow.com/questions/60269/how-to-implement-draggable-tab-using-j... |
How to copy a row from one SQL Server table to another |
|sql|sql-server| |
I have two identical tables and need to copy rows from table to another. What is the best way to do that? (I need to programmatically copy just a few rows, I don't need to use the bulk copy utility).
Thanks
rp |
|sql|sql-server| |
How do I conditionally create a stored procedure in SQL Server? |
|stored-procedures|sql-server| |
As part of my integration strategy, I have a few SQL scripts that run in order to update the database. The first thing all of these scripts do is check to see if they need to run, e.g.:
if @version <> @expects
begin
declare @error varchar(100);
set @error = 'Invalid version. Your version is '... |
I talked to a friend of mine and he told me that it's possible to create an image in an image editor ( gimp/photoshop ) and then use it as a button . He said that's the way applications that have great GUI's do it . He also said that there is a file describing which parts of the image make up the button .
Is this pos... |
Using pictures as buttons? |
|user-interface| |
I talked to a friend of mine and he told me that it's possible to create an image in an image editor (gimp/photoshop) and then use it as a button . He said that's the way applications that have great GUIs do it.
He also said that there is a file describing which parts of the image make up the button.
Is this po... |
Bootstrapper for SQL Server Express 2005 64 bit |
|sql|sql-server| |
Where can I get the 64 bit bootstrapper for SQL Server Express 2005 64 bit. The default bootstrapper is 32 bit only. This will not install on Vista 64 bit. |
You are right saying this error message is linked to the state of one of your databases. You are using here Jet connections and Access objects, and you might not be able, for multiple reasons (multi-user environment, unability to delete LDB Lock file, etc), to properly close your active database and open another one. S... |
I guess this error message is linked to the state of one of your databases. You are using here Jet connections and Access objects, and you might not be able, for multiple reasons (multi-user environment, unability to delete LDB Lock file, etc), to properly close your active database and open another one. So, according ... |
+1 for CodeRush & Refactor Pro. I've been using CodeRush since its Delphi incarnations, and it's utterly wonderful. The mantra of "Code at the speed of thought" is very close to reality ;) |
Well it seems that your program needs to impersonate a user other than the context under which it is already running. Although, it does look like a pretty automated process, but if it's not, can you simply not ask the administrator to put in username and password at the time this 'black-sheep' computer is being polled? |
I think for complex data types, you should extend them by specifying a ToDB() method which holds their own implementation for creating tables in the DB, and this way it becomes auto-recursive. |
It's really late, and I only spent about 10 minutes on this, so its extremely sloppy, however it does work and will give you a good jumping off point:
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
namespace TableGenerator
{
cla... |