This is a mirror of official site: http://jasper-net.blogspot.com/

Why support more? The story of MSTest…

| Wednesday, April 14, 2010
With the new Visual Studio comes another version of Microsoft’s unit testing framework. This is Microsoft’s take on how unit testing should be done and they got a few things right – as always it’s fully integrated with Visual Studio, and with the new version comes a two exciting new features:

  1. Run tests as 64 bit process – at last I’m able to test that my code works in x64 as well
  2. Parallel execution – run your test suite in half/quarter of the time!

Yet given a choice I still prefer to work with NUnit, and I have a few good reasons – the last strew was Microsoft’s decision not to support multi targeting of the test framework.
What does it means

Not supporting multi-targeting means that once you’ve used VS2010 to run your tests they would automatically be converted to .NET 4 which means that you won’t be able to run them using older versions of Visual Studio – want to read more have a look at this bug report turned feature.

In one of the projects I work on we need to be able to run the same test suite on VS2008 and VS2010 – but we just can’t, we need to maintain two projects just to be able to run the same tests.

So what?

Although this is not such a big deal it seems to me that similar decisions can be found on every step MSTest has done on the road. For example ExpectedException not being able to verify exception message – by design, but still have a message property used for “informative purposes”. Why put a property I’m used to from other frameworks and change the way it work - that’s just confusing. And not to mention the fact that from time to time I get an bonus – instead of running just the test in a specific context all of my tests are run.

Read more: Helper Code

Posted via email from jasper22's posterous

IBM Patents Optimization

|
IBM appears to want to patent optimizing programs by trial and error, which in the history of programming has, of course, never been done. Certainly, all my optimizations have been the result of good planning. Well done IBM for coming up with this clever idea. What is claimed is: 'A method for developing a computer program product, the method comprising: evaluating one or more refactoring actions to determine a performance attribute; associating the performance attribute with a refactoring action used in computer code; and undoing the refactoring action of the computer code based on the performance attribute. The method of claim 1 wherein the undoing refactoring is performed when the performance attribute indicates a negative performance effect of the computer code.

Read more: Slashdot

Posted via email from jasper22's posterous

Block by country

| Tuesday, April 13, 2010
Getting visitors you really don't want to have on your site?

You can now block them easily with our free blocking service. Simply select the countries you want to block from your website and press the "Go" button.

Following, in step 3, .htaccess information is generated for you. Copy and past this generated code into your .htaccess document and visitors from the selected country will not be able to access your website.

Read more: Block a country

Posted via email from jasper22's posterous

Review of Adobe Creative Suite 5

|
Adobe today updated its Creative Suite software to version 5, and PC Pro has an absolutely massive collection of reviews. Along with an overview of the entire suite, from Design to Web to Production bundles, every individual component gets the full in-depth treatment. It includes video demonstrations of Photoshop CS5's fabulous Content-Aware fill trick and new Puppet Warp function; a long-awaited step up to 64-bit for Premiere Pro CS5; and big updates to Dreamweaver CS5, After Effects CS5, and the rest.

Read more: Slashdot

Posted via email from jasper22's posterous

Serious New Java Flaw Affects All Current Versions of Windows

|
There is a serious vulnerability in Java that leaves users running any of the current versions of Windows open to simple Web-based attacks that could lead to a complete compromise of the affected system. Two separate researchers released information on the vulnerability on Friday, saying that it has been present in Java for years.

The problem lies in the Java Web Start framework, a technology that Sun Microsystems developed to enable the simplified deployment of Java applications. In essence, the JavaWS technology fails to validate parameters passed to it from the command line, and attackers can control those parameters using specific HTML tags on a Web page, researcher Ruben Santamarta said in an advisory posted Friday morning.

Tavis Ormandy posted an advisory about the same bug to the Full Disclosure mailing list on Friday as well. Ormandy said in his advisory that disabling the Java plugin is not enough to prevent exploitation, because the vulnerable component is installed separately.

In short, if you have a recent version of Java running on a Windows machine, you're affected by this flaw.

