Thursday, July 30, 2015

How to Update SourceTree Git Login Credentials

If by some reason you need to change the login for your Git repository you'll find out that there is no way to do this from SourceTree.  To do that you need to use terminal:


  1. Open SourceTree and navigate to the repository you want to update the password of
  2. Click the ‘Terminal’ button on a toolbar to jump to the location of the repo on the command line
  3. Enter ‘git pull’ command to update the repository
  4. Then you are requested enter your login & password
  5. Done

    UPDATE:  Tools->Options->Authentication. SourceTree seems to use this and not the username specified on the actual remote anymore.





          Thursday, April 17, 2014

          AngularJS Intellisense in Visual Studio 2012

          There is no extensibility for providing additional HTML attribute Intellisense

          image
          But there are 2 options hwo yo ucan enable it:

          OPTION 1 if you don't use Resharper(taken from)

          Step 1

          Find the file commonHTML5Types.xsd located in the Visual Studio install directory and back it up (just in case). Mine is here: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Packages\schemas\html

          Step 2

          Download this new version of commonHTML5Types.xsd and replace the existing one from the directory in Step 1 with it.

          Step 3

          Restart Visual Studio and that's it. You now have all the ng-* attributes available in Intellisense. This Works On My Machinetm, so please let me know if it works on yours too.
          I still want to add native support in either Visual Studio or Web Essentials, so if this is something you’re interested in, please vote for it here.

          OPTION 2

          Use resharper-angularjs

          You can get it from here - https://github.com/JetBrains/resharper-angularjs


          You can install directly into ReSharper 8.0 via the Extension Manager in the ReSharper menu. Since the package is currently pre-release for 8.0 (nightly builds might introduce breaking changes), make sure "Include prerelease" is selected in the dialog.
          To install in ReSharper 7.1:

          Friday, November 8, 2013

          The ASP.Net MVC 3 installer fails when you have a newer version of NuGet installed - WORKAROUND

          I tried to install MVC3 for VS2010 but got error during the instalation:

          MSI (s) (DC:18) [11:11:41:990]: Note: 1: 1325 2: VSIXInstaller.exe
          MSI (s) (DC:18) [11:11:41:990]: Doing action: LaunchConditions
          Action ended 11:11:41: AppSearch. Return value 1.
          Action start 11:11:42: LaunchConditions.
          MSI (s) (DC:18) [11:11:42:022]: Note: 1: 2205 2: 3: Error
          MSI (s) (DC:18) [11:11:42:022]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1709
          MSI (s) (DC:18) [11:11:42:022]: Product: NuGet -- A later version of NuGet is already installed. Setup will now exit.


          I had newer NuGet and the installer tried to install v.1.5.

          Work around
          • Run the install (even though it fails) but leave it open on the screen at the end that says "Installation Did Not Succeed" (This is very important!)
          • Now you need to track down the temp files for the installer it should be in a folder {drive}:/Temp/ext27692 (probably this goes onto whatever drive has the most free space)
          • Make a copy of this entire folder because finishing the installer will delete it.
          • Now that you have all the install files you just need to run the installers for the different components (to double check what they were you can open the log from the installer and see which msi's it ran)
          So install AspNetWebPagesVS2010Tools.msi then AspNetMVC3VS2010Tools.msi

          ASP.NET MVC3 tools are now installed!

          Monday, July 1, 2013

          Database stuck in single user mode

          If you are getting error messages like this:

          Msg 5064, Level 16, State 1, Line 1
          Changes to the state or options of database 'DbName' cannot be made at this time. The database is in single-user mode, and a user is currently connected to it.
          Msg 5069, Level 16, State 1, Line 1
          ALTER DATABASE statement failed.

          the only thing will help you:

          Get process id of active db connection using script:

          select * from master.sys.sysprocesses
          where spid>50 -- don't want system sessions
          and dbid = DB_ID('DbName')


          In my case I got 52.

          And then execute:

          use master
          kill 52-- the connection to the database in single user mode
          use [DbName]
          alter database [DbName] set multi_user with rollback immediate


          Or:

          use master
          kill 52-- the connection to the database in single user mode
          alter database [DbName] set offline with rollback immediate
          alter database [DbName] set online, multi_user with rollback immediate


          Hope this will help you.

          Wednesday, December 5, 2012

          Multiple-Constructor Injection using Unity IOC

          Unity, and the dependency injection design pattern itself, really becomes useful is when the container generates instances of objects that have dependencies. It can automatically resolve the dependent object types required by the objects it creates, generate the appropriate concrete types, and then inject these concrete instances into the object it is creating.

          The following shows a schematic view of the dependency injection process that Unity can accomplish.

          Cc816062.9444d795-6e6e-4d23-ab27-77467e20123a(en-us,MSDN.10).png

          The following are the types of injection together with descriptions of how they are applied using Unity:

          • Constructor injection. This type of injection occurs automatically. When you create an instance of an object using the Unity container, it will automatically detect the constructor with the largest number of parameters and execute this, generating instances of each object defined in the constructor parameters. It resolves each parameter type through the container, applying any registrations or mappings for that type. If you want to specify a particular constructor for Unity to use, you can add the InjectionConstructor attribute to that constructor in the target class.
          • Property (setter) injection. This type of injection is optional. You can add the Dependency attribute to any property declarations that you want Unity to resolve through the container. Unity will resolve that property type and set the value of the property to an instance of the resolved type.
          • Method call injection. This type of injection is also optional. You can add the InjectionMethod attribute to any method declarations where you want Unity to resolve the method parameters through the container. Unity will resolve each parameter type and set the value of that parameter to an instance of the resolved type, and then it will execute the method. Method call injection is useful if you need to execute some type of initialization method within the target object.

          Via http://msdn.microsoft.com/en-us/library/cc816062.aspx

          Multiple-Constructor Injection Using an Attribute

          When a target class contains more than one constructor with the same number of parameters, you must apply the InjectionConstructor attribute to the constructor that the Unity container will use to indicate which constructor the container should use. As with automatic constructor injection, you can specify the constructor parameters as a concrete type, or you can specify an interface or base class for which the Unity container contains a registered mapping.

          e.g.

          public class MyObject {

          public MyObject(SomeOtherClass myObjA)   { …  }

          [InjectionConstructor]
          public MyObject(MyDependentClass myObjB)  {  … }
          }

          In your run-time code, use the Resolve method of the container to create an instance of the target class. The Unity container will instantiate the dependent concrete class defined in the attributed constructor and inject it into the target class. For example, the following code shows how you can instantiate the example target class named MyObject containing an attributed constructor that has a dependency on a class named MyDependentClass.

          e.g.

          IUnityContainer uContainer = new UnityContainer();
          MyObject myInstance = uContainer.Resolve<MyObject>();

          How Unity Resolves Target Constructors and Parameters

          When a target class contains more than one constructor, Unity will use the one that has the InjectionConstructor attribute applied. If there is more than one constructor, and none carries the InjectionConstructor attribute, Unity will use the constructor with the most parameters. If there is more than one such constructor (more than one of the “longest” with the same number of parameters), Unity will raise an exception.

          Constructor Injection with Existing Objects

          If you use the RegisterInstance method to register an existing object, constructor injection does not take place on that object because it has already been created outside of the influence of the Unity container. Even if you call the BuildUp method of the container and pass it the existing object, constructor injection will never take place because the constructor will not execute. Instead, mark the constructor parameter containing the object you want to inject with the Dependency attribute to force property injection to take place on that object, and then call the BuildUp method. This is a similar process to property (setter) injection. It ensures that the dependent object can generate any dependent objects it requires. For more details, see Annotating Objects for Property (Setter) Injection.

          Via URL

          Thursday, February 10, 2011

          VS2010 Tips: How to make jQuery Intellisense work for external JavaScript file

          Simply drag-n-drop the jQuery library from Solution Explorer to the opened external JavaScript file.

          image

          The Intellisense should work now.

          image

          Monday, January 31, 2011

          Windows Azure SDK: connecting to non SQLExpress Instance

          When you want to build an Azure application, but you don’t have SQL Express installed the build action in Visual Studio will fail.
          You will receive the following message in your output window:
          Windows Azure Tools: Failed to initialize the Development Storage service. Unable to start Development Storage. Failed to start Development Storage: the SQL Server instance ‘localhost\SQLExpress’ could not be found. Please configure the SQL Server instance for Development Storage using the ‘DSInit’ utility in the Windows Azure SDK.
          To fix this you open the Windows Azure SDK Command Prompt:
          Windows Azure SDK Command Prompt
          And enter the following text:
          dsinit /sqlinstance:.
          dsinit /sqlinstance:.
          This will cause Azure to use the default instance (with no name). You can switch this to whatever you like, just replace the . (dot) by the appropriate MS SQL instance.
          The result will look like this:
          Development Storage Initialization
          Good luck, happy coding.