Welcome...



...All those moments will be lost in time, like tears in rain....

- soliloquy from Blade Runner


Bits and bytes do get lost, awash in the rain of data flow that is Internet. They slip away from us, never to found again... some of them will be captured here, many more will not... like tears in rain...



Monday, April 1, 2013

Entity Framework 5 and LocalDb in Visual Studio 2012


 Visual Studio 2012 introduced LocalDb - special edition of SQL Express for developers.

 Problem that I run into when trying to create database was that by default, web.config had SQLExpress datasource specified, not LocalDb.

 After searching and finding a great blog - OdeToCode, turned out that I had to change this section:

<entityFramework>
  <defaultConnectionFactory 
      type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, 
            EntityFramework">
    <parameters>
      <parameter value="v11.0" />
    </parameters>
  </defaultConnectionFactory>
</entityFramework> 

I did change defaultConnectionFactory, but it didn't work, giving me error about not recognizing LocalDbConnectionFactory etc.

Additional parameter has to be added and to be v11.0 for this to work.

Wednesday, March 20, 2013

Voyager 1 left Solar system for good...

 Looks like it's official now - Voyager 1 crossed the edge of Solar system! For somebody who still remembers Carl Sagan's "Cosmos" that's exciting news. I wonder how long it will keep sending...
Go Voyager Go!

Wednesday, March 6, 2013

This and that in JavaScript

 This and that in JavaScript - or self as I've seen it, is just a workaround for the fact that in JavaScript, inner function "this" is not behaving like "this" from the outer function, it points to the window object.. Yes, it's a bug, and it will be fixed in ECMA5.

To preserve outer function "this", putting "this" into local variable ("that" or "self") will allow transfer of variable from outer function to be used, by using closures.

Closure mechanism - an inner function always has access to the vars and parameters of its outer function, even after the outer function has returned.

Something like this:

<!DOCTYPE html><html lang="en">
<head></head>
<body>
<script>
 var myObject = 
{
  myProperty:'Some text here'
  myMethod:function() 
  {
   var that = this; //reference to myObject in myMethod scope 
   var innerFunction function() { // inner one
           console.log(that.myProperty); //logs 'Some text here'
           console.log(this); // logs window object to show what will happen if we don't store this into that
        }();
    }
}
myObject.myMethod(); // invoke myMethod

</script>
</body>
</html>

Debugging client side script

I was trying to debug client side code and was getting those "Breakpoint will not be hit" messages. Turn out that to allow debugging of the client side script, you need to Attach debugger to the process but before you actually do that,  click Select button on the top of the list of processes. If it on automatic, change it to Script.
 That functionality goes back to Visual Studio 2008 and it's still there in VS 2012.
 There are other ways too - debugger; in javascript code, or using Client debugging in IE or Firefox (or Chrome), but it's nice not to have to do anything extra but use VS when you want to attach to the process anyways.

Friday, February 8, 2013

ViewState and debuger

ViewState object is not great for debugging. Expanding it's properties at the run time will yield nothing useful unless you know what are you looking for.
Add this to Watches to get insight into collection of values stored in internal dictionary:

new System.Collections.Hashtable(ViewState)