重新实现.NET Core的 double.ToString()


.NET Core 2.0发布后,整个框架的性能提升了不少。但是仍然有一些基础数据类型的性能不尽入人意,例如double.ToString()这个常用方法的性能。一开始 .NET Core团队发现这个问题,是因为double.ToString()在Linux下的性能比在Windows下慢7倍. 后来为了提升性能,.NET Core团队利用Core RT的代码重写了造成性能瓶颈的 _ecvt 函数,但性能仍然比在Windows下慢了3倍

Read More

Use jersey 2.0 without maven

The most annoying thing recently for me is, I have to setup maven as a premise for using Jersey 2.0. The official document of Jersey does not provide enough information for me to setup Jersey without maven installed. After hours investigating and searching on the internet, I finally make it to work.

Read More

Enable telnet on Windows 10

  1. In the search box enter cmd.
  2. Right click the Command Prompt app and select “Run as administrator”.
  3. In the command prompt, execute following command:
Read More

Windows 10 - remote desktop to CentOS

Recently, I have a project needs to be developed on CentOS with C/C++. I decided to setup a CentOS VM and remote from my Windows 10 PC. To enable the RDP from windows to linux, I’ve found a very useful article HERE. However, there’s a missing step and some typos in the article. So I decide to re-write the article as following:

Read More

Windows 10 - use ctrl+space to change input method.

If you’re using multiple input methods, you’ll notice that windows 10 only supports win + space to change input methods. It’s really a pain for those who upgraded from windows 7. Fortunately, we have a simple way to save ctrl+space back in windows 10.

Read More

How to implement inheritance in react.js.

React.js is a great library to build view in component way. However, one thing makes me frustrated is there’s no inheritance support by using React.createClass() to create a react component. A “Class” cannot be inheritied! Facebook now recommend us using High order components to address code reusable issue, which makes me more frustrated. OK, I’m an old school object oriented guy. I just want something in classic: Class inheritance and overriding.

Read More

RatchetProJS v1.0.0 released! A lightweight mobile framework let you build things easier.

So what’s RatchetPro.js? Two years ago, I found a prime project released by twitter - Ratchet.js. It’s lightweight, only contains core functions to run HTML5 web apps. Compare to JQuery Mobile or Sencha Touch, it’s more like a library other than a framework. It’s extremely useful if you already familiar with bootstrap. I implemented my several mobile HTML5 apps based on Ratchet.js and it runs very smoothly and quickly.

Read More

InfoPath Analyzer is open source now.

Well, finally I made this decision. The source code is now hosted on github. There are couple of reasons for opening the source code of IA:

1. Microsoft stopped the development of InfoPath. There is no roadmap of it, says, InfoPath retired.

  1. InfoPath is still being used in the world. Alternative solutions are coming out these years.

  2. I was a C# guy as the time of building IA. It’s been a long time since then I’ve changed my career to dive into the open source world.

  3. Currently, I become the bottleneck of IA. Open the source code of IA would be helpful not only for the InfoPath users, but also for the growth of e-form industry.

Hope it helps you guys :)

Read More

Started a new project on github - fabric.ext

My project is heavily using fabricjs. However, some events and objects such as double click event, right click event, video and audio obejcts are missing in fabricjs. I decided to start a fabric.ext project on github to impelment these missing features. Hope that will help you as well.

IMPORTANT: I’m not going to include video/audio objects in this project as of our privacy. However, events and any other objects would be included.

Any feedback is welcome :)

Read More

Convert office files(ppt, excel, doc...) to images on CentOS 6.5

There’s a requirement in my recent project to convert office files to multiple images. After hard work for a week, I found the correct steps that cannot be searched through Google. I’m going to write it down, hope these steps save your time.


Use unoconv to convert office files to PDF, then convert PDF to images leveraging ImageMagick.

Install unoconv

  1. Visit http://wiki.centos.org/AdditionalResources/Repositories/RPMForge. Download RPMforge for CentOS 6 via wget. In my case, I downloaded i686 rpm.


Run following command to install the rpm key:

rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt

Run rpm -Uvh to install the downloaded rpm file.

  1. Create a file Archives.repo under /etc/yum.repos.d/. Add following contents to Archives.repo :

[c6-archives] name=CentOS-6 – Archives baseurl=http://vault.centos.org/6.2/updates/$basearch/ gpgcheck=0 enabled=1

  1. Run following comand:

yum clean all

  1. Run following command:

yum install unoconv openoffice.org-headless openoffice.org-writer openoffice.org-calc openoffice.org-impress

