instruction stringlengths 0 30k ⌀ |
|---|
Ok, here's the deal:
In silverlight, you can't bind values from one UI element to another declaratively. The only way to do what I was trying to do here would be in the C# code.
I had a reference for this yesterday, but now I guess you'll just have to take my word for it :) |
I listen to The Guardian's [TechWeekly][1], it's very informed for being done by journalists for a mainstream newspaper. Well produced and up to date. Has a focus on Britain and Europe.
[1]: http://www.guardian.co.uk/technology/series/techweekly |
DesignerCatogy is used to say if the class is a form, component etc.
Try this:
[Category("Custom")]
for the description you can use [Description("This is the description")]
to use both
[Category("Custom"),Description("This is the description")] |
DesignerCatogy is used to say if the class is a form, component etc.
The attribute you want is:
[Category("Custom")]
and for the description you can use [Description("This is the description")]
to use both together
[Category("Custom"),Description("This is the description")] |
DesignerCatogy is used to say if the class is a form, component etc.
For full windows the attribute you want is:
[System.ComponentModel.Category("Custom")]
and for the description you can use [System.ComponentModel.Description("This is the description")]
to use both together
[System.ComponentModel.Categ... |
I think the major issue is at the design level. At what level or levels within my application do I utilise transactions.
For example I could:
- Create transactions within stored procedures,
- Use the data access API (ADO.NET) to control transactions
- Use some form of implicit rollback higher in the appli... |
You can't call a member function from a pointer unless you have a reference to the object as well. For example:
<pre><code>((object).*(ptrToMember))</pre></code>
So you won't be able to acheive this without changing the signature of your render method. <a href="http://www.parashift.com/c++-faq-lite/pointers-to-me... |
You can get deadlocks even without using explicit transactions. For one thing, most relational databases will apply an implicit transaction to each statement you execute.
Deadlocks are fundamentally caused by acquiring multiple locks, and any activity that involves acquiring more than one lock can deadlock with any... |
Use PDO and prepared queries.
($conn is a PDO object)
$stmt = $conn->prepare("INSERT INTO tbl VALUES(:id, :name)");
$stmt->bindValue(':id', $id);
$stmt->bindValue(':name', $name);
$stmt->execute();
|
The default folder is actually the same as the current working folder for the buffer, i.e. it can be different for every file you work with. Say that the file you are working with is located in `C:\dir_a`, then the working directory for that buffer will by default be `C:\dir_a`. You can change this with `M-x cd` and ty... |
At university when I was doing most things under Unix Solaris I used [gdb][1].
However I would go with [valgrind][2] under Linux.
[1]: http://www.gnu.org/software/gdb/
[2]: http://valgrind.org/ |
You could also consider [google charts][1].
Not technically a python API, but you can use it from python, it's reasonably fast to code for, and the results tend to look nice. If you happen to be using your plots online, then this would be an even better solution.
[1]: http://code.google.com/apis/chart/ |
This is most likely a NT file permissions problem. IUSR_ needs to have file system permissions to read whatever file you're requesting (like /inetpub/wwwroot/index.htm).<p>If you still have trouble, check the IIS logs, typically at \windows\system32\logfiles\W3SVC*.
|
How do I enable external access to MySQL Server? |
|mysql| |
How do I enable external access to MySQL Server? I can connect locally but I cannot connect from another box on the network.
I just tried
grant all privileges on *.* to root@'%' identified by '*****' with grant option;
And restarted MySQL Server with no success.
|
Regular expression that matches valid IPv6 addresses |
|regex|networking| |
I'm having trouble writing a regular expression that matches valid IPv6 addresses, including those in their compressed form (with "::" or leading zeros omitted from each byte pair).
Can someone suggest a regular expression that would fulfill the requirement?
I'm considering expanding each byte pair and matching... |
From [here][1],
(\A([0-9a-f]{1,4}:){1,1}(:[0-9a-f]{1,4}){1,6}\Z)|
(\A([0-9a-f]{1,4}:){1,2}(:[0-9a-f]{1,4}){1,5}\Z)|
(\A([0-9a-f]{1,4}:){1,3}(:[0-9a-f]{1,4}){1,4}\Z)|
(\A([0-9a-f]{1,4}:){1,4}(:[0-9a-f]{1,4}){1,3}\Z)|
(\A([0-9a-f]{1,4}:){1,5}(:[0-9a-f]{1,4}){1,2}\Z)|
(\A([0-9a-f]{1,4}:){1... |
The short answer is that GetLeg is invariant in its return type. The long answer can be found here: [Covariance and contravariance][1]
I'd like to add that while inheritance is usually the first abstraction tool that most developers pull out of their toolbox, it is almost always possible to use composition instead. ... |
What's the cleanest way to simulate pass-by-reference in Actionscript 3.0? |
|actionscript-3| |
Actionscript 3.0 (and I assume Javascript and ECMAScript in general) lacks pass-by-reference for native types like ints. As a result I'm finding getting values back from a function really clunky. What's the normal pattern to work around this?
For example, is there a clean way to implement _swap( intA, intB )_ in ... |
If ActionScript works like Javascript,
[a,b] = [b,a] |
How do I write a for loop in bash |
|bash| |
I'm looking for the basic loop like:
for(int i = 0; i < MAX; i++) {
doSomething(i);
}
but for bash. |
See: [this site][1]
for i in `seq 1 10`;
do
echo $i
done
[1]: http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-7.html |
Consider a variation of your class A..
class A {
public:
void Foo() const;
void Moo();
};
const A *A1 = new A();
A *A2 = new A();
A1->Foo(); // OK
A2->Foo(); // OK
A1->Moo(); // Error - Not allowed to call non-const function on const object instance
... |
Consider a variation of your class A..
class A {
public:
void Foo() const;
void Moo();
};
const A *A1 = new A();
A *A2 = new A();
A1->Foo(); // OK
A2->Foo(); // OK
A1->Moo(); // Error - Not allowed to call non-const function on const object instance
... |
Unfortunately, triggering a manufactured/simulated mouse event won't work, since when you dispatch it, you have to provide a target element. Since that element is the one you're trying to figure out, all you could do is dispatch it on the body, as if it had already bubbled.
You really are left to do it on your own, ... |
The only difference between a class and a struct in C++ is that structs have default public members and classes have default private members. Both classes and structs can have a mixture of public and private members, can use inheritance, and can have member functions.
I would recommend using structs as plain-old-dat... |
For C++, there really isn't much of a difference between structs and classes. The main functional difference is that members of a struct are public by default, while they are private by default in classes. Otherwise, as far as the language is concerned, they are equivalent.
That said, I tend to use structs in C++ li... |
They are pretty much the same thing. Thanks to the magic of C++, a struct can hold functions, use inheritance, created using "new" and so on just like a class
The only functional difference is that a class begins with private access rights, while a struct begins with public. This is the maintain backwards compat... |
The supported method of doing this is [RegNotifyChangeKeyValue][1]
Most virus checkers likely perform some sort of API hooking instead of using this function. There's lots of information out there about API hooking, like http://www.codeproject.com/KB/system/hooksys.aspx, http://www.codeguru.com/cpp/w-p/system/misc/... |
As alluded to in the question, but not clearly stated, "pnputil -e 2> c:\foo.txt" does not have the intended result either. This one directs nothing into the file but it does send the output to the console.
|
> What the users have figured out is
> that they don't have to enter a
> comment if they submit the information
> and go to the page with the comment
> and then hit the back button to return
> to the previous page.
Then they are probably also smart enough to type *'no comment'* into the comments field.
You c... |
> **Adds a critical point to failure to the site**
The third highest [idea on uservoice for Stackoverflow][1] is to allow changing the OpenID provider. And in the comments there is the suggestion to allow associating more than on OpenID. On sites where multiple OpenIDs can be associated with an account if your usual... |
There are a lot of ways to skin this cat, including templates. My favorite is [Boost.function][1] as I've found it to be the most flexible in the long run. Also read up on [Boost.bind][2] for binding to member functions as well as many other tricks.
It would look like this:
void Render(boost::function0<void... |
There are a lot of ways to skin this cat, including templates. My favorite is [Boost.function][1] as I've found it to be the most flexible in the long run. Also read up on [Boost.bind][2] for binding to member functions as well as many other tricks.
It would look like this:
#include <boost/bind.hpp>
#i... |
I'm not aware of anyone using the DLR in quite this fashion yet, though this is definitely one of its intended use cases. One interesting thing to consider is that the DLR's expression trees have been merged with LINQ expression trees, so the IL being produced for LINQ in some as-yet-unannounced future version of Visu... |
The FASTA file format is very sparse. The first thing I would do is generate a compact binary format, and index *that* - it should be maybe 20-30% the size of your current file, and the process for coding/decoding the data should be fast enough (even with 4GB) that it won't be an issue.
At that point, your file sho... |
Delphi MDI Application and the titlebar of the MDI Children |
|delphi|forms|mdi| |
I've got an MDI application written in Delphi 2006 which runs XP with the default theme. Is there a way of controlling the appearance of the MDI Children to avoid the large XP-style title bar on each window? I've tried setting the BorderStyle of the MDIChildren to bsSizeToolWin but they are still rendered as normal For... |
If a query is more then just a simple SELECT on a single table I always run it through EXPLAIN if I am on MySQL or PostgreSQL. If you are using SQL Server then Management Studio has a Display Estimated Execution Plan which is essentially the same. It is useful to see how the engine will access each table and what index... |
This problem is called color quantization, and has many well known algorithms: http://en.wikipedia.org/wiki/Color_quantization I know people who implemented the octree approach to good effect. |
Back with .Net 1.1 obfuscation was essential: decompiling code was easy, and you could go from assembly, to IL, to C# code and have it compiled again with very little effort.
Now with .Net 3.5 I'm not at all sure. Try decompiling a 3.5 assembly; what you get is a long long way from compiling.
Add the optimisatio... |
Wouldn't it be simpler to use the built-in PHP FTP* functionality than trying to roll your own? If the URI is coming from a source outside your control, you would need to check the protocal definition (http:// or ftp://, etc) in order to determine which functionality to use, but that is fairly trivial. If there is no... |
Getting accurate ticks from a timer in C# |
|.net|timer| |
I'm trying to rebuild an old metronome application that was originally written using MFC in C++ to be written in .NET using C#. One of the issues I'm running into is getting the timer to "tick" accurately enough.
For example, assuming an easy BPM (beats per minute) of 120, the timer should tick every .5 seconds (or... |
We use Zend Development Environment (windows). We resolved a memory usage spike yesterday by stepping through the debugger while running Process Explorer to watch the memory/cpu/disk activity as each line was executed.
Process Explorer: <http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx>.
ZDE includ... |
If you write Perl with <code>use strict;</code>, then you'll find that the one line syntax isn't valid, even when declared.
With:<br/>
<code>
my ($newstring = $oldstring) =~ s/foo/bar/;
</code>
You get:<br/>
<code>
Can't declare scalar assignment in "my" at script.pl line 7, near ") =~"
Execution of script.... |
Drop it in a cron job that runs every night (afternoon?) when you're sleeping. |
$_SERVER['REMOTE_ADDR'] may not actually contain real client IP addresses, as it will give you a proxy address for clients connected through a proxy, for example. That may
well be what you really want, though, depending what your doing with the IPs. Someone's private RFC1918 address may not do you any good if you're... |
I have written trivial applications, it really helps if you can parallize floating point calculations.
I found the following course cotaught by a University of Illinois Urbana Champaign professor and an NVIDIA engineer very useful when I was getting started: <http://courses.ece.uiuc.edu/ece498/al1/Archive/Spring2007... |
Commodore Jaeger is right about:
dd if=/dev/sda of=/dev/sdb bs=1M
Also, adjusting "readahead" on the drives usually improves performance. The default may be something like 256, and optimal 1024. Each setup is different, so you would have to run benchmarks to find the best value.
# blockdev --getra /d... |
assuming you want the range to iterate properly through months etc, try
require 'date'
ends = '20080201..20080229'.split('..').map{|d| Date.parse(d)}
(ends[0]..ends[1]).each do |d|
p d.day
end
|
I had to do this for a programming challenge, here's a snippet of my Haskell:
isPalindrome :: String -> Bool
isPalindrome n = (n == reverse n) |
# C#: LINQ
var str = "a b a";
var test = Enumerable.SequenceEqual(str.ToCharArray(), str.ToCharArray().Reverse());
|
C#: LINQ
var str = "a b a";
var test = Enumerable.SequenceEqual(str.ToCharArray(),
str.ToCharArray().Reverse());
|
> ASP.NET MVC cannot use web controls that rely on postbacks, whereas WCSF can.
You should think of WCSF as guidance about how to use the existing WebForms infrastructure, especially introducing Model-View-Presenter to help enforce separation of concerns. It also increases the testability of the resulting code.
>... |
The [CreateToolhelp32Snapshot Function][1] has a Process32First method that will allow you to read a [PROCESSENTRY32 Structure][2]. The structure has a property that will get you the information you want:
> **th32ParentProcessID** - The identifier
> of the process that created this
> process (its parent process).
... |
like obfuscated code? Try this:
1 << ( int) log2( x) |
You probably have to edit the configuration file (usually my.cnf) to listen in the external interface instead of on localhost only.
change the bind-address parameter to your machine's IP address.
If this is an old MySQL installation, you should comment out the skip-networking parameter.
Afterwards, restart MyS... |
The [FASTA file format][1] is very sparse. The first thing I would do is generate a compact binary format, and index *that* - it should be maybe 20-30% the size of your current file, and the process for coding/decoding the data should be fast enough (even with 4GB) that it won't be an issue.
At that point, your fil... |
Have you tried setting the selected value during the page's pre-render phase instead of Page_Load? |
http://java.sun.com/developer/technicalArticles/Programming/Stacktrace/
...
"On UNIX platforms you can send a signal to a program by using the kill command. This is the quit signal, which is handled by the JVM. For example, on Solaris you can use the command kill -QUIT process_id, where process_id is the process ... |
http://java.sun.com/developer/technicalArticles/Programming/Stacktrace/
...
"On UNIX platforms you can send a signal to a program by using the kill command. This is the quit signal, which is handled by the JVM. For example, on Solaris you can use the command kill -QUIT process_id, where process_id is the process ... |
Check out **GDI++/FreeType** ([link][1], [link][2]). It's a highly configurable font-rendering replacement for Windows. With some configuration of hinting, anti-aliasing, etc, you should be able to approximate OSX style font rendering fairly close.
[1]: http://free.flop.jp/gdi++/
[2]: http://offset.skew.org/w... |
Can you view an aggregate changeset in git? If so, how? |
|git|subversion| |
One place where a struct has been helpful for me is when I have a system that's receiving fixed format messages (over say, a serial port) from another system. You can cast the stream of bytes into a struct that defines your fields, and then easily access the fields.
typedef struct
{
int messageId;... |
Maybe you can use two processes:
dd if=indevfile | dd of=outdevfile
I'll assume you can set the other dd options as it suits you.
This has some overhead but should allow asynchrony between reading
one disk and writing the other. |
In FireBug and FireBug Lite you can call the console.time() and console.timeEnd() methods in your code to start and end a timer around a particular piece of code. The Profiler tool in FireBug will measure how long each function takes. I've used it a lot to narrow down which lines of a particularly slow function are cau... |
If transport.responseXML is null but you have a value for transport.responseText then I believe it's because it's not a valid XML file.
**Edit:** I just noticed that in our code here whenever we request an XML file we set the content type to 'text/xml'. I have no idea if that makes a difference or not. |
Are you sure it isn't doing that at the same time? I would expect the disk caches to make sure it that happens. If not, non-blocking or even asynchronous reads/writes may help, |
After playing with this for a while, I found the Michael's pseudo-code was the closest, but here's how I did it:
Dim xl As Excel.Application
Set xl = CreateObject("Excel.Application")
xl.Workbooks.Open "\\owghome1\bennejm$\testing.xls"
xl.Sheets("Sheet1").Select
Then, manipulate the sheet... ma... |
You might try increasing the block size using the bs argument; by default, I believe dd uses a block size equal to the disk's preferred block size, which will mean many more reads and writes to copy an entire disk. Linux's dd supports human-readable suffixes:
dd if=/dev/sda of=/dev/sdb bs=1M |
Show us a small section of your code. It works for me.
package inputverifier;
import javax.swing.*;
class Go {
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() { public void run() {
runEDT();
}});
... |
You could generate the menus beforehand into static html / javascript files, and have all the pages pull the site from the same URL on your site. That way, the client side browser will do the caching. You'll just have to have a step in your deployment that generates the html files for the menu.
Try to have it gene... |
Read [Choosing Secure Passwords][1].
One interesting tidbit from there: For more secure passwords, make sure some numbers and special characters appear in the middle. Cracking programs check for them at the beginning and ends sooner.
[1]: http://www.schneier.com/blog/archives/2007/01/choosing_secure.html |
Host the service, and then use the URI of the hosted service in the other project to have VS create a proxy for you.
**[Here's][1]** a step by step article on how to add a reference. And **[here's][2]** an article that teaches you how to host a service in VS (which is probably the simplest thing to do while developi... |
The short answer is no, with webforms the id can always be rewritten depending on the nesting of the element. You can get access to the id through the ClientID property, so you could set the ids into variables in a script at the end of the page/control then put them into jQuery.
something like this:
<asp:b... |
The short answer is no, with webforms the id can always be rewritten depending on the nesting of the element. You can get access to the id through the ClientID property, so you could set the ids into variables in a script at the end of the page/control then put them into jQuery.
something like this:
<asp:b... |
The short answer is no, with webforms the id can always be rewritten depending on the nesting of the element. You can get access to the id through the ClientID property, so you could set the ids into variables in a script at the end of the page/control then put them into jQuery.
something like this:
<asp:b... |
can't help with VB6 solution, can help with .net or java solution on the server.
Get iText or iTextSharp from <http://www.lowagie.com/iText/>.
It has a PdfStamper class that can merge a PDF and FDF FDFReader/FDFWriter classes to generate FDF files, get field names out of PDF files, etc...
|
Consider a variation of your class A..
class A {
public:
void Foo() const;
void Moo();
private:
int m_nState; // Could add mutable keyword if desired
int GetState() const { return m_nState; }
void SetState(int val) { m_nState = val; }
};
cons... |
Consider a variation of your class A..
class A {
public:
void Foo() const;
void Moo();
private:
int m_nState; // Could add mutable keyword if desired
int GetState() const { return m_nState; }
void SetState(int val) { m_nState = val; }
};
cons... |
for ((i=0; i<$MAX; i++)) do echo $i; done |
Can cout alter variables somehow |
|c++|double|float|cout| |
So I have a function that looks something like this:
float function(){
float x = SomeValue;
return x / SomeOtherValue;
}
At some point, this function overflows and returns a really large negative value. To try and track down exactly where this was happening, I added a cout statement so... |
In Python, what is the best way to check if a list is empty? |
|python|list| |
For example, if passed the following:
a = []
How do I check to see if 'a' is empty? |
Command and syntax looks fine. Have you checked the server is listening on an interface other than 127.0.0.1? By default Im pretty sure it only listens on the localhost address (127.0.0.1)
|
Can you apply more than one OpenID to a StackOverflow account |