Search Results

Search found 71 results on 3 pages for 'mafutrct'.

Page 1/3 | 1 2 3  | Next Page >

  • How do you deal with intentionally bad code?

    - by mafutrct
    There are many stories about intentionally bad code, not only on TDWTF but also on SO. Typical cases include: Having a useless time-wasting construct (e.g. an empty loop counting to some huge value) so programmers can easily "speed up" the application by removing it when they are tasked to. Providing intentionally misleading, wrong or no documentation to generate expensive support requests. Readily generating errors, or worse, generating even though everything worked fine, locking up the application so an expensive support call is required to unlock. These points display a more or less malicious attitude (even though sometimes by accident), especially the first point occurs rather often. How should one deal with such constructs? Ignore the issue, or just remove the offending code? Notify their manager, or speak to the person who introduced the "feature"?

    Read the article

  • Is there a webproxy via email?

    - by mafutrct
    This is probably a bit weird, and I don't think it exists yet. I'm basically asking for a program that, upon receiving a request via email, downloads a html page and sends it via email, possibly changing the links inside the page into outgoing emails to this program asking for another page. This is certainly one of the most crude ways of accessing the web, and obviously fails at anything beyond the most basic stuff. But it may still be useful to those that can send email, but can't access the web due to company policy or whatever reason. In the (likely) case this does not exist, I'd be interested to write such a proxy.

    Read the article

  • Tortoise SVN appears to freeze Explorer

    - by mafutrct
    When updating a repository using Tortoise SVN, Explorer on Windows XP tends to choke and freeze in regular intervals. Something like 4 seconds freeze, 1 second fluent work. I imagine this may be caused by the (too many) svn:externals? Is this a known issue? Do you know of a way to fix this?

    Read the article

  • How do I change the default backup folder in Win7?

    - by mafutrct
    I'm using the built-in Windows Backup. The default destination folder (backup location\computer name\Backup Set year-month-day time) is unsuitable for me because I already have got some other files in that location and I'd prefer to keep them there. I found no way to change it. Is it possible to have a backup on the same partition but in a different folder? Or do I have to store backups on a different disk?

    Read the article

  • 7zip many files from different folders?

    - by mafutrct
    I would like to add a large number of files with different names from different folders to a single 7zip archive using 7za.exe. This should be simple, but it turned out to be a major pain. I created a file that contains the paths (7za -a @list.txt) but once there are too many (~100) files, it fails. Apparently the content of the argument file is pushed onto the command line buffer, which is far too small (the number of files to add is 1m). Splitting the process up by adding the files one by one is not feasible due to the way 7za works: When adding the next file, it creates a copy of the archive, adds the file to the copy and finally replaces the original. This is terribly slow once the archive gets to a couple 100MB in size. So far I am using a combination of the two approaches by adding a dozen files each time in a loop, but it is an unreliable hack and still very slow. Is there a better way to do it? I tried to use 7zip wrapper DLLs (I'm a C# programmer), but none of them worked reliably and I was repeatedly suggested to just use 7za instead.

    Read the article

  • 7-Zip many files from different folders?

    - by mafutrct
    I would like to add a large number of files with different names from different folders to a single 7-Zip archive using 7za.exe. This should be simple, but it turned out to be a major pain. I created a file that contains the paths (7za a out.7z @list.txt), but once there are too many (~100) files, it fails. Apparently the content of the argument file is pushed onto the command line buffer [Edit: This was likely a misinformation on my part, either way it was not the reason], which is far too small (the number of files to add is more than one million). Splitting the process up by adding the files one by one is not feasible due to the way 7za works: When adding the next file, it creates a copy of the archive, adds the file to the copy and finally replaces the original. This is terribly slow once the archive gets to a couple 100 MB in size. So far I am using a combination of the two approaches by adding a dozen files each time in a loop, but it is an unreliable hack and still very slow. Is there a better way to do it? I tried to use 7-Zip wrapper DLLs (I'm a C# programmer), but none of them worked reliably and I was repeatedly suggested to just use 7za instead.

    Read the article

  • WCF deadlock when using callback channel

    - by mafutrct
    This is probably a simple mistake, but I could not figure out what was wrong. I basically got a method like this: [ServiceBehavior ( ConcurrencyMode = ConcurrencyMode.Reentrant, InstanceContextMode = InstanceContextMode.PerSession, IncludeExceptionDetailInFaults = true) ] public class Impl : SomeContract { public string Foo() { _CallbackChannel.Blah(); return ""; } } Its interface is decorated: [ServiceContract ( Namespace = "http://MyServiceInterface", SessionMode = SessionMode.Required, CallbackContract = typeof (WcfCallbackContract)) ] public interface SomeContract { [OperationContract] string Foo (); } The service is hosted like this: ServiceHost host = new ServiceHost (typeof (Impl)); var binding = new NetTcpBinding (); var address = new Uri ("net.tcp://localhost:8000/"); host.AddServiceEndpoint ( typeof (SomeContract), binding, address); host.Open (); The client implements the callback interface and calls Foo. Foo runs, calls the callback method and returns. However, the client is still struck in the call to Foo and never returns. The client callback method is never run. I guess I made a design mistake somewhere. If needed, I can post more code. Any help is appreciated.

    Read the article

  • Parsing SGF files in C#

    - by mafutrct
    The text-based Smart Game Format has become the sole file format for exchanging Go game records by now. I stared with disbelieve that there are almost no parsers available. Google yielded a few results in antique Java and Python, but no modern implementations. I am curious if I have to write my own parser. Do you know of a modern implementation in C# or Java? In case there really are no parsers available, how should I implement one? Are there general guidelines or tools (in a C# environment) I should know of? This is an example file: (;GM[1]FF[4]CA[UTF-8]AP[CGoban:3]ST[2] RU[Japanese]SZ[19]KM[6.50] PW[White]PB[Black] ;B[pd] ;W[dc] ;B[dq] ;W[pp] ;B[ce] (;W[ed] ;B[ci] ;W[kc]) (;W[do] ;B[dl] ;W[gp] ;B[eo] ;W[en] ;B[fo]))

    Read the article

  • How should I map multidimensional to jagged arrays?

    - by mafutrct
    I'd like to map Foo[,] to Foo[][] and back. There are simple solutions using loops, but isn't there something more elegant? In my specific case, this is required in this scenario: [DataContract] class A { // can't serialize this thingy private readonly Foo[,] _Foo; [DataMember] private Foo[][] SerializableFoo { get { // map here } set { // map here } } } I'm aware there are advanced solutions using IDataContractSurrogate but this seems to be overkill in my case.

    Read the article

  • How are .NET 4 GUIDs generated?

    - by mafutrct
    I am aware of the multitude of questions here as well as Raymond's excellent (as usual) post. However, since the algorithm to create GUIDs was changed apparently, I found it hard to get my hands on any up-to-date information. The MSDN seems to try and provide as few information as possible. What is known about how GUIDs are generated in .NET 4? What was changed, and how does it affect the security ("randomness") and integrity ("uniqueness")? One specific aspect I'm interested in: In v1, it seems to be about impossible to generate the same GUID on a single machine again since there was a timestamp and counter involved. In v4, this is no longer the case (I was told), so the chance to get the same GUID on a single machine ... increased?

    Read the article

  • WCF: How can I send data while gracefully closing a connection?

    - by mafutrct
    I've got a WCF service that offers a Login method. A client is required to call this method (due to it being the only IsInitiating=true). This method should return a string that describes the success of the call in any case. If the login failed, the connection should be closed. The issue is with the timing of the close. I'd like to send the return value, then immediately close the connection. string Login (string name, string pass) { if (name != pass) { OperationContext.Current.Channel.Close (); return "fail"; } else { return "yay"; } } The MSDN states that calling Close on the channel causes an ICommunicationObject to gracefully transition from the Opened state to the Closed state. The Close method allows any unfinished work to be completed before returning. For example, finish sending any buffered messages). This did not work for me (or my understanding is wrong), as the close is executed immediately - WCF does not wait for the Login method to finish executing and return a string but closes the connection earlier. Therefore I assume that calling Close does not wait for the running method to finish. Now, how can I still return a value, then close?

    Read the article

  • Why is XmlSerializer so hard to use?

    - by mafutrct
    I imagine to use XML serialization like this: class Foo { public Foo (string name) { Name1 = name; Name2 = name; } [XmlInclude] public string Name1 { get; private set; } [XmlInclude] private string Name2; } StreamWriter wr = new StreamWriter("path.xml"); new XmlSerializer<Foo>().Serialize (wr, new Foo ("me")); But this does not work at all: XmlSerializer is not generic. I have to cast from and to object on (de)serialization. Every property has to be fully public. Why aren't we just using Reflection to access private setters? Private fields cannot be serialized. I'd like to decorate private fields with an attribute to have XmlSerializer include them. Did I miss something and XmlSerializer is actually offering the described possibilities? Are there alternate serializers to XML that handle these cases more sophisticatedly? If not: We're in 2010 after all, and .NET has been around for many years. XML serialization is often used, totally standard and should be really easy to perform. Or is my understanding possibly wrong and XML serialization ought not to expose the described features for a good reason? (Feel free to adjust caption or tags. If this should be CW, please just drop a note.)

    Read the article

  • Where can I get VS code snippets?

    - by mafutrct
    Apparently there are many questions that deal with how to store code snippets for Visual Studio, but I did not find one that contains links. So, is there a website that offers useful snippets? My google-fu only brought up many false positives or broken sites.

    Read the article

  • Can a WCF contract use multiple callback interfaces?

    - by mafutrct
    I'm trying something like this: [ServiceContract ( CallbackContract = typeof (CallbackContract_1), CallbackContract = typeof (CallbackContract_2), CallbackContract = typeof (CallbackContract_3)) ] public interface SomeWcfContract { I know it does not work like this. Is there still a way to get a single contract use multiple callback interfaces?

    Read the article

  • How do I properly handle a faulted WCF connection?

    - by mafutrct
    In my client program, there is a WCF connection that is opened at startup and supposedly stays connected til shutdown. However, there is a chance that the server closes due to unforeseeable circumstances (imagine someone pulling the cable). Since the client uses a lot of contract methods in a lot of places, I don't want to add a try/catch on every method call. I've got 2 ideas for handling this issue: Create a method that takes a delegate and executes the delegate inside a try/catch and returns an Exception in case of a known exception, or null else. The caller has to deal with nun-null results. Listen to the Faulted event of the underlying CommunicationObject. But I don't see how I could handle the event except for displaying some error message and shutting down. Are there some best practices for faulted WCF connection that exist for app lifetime?

    Read the article

  • Is this a correct way to host a WCF service?

    - by mafutrct
    For some testing code, I'd like to be able to host a WCF service in only a few lines. I figured I'd write a simple hosting class: public class WcfHost : IDisposable where Implementation : class where Contract : class { public readonly string Address = "net.tcp://localhost:8000/"; private ServiceHost _Host; public WcfHost () { _Host = new ServiceHost (typeof (Implementation)); var binding = new NetTcpBinding (); var address = new Uri (Address); _Host.AddServiceEndpoint ( typeof (Contract), binding, address); _Host.Open (); } public void Dispose () { ((IDisposable) _Host).Dispose (); } } That can be used like this: using (var host = new WcfHost<ImplementationClass, ContractClass> ()) { Is there anything wrong with this approach? Is there a flaw in the code (esp. about the disposing)?

    Read the article

  • += new EventHandler(Method) vs += Method

    - by mafutrct
    There are two basic ways to subscribe to an event: SomeEvent += new EventHandler<ArgType> (MyHandlerMethod); SomeEvent += MyHandlerMethod; What is the difference, and when should I chose one over the other? Edit: If it is the same, then why does VS default to the long version, cluttering the code? That makes no sense at all to me.

    Read the article

  • How does a historical debugger work?

    - by mafutrct
    A historical debugger is able to revert program state (including current instruction) to a former state. How is this possible in managed or unmanaged environments? I can't imagine that the debugger takes a state shot of the whole system on every instruction.

    Read the article

  • Is it immoral to write crappy code even if readability and correctness is not a requirement?

    - by mafutrct
    There are cases when crappy (i.e. unreadable and buggy) code is not much of a problem. For instance, imagine you need to generate a big text file that mostly follows a simple pattern with a few very complex exceptions. What do you do? You quickly write a simple algorithm and insert the exceptional bits in the output manually to save 4 hours. The code is unreadable, and the output is flawed, but it's still the correct way since it is way faster. But let's get this straight: I hate bad code. I've had to read and work with code that caused my stomach to hurt. I care a lot about good code. And actually, I caught myself thinking that it is immoral to write bad code even though the dirty approach is sometimes superior. I was surprised by myself and found my idea to be very irrational. Did you ever experience this? Should I just get rid of this stupid idea and use the most efficient approach to coding?

    Read the article

  • Is this code thread-safe?

    - by mafutrct
    I've got a class with several properties. On every value update, a Store method is called with stores all fields (in a file). private int _Prop1; public int Prop1 { get { return _Prop1; } set { _Prop1 = value; Store(); } } // more similar properties here... private XmlSerializer _Ser = new ...; private void Store() { lock (_Ser) { using (FileStream fs = new ...) { _Ser.Serialize (fs, this); } } } Is this design thread-safe? (Btw, if you can think of a more appropriate caption, feel free to edit.)

    Read the article

  • Are GUIDs the ultimate ID?

    - by mafutrct
    I noticed some people don't bother having the usual incremented number as ID but instead simply generate a GUID. The advantages include: Quick and easy No need to keep track of previous IDs Guaranteed to be unique even across machines without knowledge of each other Some disadvantages are: Possibly performance bottleneck Uses a large number of bytes My understanding is that using a GUID is beneficial in most cases, except if optimization for time or space is an issue. Did I miss something? Or do you agree with this idea?

    Read the article

1 2 3  | Next Page >