My Note on Solutions.

Friday, April 24, 2015

wse 2 run windows server 2008 R2

For some legacy issues, you app stack might use WSE to do the message level authentication. and if you have to run wse 2 in your asmx hosted on windows server 2008 R2. here could be some issues and solutions.

1. If you bind multi Binary kerberos token to the request and send to the server, you might be rejected even both of them are valid. like you put host to abc and

solution: manually downgrade the wse 2 from 2.0.3 to 2.0.1. I found since 2.0.3, the request filter does not allow 1+ tokens

2. unable to extract username from the binary token passed from client.

solution: config the application pool to run on 32 bit mode. twick the code a little bit, to remove the session key extraction.


if always shows me the memroy access exception when it try to do the session key marshaling.

check the code in Microsoft.Web.Services2.Security.Tokens.Kerberos.LsaServerContext.LogonUser(byte[] inToken), you might just decompile the code ,chagne it and sign it back using your own key. and update the reference to your version of wse.dll

Friday, April 3, 2015

JWT token, signed in C#, and Decode in JS

JWT is a widly used token system that we can share token info between APIs or between Apps.

i.e we can sign the token by using a shared key in C#, then verify the token in javascript by using the same sharedkey.

in C#, you can search nuget for the jwt , there are several libraries.

let’s I want to sign a simple clamin using the simple password.

we get token eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJuYW1lIjoiUGV0ZXIiLCJSb2xlIjoiQWRtaW5zLFJlYWRlciJ9.Qh2J93epa7ls0y6DAn_8YvIRoRHq28hLT9N-93fStcajCd90nLzLG6Vit-Qdfl1TsPtL56qh4jiKDOzpfs1OyA

then follow the library for different languages from to do the decoding

Past the token into the validation box, and enter pass in the shared key, you will see token get decoded and verified


Friday, March 27, 2015

C# TPL some basic code

Fast win pattern, you might query several urls for the same info, which one return first , that one will be the winner.

Send in parallel and join together.
long running and cancellable task, if get canceld, try compensate it




Thursday, March 12, 2015

Vagrant, Proxy issue, centos local repo and ad-hoc testing

Vagrant is a good VM automation tool for both developers and devops, here are some basic tips that I found useful

   if you are stand behind a proxy, you can install one vagran proxy module. the module will setup the proxy on guest machines, like yum.conf, http_proxy variable etc.
here is the plugin



when you boot up the vm, you can see the proxy setting applied depends on your OS type


Yum Repo.
   you might have one local repo in the company, you can either build all boxes internally which already assign the repo url to local. or just copy one repo to override the system one by using the provisioning scripts.



and in your local file, change the ip to internal one


Provision scripts to check whether package installed or not. using rpm to query package or use command to determine whether a command exists


Thursday, February 19, 2015

Opencart fix, show the shipping method in orders admin page and filter by shippingmethod

it turns that this should be a common feature for opencart admins, basically the operation team would like to see orders with priority shipping method and process those orders first. on 1.5, no way you can see this at once. basically the orders page looks like this by default


they actually want to see the UI like this, with shipping method on the overview


even more, they want a filter to see all orders with priority shipping selected.


To fix this, pretty straight forward. change the orders module/controller/template file, to include shippingmethod in the data query back. and add a filter logic to narrow down records.

I have a patch file, email me if you are interested. click about me on the page to get my email

Wednesday, February 11, 2015

C# merge sorting vs insert sorting

Quick test for a 50K random double array with random order, to soft it using the system libarry  and my own insert sorting/ merge sorting, the time takes to do the soring is quite different.

given a array with size 50K of  double values,


if increase to 100K, more time for insertion sorting


Friday, February 6, 2015

Jquery , Simple plugin with default options

check this sample fiddler,

basically, we can use the $.extend to assign a default value if options are not assigned.


if you put default option,



Locations of visitors to this page