Dec 9, 2013

LESS CSS - Dynamic Stylesheet



LESS is a dynamic stylesheet language.


LESS extends CSS with dynamic behavior such as variables, mixins, operations and functions.

LESS runs on both the server-side (with Node.js and Rhino) or client-side (modern browsers only).

You can download LESS file(s) from here.


Repetition of information: In CSS, we often repeat color calues or height values in multiple places. One can eliminate these kind of issues using LESS.

Variables

Variables allow you to specify widely used values in a single place, and then re-use them throughout the style sheet, making global changes as easy as changing one line of code.

Example:

/* Compiled CSS */
#header {
  color: #4D926F;
}
h2 {
  color: #4D926F;
}

 // LESS
@color: #4D926F;

#header {
  color: @color;
}
h2 {
  color: @color;
}

Mixins


Mixins allow you to embed all the properties of a class into another class by simply including the class name as one of its properties. It’s just like variables, but for whole classes. Mixins can also behave like functions, and take arguments, as seen in the example below.

Example:

/* Compiled CSS */
#header {
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  -ms-border-radius: 5px;
  -o-border-radius: 5px;
  border-radius: 5px;
}
#footer {
  -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  -ms-border-radius: 10px;
  -o-border-radius: 10px;
  border-radius: 10px;
}


// LESS
.rounded-corners (@radius: 5px) {
  -webkit-border-radius: @radius;
  -moz-border-radius: @radius;
  -ms-border-radius: @radius;
  -o-border-radius: @radius;
  border-radius: @radius;
}

#header {
  .rounded-corners;
}
#footer {
  .rounded-corners(10px);
}


Functions & Operations


Are some elements in your style sheet proportional to other elements? Operations let you add, subtract, divide and multiply property values and colors, giving you the power to create complex relationships between properties. Operations should only be performed within parentheses in order to ensure compatibility with CSS. Functions map one-to-one with JavaScript code, allowing you to manipulate values however you want.

Example:

/* Compiled CSS */
#header {
  color: #333;
  border-left: 1px;
  border-right: 2px;
}
#footer {
  color: #114411;
  border-color: #7d2717;
}

// LESS
@the-border: 1px;
@base-color: #111;
@red:        #842210;

#header {
  color: (@base-color * 3);
  border-left: @the-border;
  border-right: (@the-border * 2);
}
#footer {
  color: (@base-color + #003300);
  border-color: desaturate(@red, 10%);
}

Setting up LESS in ASP.NET MVC
One can use below sample code to call LESS-CSS code.
<link content="" href="@Url.Content(" less="" mysite.less="" rel="stylesheet/less" type="text/css"></link>
<script content="" less-1.3.3.min.js="" scripts="" src="@Url.Content(" type="text/javascript"></script>

Nov 28, 2013

Curah!

Curah!

Microsoft developed Curah! as a way to help customers/developers discover great technical content. Curah! has a very specific purpose: to help people searching in Bing or Google find annotated collections of great content that specifically target common user questions. 

Curah! is a simple and fun way to help others find great content on the internet. It is a curation service that enables you to share your expertise with others, collecting the sources that are truly helpful, accurate and trustworthy, and adding your own notes and guidance.

Nov 12, 2013

Reading application details using PowerShell

Windows PowerShell

Windows PowerShell is a task-based command-line shell and scripting language designed especially for system administration. In simple, it is task automation and configuartion management framework. 

It helps IT professionals and power users control and automate the administration of the Windows operating system and applications like IIS etc that run on Windows with the help of Windows Management Instrumentation(WMI).

PowerShell can be downloaded from here.

PowerShell commands are called cmdlets. It lets you executes commands over command-prompt or Integrated Scripting Environment (ISE). Detailed list of cmdlets are available here

Below example displays list of applications and directories under given Application Pool.


Import-Module WebAdministration

function Get-WebAppPoolApplications($webAppPoolName) {
    $result = @()

    $webAppPool = Get-Item ( Join-Path 'IIS:\AppPools' $webAppPoolName )
    if ( $webAppPool -ne $null ) {
        
        #For all web sites
        #$webSites = Get-ChildItem 'IIS:\Sites'
        
        #For only 'Default Web Site'
        $webSites = Get-ChildItem 'IIS:\Sites' | where { $_.Name -eq 'Default Web Site' }
        
        $webSites | % {
            $webApplications = Get-ChildItem ( Join-Path 'IIS:\Sites' $_.Name ) |
                where { $_.NodeType -eq 'application' }

            $webFolders = Get-ChildItem ( Join-Path 'IIS:\Sites' $_.Name ) |
                   where { $_.NodeType -eq 'directory' }
            
                            
            $result += $webApplications |
                where { $_.applicationPool -eq $webAppPoolName }
                
             $result += $webFolders
                
        }
    }
    #Export to CSV file
    #$result | export-csv "list.csv"
    $result
}
Get-WebAppPoolApplications('ASP.NET V2.0')

WebAdministration: Importing a web administration module. It lets you access IIS app pools and using few commands we will be able to get information about IIS. Above example works only with IIS 7.