Wednesday, November 19, 2014

Utf-8 in javascript

aciklama:'@Html.Raw(Model.Aciklama)',

Wednesday, November 5, 2014

Get shelveset to a different branch


/> tfpt unshelve “MySampleShelveName” /migrate /source:”$/MyTeamProject/TheOrigionalBranch” /target:”TheDestinationBranch”

Tuesday, November 4, 2014

Generate multiple certificates quickly

  $certificateNames = 'evs','kimlikdogrulama','kpsv2','kys','maks','mernis','vatan','veriambari'
    $certificateNames = '1','2','3','4','5','6','7','8'
Foreach ($x IN $certificateNames)
{
Get-Certificate -template "KaleWebServer" -CertStoreLocation cert:\LocalMachine\My -SubjectName "CN=$x"  -Url ldap:
}
dir cert:\localmachine\my | Where-Object { $_.hasPrivateKey } |   Foreach-Object { [system.IO.file]::WriteAllBytes("d:\certificates\$($_.Subject).pfx",     ($_.Export('PFX', '1234')) ) }

Install certificate powershell script

function Import-509Certificate {
param([String]$certPath,[String]$certRootStore,[String]$certStore)
$pfx = new-object System.Security.Cryptography.X509Certificates.X509Certificate2
$pfx.import($certPath)
$store = new-object System.Security.Cryptography.X509Certificates.X509Store($certStore,$certRootStore)
$store.open(“MaxAllowed”)
$store.add($pfx)
$store.close()
}

    function Import-PfxCertificate {   
       param([String]$certPath,[String]$certRootStore = “LocalMachine”,[String]$certStore = “My”,$pfxPass = $null)   
       $pfx = new-object System.Security.Cryptography.X509Certificates.X509Certificate2   

          $pfxPass = convertto-securestring "1234" -asplaintext -force
       $pfx.import($certPath,$pfxPass,“PersistKeySet”)   
       $store = new-object System.Security.Cryptography.X509Certificates.X509Store($certStore,$certRootStore)   
       $store.open(“MaxAllowed”)   
       $store.add($pfx)   
       $store.close()   
       $keyPath = .\FindPrivateKey My LocalMachine -t $pfx.Thumbprint -a
       icacls $keyPath /grant "IIS_IUSRS:(R)"
    }  

    $certificatelocationkys =  resolve-path .\CER\kys.pfx
    $certificatelocationkimlikdogrulama =  resolve-path .\CER\mernis.cer
    $certificatelocationkale =  resolve-path .\CER\kale.cer
Import-PfxCertificate $certificatelocationkys
Import-509Certificate $certificatelocationkimlikdogrulama  "LocalMachine" "TrustedPeople"
Import-509Certificate $certificatelocationkale "LocalMachine" "AuthRoot"

Monday, November 3, 2014

powershell remove clipboard spaces

function removeX{
 $a = Get-ClipBoard
 $b = $a.replace(' ','')
 Set-ClipBoard($b)
 }

Powershell set clipboard

function Get-ClipBoard {
    Add-Type -AssemblyName System.Windows.Forms
    $tb = New-Object System.Windows.Forms.TextBox
    $tb.Multiline = $true
    $tb.Paste()
    $tb.Text
}

function Set-ClipBoard() { Param( [Parameter(ValueFromPipeline=$true)] [string] $text ) Add-Type -AssemblyName System.Windows.Forms $tb = New-Object System.Windows.Forms.TextBox $tb.Multiline = $true $tb.Text = $text $tb.SelectAll() $tb.Copy() }

Aspect-oriented programming

 

AOP aims to increase modularity by allowing separation of cross-cutting concerns.In c# you can use postsharp,spring.net,castle.Logging exemplifies a cross cutting concern.

Advice is the additional code that you want to apply to your existing model.

Pointcut is the term given to the point of execution in the application at which cross-cutting concern needs to be applied.

Aspect is the combination of pointcut and advice

Dependency Injection(Dynamic Proxies)

Functional Programming

Code Generation

Dynamic languages

Low-Level MSIL Transformation

 

A mixin is a class which contains a combination of methods from other classes. How such a combination is done depends on the language, but it is not by inheritance. If a combination contains all methods of combined classes it is equivalent to multiple inheritance.

Object Oriented Programming

 

Object oriented programming(OOP) is a programming paradigm(like aspect oriented,imperative, declarative , event driven).

Encapsulation: creates a boundary around an object to hide its iplementation details.
Inheritance:A class can inherit from another class to reuse its functionality instead of writing it from stratch.

Ploymorphism: a variable of type xcan refer to an object that subclasses x.

Insertion Sort Algorithms

Insertion sort takes an element and checks the left element if greater,if left element is greater checks second left until left element is smaller then creates a gap by copying the first element to temp and moving the first left element to it's location then moves the second element to first left elements position does this until

 

3 7 4 9 5 2 6 1

3 7 4 9 5 2 6 1

3 7 4 9 5 2 6 1

3 4 7 9 5 2 6 1

3 4 7 9 5 2 6 1

3 4 5 7 9 2 6 1

2 3 4 5 7 9 6 1

2 3 4 5 6 7 9 1

1 2 3 4 5 6 7 9

 

Shell sort is like comb sort it attacks the problem by moving the turtles faster by introducing gaps

The first pass 5-sorting performs insertion sort on seperate sub arrays 1 6 11 16 .. 2 7 12 17 vs

 

Tree sort first builds a binary search tree(oredered or sorted binary tree) </DIV></DIV></DIV

Exchanging Sort Algorithms

  1. Buble Sort

    In buble sort iterate over the list and change the first with the second if first is greater then second exchange them with third if second greater and move to end like this changing the elements with the next if greater.After you reach end start over until you make no change in a pass.

    Buble Sort first pass

    8 4 3 1 7 6 2

    4 8 3 1 7 6 2

    4 3 8 1 7 6 2

    4 3 1 8 7 6 2

    4 3 1 7 8 6 2

    4 3 1 7 6 8 2

    4 3 1 7 6 2 8

    As we can see the large number at the begining(8) moved to end very quickly but the small number(2) at the end moved only 1 place in 1 pass

    Small number at the end are turtles

    Large number at the begining rabbits

  2. Coctail Sort is also known as bidirectional buble sort coctail shaker sort or skaker sort it is a variation of buble sort which sorts from both directions in each pass which eliminates turtle problem because turtles from one side are rabits of the other side.

  3. Comb sort is another buble sort variation, it improves buble sort by introducing a gap between swapped elements in buble sort this gap is 1 .In comb sort this gap help turtles move faster and after each pass gap is decremented undil gap becomes 1 and algorithm becomes a buble sort algorithm.The gap is calculated by dividing the lenght of the list by shrink factor(generally 1.3 ,calculated empirically)

Gnome sort is a very easy exchanging algorithm it is also called stupid sort it does not use nested loops it swaps the elements until the left element is smaller than the right.

Let s try it on our sample list

8 4 3 1 7 6 2

4 8 3 1 7 6 2

4 3 8 1 7 6 2

3 4 8 1 7 6 2

3 4 1 8 7 6 2

3 1 4 8 7 6 2

1 3 4 8 7 6 2

1 3 4 7 8 6 2

1 3 4 7 6 8 2

1 3 4 6 7 8 2

1 3 4 6 7 2 8

1 3 4 6 2 7 8

1 3 4 2 6 7 8

1 3 2 4 6 7 8

1 2 3 4 6 7 8