Install ImageMagick

Run following command:

yum install ImageMagick

Install Fonts

CentOS does not support enough fonts by default (e.g Chinese fonts). Therefore the converted file may contain unexpected characters. The easiest way to resolve this issue is to copy fonts from Windows.

  1. Create a folder named win in driver D of your Windows.

  2. Copy all files under C:\WINDOWS\Fonts to D:\win.

  3. Upload folder win to your CentOS 6.5 server(via winscp, or FTP tools).

  4. Run following command in CentOS:

mv win /usr/share/fonts

cd win



fc-cache  -fv

  1. Restart CentOS server.


Using following commands to convert an office file to images:

First convert office file to pdf:

‘unoconv -f pdf resume.ppt’

Convert pdf to images:

mkdir resume

‘convert resume.pdf resume/resume_%03d.jpg’

I’ve written a nodeJS wrapper:

var sys = require(‘sys’);

var exec = require(‘child_process’).exec;

console.log(‘converting to pdf…’);

exec(‘unoconv -f pdf resume.ppt’, function(error, stdout, stderr){

console.log(‘converted resume.pdf’);

console.log(‘converting resume.pdf to multiple pics…’);

exec(‘convert resume.pdf resume/resume_%03d.jpg’, function (error, stdout, stderr){

console.log(‘All done’);



That’s all. Cheers!

Read More

How to enable 'meta_key' option for wordpress REST api filter

I’m working at a project which is using wordpress as the backend management system. WP has a great rest api plugin . However, the filter options are limited. Unfortunately, ‘meta_key’ is not supported in current version.

I’ve spent several hours to investigate this plugin, and finally found a one-line-code solution:

  1. Find a line in get_posts function:
// Allow the same as normal WP
$valid_vars = apply_filters('query_vars', $wp->public_query_vars);
  1. Add following code below it:
// Add additional key to support.
array_push($valid_vars, 'meta_key');

Done :)

Additionally, add more custom field support you need:

// Add additional custom field keys to support.
array_push($valid_vars, 'meta_key');
array_push($valid_vars, 'meta_value');
array_push($valid_vars, 'meta_value_num');
array_push($valid_vars, 'meta_compare');
array_push($valid_vars, 'meta_query');
Read More

Alternative Way To Resolve Stream_select You Must Recompile Php With A Larger Value Of Fd_setsize Issue Without Recompiling Php

I met a boring issue when adding websocket to a PHP site by using Ratchet (A PHP websocket framework):

“It is set to 1024, but you have descriptors numbered at least as high as 1266.

–enable-fd-setsize=2048 is recommended, but you may want to set it to equal the maximum number of open files supported by your system”

I struggled and googled it, finally found a bad news: FD_SIZE is set to 1024 in the PHP source code. The error occurs if the web socket connections are over 1024. I don’t want to modify the PHP source code and recompile it, which may cause unexpected issue. So I try to find another way to solve this issue. Fortunately, I found it.

Basically, I’m opening multiple websocket service processes in the server, and each process has different port. In the front end, I wrote a js function to choose different port to connect. That means we have 1024 * n availiable connections now. Let’s go to the details.

Back-end implementation

Write a websocket service called push-server.php. Please refer to Ratchet’s example. However, we need make the php file to accept a port parameter:

$port = $argv[1];

if ($port == ""){
    $port = 40003; // Default port
// .....Ignoring other code .....
// Passing port paramter.
$webSock->listen($port, '');
Now we can start multiple websocket processes with different ports, for instance:  php push-server 40003 php push-server 40004 php push-server 40005 The server can have 1024 * 3 = 3072 websocket connections now. Front-end implementation The js code to connect websocket service randomly:
function getWSServer() {
    var serverPorts = ['40003', '40004', '40005'];
    var server = 'ws://youhost';
    var randomPortIndex = Math.floor(Math.random() * serverPorts.length);

    server += ':' + serverPorts[randomPortIndex];

    return server;
Read More

How to invoke InfoPath designer within SharePoint list data.

SharePoint 2010 has a new feature that can “Customize List” with InfoPath 2010. So how can the system do it? Just one command line can tell you the truth:

infopath.exe /spSiteURL http://sitename /spListID “{524E9C94-639F-4F95-8AD7-C699CBA499BF}” /design /noautoformsdialog

OK. Now specify your site name and list ID, you have the same functionality of “Customize List” ribbon button. /spSiteURL and /spListID are unreleased parameters. Have fun!

Read More