instruction stringlengths 0 30k ⌀ |
|---|
The ps is a really poor way of doing that and probably open to race conditions.
The traditional Unix/Linux way would be to write the PID to a file (typically in /var/run) and check to see if that file exists on startup.
e.g. the pidfile being located at /var/run/myscript.pid then you'd check to see if that exists... |
Hm, [Rockford Lhotka][1] sad, that LINQ to SQL is wonderful technology for fetching data from database. He suggests that afterwards they'll must to be bind to "reach domain objects" (aka. CSLA objetcs).
Seriously speaking, LINQ to SQL had it's support for n-tier architecture see **DataContext.Update** method.
[... |
[CreateFile][1] has support for direct disk access. Read the notes under "Physical Disks and Volumes". You should be able to P/Invoke the call.
Note that Vista and Server 2008 have [severely restricted][2] this.
[1]: http://msdn.microsoft.com/en-us/library/aa363858.aspx
[2]: http://support.microsoft.com/kb... |
100 (or some even number 2N :-) ) prisoners are in a room A. They are numbered from 1 to 100.
One by one (from prisoner #1 to prisoner #100, in order), they will be let into a room B in which 100 boxes (numbered from 1 to 100) await them. Inside the (closed) boxes are numbers from 1 to 100 (the numbers inside the bo... |
Early is good, definitely before you try to parse it. Anything you're going to output later, or especially pass to other components (i.e., shell, SQL, etc) must be sanitized.
But don't go overboard - for instance, passwords are hashed before you store them (right?). Hash functions can accept arbitrary binary data.... |
on *nix, there's a tool called [valgrind][1] that I use for dealing with memory issues, like memory leaks and memory corruption.
[1]: http://valgrind.org/ |
We currently have one branch for ongoing maintenance, one branch for "new initiatives" which just means "stuff that will come out sometime in the future; we're not sure when." We have also occasionally had two maintenance branches going on: one to provide fixes for what is currently in production and one that is still ... |
The C-runtime libraries are often the biggest culprit. Making sure all your projects have the same settings wrt single vs multi-threading and static vs dll.
The MSDN documentation is good for pointing out which lib a particular Win32 API call requires if it comes up as missing.
Other than that it usually comes d... |
Same concept.
**Aonther take:**
1. Write down a list of the first 100 binary numbers which has fifty 1s and fifty 0s.
2. Sort them from lowest to highest.
3. Prisoner #1 gets the first number, prisoner #2 gets the second, prisoner #3 gets the third and so on...
4. Each prisoner remembers his/her binary number.... |
Same concept.
**Aonther take:**
1. Write down a list of the first 100 binary numbers which has fifty 1s and fifty 0s.
2. Sort them from lowest to highest.
3. Prisoner #1 gets the first number, prisoner #2 gets the second, prisoner #3 gets the third and so on...
4. Each prisoner remembers his/her binary number.... |
Bear in mind that the EntLib documentation specifically steers you towards the ASP.NET cache for ASP.NET applications. That's probably the strongest recommendation towards using it here. Plus the EntLib cache doesn't have dependencies, which for me is a big reason not to use it.
I don't think there's a technical lim... |
@TK: a hashing algo can only be 'guessed', not reverse engineered. One can only reconstruct the input to a hash value by completely guessing the input (apart from collisions, that is) This can be done by a rainbow crack for example (see [an implementation of a rainbow cracker here][1])
I would say that a 3rd party e... |
FlashWindowEx FLASHW_STOP still keeps taskbar colored |
|c#|winapi|pinvoke| |
<p>I am developing an application that controls an Machine.<br/>
When I receive an error from the Machine the users should be able to directly notice it, one way that is done is Flashing the tray on the taskbar. When the machine clears the error the tray should stop flashing.</p>
<p>There's one little annoyance usi... |
<P>Ok, in terms of reading material, this is the pick of the books out there: <A href="http://www.amazon.com/exec/obidos/ASIN/0672328917">Windows Presentation Foundation Unleashed</A>.</P>
<P>For blogs, there are a lot of blogs and articles on <A href="http://windowsclient.net/">WindowsClient.net</A>, and there... |
Input filtering is usually done on the language level rather than database layers.
php and .NET both have their respective libraries for escaping sql statements. Check your language, see waht's available.
If your data are trustable, then you can just do a string replace to add another ' infront of the ' to escap... |
Here's a little ruby script that does *exactly* what your question asks (pull an attribute called 'name' out of elements called 'myel'. Should be easy to generalize
#!/usr/bin/ruby -w
require 'rexml/document'
xml = REXML::Document.new(File.open(ARGV[0].to_s))
xml.elements.each("//myel") { ... |
Here's a little ruby script that does *exactly* what your question asks (pull an attribute called 'name' out of elements called 'myel'). Should be easy to generalize
#!/usr/bin/ruby -w
require 'rexml/document'
xml = REXML::Document.new(File.open(ARGV[0].to_s))
xml.elements.each("//myel") {... |
I suppose a good question is what language are you using?<br />
In PHP you would do: SELECT * FROM PEOPLE WHERE SURNAME='mysql_escape_string(O'Keefe)'<br />
But since you didn't specify the language I will suggest that you look into a escape string function mysql or otherwise in your language. |
If you right-click in the source of a file in Eclipse, it has a Javadoc generation option under the source menu. |
@garethm(29662):
> I believe that the function you're looking for is called tmpnam.
You should definitely *not* use `tmpnam`. It suffers from the race condition problem I mentioned in my answer: Between determining the name and opening it, another program may create the file or a symlink to it, which is a huge secu... |
@[garethm](#29662):
> I believe that the function you're looking for is called tmpnam.
You should definitely *not* use `tmpnam`. It suffers from the race condition problem I mentioned in my answer: Between determining the name and opening it, another program may create the file or a symlink to it, which is a huge s... |
I seem to remember that I have sometimes found it useful to use RunAs when you run msvcmon (or whatever it's called this week - the remote debugging stub anyway), to force it to start as the user which you have set up to be the same on both machines.
I would guess that on the machine you're running VS on, you will ... |
Same concept.
**Aonther take:**
> 1. Write down a list of the first 100 binary numbers which has fifty 1s and fifty 0s.
2. Sort them from lowest to highest.
3. Prisoner #1 gets the first number, prisoner #2 gets the second, prisoner #3 gets the third and so on...
4. Each prisoner remembers his/her binary numbe... |
The `|` is a bitwise operator in PHP. It does not mean `$a OR $b`, exactly. You'll want to use the double-pipe. And yes, as mentioned, PHP does short-circuit evaluation. In similar fashion, if the first condition of an `&&` clause evaluates to false, PHP does not evaluate the rest of the clause, either. |
While Scrum other agile methodologies like it embody a lot of good practices, sometimes giving it a name and making it (as many bloggers have commented on) a "religion" that must be adopted in the workplace is rather offputting to a lot of people, including myself.
It depends on what your options and commitments are... |
Some notes that I also found useful:
- Keep your default values on the right side.
function whatever($var1, $var2, $var3="constant", $var4="another")
- The default value of the argument must be a constant expression. It can't be a variable or a function call. |
I think the key would be to help her understand why you are doing Scrum in the first place. I guess you have your reasons, so why not tell her? You are likely to get resistance towards any change if the people involved don't understand why there is change or what they will benefit from it. If you can explain your reaso... |
We've invested in a few licenses of [Simply File][1] for our employees. Works a treat at managing your inbox - it learns (don't ask me how, but it is very good) how to file things for you and does it automatically.
I was sceptical about it at first, until I tried it then I was a convert.
[1]: http://www.techhi... |
Sure there is. This is all you need to do:
- Go to
<pre>File -> Settings -> Global Code Style -> General</pre>
- Disable the checkbox next to 'Use same settings for all file types'
- The 'XML' tab should become enabled. Click it and set the 'tab' (and probably 'indent') size to 2. |
<pre>
maxjobs=4
parallelize () {
while [ $# -gt 0 ] ; do
jobcnt=(`jobs -p`)
if [ ${#jobcnt[@]} -lt $maxjobs ] ; then
do-something $1 &
shift
fi
done
wait
}
parallelize arg1 arg2 "5 arg... |
Compiling the boost libraries for yourself is actually quite simple, if not that well documented. The documentation is in the jamroot file. Run `bjam --help` in the boost root directory for a detailed list of options. As an example I used the following command line to build my current set up with boost 1.36.0:
b... |
celsius = (5.0/9.0) * (fahr-32.0);
In this expression, `5.0`, `9.0`, and `32.0` are `double`s. That's the default type for a floating-point constant - if you wanted them to be `float`s, then you would use the `F` suffix:
celsius = (5.0F/9.0F) * (fahr-32.0F);
Note that if `fahr` was a `double`, then the r... |
Mark's answer is the way to go, after all, that's why the /proc file system is there. For something a little more copy/pasteable:
>>> import os.path
>>> os.path.exists("/proc/0")
False
>>> os.path.exists("/proc/12")
True |
Inbox Management (in Outlook) |
|email|outlook|gettingthingsdone| |
I've gone back and forth between having an organized inbox and having an inbox with absolutely everything I've received in it.
Would you recommend leaving everything in an inbox, or organize it? If you organize it, is there any method to your madness or possibly an Outlook (2003) plug-in to aid in this task?
F... |
|email|outlook|gtd| |
The limitation of MOSS crawling sites with different forms authentication should have been addressed in MOSS SP1. :
<a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=ad59175c-ad6a-4027-8c2f-db25322f791b&displaylang=en">http://www.microsoft.com/downloads/details.aspx?FamilyID=ad59175c-ad6a-4027-8c2f-d... |
I haven't used it myself, but the Microsoft Enterprise library has good encryption support that will possibly suit your needs:
[http://msdn.microsoft.com/en-us/library/cc309503.aspx][1]
[1]: http://msdn.microsoft.com/en-us/library/cc309503.aspx |
XmlHttpRequest return values |
|javascript|ajax| |
For an application I'm building in my spare time I am looking for (arguably) the correct way to return data from an XmlHttpRequest. Options I see are:
- Plain HTML. Let the request format the data and return it in a usable format.
Advantage: easy to consume by the calling page. Disadvantage: Very rigid, stuck wit... |
Using fck for some tine now, after "free text box", or something like that. Had problems only once, when I put fck inside asp.net ajax updatepanel, but found fix on forums. Problem was solved in next release.
I would like to see some nice photo browser in it, because fck comes only with simple browser that displays... |
The problem with catching all exceptions is that you may be catching ones that you don't expect, or indeed ones that you should **not** be catching. The fact is that an exception of any kind indicates that something has gone wrong, and you have to sort it out before continuing otherwise you may end up with data integri... |
Post office box number.
It's a piece of information that allows you to access something else.
(And if you do arithmetic on post office box numbers, you may have a problem, because the letter goes in the wrong box. And if somebody moves to another state -- with no forwarding address -- then you have a dangling poi... |
To answer the first part of your post, check out AzMan (Authorization Manager), which, incidentally, is built into windows. It has the capability to specify operations which can be recombined into roles or assigned directly to users.
http://msdn.microsoft.com/en-us/magazine/cc300469.aspx
|
To answer the first part of your post, check out AzMan (Authorization Manager), which, incidentally, is built into windows. It has the capability to specify operations which can be recombined into roles or assigned directly to users.
http://msdn.microsoft.com/en-us/magazine/cc300469.aspx
To answer the second par... |
> Problems - no way to get the number of strings automatically (that i know of).
There is a bog-standard way of doing this, which lots of people (including MS) define macros like arraysize() for:
#define arraysize(ar) (sizeof(ar) / sizeof(ar[0])) |
This [article describes][1] another developers frustrations with lack of C++ code coverage tools. It looks like their search led them to a tool called [Bullseye Coverage][2].
I haven't used any C++ coverage tools myself, but if you find one that works for you, find a way to get coverage to launch via a make file. ... |
This [article describes][1] another developers frustrations with lack of C++ code coverage tools. It looks like their search led them to a tool called [Bullseye Coverage][2]. Other tools like gcov are also mentioned in the article.
I haven't used any C++ coverage tools myself, but if you find one that works for yo... |
###What tools are available?
This [article describes][1] another developers frustrations with lack of C++ code coverage tools. It looks like their search led them to a tool called [Bullseye Coverage][2]. Other tools like gcov are also mentioned in the article.
I haven't used any C++ coverage tools myself, but i... |
Here are a few "How Do I" videos to get you started:
<http://windowsclient.net/learn/videos_wpf.aspx>
|
Scott Hanselmann has blogged extensively about his experience in learning WPF by creating his 'BabySmash' windows application. All the source code is on codeplex and he has many blog articles describing his progress.
[Initial BabySmash article][1]
[Codeplex source][2]
[BabySmash website][3]
[1]: http://... |
Add these attributes to the property in your control:
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
You can modify the user's personal.xls file, stored in the excel startup directory (varies between Office versions). If you have lots of users though, that can be fiddly.
An alternative way to get over your problem is to store the macro in a template (.xlt) file. Then when the users opens it they can't save it back ... |
Use the DesignerSerializationVisibilityAttribute on the properties that you want to hide from the designer serialization and set the parameter to Hidden.
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string Name
{
get;
set;
} |
This is my install scrpt, I use it on debian servers, but it will work in Ubuntu (Ubuntu is built on Debian)
apt-get -yq update
apt-get -yq upgrade
apt-get -yq install sudo
apt-get -yq install gcc
apt-get -yq install g++
apt-get -yq install make
apt-get -yq install apache2
apt-... |
Not sure where it went. You could roll your own extension though:
<pre>
public static class MyBindingExtensions
{
public static T ReadFromRequest &-l-t-; T &-g-t-; (this Controller controller, string key)
{
// Setup
HttpContextBase context = controller.ControllerContext.HttpContext;
obje... |
Not sure where it went. You could roll your own extension though:
public static class MyBindingExtensions
{
public static T ReadFromRequest < T > (this Controller controller, string key)
{
// Setup
HttpContextBase context = controller.ControllerContext.HttpContext;
o... |
I was going to suggest [Gridiron Flow][1]. But Brian beat me to it.
[1]: http://www.gridironsoftware.com/Flow/ |
@[BCS][1]
I'm 99.9% sure that the -l isn't causeing the problem because I can watch the load average on the machine and it drops down to about three and sometimes as low as one (!) without starting the next job.
[1]: http://stackoverflow.com/users/1343/bcs |
The XMPP gateway protocol you've heard of is most likely to do with transports. A transport is a server that connects to both a XMPP server and a non-XMPP server. By running a transport, I can use my Jabber client to talk to someone using, say, MSN Messenger.
A transport typically connects once to the remote netwo... |
@pkaeding
Yes, you're right. *window\[functionName]()* doesn't work in this case, but *eval* does. If I needed something like this, I'd create my own object to keep those functions together.
var func = {};
func.bar = ...;
var s = "bar";
func[s](); |
I think [GPGME][1] and the [PyMe Python wrapper][2] should do what you need.
[1]: http://www.gnupg.org/related_software/gpgme/
[2]: http://pyme.sourceforge.net/ |
Here's the basic pattern:
- Check the cache for the value, return if its available
- If the value is not in the cache, then implement a lock
- Inside the lock, check the cache again, you might have been blocked
- Perform the value look up and cache it
- Release the lock
In code, it looks like this:
... |
Here's the basic pattern:
- Check the cache for the value, return if its available
- If the value is not in the cache, then implement a lock
- Inside the lock, check the cache again, you might have been blocked
- Perform the value look up and cache it
- Release the lock
In code, it looks like this:
... |
I am not sure WHY it does that, but here's what you do in order to get Visual Studio to create the class as Public by default:
Go over to “Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033″, you will find a file called Class.zip, inside the .zip file open the file called Class.cs, ... |
I am not sure WHY it does that, but here's what you do in order to get Visual Studio to create the class as Public by default:
Go over to “Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033″, you will find a file called Class.zip, inside the .zip file open the file called Class.cs, ... |
I think this sort of depends on the level of "ajaxyness" your app is going to have. If your front end is a "rich client", al'a gmail, I'd go with the JSON solution, as you'd have to solve the problem of having client side view generation anyway. If you're using ajax sparingly, to provide simple messages to the user, up... |
Table cells larger than they are meant to be |
|html|css| |
I've created a map system for a game that runs on the principle of drawing the picture of the map from tiles. There are many reasons for this which I won't go into here but if you really want to know then I'm sure you can find out how to contact me ;)
I have [made the latest version live][1] so you can see exactly w... |
Different response format shouldn't be difficult to produce.
JSON works best for me, i like to keep OO in js, and don't know how to parse xml well :) |
#define IBOutlet
Whenever IBOutlet is used in program text, it will be replaced with nothing at all. |
If you're looking for a quick solution that should work with most available frameworks, I'd go for JSON. It's easy to start with and works.
If you're trying to build a larger application that you're going to extend (in terms of size or maybe your own API for 3rd party extensions) I'd go for XML. You could write a pr... |
The File.Copy method:
http://msdn.microsoft.com/en-us/library/system.io.file.copy(VS.71).aspx |
The File.Copy method:
[MSDN Link][1]
[1]: http://msdn.microsoft.com/en-us/library/system.io.file.copy.aspx |
I'd agree with John Topley - it depends on the application. There's a good article on quirksmode that discusses the advantages and disadvantages of each format that you might want to read: [http://www.quirksmode.org/blog/archives/2005/12/the_ajax_respon.html][1]
[1]: http://www.quirksmode.org/blog/archives/2005/... |
Loading assemblies and its dependencies |
|c#|.net| |
My application dynamically loads assemblies at runtime from specific subfolders. These assemblies are compiled with dependencies to other assemblies. The runtime trys to load these from the application directory. But I want to put them into the modules directory.
Is there a way to tell the runtime that the dlls are ... |
|javascript|firebug| |
I can easily set breakpoints in embedded JS functions, but I don't see any way of accessing extarnal JS scripts via Firebug unless I happen to enter them during a debug session. Is there a way to do this w/o having to 'explore' my way into the script? |
|javascript|firebug|debugging| |
|javascript|debugging|firebug| |
I can easily set breakpoints in embedded JS functions, but I don't see any way of accessing extarnal JS scripts via Firebug unless I happen to enter them during a debug session. Is there a way to do this w/o having to 'explore' my way into the script?
@Jason: This is a good point, but in my case I do not have easy a... |
For me sticking with the Dialog returning the standard dialog responses and then accessing the results via properties is the way to go.
Two good reasons from where I sit:
1. Consistency - you're always doing the same thing with a dialog and the very nature of the question suggests that patterns are good (-: Alth... |
What happens if you remove the `Alias /` directive? |
Protected member variables? |
|c#|java|c++|coding-style| |
Should you ever use protected member variables? What are the the advantages and what issues can this cause? |
There is a good writeup on [Craig McMurtry's WebLog][1]. Its a couple of years old, but most of it is still relevant.
As well as a decision tree to walk through the choices, he shows how to implement those changes using Windows Communication Foundation
[1]: http://blogs.msdn.com/craigmcmurtry/archive/2006/07/23... |
Tail recursion is well-described in previous answers, but I think an example in action would help to illustrate the concept.
Consider a simple function that adds the first N integers. (e.g. `sum(5)=1+2+3+4+5=15`).
Here is a simple Python implementation that uses recursion:
def recsum(x):
if x==1:
... |
try with addTab instead of loadOneTab, and remove the last parameter.
Check out [this page][1] over at the Mozilla Development Center for information on how to open tabs.
You could use this function, for example:
function openAndReuseOneTabPerURL(url) {
var wm = Components.classes["@mozilla.org/ap... |
You pointed to a breakpoint in the code. Since you are in the debugger, you could set a breakpoint on the constructor of the exception class, or set Visual Studio debugger to break on all thrown exceptions (Debug->Exceptions Click on C++ exceptions, select thrown and uncaught options) |
It seems that lxml does not expose this libxml2 feature, grepping the source only turns up some #defines for the error handling:
C:\Dev>grep -ir --include=*.px[id] catalog lxml-2.1.1/src | sed -r "s/\s+/ /g"
lxml-2.1.1/src/lxml/dtd.pxi: catalog.
lxml-2.1.1/src/lxml/xmlerror.pxd: XML_FROM_CATALOG = 20 #... |
This is my install scrpt, I use it on debian servers, but it will work in Ubuntu (Ubuntu is built on Debian)
apt-get -yq update
apt-get -yq upgrade
apt-get -yq install sudo
apt-get -yq install gcc
apt-get -yq install g++
apt-get -yq install make
apt-get -yq install apache2
apt-... |
This is my install scrpt, I use it on debian servers, but it will work in Ubuntu (Ubuntu is built on Debian)
apt-get -yq update
apt-get -yq upgrade
apt-get -yq install sudo
apt-get -yq install gcc
apt-get -yq install g++
apt-get -yq install make
apt-get -yq install apache2
apt-... |