A Confused Programmer's Blog

This blog is dedicated to C# and Java programming that I happen to do for living – with accent on curious cases and with sincere intent to make the world of coding a slightly better place as a result

Preventing TCP packets from growing in size

Recently I was setting up environment with WAN emulation on ESX VMs. The basic setup contained Windows XP/7 VM connected to Windows server VM with WAN emulator in the middle (Ubuntu VM). Traffic sent from XP machine utilized the bandwidth set by the WAN emulator; however, traffic sent from Windows 7/2008 was really struggling to rise above 15KB/sec. After looking at sniffer’s traces I discovered that while XP client was continuously sending packets of 1514 bytes length: VMs with more  [ Read More ]

Continue

No super class for numeric values in C#? Not cool, dudes

Today I discovered a surprising C# limitation: apparently (as of .Net 3.5) numeric types in C# do not share common super class. I believe that this feature would come quite handy in cases like mine. My goal was to write a function that calculates average value of some numeric collection without taking into account top 10% and bottom 10%. So the code I came up with was: public static double AverageWithoutExtremeValues(List<double> values) {   values.Sort();   return values.Skip((int)Math.Round(values.Count * 0.1))     .Take((int)Math.Round(values.Count *  [ Read More ]

Continue

Enable ‘system standby’ capability of your XP virtual machine

In my recent attempts to set automatic power management of virtual machines I ran into a problem of few virtual machines running XP operating system not supporting standby option: C:\Documents and Settings\Administrator>powercfg /a The following sleep states are not available on this system: Standby (S1) Standby (S2) Standby (S3) Hibernate I solved this issue by updating vmware tools on vm (by the way, we are talking about VMware ESXi 4.1.0). And this is how power capabilities look after vmware tools  [ Read More ]

Continue

Possible reason of System.AccessViolationException when using PInvoke

I this short post I will not dive into details describing why PInvoke is essential to writing Windows based applications. Most people who are referred to this page by search engine already know what it is and have an issue of System.AccessViolationException popping when invoking one of Win32 API functions. In my case, reason for this exception appeared to be trivial – usage of wrong parameter type in the function signature. Namely, I was trying to set power scheme: [DllImport(“powrprof.dll”,  [ Read More ]

Continue

One of the products that I am working with uses MySQL database located at the Ubuntu host remotely connected by .NET based web service. For a long time, web service had been suffering from MySQL long response times. We tried different solutions, like connection pooling, all in vain. Yesterday, the situation worsened and web services started failing with connection timeout. When we tried connect using tools like Toad and Navicat, we saw severe delays in server’s response: Apparently, the problem  [ Read More ]

Continue

OWASP 2011 conference impressions, part two

Today I am going to present the rest of what I consider to be the highlights from the OWASP IL 2011 conference that took place ten days ago. Jumping ahead, combined with my first OWASP post, the main conclusion that one can draw from the use cases presented is that coding is a business that involves some basic thinking in addition to ability to press keyboard keys in a sequence that will be accepted by a compiler. One exploit –  [ Read More ]

Continue

Visual Studio will talk to you if you are willing to listen

In this post I will share with you one of the development environment practices that I use and find quite helpful. Few years ago I was browsing through windows “Sounds” tab for some irrelevant obscure reason and stumbled into option of setting Visual Studio sounds. You see, incidentally, both Visual Studio and MS Windows are Microsoft’s products  – and this fact opens a room for integration features between these products that one wouldn’t normally expect. There are 4 Visual Studio  [ Read More ]

Continue

OWASP 2011 conference impressions, part one

Last week I visited OWASP IL 2011 annual conference. OWASP is a non profit organization dedicated to promote web and application security. I first got to know this initiative when the lecture based on my university research was presented about 4 years ago. Since then local OWASP branch has grown and now one can actually find interesting presentations being shown there from time to time. I myself began regularly visiting OWASP meetings since then (who in their right mind would possibly  [ Read More ]

Continue

NetJoinDomain failed with code 2 (File Not Found)

Many times when we are using PInvoke, the return value of the function specifying the error code might return some generic error that will leave the programmer scratching his head. We cannot demand from DLL producers to return meaningful error for each possible case and what happened today was just one example of this happening. I hope that my sad example will prevent critical sanity loss to someone who encounters similar problem. In order to implement domain management, we are  [ Read More ]

Continue

Subscribe to email feed

  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube

REST Assured and une

If you stumbled onto this article, it is safe to ...

Getting rid of Error

Since I upgraded my Windows 8 to Windows 10, I ...

Bypassing EULA step

We are working on automated testing of virtual appliance. This appliance ...

How I got rid of "Ac

OVF is a VMware virtual appliance format which allows you ...

My use-case of Perfo

In my blog I am set on a mission to ...

Twitter updates

RSS not configured