VSO Prebuild

When you add vNext project in the VSO it will always encounter an err because it didn’t install the dnvm.

Run this prebuild before run other test.

# bootstrap DNVM into this session.
&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}

# load up the global.json so we can find the DNX version
$globalJson = Get-Content -Path $PSScriptRoot\global.json -Raw -ErrorAction Ignore | ConvertFrom-Json -ErrorAction Ignore

    $dnxVersion = $globalJson.sdk.version
    Write-Warning "Unable to locate global.json to determine using 'latest'"
    $dnxVersion = "latest"

# install DNX
# only installs the default (x86, clr) runtime of the framework.
# If you need additional architectures or runtimes you should add additional calls
# ex: & $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -r coreclr
& $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -Persistent

 # run DNU restore on all project.json files in the src folder including 2>1 to redirect stderr to stdout for badly behaved tools
Get-ChildItem -Path $PSScriptRoot\src -Filter project.json -Recurse | ForEach-Object { & dnu restore $_.FullName 2>1 }

Hack DDoS protection by Cloudflare

Some website try to protected their site by using DDoS protection by Cloudflare. If we look into below url: “http://www.jlotto.kr/keno.aspx?method=kenoWinNoList” 1. The cloudflare will checking for the browser information, then will redirect the page into the jlotto.kr. DDoSProtectionCloudFlare DDoSBreakCloudflare ¬† 2. After we see this, we turn on the fiddler to capture what happen, we will see that the step. 503, 302, 200 HttpStatus. DDoSBreakFiddler Then we need to investigate the more details like what information that parse from 503 -> 302 -> 200. 3. When we look into the last request 200 success we can identify, that it required “cf_clearance” to be set on the cookie. 4. Continue to trace back, the 2nd request is “http://www.jlotto.kr/cdn-cgi/l/chk_jschl?jschl_vc={0}&pass={1}&jschl_answer={2}” How the value jschl_vc, pass & jschl_answer it get the value from the first request. jschl_vs & pass we can get from the innerHtml jschl_answer we need to use javascript to calculate it.

After we apply this rule into the code we will able to crawler the official site.

Reduce the json size in MVC 6

In here we removed all default value and null in our json output.

        .Configure<MvcOptions>(options => {
          var jsonOutputFormatter = new JsonOutputFormatter();
          jsonOutputFormatter.SerializerSettings.DefaultValueHandling = DefaultValueHandling.Ignore;
          jsonOutputFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;

          options.OutputFormatters.Insert(0, jsonOutputFormatter);

EntityFramework 7

After I upgrade my Win 10 to latest technical preview 10074 and upgrade my VS 2015 to RC. I got a lot of error into my project when I build it. I watch the Build 2015 to figure out what it has changes. Usually I using “k ef add migration addProfile” it not going work anymore. check out this docs the latest asp.net 5. http://docs.asp.net/en/latest/ DNX (Dot Net Execution Environment) dnx . ef migration add ¬†addProfile

Git swap branch to master

Sometimes in the development we always commit into the master but at the end we want to make our branch source become master.
I feel this is easier way to do it.

git branch -m master abandonmaster //Move the master to Branch abandonmaster
git branch -m branchName master //Move the branchName to master
git push origin master //push master to remote
git push origin abandonmaster //pust abandonmaster branch to remote