instruction stringlengths 0 30k ⌀ |
|---|
|web-services|wcf| |
We have an encryption service that we've exposed over net.tcp. Most of the time, the service is used to encrypt/decrypt strings. However, every now and then, we the need to encrypt large documents (pdf, jpg, bmp, etc).
What are the best endpoint settings for a scenario like this? Should I accept/return a stream? I'v... |
How do I create an XmlNode from a call to XmlSerializer.Serialize? |
|c#|xml| |
I am using a class library which represents some of its configuration in .xml. The configuration is read in using the XmlSerializer. Fortunately, the classes which represent the .xml use the XmlAnyElement attribute at which allows me to extend the configuration data for my own purposes without modifying the original cl... |
Delete the table from the designer and then put it in again (or rerun SqlMetal). |
If you are in the scenario where you have reordered the columns in the database, and you now want to have this new order be reflected in the designer, I think that you have to delete the table from the designer and then put it in again. Or if you use <a href="http://msdn.microsoft.com/en-us/library/bb386987.aspx">SqlMe... |
After plenty of reading up on extender controls and javascript, I've cobbled together a solution that seems to be working so far.
The main trick was getting the necessary postback code from server-side to the client-side behavior script. I did this by using an ExtenderControlProperty which is set in the control's On... |
Patrick's solution is probably the cleanest.
If you need to dynamically pick up the module as well, you can import it like:
m = __ import __ ('foo')
func = getattr(m,'bar')
func() |
Patrick's solution is probably the cleanest.
If you need to dynamically pick up the module as well, you can import it like:
m = __import__ ('foo')
func = getattr(m,'bar')
func() |
Function prototypes were the most obvious change between K&R C and C89, but there were plenty of others. A lot of important work went into standardizing the C library, too. Even though the standard C library was a codification of existing practice, it codified *multiple* existing practices, which made it more difficu... |
Ok, since you are looking for language-agnostic then you can try a REGEX like `/<meta\s.*content=.*>/` and take the result from that and parse out the specific values that you are looking for. I'm by no means a REGEX expert so there is probably a better way but in using the tool at http://www.codehouse.com/webmaster_to... |
Testing a client-server application |
|testing|eclipse|rcp| |
I am coding a client-server application using Eclipse's RCP.
We are having trouble testing the interaction between the two sides
as they both contain a lot of GUI and provide no command-line or other
remote API.
Got any ideas? |
Virtual PC 2007 is very fast esp on a CPU that has hardware support for VM's. 3GB RAM a must for anything not small. XP makes a good guest OS, Vista works well as a host. |
You may want to give Java's [HTMLEditorKit](http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/text/html/HTMLEditorKit.html) a shot. It is easy to experiment with to see if the parsing provides what you are looking for.
|
[Map](http://www.lispworks.com/documentation/HyperSpec/Body/f_map.htm) is more general than mapcar, for example you could do the following rather than using mapcar:
(map 'list #'function listvar)
How do I keep scheme and CL separate in my head? I guess when you know both languages well enough you just know wh... |
I prefer <a href="http://sourceforge.net/projects/dbfpy/">dbfpy</a>. It supports both reading and writing of <code>.DBF</code> files and can cope with most variations of the format. It's the only implementation I have found that could both read and write the legacy DBF files of some older systems I have worked with. |
There is a small Rails plugin called [PermalinkFu][1], that does this.
The [escape method][2] does the transformation into a string that is suitable for a url. Have a look at the code, that method is quite simple.
To remove non-ascii chars it uses the iconv lib to translate to 'ascii//ignore//translit' from 'utf-... |
Read [this][1] if you're struggling with UI Testing
www.objectmentor.com/resources/articles/TheHumbleDialogBox.pdf
+1 to people posting keep UIs as thin as possible. Manually test UI stuff where benefit to cost in automating it is minimal. Test everything under the UI skin ruthlessly. Use Humble Dialog, MVC or va... |
You can also use this javascript function for in-form generation of the slug's (This one is based on/copied from Django):
<code><pre>
function makeSlug(urlString, filter) {
// changes, e.g., "Petty theft" to "petty_theft"
// remove all these words from the string before urlifying
if(filter) {
... |
I have to disagree with a lot of the answers to this question.
It is possible to collect random data on a computer. SSL, SSH and VPNs would not be secure if you couldn't.
The way software random number generator work is there is a _pool_ of random data that is gathered from many different places, such as clock dr... |
A heads up, this example is not concise nor exceptionally clear. This is a demonstration of a powerful application of continuations. As a VB/ASP/C# programmer, you may not be familiar with the concept of a system stack or saving state, so the goal of this answer is a demonstration and not an explanation.
Continuatio... |
I would create a filter and bounce all requests to root back with forward responce. Hacks with creating home.do page looks ugly to me (One more thing to remember for you and investigate for someone who will support your code). |
The easiest answer is probably that they are suited for practically any problem. Don't forget that a computer itself is also a state machine.
Regardless of that, state machines are typically used for problems where there is some stream of input and the activity that needs to be done at a given moment depends the las... |
Performance is not significantly better in either case. While is useful for more complex tasks than iterating, but `for` and `while` are functionally equivalent.
`Foreach` is nice, but has one important caveat: you **can't modify** the enumerable you're iterating. So no removing, adding or replacing entries to/in it... |
With a foreach loop, a copy of the original array is made in memory to use inside. You shouldn't use them on large structures; a simple for loop is a better choice. You can use a while loop more efficiently on a large non-numerically indexed structure like this:
while(list($key, $value) = each($array)) {
But ... |
In regards to performance, a foreach is more consuming than a for
http://forums.asp.net/p/1041090/1457897.aspx
|
How to decode viewstate |
|asp.net|viewstate| |
I need to see the contents of the viewstate of an asp.net page. I looked for a viewstate decoder, found [Fridz Onion's ViewState Decoder][1] but it asks for the url of a page to get its viewstate. Since my viewstate is formed after a postback and comes as a result of an operation in an update panel, I cannot provide a ... |
Libraries for pretty charts in SWT? |
|java|eclipse|charts|swt| |
I know the following libraries for drawing charts in an SWT/Eclipse RCP application:
- [Eclipse BIRT Chart Engine][1] (Links to an article on how to use it)
- [JFreeChart][2]
Which other libraries are there for drawing pretty charts with SWT? Or charts in Java generally? After all, you can always display an ... |
That is terrible, take a look at [Only In A Database Can You Get 1000% + Improvement By Changing A Few Lines Of Code][1] to see how you can optimize this since that is not sargable
Also check out [Get Datetime Without Time][2] and [Query Optimizations With Dates][3]
[1]: http://blogs.lessthandot.com/index.php... |
Use [Fiddler](http://www.fiddlertool.com) and grab the view state in the response and paste it into the bottom left text box then decode. |
@[Staale](http://stackoverflow.com/questions/37041/exposing-a-remote-interface-or-object-model#37093): Thanks a bunch!
Using Future for the async operations is interesting. The only drawback being that it is doesn't provide callbacks. But then again, I tried that approach, and look where that got me :)
I'm curren... |
@[Staale](http://stackoverflow.com/questions/37041/exposing-a-remote-interface-or-object-model#37093): Thanks a bunch!
Using Future for the async operations is interesting. The only drawback being that it is doesn't provide callbacks. But then again, I tried that approach, and look where that got me :)
I'm curren... |
[extern alias][1] keyword to reference two versions of assemblies that have the same fully-qualified type names.
[1]: http://msdn.microsoft.com/en-us/library/ms173212.aspx |
A good resource to teach young people is the free eBook "Invent your own games with Python":
http://pythonbook.coffeeghost.net/book1/IYOCGwP_book1.pdf
|
How to test java application for performance bottlenecks? |
|java|performance| |
I am reviewing a big java application to see if there are any performance bottlenecks. The real problem is that I cannot pinpoint the performance issues to any single module. The whole application is slow as such.
Is there some tool/technique I can use to help me out in this? |
This is called a [Fluent Interface][1], for reference.
Personally, I think it's a pretty neat idea, but a matter of taste really. I think [jQuery][2] works this way.
[1]: http://en.wikipedia.org/wiki/Fluent_interface
[2]: http://en.wikipedia.org/wiki/Jquery |
I agree with @Bernard that method chaining like this muddles the purpose of the setters. Instead I would suggest that if you are always creating chains of setters like this that you create a custom Constructor for your class so instead of
MyClass
.setInt(1)
.setString("test")
.setB... |
Circuit diagrams.
Compilation (Directed Acyclic graphs)
Maps. Very compact as graphs.
Network flow problems.
Decision _trees_ for expert systems (sic)
Fishbone diagrams for fault finding, process improvment, safety analysis. For bonus points, implement your error recovery code as objects that _are_ the... |
Could you set the build output path of the concrete DAL project to be the bin folder of the dependent project? |
One word of warning - jdbc -> Access queries (which bridge using odbc) do not work on 64 bit systems, as there exist no 64 bit Access database drivers (The driver is included into 32 bit copies of Windows and can only be accessed by 32 bit processes. You can run "odbcad32" or look at the ODBC control panel to see that ... |
This idea is seen a lot in c++, it allows operations to be cascaded...
for example
<pre>
<code>
std::cout << "this" << "is" << "cascading" << std::endl;
</code>
</pre>
is where the stream method << returns an instance of itself (*this).
see this: http://www.java2s.com/Tutorial/Cpp/0180... |
`CREATE INDEX`
Assure there are indexes available for your `WHERE` and `JOIN` clauses. This will speed data access greatly.
If your environment is a *data mart or warehouse,* indexes should abound for almost any conceivable query.
In a *transactional environment*, the number of indexes should be lower and the... |
You can do RESTful web services easily by implementing the spec using IHTTPHandlers.
|
Basically, a continuation is the ability for a function to stop execution and then pick back up where it left off at a later point in time. In C#, you can do this using the yield keyword. I can go into more detail if you wish, but you wanted a concise explanation. ;-) |
I think it's typical for professionals who deal with customers to spend more time in brownfield development. The reason is that customers typically aren't willing to throw out their existing software to adopt the "latest and greatest" (green) software.
Developers in research or academics, however, may be more likel... |
The feeling I get from Matthew MacDonald's *Pro WPF Windows Presentation Foundation in .NET 3.0* is that it's not possible:
> There's one exception to WPF's software support. Due to poor driver support, WPF only performs antialiasing for 3-D drawings if you're running your application on Windows Vista (and you have... |
That depends on your definition of which disk drive Windows used to boot. I can think of 3 different answers on a standard BIOS system (who knows what an EFI system does):
1. The drive that contains the active MBR
2. The active partition, with NTLDR (the system partition)
3. The partition with Windows on it (th... |
To give auto implemented properties a default value, you'd have to do it in the constructor. |
I'd highly recommend reading ["What Every Computer Scientist Should Know About Floating-Point Arithmetic"][1]. A lot of problems I encounter on a regular basis come from issues with floating point programming.
[1]: http://docs.sun.com/source/806-3568/ncg_goldberg.html "What Every Computer Scientist Should Know A... |
First pick up a copy of Michael Feather's Working [Effectively with Legacy Code][1]. Then identify how best to test the existing code. The worst case is that you are stuck with just some high level regression tests (or nothing at all) and If you are lucky there will be unit tests. Then it is a case of slow steady r... |
I try to follow the PSP 2.1 process when possible. It really helps me keep a focus on not skipping important, but less exciting, portions of a project. Usually this is design and design review for small projects.
To keep track of time you can use the PSP Dashboard, which has a bunch of built in features and script... |
Assuming you already know how to detect which key the user hit, this should be doable reasonably easily. In the security world, there is the notion of a "one time" password. This is sometimes referred to as a "disposable password." Normally these are restricted to the (easily typable) ASCII values. So, [a-zA-z0-9] and ... |
It sounds like you have the unspoken requirement that it must be quickly determined, via algorithm, that the code is valid. This would rule out you simply handing out a list of one time pad numbers.
There are several ways people have done this in the past.
1. Make a public key and private key. Encode the numb... |
Might want to try the TFS Follow branch History tool:
<a href="http://www.codeplex.com/TFSBranchHistory">http://www.codeplex.com/TFSBranchHistory</a> |
I've used both the profiler in Compuware’s DevPartner (I like to still call it “TrueTime”) and [Rational's Quantify][1]. I always liked Quantify better, but as I've moved between companies DevPartner is usually already the “standard”.
Both are expensive, but they (seem to) add so much value that any commercial shop... |
What's the use of value types in .Net? |
|.net| |
The [official guidelines][1] suggest that there can be very few practical uses for these. Does anyone have examples of where they've put them to good use?
[1]: http://msdn.microsoft.com/en-us/library/y23b5415.aspx |
My conclusions so far;
I am torn on whether to use getters for the Track objects or just expose the members since the object is immutable.
class Track {
public final String album;
public final String artist;
public final String title;
public final String genre;
public final Strin... |
Try using a profiler on your running code. It should help you identify the bottlenecks. Try [jprofiler](http://www.ej-technologies.com/products/jprofiler/overview.html) or [Netbeans profiler](http://www.netbeans.org/features/java/profiler.html) |
Python doesn't have a built-in equivalent to `enum`, and other answers have ideas for implementing your own (you may also be interested in the [over the top version][1] in the Python cookbook).
However, in situations where an `enum` would be called for in C, I usually end up ***just using simple strings***: because ... |
How to detect duplicate data? |
|duplicate|data|language-agnostic|algorithm| |
I have got a simple contacts database but I'm having problems with users entering in duplicate data. I have implemented a simple data comparison but unfortunately the duplicated data that is being entered is not exactly the same. For example, names are incorrectly spelled or one person will put in 'Bill Smith' and anot... |
|language-agnostic|algorithm|duplicate-data| |
@[Haacked](http://stackoverflow.com/questions/31567/how-to-properly-cast-objects-created-through-reflection#31576)
I tried to keep the pseudocode simple. foreach's take up a lot of space and braces. I clarified it.
o.GetType().FullName returns Plugins.Multiply which is the expected object. Plugins.Multiply implem... |
Mike: Didn't think of that, that could work, have to remember to turn off copy-local for any libraries / projects that are common between them |
> So there's the potential for an "IN" clause to run a table scan, but the optimizer will
> try and work out the best way to deal with it?
Whether an index is used doesn't so much vary on the type of query as much of the type and distribution of data in the table(s), how up-to-date your table statistics are, and t... |
I find this to be in poor style when used in setters. Immutable classes are usually a better fit for chaining, such as:
aWithB = myObject.withA(someA).withB(someB);
where `myObject` is of this class:
class MyClass {
withA(TypeA a) {
this.a.equals(a) ? this : new MyClass(this, a);... |
Image processing in Silverlight 2 |
|silverlight| |
Is it possible to do image processing in silverlight 2.0?
What I want to do is take an image, crop it, and then send the new cropped image up to the server. I know I can fake it by clipping the image, but that only effects the rendering of the image. I want to create a new image. |
Is it possible to do image processing in silverlight 2.0?
What I want to do is take an image, crop it, and then send the new cropped image up to the server. I know I can fake it by clipping the image, but that only effects the rendering of the image. I want to create a new image.
After further research I have... |
Is it possible to do image processing in silverlight 2.0?
What I want to do is take an image, crop it, and then send the new cropped image up to the server. I know I can fake it by clipping the image, but that only effects the rendering of the image. I want to create a new image.
After further research I have... |
The Halting Problem is really only interesting if you look at it in the general case, since if the Halting problem were decidable, all other undecidable problems would also be decidable via reduction.
So, my opinion on this question is, no, it is not easy in the cases that matter. That said, in the real world, it m... |
How about:
session.replicate(entity, ReplicationMode.OVERWRITE);
? |
How do I add a user in Ubuntu? |
|ubuntu|user| |
... using the command line |
|ubuntu|user|linux|system-administration| |
|linux|ubuntu|system-administration|user| |
Specifically, what commands do I run from the terminal? |
As a day-to-day programmer, I'd say it's worthwhile to continue as far down the *path* to solving halting-style problems, even if you only approach that limit and never reach it. As you pointed out, virus scanning proves valuable. Google search doesn't pretend to be the absolute answer to "find me the best X for Y," bu... |
Python doesn't have a built-in equivalent to `enum`, and other answers have ideas for implementing your own (you may also be interested in the [over the top version][1] in the Python cookbook).
However, in situations where an `enum` would be called for in C, I usually end up ***just using simple strings***: because ... |
Enums are first class citizens of .NET world. As for structures I found that in most cases classes can be used, however for memory-intense scenarios consider using structures. As a practical example I used structures as data structures for OSCAR (ICQ) protocols primitives. |
I tend to use enum for avoiding magic numbers, this can be overcome by const I guess, but enum allows you to group them up.
i.e
enum MyWeirdType {
TypeA, TypeB, TypeC};
switch(value){
case MyWeirdType.TypeA:
...
|
Quick question. Why do you need an Xml template? If you already know the schema before hand, then simply generate the complete Xml in your code. There shouldn't be a need for loading a template file. |
To get the name of the currently executed method, you can look at the stack trace:
public static string GetNameOfCurrentMethod()
{
// Skip 1 frame (this method call)
var trace = new System.Diagnostics.StackTrace( 1 );
var frame = trace.GetFrame( 0 );
return frame.GetMetho... |
XML in C# - Read from Resources, Manipulate and Display. |
|c#|xml| |
I'd like to do the following and can't find an elegant way:
1) Read an XML template into a System.Xml.XmlDocument
2) Populate it with data from my UI
3) Transform it with an XSLT I've written
4) Apply a CSS Stylesheet
5) Render it to a WebBrowser control
I'm currently reading it from a file on disk, ... |