Wednesday, 14 August 2013

Could not load file or assembly 'Microsoft.SqlServer.BatchParser, Version=11.0.0.0,

Tuesday, 13 August 2013

For loop in F#

Tutorial 2

Define list of numbers
Create for loop to display results.



Code:


// Learn more about F# at http://fsharp.net
// See the 'F# Tutorial' project for more help.

open System

printfn "Started"

// define list
let list1 = [ 1; 2; 3; 4; 5; ]

//loop through all
for i in list1 do
   printfn "%d" i

// i squared
for i in list1 do
    printfn "%d squared %d" i (i*i)

printfn "Press any key to exit"
Console.ReadKey()




Your result




Hello world in F#

Lets open our VS studio and open new F# console application project.
I am writing this example based of my C# knowledge

  1. Text starting with // are comments
  2. The are no {}  as indenting does the same thing.. neeter code love it


type following

// same as using
open System

// write to screen same as Console.Write("Hello world")
printfn "Hello world"

// waits for any key to be pressed
Console.ReadKey(true)



Hit F5 and you have nice console application






Monday, 12 August 2013

Umbraco get media id from url

Working with umbraco 6 is great fun.

I am working with images and needed to access image before is served to public.
Hope my solution will  save you some time.

Here is solution


var path = HttpContext.Current.Request.Path.ToLower();

// filter requests that we know are not relevant
if (!path.StartsWith("/media/") || path.StartsWith("/media/temp/") || path.Contains("_thumb.")) return;


// access medisa service
Umbraco.Core.Services.MediaService ms = new Umbraco.Core.Services.MediaService(new Umbraco.Core.Persistence.RepositoryFactory()); 
var item = ms.GetMediaByPath(path);

Monday, 5 August 2013

Adding typescript minified scripts into bundles.

Problem:

I want to add TypeScript generated minified files into bundle configuration.

By default, minified files are excluded.


Solution:
I need to add custom implementation of ignore list in order to manage ignore list. I do not change any configuration of typescripts generated files, but add custom code.

See implementation below:


 protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();
        }

public class BundleConfig
    {

   public static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
        {
            ignoreList.Clear();
            ignoreList.Ignore("*.min.css", OptimizationMode.WhenDisabled);
        }

        // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
        public static void RegisterBundles(BundleCollection bundles)
        {
            AddDefaultIgnorePatterns(bundles.IgnoreList);

            bundles.Add(new ScriptBundle("~/bundles/site")
                .Include("~/Scripts/Site.min.js",
                         "~/Scripts/Test2.min.js"));
        }
}