Categories for

Software Development

WCF returning “The content type text/html of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8)

To fix install the WCF non-HTTP activation components

  1. Click the Start button, and then click Control Panel.
  2. Click Programs, and then click Programs and Features.
  3. On the Tasks menu, click Turn Windows features on or off.
  4. Find the .NET Framework 3.0 node, select and then expand it.
  5. Select the WCF Non-Http Activation Components box and save the setting.

Read more...

Log4net “it is being used by another process” Problem

If you use log4net for logging and try to download log files from the server, sometimes “file is being used” problem occurs. There is a configuration for minimal locking the log file.

<log4net>
<appender…
<lockingModel type=”log4net.Appender.FileAppender+MinimalLock” />
</appender>
</log4net>

 There is some performance impact because this means that log4net will lock the file, write to it, and unlock it for each write operation.

If you use RollingFileAppender things become even worse as several process may try to start rolling the log file concurrently. RollingFileAppender completely ignores the locking model when rolling files, rolling files is simply not compatible with this scenario.

Read more...

HackerRank NEW YEAR CHAOS Constructive Algorithm Challenge [SOLVED]

NEW YEAR GIFT !!! IT IS ALSO SOLVED IN JAVA !!!!

    static void minimumBribes(int[] q) {
        boolean sorted = false;
        int bribes = 0;
        if (q.length < 2) 
        System.out.println(bribes);
        while (!sorted) {
            sorted = true;
            for (int i = 0; i < q.length - 1; i++) {
                if (q[i] - i > 3) {
                    System.out.println("Too chaotic");
                    return;
                }
                if (q[i] > q[i+1]) {
                    sorted = false;
                    q = swap(q, i, i+1);
                    bribes++;
                }
            }
        }
        System.out.println(bribes);
    }
        private static int[] swap(int[] q, int i, int j) {
        int tmp = q[i];
        q[i] = q[j];
        q[j] = tmp;
        return q;
    }

Read more...

The Pads HackerRank Advanced SQL Questions [Solved]

Stuck with Advanced Select problem in SQL?
https://www.hackerrank.com/challenges/the-pads/problem

NO WORRIES! HERE IS THE SOLUTION!

SELECT CONCAT(NAME,'(',SUBSTR(OCCUPATION,1,1),')') AS N
 FROM OCCUPATIONS
 ORDER BY N;
 SELECT CONCAT('There are a total of ',COUNT(OCCUPATION),' ',LOWER(OCCUPATION),'s.')
 FROM OCCUPATIONS
 GROUP BY OCCUPATION
 ORDER BY COUNT(OCCUPATION), OCCUPATION;

Read more...

HackerRank Minimum Swaps 2 Problem [Solved]

https://www.hackerrank.com/challenges/minimum-swaps-2/problem No worries! It is as simple as HELL!!

    static int minimumSwaps(int[] arr) {
            int swapCount = 0;
            for (int index = 0; index < arr.Length - 1; index++)
            {
                if (arr[index] != (index + 1))
                {
                    for (int swapIndex = index + 1; swapIndex < arr.Length; swapIndex++)
                    {
                        if (arr[swapIndex] == (index + 1))
                        {
                            int aux = arr[swapIndex];
                            arr[swapIndex] = arr[index];
                            arr[index] = aux;
                            swapCount++;
                            break;
                        }
                    }
                }
            }
            return swapCount;   
}

Read more...