instruction stringlengths 0 30k ⌀ |
|---|
LinkedResource objLinkedRes = new LinkedResource(
Server.MapPath(".")
+ "\\fuzzydev-logo.jpg",
"image/jpeg");
objLinkedRes.ContentId = "fuzzydev-logo";
AlternateView objHTLMAltView = AlternateView.CreateAlternateViewFromString(
"<img src='cid:fuzzydev-logo' />",
new System.Net.Mime.Con... |
It can catch actual bugs, like forgetting to Dispose IDisposables. |
how do I query multiple SQL tables for a specific key-value pair? |
|sql|lazy-evaluation| |
Situation: A PHP application with multiple installable modules creates a new table in database for each, in the style of mod_A, mod_B, mod_C etc. Each has the column section_id.
Now, I am looking for all entries for a specific section_id, and I'm hoping there's another way besides "Select * from mod_a, mod_b, mod_c ... |
Where can I find the world's fastest atof implementation? |
|c|c++|assembly| |
I'm looking for an extremely fast atof() implementation on IA32 optimized for US-en locale, ASCII, and non-scientific notation. The windows multithreaded CRT falls down miserably here as it checks for locale changes on every call to isdigit(). Our current best is derived from the best of perl + tcl's atof implementat... |
|c++|c|assembly| |
I'm looking for an extremely fast atof() implementation on IA32 optimized for US-en locale, ASCII, and non-scientific notation. The windows multithreaded CRT falls down miserably here as it checks for locale changes on every call to isdigit(). Our current best is derived from the best of perl + tcl's atof implementat... |
I don't have a specific site, but tend to just google the main keywords of what I am looking for. There are many sites out there, however, I have got the best responses here for very specific stuff. |
Unfortunately, I'm not aware of a ready-made solution for this. In the worst case scenario, consider developing it yourself, say, using Java NIO -- it shouldn't take more than a week. |
You can't really answer this kind of question with a "I like 'insert provide name here'" type answer because like so many things it is a balance and the reasons for choosing a payment processing solution tend to be complex.
## Volume / Value
The most important factor in choosing a secure payment clearance service... |
I like IRC, try #perl on irc.perl.org or irc.freenode.net, or maybe #perlhelp on irc.efnet.nl. Lots and lots of very clever, helpful people always willing to discuss perl-related issues.
Maybe I'll see you there :) |
You'd probably have to loop through the results and reject those with the attributes that you don't want (use the Attributes property).
|
We use Quality Center / Test Director stuff. Its expensive as far as I know, and it's not that great. |
Important point to note though - if your thread is marked with IsBackground=True, it won't prevent the whole process from exiting |
I haven't been succesful at getting Cobertura to combine reporting from multi-projects. This has been a problem in general with multi-project reporting.
We have been evaluating [sonar][1] as a solution for our metrics reporting. It seems to do a great job of providing summary metrics across projects, including multi... |
I've been trying to retrieve the locations of all the page breaks on a given Excel 2003 worksheet over COM. Here's an example of the kind of thing I'm trying to do:
Excel::HPageBreaksPtr pHPageBreaks = pSheet->GetHPageBreaks();
long count = pHPageBreaks->Count;
for (long i=0; i < count; ++i)
{
... |
After doing a bit more research I decided to go with the open source [MojoBlog][1]. It was quite easy to install and configure and after a few stalls and hang ups that were resolved via perusal of their forums I was up and running. The edit interface is not ideal but it much better than Joomla admin, and it has multi... |
You mean you want to pad all numbers on the right with spaces?
If so, [String.PadRight][1] or [String.Format][2] should get you on track.
[1]: http://msdn.microsoft.com/en-us/library/system.string.padright.aspx
[2]: http://msdn.microsoft.com/en-us/library/system.string.format.aspx |
Probably, but to do so we'd need to get the major browsers to support them. IE support would be the hardest to get. JavaScript is used because it is the only thing you can count on being available. |
You raise a lot of questions that make it hard to select any of your proposed solutions without a lot more clarification on the exact problem you are trying to solve. Consider not just my clarification questions, but the criteria that you will use to evaluate my questions, as an indication of the amount of detail requ... |
public double PI = 22.0/7.0; |
Have you tried this (from your thread on MSDN forums)?
> Well, it seems the reference in the MSDN link above incorrectly specify the affected registry root key. In MSDN it is specified as HKEY_CURRENT_USER, while the correct root key should be HKEY_LOCAL_MACHINE. I've tried setting up the HKEY_LOCAL_MACHINE\Software... |
You'll have to add both trunk and test versions as different applications and test them using [test accounts][1]. You may also use a single application and switch its target URL between cycles.
[1]: http://developers.facebook.com/news.php?blog=1&story=35 |
Since everyone else said pretty much what I'm thinking when I read this question, I'll just share two books related to this subject that you might be interested in reading. These books use open source code examples to explain how to read and write high quality code. In addition to Code Complete, I think they are valuab... |
Your best bet will probably be to use the Windows32 API for this. See the following MSDN article for sample VBA code on how to interact with the API.
[http://msdn.microsoft.com/en-us/library/aa155724(office.10).aspx][1]
The article outlines a few different techniques, but I'd suggest searching the article for "CO... |
|c|pointers|malloc| |
I think I've got it down to the most basic case:
int main(int argc, char ** argv) {
int * arr;
foo(arr);
printf("car[3]=%d\n",arr[3]);
free (arr);
return 1;
}
void foo(int * arr) {
arr = (int*) malloc( sizeof(int)*25 );
arr[3] = 69;
}
The o... |
How do I stop Blend 2.5 June Preview replacing Canvas.ZIndex with Panel.ZIndex on SL1.0 XAML? |
|wpf|silverlight|xaml|blend| |
I have a Silverlight 1.0 application that I edit with Blend 2.5. Whenever I touch a UIElement in the designer that has a Canvas attribute such as Canvas.ZIndex="1", when it updates the XAML, it changes the Canvas prefix to Panel, leaving Panel.ZIndex="1", causing the page to fail to load.
How do I make it stop the ... |
"premature optimization is the root of all evil"
In terms of database programming, I think this quote is nonsense. It is extremely expensive to re-write your whole application because your developers don't care to write efficient code the first time. All t-sql code should be thought of in terms of how it will affect... |
Is that the entirety of your source code? I'm sure this isn't the problem but just in case, you ***are*** opening the **?php** tag right?
Here's one of my simple service classes:
<?php
class Products {
public function __construct() {
mysql_connect("localhost", "myuser", "mypass"... |
|asp.net|asp.net-mvc|model-view-controller| |
When I first heard about StackOverflow, and heard that it was being built in ASP.Net MVC, I was a little confused. I thought ASP.Net was always an example of an MVC architecture. You have the .aspx page that provides the view, the .aspx.vb page that provides the controller, and you can create another class to be the ... |
You just asked the [million dollar question][1]. Finding a Hamilton path is an NP-complete problem. Some NP-hard problems can be solved in polynomial time using dynamic programming, but (to my knowledge) this is not one of them.
[1]: http://en.wikipedia.org/wiki/P_versus_NP |
I just tested that and **it works, as expected,** with the kind of code you tried.
Compiled in D2007/XP, ran in both XP and Vista without problem.
procedure TForm1.Button1Click(Sender: TObject);
begin
Application.HelpFile:= 'depends.chm';
Application.HelpContext(0);
HelpFile:='GExp... |
When you say the "Printing" Dialog, I assume you mean the "Now printing xxx on <printer>" dialog rather than standard print dialog (select printer, number of copies, etc). Taking your example above & trying it out, that is the behaviour I saw - "Now printing..." was displayed briefly & then auto-closed.
What you're ... |
When you say the "Printing" Dialog, I assume you mean the "Now printing xxx on <printer>" dialog rather than standard print dialog (select printer, number of copies, etc). Taking your example above & trying it out, that is the behaviour I saw - "Now printing..." was displayed briefly & then auto-closed.
What you're ... |
Many classes of memory leaks and common logic errors can be caught statically as well. You can also look at cyclomatic complexity and such, which may be part of the "coding standards" you mentioned, but may be a separate metric you use to evaluate the algorithmic "cleanliness" of your code.
In any case, only a judi... |
Ajax should be thought of as a means to alter some content on a page without reloading the entire page.
So when do you need to do this? Really only when you have some user interactions or form information that you want to keep intact while you change some content on the page. |
You'd have to read the file contents first like:
<?php
$file=fopen(date("Y-m-d").".txt","r+") or exit("Unable to open file!");
if ($_POST["lastname"] <> "")
{
$existingText = file_get_contents($file);
fwrite($file, $existingText . $_POST["lastname"]."\n");
}
f... |
If you want to put your text at the beginning of the file, you'd have to read the file contents first like:
<?php
$file=fopen(date("Y-m-d").".txt","r+") or exit("Unable to open file!");
if ($_POST["lastname"] <> "")
{
$existingText = file_get_contents($file);
fwrite($file... |
Depends on the rules, but many subtle defects can be avoided, code can be cleaned, potential performance problems can be detected etc.
Put it one way...if it's cheap or free (in both time and financial costs) and doesn't break anything, why not use it? |
To iterate the point further:
select a.*
from @a a
inner join @b b on a.value = b.value
This will return all the values in @a that match @b |
There are all kinds of benefits:
1) If there are anti-patterns in your code, you can be warned about it.
2) There are certain metrics (such as McCabe's Cyclomatic Complexity) that tell useful things about source code.
3) You can also get great stuff like call-graphs, and class diagrams from static analysis. Those... |
If nothing else, bash shells still use 0 for true, and 1 for false. |
It might be in reference to a result code of 0 which in most cases after a process has run, a result code of 0 meant, "Hey, everything worked fine, no problems here." |
Is it possible in W3C's XML Schema language (XSD) to allow a series of elements to be in any order but still limit occurrences? |
|xml|schema|xsd| |
I know about `all` and `choice`, but they don't account for a case where I do want some elements to be able to occur more than once, such as:
<Root>
<ThingA/>
<ThingB/>
<ThingC/>
<ThingC/>
<ThingC/>
</Root>
I could use `sequence`, but I'd prefer to allow these... |
JavaScript is your only native, standard option available. If you want lots of power, grab jQuery, but if you need to do a bunch more, consider writing an addon for Firefox? or similar for IE etc. |
You have to bootstrap it using the void* parameter:
<pre>class A
{
static void* StaticThreadProc(void *arg)
{
return reinterpret_cast<A*>(arg)->ThreadProc();
}
void* ThreadProc(void)
{
// do stuff
}
};
...
pthread_t theThread;
pthread_create(&theThread, NULL, &A::StaticThreadPr... |
You have to bootstrap it using the void* parameter:
<pre>class A
{
static void* StaticThreadProc(void *arg)
{
return reinterpret_cast<A*>(arg)->ThreadProc();
}
void* ThreadProc(void)
{
// do stuff
}
};
...
pthread_t theThread;
pthread_create(&theThread, NULL, &A::StaticTh... |
Firing COM events in C++ - Synchronous or asynchronous? |
|c++|com|activex|atl| |
I have an ActiveX control written using the MS ATL library and I am firing events via `pDispatch->Invoke(..., DISPATCH_METHOD)`. The control will be used by a .NET client and my question is this - is the firing of the event a synchronous or asynchronous call? My concern is that, if synchronous, the application that h... |
You could use ASCIIEncoding.UTF8.GetBytes(text) to convert it to a byte array. Then write the byte arrays out to the file as a fixed-size record.
UTF8 varies in the number of bytes required to represent some characters, UTF16 is a little more predictable, 2 bytes per character. |
There used to be an add-in to Reflector which creates a complete Visual Studio solution. However, I don't know if it's still available or working, now that Red Gate owns it. |
There used to be an add-in to Reflector which creates a complete Visual Studio solution. However, I don't know if it's still available or working, now that Red Gate has taken over Reflector. |
Just catch the exception. The small overhead from catching an exception drowns compared to parsing the XML.
If you really want the function, implement it yourself:
public class MyXmlDocument: XmlDocument
{
bool TryParseXml(string xml){
try{
ParseXml(xml);
return true... |
Just catch the exception. The small overhead from catching an exception drowns compared to parsing the XML.
If you want the function (for stylistic reasons, not for performance), implement it yourself:
public class MyXmlDocument: XmlDocument
{
bool TryParseXml(string xml){
try{
... |
The way I currently work is that I (the developer) build the functionality using a dummy FLA file, using only external class files. When the designer(s) finish up the layout, they send me a FLA with all the imported assets, and linked buttons and MovieClips. I then spend a attach my document class to the new FLA, and m... |
I have used turbogears and rails a little bit. Before using rails, I tried using grails because I was using groovy for my scripting. Grails was a difficult experience.
The groovy call stack is difficult to read for a small program, but when you add in several heavy weight frameworks a simple error can yield 100s... |
That is perfectly reasonable C++. |
Flex and Flash SWFs are essentially the same, just built using different tools. I'm not sure if they share the same component libraries, but based on the package names I'm guessing they at least mostly do.
If it's a normal Text Input then I would guess it's an instance of mx.controls.TextInput. |
interacting with a CMutex without MFC |
|windows|mfc|qt|mutex|cmutex| |
We have multiple MFC apps, which use CMutex( false, "blah" ), where "blah" allows the mutex to work across process boundaries.
One of these apps was re-written without MFC (using Qt instead). How can I simulate the CMutex using Win32 calls? (Qt's QMutex is not inter-process.) I prefer not to modify the MFC apps. |
You might also want to try using windmove which lets you navigate to the window of your choice based on geometry. I have the following in my .emacs file to change windows using C-x arrow-key.
(global-set-key (kbd "C-x <up>") 'windmove-up)
(global-set-key (kbd "C-x <down>") 'windmove-down)
(global-set-k... |
Is there an elegant way to instantiate a variable type with parameters? |
|.net|generics|instantiation| |
This isn't legal:
public class MyBaseClass
{
public MyBaseClass() {}
public MyBaseClass(object arg) {}
}
public void ThisIsANoNo<T>() where T : MyBaseClass
{
T foo = new T("whoops!");
}
In order to do this, you have to do some reflection on the type objec... |
You could also use [Perl6::Junction][1].
use Perl6::Junction qw'any';
my @arr = ( 1, 2, 3 );
if( any(@arr) == 1 ){ ... }
[1]: http://search.cpan.org/~cfranks/Perl6-Junction-1.40000/lib/Perl6/Junction.pm |
Data declared in a compilation unit will go into the .BSS or the .Data of that files output. Initialised data in BSS, uninitalised in DATA.
The difference between static and global data comes in the inclusion of symbol information in the file. Compilers tend to include the symbol information but only mark the glob... |
One thing to pay extra attention to is if you by _library_ mean a DLL or similar. Then there might be problems if the library consumer, say an application, is built with another compiler than the library itself.
Consider the case where you in your example return a `std::vector<>` by value. Memory will then be alloca... |
It's mapping user rights to specific databases. If you don't check any, that user won't have rights to any database unless it is in a server role that allows rights to individual databases. |
As someone else noted, chapter 11 of Josh Bloch's [Effective Java][1] is an indispensible resource on Java Serialization.
A couple points from that chapter pertinent to your question:
- assuming you want to serialize the state of the non-serializable field in MyClass2, that field must be accessible to MyClass, ei... |
I am assuming you want to get the name of the process owning the currently focused window. With some pinvoke:
// The GetForegroundWindow function returns a handle to the foreground window
// (the window with which the user is currently working).
[System.Runtime.InteropServices.DllImport("u... |
MVC is great but won't become a real contender as a replacement for Web Forms until it includes it's own rich control set. As you probably already know, some of the existing controls do work with it but many don't. Regardless of this though, I still love using it. |
Have you looked into any Continuous Integration solutions such as CruiseControl.NET? If you are able to deploy Reports using rs.exe then you can setup an automated process in CruiseControl to build and deploy your Reports on a timer or whenever a report is modified. |
String original = "hello world";
byte[] utf8Bytes = original.getBytes("UTF8");
|
String original = "hello world";
byte[] utf8Bytes = original.getBytes("UTF8");
|
I'm not 100% sure of what you are trying to do but this solution may work if your element1, element2 and element3 are nested consistently.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
... |
I don't know of a standard API for creating a node pragmatically. But this is what I've gleaned from building a module that does what you're trying to do.
1. Make sure the important fields are set: uid, name, type, language, title, body, filter (see `node_add()` and `node_form()`)
2. Pass the node through `node_o... |
Maven Jdepend report contains no data |
|java|maven-2|maven2|jdepend| |
I'm running the jdepend maven plugin on my project and whether I run "mvn site:site" or "mvn jdepend:generate" the report that gets generated says "There are no package used." There are no errors in the maven output. Other plugins (cobertura, findbugs, etc.) run fine. My pom is configured like this:
<reporting>... |
Assuming you had a backup, the binary log holds the stuff that has happened since that backup. Using the mysqlbinlog utility you could do something like:
mysqlbinlog the_log_file > update.sql
Though I think you might have to edit that file to remove anything you didn't want to execute again (like the drop databa... |
ResourceBundleViewResolver uses the key/vals in views.properties to create view beans (actually created in an internal application context). The name of the view bean in your example will be "logout" and it will be a bean of type JstlView. JstlView has an attribute called URL which will be set to "WEB-INF/jsp/logout.js... |
I would consider looking at the [Interop Forms Toolkit][1]. As I understand it, this tool makes it quite easy to use .NET forms from within VB6, so perhaps it can also be used from within Microsoft Access? If so, it may help you migrate the application to .NET in an incremental fashion. Doing a quick search, I was unab... |
To me, the antipathy towards `var` illustrates why bilingualism in .NET is important. To those C# programmers who have also done VB .NET, the advantages of `var` are intuitively obvious. The standard C# declaration of:
List<string> whatever = new List<string>();
is the equivalent, in VB .NET, of typing this... |
[TCPView][1] can do what you asked for.
[1]: http://technet.microsoft.com/en-us/sysinternals/bb897437.aspx |
Yes, you will still need locks if you share state between threads. The GIL only protects the interpreter internally. You can still have inconsistent updates in your own code.
For example:
#!/usr/bin/env python
import threading
shared_balance = 0
class Deposit(threading.Thread):
... |
In any language I've ever worked in (going back to BASIC in the late 70s), false has been considered 0 and true has been non-zero. |
http://www.docjar.com/html/api/java/util/HashMap.java.html
here is the source for HashMap. As you can tell, there is absolutely no locking / mutex code there.
This means that while its okay to read from a HashMap in a multithreaded situation, I'd definitely use a ConcurrentHashMap if there were multiple writes.
... |
It's probably better to *not* uninstall, and if it's on the device in ROM you can't uninstall it anyway.
There are a couple options available to you.
1. The different CF versions coexist fine, so you can install the older version and leave 3.5 on it.
2. The CF can be set for compatibility mode. That means you... |
It's probably better to *not* uninstall, and if it's on the device in ROM you can't uninstall it anyway.
There are a couple options available to you.
1. The different CF versions coexist fine, so you can install the older version and leave 3.5 on it.
2. The CF can be set for compatibility mode. That means you... |