"Java.exe and javaw.exe support an undocumented-hidden command-line parameter "-XXaltjvm" and curiosly also "-J-XXaltjvm" (see -J switch in javaws.exe). This instructs Java to load an alternative JavaVM library (jvm.dll or libjvm.so) from the desired path. Game over. We can set -XXaltjvm=\\IP\evil , in this way javaw.exe will load our evil jvm.dll. Bye bye ASLR, DEP...," Santamarta said in his advisory.

Because the JavaWS technology is included in the Java Runtime Environment, which is used by all of the major browsers, the vulnerability affects all of these applications, including Firefox, Internet Explorer and Chrome, on all versions of Windows from 2000 through Windows 7, Santamarta said. Browsers running on Apple's Mac OS X are not vulnerable.

Read more: threat post

Posted via email from jasper22's posterous

Daily Dose - Novell Keeps Unix Copyrights; Linux is Safe

|
A US federal judge ruled  on Tuesday that Novell owns the Unix copyrights, and not SCO.  In the 7-year court battle, SCO claimed that copyrights transferred from their predecessor, the Santa Cruz Operation, to them.  In the court ruling, the judge said that the copyrights never transferred to the Santa Cruz Operation in the first place.  Tuesday's ruling was a key victory for IBM, who would have faced a multibillion dollar lawsuit had SCO won, and for Linux users, who could have been subject to fees if SCO had gotten the copyrights.  SCO's open source enemies will be glad to know that the long trial has depleted the company's resources.l  They are currently under bankruptcy court protection and this recent legal defeat could be the final nail in the coffin.

US Cybersecurity Act "Kill Switch" Removal Questioned
In August, the US Cybersecurity Bill was met with harsh criticicsm because it allowed the President to shut down internet traffic by seizing private networks.  The new draft, which passed last week, has removed the explicit "kill switch" language from the bill, but Donny Shaw's blog has led many to believe that the President would still possess "kill switch" power under the new bill.  Shaw says that the language is still vague, and does not limit what the President can do in an "emergency response and restoration."  This is a plan (replacing the "kill switch") that the President would develop by collaborating with government agencies and private industries.  A cybersecurity emergency response may be declared "in the event of an immediate threat to strategic national interests involving compromised Federal Government or United States critical infrastructure information systems."  This seems to indicate that the President would only be able to declare an emergency if there were a cyber threat to US critical systems.  It's unlikely that we'll see the government shutting down newspapers or any other subversive websites anytime soon.

Read more: DZone

Posted via email from jasper22's posterous

Use Named Pipes and Shared Memory for inter process communication with a child process or two

|
I wanted to inject some very low impact code that would run in any “parent” process, like Notepad or Excel or Visual Studio. I wanted to have some User Interface for the data that my injected code gathered about the parent process, and that would work best in a different “child” process, preferably using WPF.

In the old days, I could call a COM server to handle the job. A DLL server would be in process, but it could be made out of process by making it a COM+ application (see Blogs get 300 hits per hour: Visual FoxPro can count. and Create multiple threads from within your application).

.Net Remoting seemed to be a little heavyweight for Parent->Child process communication.

About 5 years ago, I wrote this: Use Named Pipes to communicate between processes or machines, so I thought I’d use a combination of Named Pipes and Shared Memory. Luckily .Net 3.5 added support for Named Pipes making the child process pretty simple.

Pipes could be used to send messages, and the lion’s share of data movement could be in the Shared memory.

Synchronization and lifetime management are a little tedious. We want the parent process to continue optionally if the child process terminates, but we want the child to terminate automatically when the parent terminates for any reason. Similarly, the child process should terminate if the parent has gone.

This sample shows a parent process in C++ and 2 child processes in C# and VB. The parent spins off a thread to use to service incoming requests from the children. Events are used to synchronize communication. A timer in each child process fires off requests to the parent.

I was using Visual Studio 2010: you can use VS 2008, but you’ll have to adjust for some of the new features I use, especially in the VB code.

Start Visual Studio. File->New->Project->C++ Win32 Project->Windows Application. In the wizard, Click Add common header files for ATL Now hit F5 to build and see it execute: there’s a window and a couple menus.

