instruction stringlengths 0 30k ⌀ |
|---|
I've had a bug in our software that occurs when I receive a connection timeout. These errors are very rare (usually when my connection gets dropped by our internal network). How can I generate this kind of effect artificially so I can test our software?
If it matters the app is written in C++/MFC using CAsyncSocket... |
I've had a bug in our software that occurs when I receive a connection timeout. These errors are very rare (usually when my connection gets dropped by our internal network). How can I generate this kind of effect artificially so I can test our software?
If it matters the app is written in C++/MFC using CAsyncSocket... |
|networking|network-programming|connection|tcp| |
I've had a bug in our software that occurs when I receive a connection timeout. These errors are very rare (usually when my connection gets dropped by our internal network). How can I generate this kind of effect artificially so I can test our software?
If it matters the app is written in C++/MFC using CAsyncSocket... |
Well if all else fails you could just take the ruthless approach and kill the process running mysql manually.
i.e. "`ps -Af`" to list all processes, then do "`kill <pid>`" where `<pid>` is the process id of the mysql daemon (mysqld). |
i know this seems silly but did you try removing it and reinstalling?
yum remove elfutils
then
yum install elfutils
alternatively you could try updating everything:
yum update |
i know this seems silly but did you try removing it and reinstalling?
yum remove elfutils
then
yum install elfutils
alternatively you could try updating everything:
yum update
...if their is no update marked in the repository you might try:
yum upgrade
|
I prefer to keep styling in CSS as it separates view from presentation, allowing me to swap between presentations fairly easily. Plus it keeps all the information in one place instead of split between two places. |
Accessing Greasemonkey metadata from within your script? |
|javascript|greasemonkey|metadata| |
Is there any way that my script can retrieve metadata values that are declared in its own header? I don't see anything promising in the API, except perhaps `GM_getValue()`. That would of course involve a special name syntax. I have tried, for example: `GM_getValue("@name")`.
The motivation here is to avoid redundant... |
There's an option to place the opening curly brace and a semicolon automagically in the "correct" position. You'll have to enable this - Choose Window/Preferences and type "brace" in the searchbox - should be easily findable (no eclipse on this computer). The effect:
- Typing a semicolon anywhere on the line will... |
You can do either. However, by shifting your CSS out to a separate file, it can be cached. This reduces the amount of data that you need to transmit for each page, cutting down on bandwidth costs, and increasing speed. |
Not sure why `@performed_redirect` isn't working, but I'll try to find out.
In the meanwhile, instead of doing
flash[:previous_page] = flash[:previous_page]
you can do
flash.keep :previous_page
(My patch, that. back in the days :P) |
Not sure why `@performed_redirect` isn't working, you can see that it does exist and have the desired values by calling the actions on this test controller:
class RedirController < ApplicationController
after_filter :redir_raise
def raise_true
redirect_to :action => :whatever
en... |
From http://codex.wordpress.org/Theme_Development
The following is an example of the first few lines of the stylesheet, called the style sheet header, for the Theme "Rose":
/*
Theme Name: Rose
Theme URI: the-theme's-homepage
Description: a-brief-description
Author: your-name
Author... |
Based on http://codex.wordpress.org/Theme_Development:
The following is an example of the first few lines of the stylesheet, called the style sheet header, for the Theme "Rose":
/*
Theme Name: Rose
Theme URI: the-theme's-homepage
Description: a-brief-description
Author: your-name
A... |
I often see code like:
Iterator i = list.iterator();
while(i.hasNext()) {
...
}
but I write that (when Java 1.5 isn't available or for in can't be used) as:
for(Iterator i = list.iterator(); i.hasNext(); ) {
...
}
because
- It is shorter
- It keeps i in a sma... |
I often see code like:
Iterator i = list.iterator();
while(i.hasNext()) {
...
}
but I write that (when Java 1.5 isn't available or for each can't be used) as:
for(Iterator i = list.iterator(); i.hasNext(); ) {
...
}
because
- It is shorter
- It keeps i in a s... |
Mips appear to be coming back in embedded systems. @[sk] has given a better summary than me, but I have a recent example :
Broadcom appear to make Wifi cards these days with either MIPS or ARM chips on them ( I'm not sure which tho, documentation says one, firmware says the other ). However, on thier newer chi... |
Assembly language is always worth learning. You probably aren't being taught or seeing how the compiler turns high-level language code to assembly code, but I'd say that knowledge is the most important benefit of knowing assembly language. It's sobering how inefficient many compilers are even on the highest optimizat... |
I see all these people here saying that while they would never actually use Scheme again it's nevertheless been a worthwhile language to learn because it forces a certain way of thinking. While this can be true, I would hope that you would learn Scheme because you eventually will find it useful and not simply as an exe... |
Looking through the Qt source it seems that when a slot is called from QMetaObject::invokeMethod the return type can be specified and the return value obtained. (Have a look at invokeMethod in the Qt help)
I could not find many examples of this actually being used in the Qt source. One I found was
bool QAbs... |
Buy Books:
Requirements Engineering by Ian Sommerville & Pete Sawyer ISBN 0-471-97444-7
or
Software Requirements by Karl Wiegers ISBN 0-7356-0631-5 |
Another option is Inno Setup, a third-party installer which is free, easy to use and excellent:
[Inno Setup][1]
[1]: http://www.innosetup.com/isinfo.php |
I assume from your question that your research colleagues want to automate the process by which certain statistical analyses are performed (i.e., they want to batch process data sets). You have two options:
1) SPSS is now scriptable through python (as of version 15) - go to spss.com and search for python. You can ... |
Writing to the windows logs in Python |
|python|windows-logging| |
Is it possible to write to the windows logs in python? |
|python|windows|logging| |
Classes can be both public AND sealed.
But, don't do that.
You can create a tool to reflect over internal classes, and emit a new class that accesses everything via reflection. MSTest does that. |
Classes can be both public AND sealed.
But, don't do that.
You can create a tool to reflect over internal classes, and emit a new class that accesses everything via reflection. MSTest does that.
Edit: I mean, if you don't want to include -any- testing stuff in your original assembly; this also works if the mem... |
def unique(items):
found = set([])
keep = []
for item in items:
if item not in found:
found.add(item)
keep.append(item)
return keep
print unique([1, 1, 2, 'a', 'a', 3]) |
Most people want to ship an optimised build. But if you ship a pdb with an optimised build, the source line numbers you get are likely to be off. |
It's been ages since I've done any Win32 coding, but AFAIK, WMF as a format is basically a list of GDI commands and their parameters which would explain why it is much more efficient to encode...
You'd probably need to hook into the top level GDI context (just as Remote Desktop does, I guess) and capture the GDI com... |
I'd recommend using the subprocess module instead of os.system because it does shell escaping for you and is therefore much safer: http://docs.python.org/lib/module-subprocess.html
> subprocess.call(['ping', 'localhost']) |
You use one master config file that points to other config files. [Here's an example of how to do this.][1]
[1]: http://blog.andreloker.de/post/2008/06/Keep-your-config-clean-with-external-config-files.aspx |
I honestly wouldn't worry about it. Testing a boolean is *really fast*. Short-circuiting only gets interesting / useful when the second expression has side effects:
if ( ConfirmAction() && DestroyAllData() )
Reboot();
|
I honestly wouldn't worry about it. Testing a boolean is *really fast*. Short-circuiting only gets interesting / useful when the second expression has side effects:
if ( ConfirmAction() && DestroyAllData() )
Reboot();
...or depends on the first test:
if ( myDodgyVar != null && myDodgyVar.IsActi... |
http://www.python.org/doc/2.5/lib/module-subprocess.html
...or for a very simple command:
import os
os.system('cat testfile')
|
I use [jmeter][1] for session-based testing - it allows very fine-grained control over pages you want to hit, parameters to inject, loops to go through, etc. It's great for simulating how many real users your site can handle, rather than just performance testing a set of static urls. You can distribute tests over mul... |
I would invest in profiling software to trace down the actual cause of the problem.
On linux, Valgrind ( which contains Cachegrind & Callgrind ) + KCacheGrind can make working out where all the heavy function calls are going on.
Also, compile with full debug symbols and it can even show the assembley code at t... |
The [JQuery Browser Plugin](http://jquery.thewikies.com/browser/) will do it client-side for you.
>**What is the jQuery Browser Plugin?**
>The jQuery Browser Plugin is an addon for jQuery that makes it easy to uniquely identify your visitors' browsers.
>**What does it do?**
>
It gives you an object in javasc... |
The [JQuery Browser Plugin](http://jquery.thewikies.com/browser/) will do it client-side for you.
>**What is the jQuery Browser Plugin?**
>The jQuery Browser Plugin is an addon for jQuery that makes it easy to uniquely identify your visitors' browsers.
>**What does it do?**
>
It gives you an object in javasc... |
As it currently stands, you'll have to compile the code on the server. The server should not serve any code that might allow cross site attacks, so be very careful. The client can then use URLClassLoader.newInstance to load it. |
You're going to have to provide more information - what is "s_MaxGetTaskInterface" (Google provides no results). SendMessage will return with whatever value is returned from the WndProc that handles the message "s_MaxGetTaskInterface". If it's not handled, you will get zero back and your pointer will still be NULL. |
If you're trying to read those deep linking URLs on the server side (which I assume you are), know that it's not possible.
Those deep linking systems use the fragment part of URLs (the part that comes after the hash (`#`) symbol) for designating specific parts of the flash apps in the browser URL and fragments are n... |
The below batch will create a .Net **Class** from **XML** in the current directory.<br>
So... XML -> XSD -> VB
(Feel free to substitute CS for Language)
Create a **Convert2Class.Bat** in the %UserProfile%\SendTo directory.<br>
Then copy/save the below:
@Echo off
Set XsdExePath="C:\Program Files\Micr... |
The below batch will create a .Net **Class** from **XML** in the current directory.<br>
So... XML -> XSD -> VB
(Feel free to substitute CS for Language)
Create a **Convert2Class.Bat** in the %UserProfile%\SendTo directory.<br>
Then copy/save the below:
@Echo off
Set XsdExePath="C:\Program Files\Micr... |
Are you talking about the [Actionscript 3.0 Runtime Error 2082][1]?
[1]: http://livedocs.adobe.com/flex/3/langref/runtimeErrors.html |
It is technically possible to use inline CSS formatting exclusively and have no external stylesheet. You can also embed the stylesheet within the HTML document. The best practice in web design is to separate out the CSS into a separate stylesheet. The reason for this is that the CSS stylesheet exists for the purpose... |
Don't have the evaluation based on "days since install", instead do number of days used, or number of times run or something similar. People tend to download shareware, run it once or twice, and then forget it for a few weeks until they need it again. By then, the trial may have expired and so they've only had a few tr... |
RMI server: rmiregistry or LocateRegistry.createRegistry |
|java|rmi|rmiregistry| |
For RMI on server-side, do we need to start `rmiregistry` program, or just call `LocateRegistry.createRegistry`?
If both are possible, what are the advantages and disadvantages? |
both of the prior responses (creating a new CustomControl or an Adorner) are better practices, but if you just want quick and dirty (or to understand visually how to do it) then this code would work:
<Grid Width="300" Height="50">
<ProgressBar Value="50" />
<TextBlock HorizontalAlignment="C... |
There are appropriate uses for the while, the for, and the foreach constructs:
- `while` - Use this if you are iterating and the deciding factor for looping or not is based merely on a condition. In this loop construct, keeping an index is only a secondary concern; everything should be based on the condition
... |
I've done both lately, I would take MVC nine times out of ten.
- I really dislike the implementation of the asp.net ajax controls, I've run into a lot of issues with timing, events, and debugging postback issues. I learned a lot from [http://encosia.com/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous/][1]
... |
You'll need to make sure that all your "cells" float either left or right (depending on their internal ordering), and they also need a fix width.
Also, make sure that their "row" has a fixed width which is equal to the sum of the cell widths + margin + padding.
Lastly make sure there is a fixed width on the "tabl... |
or indeed this, which is very literally using tables for tabular data:
http://stackoverflow.com/badges |
'file' is a type, like an int or a list. 'open' is a function for opening files, and will return a 'file' object.
This is an example of when you should use open:
f = open(filename, 'r')
for line in f:
process(line)
f.close()
This is an example of when you should use file:
clas... |
SELECT CONVERT(VARCHAR(10),GETDATE(),111)
|
As has been stated, you're probably modifying a copy instead of the original.
To prevent this kind of mistake, you can explicitly declare copy constructors and equals operators as private.
private:
Hand(const Hand& rhs);
Hand& operator=(const Hand& rhs); |
SELECT CONVERT(datetime, CONVERT(varchar, GETDATE(), 101)) |
You can use the 'convert' function to return only the date. See the link below:
[Date and Time Manipulation in SQL Server 2000 ][1]
[1]: http://www.sqljunkies.ddj.com/Article/6676BEAE-1967-402D-9578-9A1C7FD826E5.scuk
The syntax for using the convert function is:
CONVERT ( data_type [ ( length ) ] , exp... |
I don't mean to sound patronizing; if I do, I've misunderstood you and I'm sorry.
Most people frown upon tables because people use them for the wrong reason. Often, people use huge tables to position things in their website. *This* is what divs should be used for. Not tables!
However, if you want to display *t... |
Functionally, the two are the same; `open` will call `file` anyway, so currently the difference is a matter of style. The [Python docs][1] recommend using `open`. The reason is that in future versions they is not guaranteed to be the same (`open` will become a factory function, which returns objects of different types... |
The only situation in which I've had to do this is sending a templated e-mail. In .NET this is provided out of the box by the [MailDefinition class](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.maildefinition.aspx). So this is how you create a templated message:
MailDefinition md = new MailD... |
Best option would be to assume nothing. If they have meaning, you will find that from the other side when you need the information they provide. |
Undefined, I believe? I think it depends on the mainboard and CPU, and should be treated as random for your own good. |
First thing I would look for is that you don't have the second ComboBox's AutoPostBack property set to true. If you change the value in the second combo with that property set true, I believe it will generate a postback on that control. |
If the client would ever need to restore only a single entity from a backup and leave the others in their current state, then the maintenance will be much easier if each entity is in a separate database. if they can be backed up and restored together, then it may be easier to maintain the entities as a single database... |
An attribute is a class that contains some bit of functionality that you can apply to objects in your code. To create one, create a class that inherits from System.Attribute.
As for what they're good for... there are almost limitless uses for them.
http://www.codeproject.com/KB/cs/dotnetattributes.aspx |
When I had to do this, I created a blank solution in VS and then added the folders from the ASP site one at a time, adding "existing items" to each folder as I created it.
In this way I'm able to open the solution which keeps track of what files I had open at last open, plus I get the benefits of intellisense |
Give this a try:
Shell "p4 open" & ActiveDocument.FullName |
Attributes are like metadata applied to classes, methods or assemblies.
They are good for any number of things (debugger visualization, marking things as obsolete, marking things as serializable, the list is endless).
Creating your own custom ones is easy as pie. Start here:
<http://msdn.microsoft.com/en-us/li... |
You can use custom attributes as a simple way to define tag values in sub classes without having to write the same code over and over again for each subclass. I came across a nice [concise example by John Waters][1] of how to define and use custom attributes in your own code.
There is a tutorial at http://msdn.micr... |
You're going to have to provide more information - what is "GetTaskInterface" (Google provides no results). SendMessage will return with whatever value is returned from the WndProc that handles the message "s_MaxGetTaskInterface". If it's not handled, you will get zero back and your pointer will still be NULL. |
Wonder what happens if you call SetWindowPos with SWP_DEFERERASE as uFlags.
This should prevent generation of the WM_SYNCPAINT message which would indirectly causes WM_NCPAINT message sent.
|
If you ask
if not spam:
print "Sorry. No SPAM."
the _\_\_nonzero\_\__ method of _spam_ gets called. From the Python manual:
> __\_\_nonzero\_\___(_self_)
Called to implement truth value testing, and the built-in operation bool(); should return False or True, or their integer equivalents 0 or 1.... |
!["When I started programming, we didn't have any of these sissy 'icons' and 'Windows.' All we had were zeros and ones -- and sometimes we didn't even have ones. I wrote an entire database program using only zeros." "You had zeros? We had to use the letter 'O'." -Dilbert (Scott Adams)][1]
[1]: http://www.mscha.n... |
Blocking https url's in a embedded gecko browser |
|ssl|https|gecko|embedding|nss| |
I have an application in which a gecko browser is embedded. The application is crashing when I try to access any https url's because nss is not properly initialised at this point. The crash is in PK11_TokenExists(). I want to block my browser from rendering https sites. If a user clicks on a https link I can block that... |
My general advice here is to refactor an existing system away from its bad designs to a system with better designs. This maintains the system and allows it to be deployed at all times. If you start from scratch it may be a while before you can deploy, or never.
If you are talking about just writing some brand new ... |
I have always found Hibernate to be a bit complex and hard to learn. But as [JPA][jpa] (Java Persistence API) and [EJB][ejb] (Enterprise Java Beans) 3.0 has existed for a while things have gotten a lot easier, I much prefer annotating my classes to create mappings via JavaDoc or XML. Check out the [support in Hibernate... |
Looking for a more flexible tool than GNU indent |
|pretty-print|indentation| |
When I run indent with various options I want against my source, it does what I want but also messes with the placement of *s in pointer types:
-int send_pkt(tpkt_t* pkt, void* opt_data);
-void dump(tpkt_t* bp);
+int send_pkt(tpkt_t * pkt, void *opt_data);
+void dump(tpkt * bp);
I know ... |
|indentation|pretty-print| |
When I run indent with various options I want against my source, it does what I want but also messes with the placement of *s in pointer types:
-int send_pkt(tpkt_t* pkt, void* opt_data);
-void dump(tpkt_t* bp);
+int send_pkt(tpkt_t * pkt, void *opt_data);
+void dump(tpkt * bp);
I know ... |
I think that is a common misconception (about MIB reload each time you resolve a name).
Most of the SNMP APIs (such as AdventNet, CMU) load the MIBS at startup and after that there is no 'overhead' of loading MIBs everytime you ask for a 'translation' from name to oid and vice versa. What's more, some of them cac... |
The most common refactoring suggested for eliminating if-else or switch statements is introducing polymorphism (see [http://www.refactoring.com/catalog/replaceConditionalWithPolymorphism.html][1]). Eliminating such conditionals is most important when they are duplicated. In the case of XML parsing like your sample yo... |
You don't <i>have</i> to keep your CSS in an external file, no. What you're asking about is "inline" css: including style directives directly within the page itself via <style> blocks.
There are times where that may makes sense, in moderation, but in general <a href="http://www.communitymx.com/content/article... |
Interfaces are pretty old, and have been around for quite a while.
Early (mid to late late 1970's) non-object oriented languages such as Modula and Euclid used constructs called "modules" to specify the interfaces between components. Components would then communicate with each other via explicit importing and export... |
Interfaces are pretty old, and have been around for quite a while.
Early (mid to late late 1970's) non-object oriented languages such as Modula and Euclid used constructs called "modules" to specify the interfaces between components. Components would then communicate with each other via explicit importing and export... |
Best practices aside, i believe it could also depend on how your going to access your cfc's i have not had any problems leaving them out when creating objects and accessing them from coldfusion. However i think it might be needed when accessing and/or mapping them remotely via actionscript in flex/flash. |
When I am designing a site one of the big things I prefer is the DRY principle. IMO ASP.NET MVC is much more dry than web forms.
I have recently made the move from webforms to MVC and I hope I never have to go back! |
How to get runonce to run, without having to have an adminstrator login. |
|installation|registry|runonce|windows-services| |