instruction stringlengths 0 30k ⌀ |
|---|
What are the pros/cons of doing either way. Is there One Right Way(tm) ? |
I too thought that the Serializable attribute had to be on the object but unless I'm being a complete noob (I am in the middle of a late night coding session) the following works from the [SnippetCompiler][1]:
using System;
using System.IO;
using System.Xml;
using System.Collections.Generic;
... |
You don't now for sure that the compiler will do exactly what you expect. The reason is, of course, that a compiler is a peice of software, and is therefore susceptible to bugs.
Compiler writers have the advantage of working from a high quality spec, while the rest of us have to figure out what we're making as we... |
I copied some Delphi code from one project to another, and found that it doesn't compile in the new project, though it did in the old one. The code looks something like this:
procedure TForm1.CalculateGP(..)
const
Price : money = 0;
begin
...
Price := 1.0;
...
end;
... |
I copied some Delphi code from one project to another, and found that it doesn't compile in the new project, though it did in the old one. The code looks something like this:
procedure TForm1.CalculateGP(..)
const
Price : money = 0;
begin
...
Price := 1.0;
...
end;
... |
Also, if you need to get an .egg package off a single .py file app, check this link: [EasyInstall - Packaging others projects as eggs][1].
[1]: http://peak.telecommunity.com/DevCenter/EasyInstall#packaging-others-projects-as-eggs |
You probably have to use impersonation to change the credentials of the thread that calls the remote registry methods. See here ([linky][1]) for some information on MSDN. Basically, your thread has a security context that is used to make managed and unmanaged calls.
[1]: http://msdn.microsoft.com/en-us/library/s... |
According to [MSDN][1], UnauthorizedAccessException is **not thrown** by OpenSubKey. So I think it's not needed.
[1]: http://msdn.microsoft.com/en-us/library/z9f66s0a.aspx |
There's another library called [ExtremeSwank][1]. This article by Andrew Arnott, a dotnetopnid developer, might also help you "[Why DotNetOpenID as your C# OpenID library of choice][2]".
[1]: http://extremeswank.com/aspnet_openid.html
[2]: http://blog.nerdbank.net/2008/04/why-dotnetopenid-as-your-c-openid.htm... |
There's another library called [ExtremeSwank][1]. This article by Andrew Arnott, a dotnetopenid developer, might also help you "[Why DotNetOpenID as your C# OpenID library of choice][2]".
[1]: http://extremeswank.com/aspnet_openid.html
[2]: http://blog.nerdbank.net/2008/04/why-dotnetopenid-as-your-c-openid.ht... |
See a short list of python packaging tools on [FreeHackers.org][1].
[1]: http://www.freehackers.org/Packaging_a_python_program |
I use variations of this all the time to process files...
> for files in *.log; do echo "Do stuff with: $files"; echo "Do more stuff with: $files"; done;
If processing lists of files is what you're interested in, look into the **-execdir** option for **files**.
|
To expand on what "17 of 26" said, the answer depends on value to the customer. In the case of critical software, like aircrafct controller applications, the value to the customer of a high quality rating by whatever measure they use is quite high. To the user of an RSS feed reader, the value of high quality is consi... |
Off the top of my head, you can try something like this:
<ItemTemplate>
<tr>
<td "class1"><asp:Literal ID="litField1" runat="server" Text='<%# Bind("Field1") %>'></td>
<td "class1"><asp:Literal ID="litField2" runat="server" Text='<%# Bind("Field2") %>'></asp:Literal... |
Off the top of my head, you can try something like this:
<ItemTemplate>
<tr>
<td "class1"><asp:Literal ID="litField1" runat="server" Text='<%# Bind("Field1") %>'/></td>
<td "class1"><asp:Literal ID="litField2" runat="server" Text='<%# Bind("Field2") %>'/></td>
... |
Here's a quick and dirty way to do it:
String propFile = "/path/to/file";
Properties props = new Properties();
/*set some properties here*/
Properties tmp = new Properties() {
@Override
public Set<Object> keySet()
{
return new TreeSet<Object>(super.keySet());
... |
C++ inheritance and member function pointers |
|c++|inheritance|oop|pointer-to-member| |
In C++, can member function pointers be used to point to derived (or even base) class members? |
|c++|oop|inheritance|pointer-to-member| |
In C++, can member function pointers be used to point to derived (or even base) class members?
EDIT:
Perhaps an example will help. Suppose we have a hierarchy of three classes `X`, `Y`, `Z` in order of inheritance.
`Y` therefore has a base class `X` and a derived class `Z`.
Now we can define a member functio... |
I found that one of the undocumented requirements for using ant with Flexbuilder was to have the varible FLEX_HOME set within your ant script. Typically within build.xml have the following:
<!– Module properties –>
<property environment=”env”/>
<property name=”build.dir” value=”build”/>
<property ... |
Here's a quick and dirty way to do it:
String propFile = "/path/to/file";
Properties props = new Properties();
/*set some properties here*/
Properties tmp = new Properties() {
@Override
public Set<Object> keySet()
{
return new Collections.unmodifiableSet(TreeSet... |
Here's a quick and dirty way to do it:
String propFile = "/path/to/file";
Properties props = new Properties();
/*set some properties here*/
Properties tmp = new Properties() {
@Override
public Set<Object> keySet()
{
return Collections.unmodifiableSet(new TreeSet... |
Have you been looking at the output from running make -n and make -np, and the biggie make -nd?
Are you using a fairly recent version of gmake?
Have you looked at the free chapter on [Debugging Makefiles][1] available on O'Reilly's site for their excellent book "Managing Projects with GNU Make" ([Amazon Link][2])... |
I would say that the simplest method would be to add onmouseover/out Javascript functions. |
Best iCalendar library for Java? |
|java|icalendar| |
I'm looking for a library to handle [iCalendar][1] data in Java.
Open source, well-documented implementations with a good object model are preferred. iCal parsing capabilities are less important to me, but still nice to have.
Does anyone have any recommendations?
[1]: http://en.wikipedia.org/wiki/ICalendar |
|java|icalendar| |
I think you can still use all of the normal D3D tools, but you won't be able to render to a surface associated with the screen. You'll have to render to a DIB (or some such) and Blt it with GDI to a normal window HDC. RDC/VNC/Citrix should all work with this technique.
Performance will definitely suffer - but that's... |
Note that in the case of reflection, you get an `NoSuchMethodException`, while with non-reflective code, you get `NoSuchMethodError`. I tend to go looking in very different places when confronted with one versus the other.
|
What you're going for is the following SQL:
SELECT COUNT(DISTINCT date) FROM records
ActiveRecord has this built in:
Record.count('date', :distinct => true) |
*Aside:*
> I actually already needed to swap the image anyhow
Make sure you take a look at [Image Sprites](http://www.alistapart.com/articles/sprites). Sometimes its much nicer to use one image and "shift" the image then to use two separate images and "toggle" or "swap" between them. In my experience its been m... |
> Why isn't my custom error handler catching undefinedd functions? Are there other problems that this will cause?
At a guess, I'd say that undefined function errors travel through a different execution path than other error types. Perhaps the PHP designers could tell you more, except I doubt PHP is in any way design... |
You might want to consider CI-Factory. It's a continuous integration environment builder that uses CruiseControl.NET and a dozen other tools. There's an excellent screencast here: [http://www.dnrtv.com/default.aspx?showID=64][1]
[1]: http://www.dnrtv.com/default.aspx?showID=64 |
Another very hacky option, if you are stuck with a lot of constraints, but know what the surrounding dom will look like:
style="width:100%;width:expression(parentNode.parentNode.parentNode.parentNode.width +'px')"
not pretty, but does work in IE7.
Using jquery or similar would be a much neater solution, ... |
Based on the [documentation on MSDN][1] and my experience, binary is better, since the md5 hash does not vary in size.
The size for a binary data type is n bytes, so the size of the data. The size of a varbinary data type is n bytes + 2 bytes on top of the size of the data.
[1]: http://msdn.microsoft.com/en-... |
MFC: MessageBox during a Drag-Drop |
|mfc|drag-and-drop| |
I need to display an error message on rejecting a drop in my application. I tried this in the OnDrop() but then the source application hangs till my message box is dismissed.
How? |
Short of just including the js in every page automatically, I do not think so. It really would not be something that tags are designed to to.
Without knowing what your tag is actually doing (presumably its its outputting something in the body section) then there is no way that it will be able to get at the head to p... |
John's pointer to MSDN answered what UnauthorizedAccessException is for - it only appears when you try to access a key remotely, using OpenRemoteBaseKey.
We're a little wary about changing the security context on the computer - I've found a reference [here][1] about using WMI (which we're already using for the vast ... |
Why don't you use Firefox (I assume you're using Firefox) to remember your credentials using the Password Manager?
I found this link: [HTTP Authentication with HTML Forms][1]. Looks like you can use javascript to do HTTP authentication. I don't think you can have Greasemonkey interrupt when you are first navigatin... |
You can always call PostMessage with a private message in the WM_APP range and in the message handler show the error.
That way you show the error after the drag and drop operation is really over and there is no danger of messing up anything. |
What I'd do is ditch the blank Delete(), and only use Delete(string username)
In your url routing you'd have something similar to "/{Controller}/{Action}/{username}/" ?
If you have "/{Controller}/{Action}/{Id}/" you'd be better off doing Delete(string id) and that way just using the url to handle this "/Account/Del... |
You can use cut to get at each of the 3 'fields', e.g.:
echo "system-source-yyyymmdd.dat" | cut -d'-' -f1
"-d" specifies the delimiter, "-f" specifies the number of the field you require |
You can use the cut command to get at each of the 3 'fields', e.g.:
# echo "system-source-yyyymmdd.dat" | cut -d'-' -f2
source
"-d" specifies the delimiter, "-f" specifies the number of the field you require |
You can use the [cut command][1] to get at each of the 3 'fields', e.g.:
# echo "system-source-yyyymmdd.dat" | cut -d'-' -f2
source
"-d" specifies the delimiter, "-f" specifies the number of the field you require
[1]: http://en.wikipedia.org/wiki/Cut_(Unix) |
You can use the [cut command][1] to get at each of the 3 'fields', e.g.:
$ echo "system-source-yyyymmdd.dat" | cut -d'-' -f2
source
"-d" specifies the delimiter, "-f" specifies the number of the field you require
[1]: http://en.wikipedia.org/wiki/Cut_(Unix) |
ClickOnce Deployment, system update required Microsoft.mshtml |
|clickonce|microsoft.mshtml| |
We have an application that works with MS Office and uses Microsoft.mshtml.dll. We use ClickOnce to deploy the application. The application deploys without issues on most machines, but sometimes we get errors saying "System Update Required, Microsoft.mshtl.dll should be in the GAC".
We tried installing the PIA for ... |
Of course, the prime directive should be to "use whatever you're comfortable with." If Java is getting the job done right and on time, stick to it. But a lot of the scripting languages could save you some time because they're attuned to different problems. If you're using regular expressions, the scripting languages ar... |
ICriteria has a SetFirstResult(int i) method, which indicates the index of the first item that you wish to get (basically the first data row in your page) and SetMaxResult(int i) which indicates the number of rows you wish to get (e.g., your page size).
For example, this criteria object gets the first 10 results of ... |
If you just want to know if your server is serving out content or not, take a look at [Montastic][1]. I use it, and am pleased. Plus its free!
It will ping your site periodically, and if it doesn't get a 200 status, it lets you know.
[1]: http://www.montastic.com/ |
Come to think of it, I've never done it with a bottom border on the column. It's probably just overflowing, and getting cut off. You might want to have the bottom border come from a separate element that's part of the column content.
Anyway, I know it's not a perfect magic bullet solution. You might just have to pla... |
We had a similar requirement for reporting bugs. Since it was for Intranet scenario, we were able to use browser addons (like [Fireshot][1] for Firefox, [IE Screenshot][2] for IE)
[1]: https://addons.mozilla.org/en-US/firefox/addon/5648
[2]: http://www.softpedia.com/get/Tweak/Browser-Tweak/IE-Screenshot-Pro.s... |
I think classes are lazy loaded in applets. being loaded on demand.
Anyway, if the classes are outside of a jar you can simply use the applet classloader and load them by name. Ex:
ClassLoader loader = this.getClass().getClassLoader();
Class clazz = loader.loadClass("acme.AppletAddon");
If you want to... |
I don't know if this is a difference worth mentioning but...
Would it be possible to have the implementation in its own namespace and have a public wrapper / library namespace for the code the user sees:
catlib::Cat::Purr(){ cat_->Purr(); }
cat::Cat::Purr(){
printf("purrrrrr");
}
This way... |
I've always just made an iframe which points to the file.
<iframe src="/download.exe" frameborder="0" height="0" width="0"><a href="/download.exe">Click here to download.</a></iframe>
|
[Selenium][1] has been very useful for me for compatibility testing.
[1]: http://selenium.openqa.org/ |
A combination of using the format and assert_select in an integration test works great:
class ProductsTest < ActionController::IntegrationTest
def test_contents_of_xml
get '/index/1.xml'
assert_select 'product name', /widget/
end
end
For more details check out [assert_sele... |
I use [Selenium RC](http://selenium-rc.openqa.org/python.html). All my tests are written in Python and are run with test suite.
One minor thing is that You either have to start selenium manually and point Your tests to it or start selenium from test suite which requires little bit of coding. But it's doable.
Gene... |
It depends on the situation. I tend to use Exceptions when I am writing business logic/application internals, and trigger_error for Validator's and things of that sort.
The pro's of using Exceptions at the logic level is to allow your application to do in case of such an error. You allow the application to chose ins... |
My opinion is that the application itself should handle authentication and authorisation. On the database side you should only handle encryption of data as needed. |
No, you can't, and it only takes one person and a willing forum to [change the outcome of an online vote][1].
You have to realize the inherent flaws of an online vote and rather than attempting to get around them try to use them to your advantage.
-Adam
[1]: http://news.cnet.com/8301-13577_3-9914423-36.ht... |
catching all types of exceptions in C++ in one catch block |
|c++| |
in c++, Iam trying to catch all types of exceptions in one catch (like catch(Exception) in C#). how is it done ? and more, how can one catch devide-by-zero exceptions ? |
Why can't I delete this cookie?! |
|c#|asp.net|javascript|ajax|cookies| |
Okay, here is the 411 - I have the following event handler in my Global.asax.cs file:
private void Global_PostRequestHandlerExecute(object sender, EventArgs e)
{
if (/* logic that determines that this is an ajax call */)
{
// we want to set a cookie
Response.Cookies.Add... |
Make all your custom exception classes inherit from std::exception, then you can simply catch std::exception. Here is some example code:
class WidgetError
: public std::exception
{
public:
WidgetError()
{ }
virtual ~WidgetError() throw()
{ }
virtual con... |
If I recall correctly (it's been a while since I've looked at C++), I think the following should do the trick
try
{
// some code
}
catch(...)
{
// catch anything
}
and a quick google(http://www.oreillynet.com/pub/a/network/2003/05/05/cpluspocketref.html) seems to prove me ... |
This can be done using the following in a script tag (I can't include to script tag sorry, the html sanitizer doesn't like it):
<pre><code>
function pageLoad()
{
$find('TextBox1_DropDownExtender')._dropWrapperHoverBehavior_onhover();
$find('TextBox1_DropDownExtender').unhover = VisibleMe;... |
Well I found the "Server Logs" mentioned in the error above.
You need to turn on tracing in the web.config file by adding the following tags:
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing" >
<listeners>
<add name=... |
since you are thinking in *variables*, you might prefer a dictionary over a list of lists:
data = {}
data['a'] = [generate_poll_data()]
data['b'] = [generate_poll_data()]
etc. |
Haskell list difference operator in F# |
|functional-programming|f#|haskell| |
Is there an equivalent operator to Haskell's list difference operator `\\` in F#? |
The United States has requirements put out regarding the erasure of sensitive information (i.e. Top Secret info) is to destroy the drive. Basically the drives were put into a machine with a huge magnet and would also physically destroy the drive for disposal. This is because there is a possibility of reading informat... |
Set the request objects accept header:
@request.accept = 'text/xml' # or 'application/xml' I forget which
Then you can assert the response body is equal to what you were expecting
assert_equal '<some>xml</some>', @response.body |
You may be able to get some use out of [`+[NSPasteboard typesFilterableTo:]`][1]. I'm picturing a snippet like this:
NSArray *allTypes = [pb types];
NSAssert([allTypes count] > 0, @"expected at least one type");
// We always require the first declared type, as a starting point.
NSMutableSet *req... |
Another very hacky option, if you are stuck with a lot of constraints, but know what the surrounding dom will look like:
style="width:100%;width:expression(this.parentNode.parentNode.parentNode.parentNode.width +'px')"
not pretty, but does work in IE7.
Using jquery or similar would be a much neater solut... |
[Modified pre-order tree traversal][1] (or what Matt refers to as "nested set") is the way to go.
If you happen to be working in Django, there's a third-party app, [django-mptt][2], that makes implementing MPTT in your models a one-liner.
[1]: http://www.sitepoint.com/print/hierarchical-data-database
[2]: ... |
There are also some properties you can set to force a control to fill its available space when it would otherwise not do so. For example, you can say:
HorizontalContentAlignment="Stretch"
... to force the contents of a control to stretch horizontally. Or you can say:
HorizontalAlignment="Stretch"
..... |
I'll give an example (in Scheme):
(define (make-counter)
(let ((count 0))
(lambda ()
(set! count (+ count 1))
count)))
(define x (make-counter))
(x) returns 1
(x) returns 2
...etc...
What this function, make-counter, does is it returns a functi... |
How do you combine multiple result sets in SSRS? |
|reporting-services| |
What's the best way to combine results sets from disparate data sources in SSRS?
In my particular example, I need to write a report that pulls data from SQL Server and combines it with another set of data that comes from a DB2 database. I know that you can't do this "out of the box" in SSRS 2005. I'm not excited a... |
What's the best way to combine results sets from disparate data sources in SSRS?
In my particular example, I need to write a report that pulls data from SQL Server and combines it with another set of data that comes from a DB2 database. In the end, I need to join these separate data sets together so I have one comb... |
What I'd do is ditch the blank Delete(), and only use Delete(string username)
In your url routing you'd have something similar to "/{Controller}/{Action}/{username}/" ?
If you have "/{Controller}/{Action}/{Id}/" you'd be better off doing Delete(string id) and that way just using the url to handle this "/Account/Del... |
What language should i learn as a bridge to C (and derivatives) |
|python|c| |
The first language i learnt was PHP, but i have more recently picked up python. As these are all 'high-level' languages, i have found them a bit difficult to pick up. I tried a bit of objective-c, and i just gave up.
So, what language should i learn to bridge between python to C |
store everything you will need to build the project 10 years from now.I store the entire zip distribution of any library, just in case |
You're right. But all the data I need to report in the message box is in the OnDrop. |
I like to write two or more test methods to execute on parallel threads, and each of them make calls into the object under test. I've been using Sleep() calls to coordinate the order of the calls from the different threads, but that's not really reliable. It's also a lot slower because you have to sleep long enough tha... |
If you mean ActionScript I once heard that [PrimalScript][1] will do Intellisense. Never tested it though. As for debugging, MAYBE, [PrimalScope][2] will have that too. I'd recommend you try before you buy, though. (They both have trials.)
[1]: http://www.primalscript.com/
[2]: http://www.primalscope.com/ |