Now add a second EXE project to your solution: choose File->Add->New Project->VB WPF Application.  (Repeat to add a 3rd project for C# !)

Fiddle with the Project->Properties->Compile->Build Output path so it builds into the same folder as the parent exe (for me, it was” ..\Debug\”)

Paste in the VB code below into MainWindow.Xaml.Vb

Somewhere inside the _tWinMain of your CPP project, add these 2 lines to instantiate a class that calls the WpfApplication as a child process, with a shared memory size of 2048 (make sure to change the name of the EXE to match your VB and C# EXEs):

   CreateChildProcess opCreateChildProcessCS(_T("NamedPipesCS.exe"),2048, 1);
   CreateChildProcess opCreateChildProcessVB(_T("NamedPipesVB.exe"),2048, 2);


Paste the CPP code below before the _tWinMain. F5 will show both processes launched. You can alt-tab between the 2: they behave like independent processes. Try terminating one of them.
If you uncomment the MsgBox, then hit F5, you can actually use VS to attach to a child process before it does too much. Try attaching to all 3!  

See also:

<C++ Code>

// CreateChildProcess : class in parent process to instantiate and communicate with a child process
// usage:    CreateChildProcess opCreateChildProcess(_T("WpfApplication1.exe"),2048);

class CreateChildProcess
{
   HANDLE m_hChildProcess;// handle to the child process we create
   HANDLE m_hNamedPipe;    // handle to the named pipe the paren process creates
   HANDLE m_hEvent;
   HANDLE m_hThread; // thread in parent process to communicate with child
   LPVOID m_pvMappedSection;
   DWORD m_cbSharedMem;

public:

   CreateChildProcess(TCHAR* szChildExeFileName,DWORD cbSharedMemSize, int ChildNo )
   {
       m_cbSharedMem = cbSharedMemSize;
       TCHAR szPipeName[1000];
       TCHAR szEventName[1000];
       swprintf_s(szPipeName, L"Pipe%d_%d", ChildNo, GetCurrentProcessId()); //make the names unique per child and per our (parent) process
       swprintf_s(szEventName,L"Event%d_%d", ChildNo, GetCurrentProcessId()); //
     
       SECURITY_ATTRIBUTES SecurityAttributes = {
           sizeof( SECURITY_ATTRIBUTES ),  // nLength
           NULL,                           // lpSecurityDescriptor. NULL = default for calling process
           TRUE                            // bInheritHandle
       };

Read more: Calvin Hsia's WebLog

Posted via email from jasper22's posterous

General Guidance for SQL Server on Virtualisation

|
I have been on about four engagements in a row this year where we are looking at SQL performance on VMWare or Hyper-V.

Here is a list of common things that you can do with virtualisation that may adversely affect SQL performance. Most of them also apply to physical environments, for example if you are consolidating SQL onto multiple instances.

   * Using a large Shared disk group for all virtual workloads
   * Mounting the VHD to VMWare disk on a server file system (instead of pass though disks)
   * Using a large disk pool when only one controller can own the disk group (some SAN’s are limited in this way and some are not)
   * Overcommiting CPU
   * Overcommiting Memory
   * Not using 64k block size and allocation unit size
   * Not using Volume alignment (on guest and host)
   * Using dynamic disks (much better in Hyper-V R2, but still not generally recommended)
   * Not ensuring Logs are on dedicated spindles
   * Not using multiple HBA channels on larger workloads
   * Sharing a switch between data, network and CSV
   * Not using CPU affinity (some virtualisation platforms support affinity)
   * Not using an “enlightened” operating system (Hyper-V)
   * Running multiple VM’s on a single host slightly decreases throughout, but this is kinda the point of virtualisation so hard to avoid.
   * Running lots of SQL Servers on one host and having too few HBA cards or a low queue depth
   * Running 32 bit SQL Server guest on workloads that need lot of memory.
   * Not pre-sizing TempDB
   * not planning for database growth events


The top one item (use of a shared disk group) is a very common configuration for disks, especially when using the clustered shared disk volumes. But we know they will adversely affect performance, so what to do ? ban these configurations?

Read more: Bob Duffy's Blobby Blog

Posted via email from jasper22's posterous

BlogEngine.NET Themes

|
A collection of every single theme pack for BlogEngine.net that can be found.

Read more: Codeplex

Posted via email from jasper22's posterous

Win32 Thread Pool

|
What is a thread pool? Exactly that, a pool of threads. You may have heard of terms like object pooling, thread pooling, car pooling (oops), anyway, the idea behind pooling is that you can re-use the objects which may be threads or database connections or instances of some class. Now why would we ever want to re-use such things? The most important reason would be that creating such an object might take up a lot of resources or time, so, we do the next best thing. We create a bunch of them initially and call the bunch a pool. Whenever someone (some code) wants to use such an object, instead of creating a new one, it gets it from the already existing bunch (pool).

Background

Usually when I develop something, there is a fairly good reason behind it like my project demanded it or I did it for someone who asked me about it, but this thread pool was a result of neither of these. Actually, around a year back, I had attended an interview with a company where I was asked this question. Well at that time, I didn't really think of it seriously, but a few days back the question came back to me, and this time I decided it was time to get my answer working.

Using the Code

Main Files

   * threadpool.h & threadpool.cpp - defines the CThreadPool class. This class is the main class which provides the thread pooling facilities.
   * ThreadPoolAppDlg.cpp - see the OnOK() method. This method makes use of the thread pool.

This example was written using VC++ 6.0. The source has now been updated for Visual Studio 2008. The thread pool class itself does not make use of any MFC classes so you should be able to use the thread pool for pure Win32 applications also.

Read more: Codeproject

Posted via email from jasper22's posterous

Becoming a Windows Search Ninja - “Mastering Windows Search using Advanced Query Syntax”

|
Search has become an integral part of Windows, particularly in later versions. While the major search improvements began with Windows Vista and were backported to Windows XP, it's really only with Windows 7 that the larger majority of users are discovering the search bar all over in the operating system. Search is built into every aspect of Windows 7 to help users cope with the increasingly rapidly growing number of files, be they work documents and e-mails, personal photos and videos, or music collections.

Many users perform searches without thinking nowadays: it's an ingrained habit of using the operating system. Like many habits, this one is worth breaking in order to to develop an even better one. Here we take a quick look at a few basic search techniques and a few more advanced ones. Force yourself to use them and you'll soon become a master of Windows Search. A bit of extra time now will save you loads of effort in the long run.

Read more: Greg's Cool [Insert Clever Name] of the Day

Posted via email from jasper22's posterous

Finding meaningful error details to report execution failures

|
Today a friend of mine asked for a hand with an SSRS error he was getting. I have to admit, at the time I was pretty busy and feel bad that I didn’t answer the question completely. The error was resolved though and the find/fix by him was impressive to say the least. One thing that was frustrating for both of us was the error presented from the report server when this particular report execution failed. In short, the error was not helpful at all. There is resource to find more in-depth descriptions on the error though by turning to the trace logs that are enabled on reporting services. Below, we will go through searching for these descriptive errors in the logs.

On the report server, navigate through the directory structure to the installation folders for the SSRS binary files. In these folder you will find a folder named, LogFiles. This folder will house the default report server trace logs. All execution trace events will be logged in these flat files and can be excellent information to troubleshooting report execution issues. After understanding the trace files, it is also a great way to utilize SSIS to import and report off of them to be more proactive on the report executions.

To read in-depth on the trace logs see, "Report Server Service Trace Log"

Learning how the log files are recycled can be key on finding the file that will help you in a troubleshooting session. The following extract from the BOL documentation explains just how this process is handled.

   "The trace log file is ReportServerService_.log. The trace log is an ASCII text file. You can use any text editor to view the file. This file is located at \Microsoft SQL Server\\Reporting Services\LogFiles. The trace log is created daily, starting with the first entry that occurs after midnight (local time), and whenever the service is restarted. The timestamp is based on Coordinated Universal Time (UTC). The file is in EN-US format. By default, trace logs are limited to 32 megabytes and deleted after 14 days"

Knowing the recycle times and when a new log is created can lower the length of time spent on searching them for the error needed.

Read more: LessThanDot

Posted via email from jasper22's posterous

Using HtmlUnit on .NET for Headless Browser Automatio

|
If you subscribe to this blog, you may have noticed that I’ve been writing about test automation methods a lot lately. You could even think of it as a series covering different technical approaches:

   * Hosting your app in a real web server and testing it through a real web browser using WatiN (plus, in this case, SpecFlow for Cucumber-style specifications)
   * Hosting your app in a real web server and testing it with client-side automation using Microsoft’s Lightweight Test Automation Framework
   * Hosting your app directly in the test suite process and bypassing both the web server and the browser entirely using my MvcIntegrationTestFramework experiment
   * Unit testing code in isolation – best and worst practices, and why I think unit testing isn’t applicable to all types of code
   * Injecting code across process boundaries to assist integration testing approaches that host your app in a real web server, using Deleporter

The reason I keep writing about this is that I still think it’s very much an unsolved problem. We all want to deliver more reliable software, we want better ways to design functionality and verify implementation… but we don’t want to get so caught up in the beaurocracy of test suite maintenance that it consumes all our time and obliterates productivity.

Yet another approach

Rails developers (and to a lesser extent Java web developers) commonly use yet another test automation technique: hosting the app in a real web server, and accessing it through a fast, invisible, simulated web browser rather than a real browser. This is known as headless browser automation.

Read more: Steve Sanderson’s blog

Posted via email from jasper22's posterous

Free-to-use CryEngine plans emerge

|
Crytek wants to release a standalone, free platform, that will be ‘up to speed’ with CE3

Frankfurt-headquartered Crytek may be about to compete with both Unity and Epic Games on the emerging battleground of free-to-use engines. The global indie outfit told Develop that it wants to release a standalone free engine “that will be up to speed” with the CryEngine 3 platform. Unreal vendor Epic Games and Unity have both seen their user-bases mushroom overnight since launching versions of their own engines that, while tied to different royalty rates, are completely free to download and operate. Now the CryEngine 3 group has revealed it wants to tap into this thriving market.
The firm’s CEO Cevat Yerli told Develop that Crytek already gives away a CryEngine 2 editor to the mod community, but explained that Crytek’s expansion strategy stretches beyond. “We have a very vivid community of users and modders and content creators, and usually that’s a great way of unlocking the engine,” he said. “That being said, it’s not the same as what Epic or Unity are currently doing, but we are now pushing harder on this area. We did it before already, but we haven’t pushed it that far yet.”

Read more: Develop

Posted via email from jasper22's posterous

Project Packager Add-In for Visual Studio 2010

|
This Add-In for Visual Studio 2010 will package up your solution (actually, any folder you choose) into a zip file excluding any files with extensions you specify and any folders whose names you specify.I cant upload msi files to this blog, so in order to install you will need to build the project.

I packaged up the Add-In solution using the Add-In itself and uploaded it here.

  1. Download the solution, open with Visual Studio 2010 and Build All.
  2. Right click the setup project and select Install.
  3. Close Visual Studio 2010 and restart.
  4. In the Tools menu item –> Add-in Manager click the PackagerAddIn check box.

To use the Add-In, go to Tools –> PackagerAddIn
Motivation

After completing a project, either as a demo in class, or for a customer, I often need to zip up a solution send it by email or store it somewhere.

But even simple projects with Visual Studio 2010 create many binary files that increase the size of the package and contribute nothing to the recipient. Moreover, the baggage, once delivered is usually never deleted for fear that it is essential to to the solution. Once added to the source code control system it will slow down every check out and build for life. Moreover, it makes the project unnecessarily daunting for less experienced developers to learn.

I have tried using "Clean Solution" from the Build menu to remove the baggage, and, yes, it kinda works. But it is not quite as flexible as I need. For instance, though you can configure which file extensions will be deleted, you can't configure it to delete folders even if they are empty after the clean. "Clean Solution" also wont zip up the solution for you when you are done.

Rather than delete the files myself, and run the risk of deleting something important, I would like to copy all the important files without the baggage to a separate location, then zip up that folder and then delete the folder. This way, even if I forget an important file in the process, the original still exists and can be added.

Read more: David Sackstein's Blog

Posted via email from jasper22's posterous

More T4

|
T4 (Text Template Transformation Toolkit) is a code generator integrated on Visual Studio. Hmmm CodeSmith? ;-)

Creating and editing a T4 Template
Steps

   * Add a Text File
   * Rename with a .tt extension
   * Write T4 template header configuration and template code


<#@ template language="C#v3.5" #>
<#@ import namespace = "System.Text.RegularExpressions" #>
<#@ output extension=".cs" #>

<#
string lTitle = "MyHelloWorldClass";
#>

namespace MyProject.Test
{
   public class <#=lTitle #>
   {
       public <#=lTitle #>()
       {
       }
   }
}

Actually EF (Entity Framework) uses T4 to customize your EF generated classes.

Tools
Tangible Engineering offer a T4 Editor (Free or Pro versions) to integrate on Visual Studio with intellisense.

Read more: Refact your C# Code

Posted via email from jasper22's posterous

“Originally Written in…” vs. Code Generation

|
My assertion that the iPhone license phrase “Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine” can only mean zero code generation has been questioned. Here’s why I stand by that assessment (and consider the clause beyond the pale).

Let me point out that the common-sense reading of that clause is straightforward. The word “originally” clearly implies that writing this:

UIView.BeginAnimations("");
UIView.SetAnimationTransition(UIViewAnimationTransition.FlipFromLeft, this.Superview, true);
UIView.SetAnimationCurve(UIViewAnimationCurve.EaseInOut);
UIView.SetAnimationDuration(1.0);

and transforming it into:

[UIView beginAnimations: nil context:context];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView: [self superView] cache: YES];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration: 1.0]

is forbidden. To take it to the extreme, can you imagine betting your company on convincing a jury that writing the first (which is C# and MonoTouch) and generating the second means it was “originally written in Objective C”? If so, you have some hard lessons about the legal system to learn.

I should point out that even though this code is clearly very similar, there are some slight differences, such as C#’s enumerated values UIViewAnimationTransition.FlipFromLeft as opposed to Objective C’s constant value UIViewAnimationTransitionFlipFromLeft. The . makes a difference in the parse tree and in the programmer’s mind — a small one, but a helpful one.

Read more: Knowing .NET

Posted via email from jasper22's posterous

AWESOMIUM

|
webflow_1.6_screen-300x187.jpg
What Is “Awesomium”?

The Web is changing. The way we browse that web is not. Users today are wholly dependent upon mainstream browsers to access their content (in fact, you’re probably using one right now to read this sentence).

Our vision to break the Web out of this box by providing developers the tools they need to develop the next generation of browsers.

Awesomium is a software library that allows developers to embed the client-side web in their own applications.

A few examples of usage

   * An offscreen renderer for snapshots or recordings of web-pages
   * A framework for an advanced, 3D web-browser
   * Powering a GUI using Web-based content
   * The implementation of in-game advertisting.


Read more: Khrona

Posted via email from jasper22's posterous

My Visual Studio Theme for Windows 7

|
original.aspx

This is a simple Visual Studio theme I put together for Windows 7 on my laptop. Enjoy!

Read more: Rob Caron

Posted via email from jasper22's posterous

How I made our websites run 10 times faster

|
For a very long time our websites have been very sluggish. There are several reasons to this, some obvious, while other not so obvious. Here I will explain to you how we made our websites perform at lightning speed!
How I made our websites run 10 times faster

The first thing you have to realize when working with a website project, which isn't just merely HTML documents offed at some server somewhere, is that although YSlow is a very good product, the assumption that most of your website speed is in the client-layer just isn't true. YSlow is a *KICK-ASS* product, and start out with YSlow, but once you have gone through the issues you can fix that YSlow shows you, please do not stop there...!

If you have any kind of complex server back-end, you will have to move on further and also optimize your server back-end...

What we did...

First of all I started out with figuring out how to reduce the impact of the ViewState. The ViewState has a very bad reputation, and to be quite frankly, most of its bad reputation is not justified. The ViewState is a really beautiful thing, and if you're going to develop any kind of complex application or website, you will have to use some kind of either similar mechanism to the ViewState, or the ViewState itself.

Though when you couple the ViewState with a Modularized Framework like Ra-Brix, the ViewState problems accumulate. Since all our websites are built on Ra-Brix, we had to do something about it. A couple of weeks ago I wrote a pretty detailed blog about how we fixed our ViewState problems in Ra-Brix. To summarize; we saved it on the server...

Read more: Ra-Ajax

Posted via email from jasper22's posterous