instruction stringlengths 0 30k ⌀ |
|---|
This is linux specific, but you could use:
readlink /proc/$$/fd/255
|
Common Lisp, used in the real-world albeit not wildely so, I guess. |
You could use a `System.Diagnostics.Stopwatch` it will allow you to track the time the query executes. Just remember that Linq->SQL queries aren't executed until you enumerate over them. Also note that if you are logging to `Console.Out` there will be a significant performance hit. |
Here's another solution that I just did, seeing that I understand what you want to do:
**Here's your ASCX / ASPX**
<asp:ListView ID="ListView1" runat="server" DataSourceID="MyDataSource" ItemPlaceholderID="itemPlaceHolder" OnDataBound="ListView1_DataBound">
<LayoutTemplate>
<... |
Leave the markup as is and make a call to Page.DataBind(); in your code behind. |
How to tell if .net code is being run by Visual Studio designer |
|visual-studio|gui-designer| |
I am getting some errors thrown in my code when I open a win form in visual studio's designer. I would like to branch in my code and perform a different initialization if the form is being opened by designer than if it is being run for real.
How can I determine at run-time if the code is being executed as part of d... |
Doxygen is wonderful. I've had to get across several legacy code bases that I was never involved in before, and it's been fantastic for that (even though the code bases were not documented using Doxygen format). |
Silverlight Cross Domain Policies |
|silverlight| |
In a silverlight application, I want to access the page the silverlight .xap file from an HTTP subdomain, but have the web services access a different subdomain for sensitive information over HTTPS.
I set up clientaccesspolicy.xml at the root of the subdomain and it lets the silverlight app access its services over ... |
How do you direct traffic to/from a particular site to a specific NIC? |
|networking| |
In Windows XP:
How do you direct traffic to/from a particular site to a specific NIC?
For Instance: How do I say, all connections to stackoverflow.com should use my wireless connection, while all other sites will use my ethernet?
|
Threads by definition are part of the same process. If you want them to keep running, they need to be forked off into a new process; see os.fork() and friends. |
Threads by definition are part of the same process. If you want them to keep running, they need to be forked off into a new process; see os.fork() and friends.
You'll probably want the new process to end (via exit() or the like) immediately after spawning the script. |
Most modern processors have floating point registers that have more than 64 bits of precision. That way, if you run several operations on double-precision numbers, you actually get a higher-precision answer than if you were to truncate each intermediate result to 64 bits.
This is usually great, but it means that de... |
Garbage collectors for C++ |
|c++|garbage-collection| |
What free and commercial garbage collection libraries are available for C++, and what are the pros and cons of each?
I am interested in hard-won lessons from actual use in the field, not marketing or promotional blurb.
There is no need to elaborate on the usual trade offs associated with automatic garbage collect... |
You would use abstract if you do not want to define any implementation in the base class and want to force it to be defined in any derived classes. Define it as a virtual if you want to provide a default implementatio that can be overriden by derived classes.
Yes, only methods can be virtual. |
From the root level of the source tree and do the following (\t is the tab character):
find . -exec grep '[ \t]*#include[ \t][ \t]*["<][^">][">]' {} ';'
| sed 's/^[ \t]*#include[ \t][ \t]*["<]//'
| sed 's/[">].*$//'
| sort
| uniq -c
| sort -r -k1 -n
Line 1 get all ... |
Here's my response to a [similar question][1]:
The combination of OneNote with a tablet PC is awesome! I was a bit of a skeptic at first. I used the trial version and then forgot about it. A year later I had an unruly collection of files, project related emails, notebooks and scraps of paper all scattered throughout... |
The answer does depend really on what your application actually does and your platform requirements.
If its a regular web application like gmail and you want it to work on lots of browsers and platforms; then I'd recommend a combination of HTML, CSS and [GWT](http://code.google.com/webtoolkit/) as this means your a... |
There is no reason why your test package cannot catch asserts such as the one in doMoreWonderfulThings. This can be done either by having your ASSERT handler support a callback mechanism, or your test asserts contain a try/catch block.
|
Realistically, setting i to be a register variable won't do anything that the compiler wouldn't do already.
If you are willing to spend some time upfront preprocessing the reference array, you should google "The World's Fastest Scrabble Program" and implement that. Spoiler: it's a DAG optimized for character lookups... |
Okay, fine, I'll throw another one out there: audio file support. I'd love to be able to generate WAV data on the client and immediately play it. As it is, Silverlight only plays WMV and MP3, neither of which is simple (legal?) to create without a per-client license. |
One interesting use is as a mechanism for asynchronous programming esp for tasks that take multiple steps and require the same set of data. Two examples of this would be Jeffery Richters AysncEnumerator [Part 1](http://msdn.microsoft.com/en-us/magazine/cc163323.aspx) and [Part 2](http://msdn.microsoft.com/en-us/magazin... |
One interesting use is as a mechanism for asynchronous programming esp for tasks that take multiple steps and require the same set of data in each step. Two examples of this would be Jeffery Richters AysncEnumerator [Part 1](http://msdn.microsoft.com/en-us/magazine/cc163323.aspx) and [Part 2](http://msdn.microsoft.com/... |
> Awesome, this seems like the best way to do permissions in a CMS. Yes? No?
Maybe, I've never really done it that way. What I have done is used bitwise operators to store a whole bunch of "yes or no" settings in a single number in a single column in the database.
I guess for permissions, this way would work good... |
IE7 HTML/CSS margin-bottom bug. |
|internet-explorer-7|css|html|design| |
Here is the scenario:
I have a table with a margin-bottom of 19px. Below that I have a form that contains some fieldsets. One of them is floated right. The problem is that the margin-bottom is not getting the full 19px in IE7. I've gone through all of the IE7 css/margin/float bugs that I can think of and have tried... |
For smaller differences you might be able to do a normal text-diff, and then analyse the missing or inserted pieces to see how to resolve it, but for any larger differences you're going to have a very tough time doing this.
For instance, how would you detect, and show, that a left-aligned image (floating left of a p... |
Is there a user friendly XML editor out there? I can't find anything good, preferably open source |
|xml|server|cms|user-interface|editing| |
Something to take an XML schema and let you add/edit data but not change the XML structure, preferably installed on a server. basically a UI to edit xml documents as a web app. Someone has got to have done this already right? |
Batch insert using JPA/Toplink |
|java|oracle-database|jpa|toplink| |
I have a web application that receives messages through an HTTP interface, e.g.:
http://server/application?source=123&destination=234&text=hello
This request contains the ID of the sender, the ID of the recipient and the text of the message.
This message should be processed like:
- finding the matchin... |
I have a web application that receives messages through an HTTP interface, e.g.:
http://server/application?source=123&destination=234&text=hello
This request contains the ID of the sender, the ID of the recipient and the text of the message.
This message should be processed like:
- finding the matchin... |
How to work around a very large 2d array in C++ |
|c++|graphics|2darray|vectors|zbuffer| |
I need to create a 2D int array of size 800x800. But doing so creates a stack overflow (ha ha).
I'm new to C++, so should I do something like a vector of vectors? And just encapsulate the 2d array into a class?
Specifically, this array is my zbuffer in a graphics program. I need to store a z value for every pi... |
|c++|arrays|graphics|2d|multidimensional| |
|c++|arrays|graphics|2d| |
|c++|graphics|arrays|2d|zbuffer| |
That looks like a perfectly acceptable solution. If that works, use it. That is minimal code and there's no reason to optimize it unless you have to. |
At my company, we started using [Red-gate][1]'s data generator to generate test data. There is a bit of setup, but you can use the tools to generate very usable test data. Yes, I would prefer to use live production data, but it's not feasible (especially if you need to consider in HIPAA). It uses regex for each column ... |
I don't have any best practices paper or anything. But I would think that if you're developing out of an environment that is *as protected* as the environment that hosts the data in production, there wouldn't be a lot of argument to be made against it.
That is, if your production database is in a datacenter hosted ... |
One solution to prevent spam, make sure the first line, last line or a specific line contains a certain string, almost like a password, but a full sentence is better.
Only you have the word or words, pretty secure, just remember to delete the mails after use and those that do not have the secret line. |
This page from Microsoft goes into the details of DLL initialization and destruction of globals:
http://msdn.microsoft.com/en-us/library/988ye33t(VS.80).aspx |
How can I kill a process, using VBScript, started by a particular user. |
|vbscript|windows-server-2003|kill| |
I have multiple users running attachemate on a Windows 2003 server. I want to kill attachemate.exe started by user_1 without killing attachemate.exe started by user_2.
I want to use VBScript. |
More answers [here][1].
[1]: http://stackoverflow.com/questions/42308/tool-to-track-include-dependencies |
The answers [here][1] will give you tools which track #include dependencies. But there's no mention optimization and such.
Aside: The book "Large Scale C++ Software Design" should help.
[1]: http://stackoverflow.com/questions/42308/tool-to-track-include-dependencies |
Map 192.168.0.10 to 127.0.0.1 on windows |
|networking|hosts| |
I need to access a svn repository from home, that runs under the IP 192.168.0.10 in the work network.
I can establish a SSH tunnel to my localhost.
Now I have to map 192.168.0.10 in a way, that instead 127.0.0.1 is accessed.
Does anybody know a way to do this under Windows?
Thanks in advance! |
AFAIK you can't express recursion with regular expressions.
You can however do that with .NET's System.Text.RegularExpressions using balanced matching. See more here: http://blogs.msdn.com/bclteam/archive/2005/03/15/396452.aspx
If you're using .NET you can probably implement what you need with a callback.
If ... |
For MSVC only, add the following to the top of each .cpp file:
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
Then, when debugging with VS2003 or greater, you will be told of any leaks when your program exits (it tracks new/delete). It's basic, but it has helped me in the past. |
**I agree with Stephan: One task, one method name**, even if you can do it multiple ways.
Method overloading feature was provided exactly for your case.
* getEmployeeName(int BatchID)
* getEmployeeName(String Email)
* etc.
And **avoid** your second solution at all cost. It smells like "thy olde void * of C". L... |
emacs has a great front end to gdb too. |
Check that your UTF-8 data is all 3-bit Unicode. If you have 4-bit characters (legal in Unicode and Java, illegal in MySQL 5), it can throw this error when you try to insert them. This is an [issue that should be fixed][1] in MySQL 6.0.
[1]: http://bugs.mysql.com/bug.php?id=25666 |
Check that your UTF-8 data is all 3-byte Unicode. If you have 4-byte characters (legal in Unicode and Java, illegal in MySQL 5), it can throw this error when you try to insert them. This is an [issue that should be fixed][1] in MySQL 6.0.
[1]: http://bugs.mysql.com/bug.php?id=25666 |
I don't really know why you want to do that, but you can install an excepthook that will be called by Python whenever an uncatched exception is raised, and in it clear the array of registered function in the `atexit` module.
Something like that :
import sys
import atexit
def clear_atexit_excepthoo... |
Forward declaring an enum in c++ |
|c++|enums| |
I'm trying to do something like the following:
----
enum E;
void Foo(E e);
enum E {A, B, C};
----
which the compiler rejects. I've had a quick look on Google and the consensus seems to be "you can't do it", but I can't understand why. Can anyone explain? Many thanks. |
I'm trying to do something like the following:
enum E;
void Foo(E e);
enum E {A, B, C};
which the compiler rejects. I've had a quick look on Google and the consensus seems to be "you can't do it", but I can't understand why. Can anyone explain? Many thanks.
|
I'm trying to do something like the following:
enum E;
void Foo(E e);
enum E {A, B, C};
which the compiler rejects. I've had a quick look on Google and the consensus seems to be "you can't do it", but I can't understand why. Can anyone explain? Many thanks.
edit: I'm doing this as ... |
I'm trying to do something like the following:
enum E;
void Foo(E e);
enum E {A, B, C};
which the compiler rejects. I've had a quick look on Google and the consensus seems to be "you can't do it", but I can't understand why. Can anyone explain? Many thanks.
Clarification 2: I'm doi... |
ATL was only included in older versions of the SDK. Recent versions of ATL share much code with MFC and are only available with the real versions of Visual Studio, i.e. not with VS Express.
So: to use ATL and/or MFC, you need to buy the Professional version of Visual Studio. If you are content with old versions of A... |
I think the question is valid. I agree with the other responses, but it doesn't mean it's a terrible question. I've only ever had to use a Safari CSS hack once as a temporary solution and later got rid of it. I agree that you shouldn't have to target just Safari, but no harm in knowing how to do it.
FYI, this hack o... |
The Class class is a run-time representation of a type. Since parametrized types undergo type erasure at runtime, the class object for Class<List> would be the same as for Class<List<Integer>> and Class<List<String>>.
The reason you cannot instantiate them using the .class notation is that this is a spec... |
It is possible, but you will have to link lua interpreter source code to your application source code and wrap BREW API functions in order to use them from lua scripts.
Check out [LuaBREW][1] project as an example of approach I briefly explained above.
[1]: http://luaforge.net/projects/luabrew |
Try:
Regex rex = new Regex(",(?=([^\"]*\"[^\"]*\")*(?![^\"]*\"))");
string[] values = rex.Split( csvLine );
Source: [http://weblogs.asp.net/prieck/archive/2004/01/16/59457.aspx][1]
[1]: http://weblogs.asp.net/prieck/archive/2004/01/16/59457.aspx |
This could also be because your FTP client might not be showing the hidden files (like cache, or any hiddn files that your application might create), while the hidden files are preventing you from deleting the directory. (though, in your case, I am not sure if this is the cause .. .it could be permission issue with you... |
Radio buttons and check buttons are just buttons. Use a CButton control and use GetCheck/SetCheck. |
There is a domain transfer procedure. GoDaddy does a good job of talking you through it (I've transferred a domain to them in the past). Of course, you're going to have to pay them to register the domain for you (though they occasionally offer discounts on domain transfers). |
There is a domain transfer procedure. It's kind of complex, since it's intended to keep people from stealing domains by transferring them to another registrar (like happened to [sex.com][1] back in the 90's). GoDaddy does a good job of talking you through it (I've transferred a domain to them in the past). Of course... |
System.Diagnostics.Debugger.IsAttached
|
Keep it a natural design (denormalize as much as needed, normalize as less as required). Split the DB Model into its modules and keep the service oriented principles in mind by fronting data with a service (that owns the data). |
The answer really depends on why you want to do this. If you just want to clean up dead threads, for example, it's probably easiest just to have a "dead thread cleaner" thread that loops and joins. |
[RFC 1034][1] describes how to cache negative responses but did not define a mechanism for returning those cache results to peer resolvers. [RFC 2308][2] defines these attributes.
Negative caching was an optional part of the DNS Specifications...
[1]: http://www.faqs.org/rfcs/rfc1034.html
[2]: http://www.faq... |
This may be barking up the wrong tree, but a couple of things that have bitten me in the past that left me scratching my head:
- Naming the input element a duplicated/reserved word (thinking "name", "method", "reset", etc.)
- having the form element physically outside of the form being submitted
I find that ... |
What is the most straightforward way to pad empty dates in sql results (on either mysql or perl end)? |
|perl|mysql|calendar|datediff| |
I'm building a quick csv from a mysql table with a query like:
select DATE(date),count(date) from table group by DATE(date) order by date asc;
and just dumping them to a file in perl over a:
while(my($date,$sum) = $sth->fetchrow) {
print CSV "$date,$sum\n"
}
There are date gaps in the... |
I'm building a quick csv from a mysql table with a query like:
select DATE(date),count(date) from table group by DATE(date) order by date asc;
and just dumping them to a file in perl over a:
while(my($date,$sum) = $sth->fetchrow) {
print CSV "$date,$sum\n"
}
There are date gaps in the... |
|mysql|perl|calendar|datediff| |
I'm building a quick csv from a mysql table with a query like:
select DATE(date),count(date) from table group by DATE(date) order by date asc;
and just dumping them to a file in perl over a:
while(my($date,$sum) = $sth->fetchrow) {
print CSV "$date,$sum\n"
}
There are date gaps in the... |
The suggestions about using custom class loaders and dynamically commented code are a bit incredulous when it comes to maintenance and the preservation of the sanity of whichever poor soul picks up the project after you shuffle to pastures new.
The solution is easy. Pull the affected classes out into two separate, ... |
<blockquote><p>You also have a fourth alternative that I think would be better than alternative 3:</p>
<pre><code>haystack.find(needle, searcher)</code></pre>
</blockquote>
I see your point, but what if <code>searcher</code> implements a searching interface that allows for searching other types of objects than hay... |
<blockquote><p>You also have a fourth alternative that I think would be better than alternative 3:</p>
<pre><code>haystack.find(needle, searcher)</code></pre>
</blockquote>
I see your point, but what if <code>searcher</code> implements a searching interface that allows for searching other types of objects than hay... |
That is the correct approach in WPF, but not in Silverlight.
You cannot bind to elements using xaml in Silverlight.
This is the offending line:
TeamId="{Binding ElementName=oUserTeams, Path=TeamId}"
Specificly ElementName
If you cant place the data object into Resources and declare it there, you can ... |
That is the correct approach in WPF, but not in Silverlight.
You cannot bind to elements using xaml in Silverlight.
This is the offending line:
TeamId="{Binding ElementName=oUserTeams, Path=TeamId}"
Specificly ElementName
If you can, place the data object into Resources and declare it there, then you... |
Have you tried using SetWindowPos. This is the canonical function for moving, resizing and setting z-order in Windows. There is a SWP_NOACTIVATE flag you can use. Look at http://msdn.microsoft.com/en-us/library/ms633545(VS.85).aspx. I have not tried this on a window belonging to another process, but it is probably wort... |