{{ message }}

Instantly share code, notes, and snippets.

# William He Williammer

Last active Dec 28, 2019
View math.sqrt.bsearch.py
 def sqrt_binary(num): if num > 1: low = 1 high = num else : low = num high = 1 mid = float(low) + float((high - low) / 2) while abs(mid ** 2 - num) > 0.000001: if mid ** 2 < num:
Last active Dec 26, 2019
Some basic functions for the bitwise operations
View bitwise.basic.js
 // right shift of 0 makes the num unsigned: https://stackoverflow.com/questions/9939760/how-do-i-convert-an-integer-to-binary-in-javascript const numToBinary(num) => (n >>> 0).toString(2); const lowBit = (n) => n & -n; // returns the sub-number which is the last 1 in binary of the original number // low Bit operation is used in "Binary indexed Trees" // https://zh.wikipedia.org/zh-hans/%E6%A0%91%E7%8A%B6%E6%95%B0%E7%BB%84
Created Nov 19, 2018
View node-rename-dir-files.js
 const fs = require('fs'); function addSchemaName(basePath) { const result = fs.readdirSync(basePath); // console.log(result); result.forEach((path) => { if (path.startsWith('_') || path.endsWith('Schema.js')) { return; } if (path.endsWith('.js')) { const prefix = path.split('.')[0];
Last active Jun 18, 2018
jsBasic.bindRight.js - implementation for the bind function that accept arguments from right most to the left.
View jsBasic.bindRight.js
 Function.prototype.bindRight = function (context, ...firstArgs) { return (...secArgs) => { return this.apply(null, [...secArgs.reverse(), ...firstArgs.reverse()]); }; }; function add(x, y, z) { return 100 * x + 10 * y + z; }
Last active Sep 14, 2018
backpack solution recur/dynamic/greedy with javaScript.
View algorithm.backpack.js
 function max(a, b) { return (a > b) ? a : b; } function knapsackRecur(capacity, size, value, n) { if (n == 0 || capacity == 0) { return 0; } if (size[n - 1] > capacity) { return knapsack(capacity, size, value, n - 1);
Last active May 31, 2016
jsPatterns.recur.trampoline.js
View jsPatterns.recur.trampoline.html


Hi there, my name is William He or Weinan He in Chinese. I'm currently living in Hong Kong and working at Accedo as the Software Developer.

My current job is to develop cool Web TV applications, which is one type of web application, with the amazing javaScript. I love to explore and learn more about the web technology world and develop some useful applications in my spare time!

Last active May 22, 2016
HashTable in js, with simple Hash and the better Horner's hash method.
View algorithm.DS.HashTable.js
 function HashTable() { this.table = new Array(137); this.simpleHash = simpleHash; this.betterHash = betterHash; this.showDistro = showDistro; this.put = put; this.get = get; } /*function put(data) {
Last active May 15, 2016