Skip to content

Instantly share code, notes, and snippets.

View williamcspace's full-sized avatar

William Chan williamcspace

  • Shanghai Xinyue Information Technology Ltd.
  • Shanghai
View GitHub Profile
registry=https://registry.npm.taobao.org/
disturl=https://npm.taobao.org/dist
chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver
operadriver_cdnurl=http://cdn.npm.taobao.org/dist/operadriver
phantomjs_cdnurl=http://cdn.npm.taobao.org/dist/phantomjs
fse_binary_host_mirror=https://npm.taobao.org/mirrors/fsevents
sass_binary_site=http://cdn.npm.taobao.org/dist/node-sass
electron_mirror=http://cdn.npm.taobao.org/dist/electron/
selenium_cdnurl=http://npm.taobao.org/mirrors/selenium
node_inspector_cdnurl=https://npm.taobao.org/mirrors/node-inspector
@williamcspace
williamcspace / overview.html
Created November 22, 2018 07:44
Edx Course Overview Template
<section class="about">
<h2>About This Course</h2>
<p>Include your long course description here. The long course description
should contain 150-400 words.</p>
<p>This is paragraph 2 of the long course description. Add more paragraphs
as needed. Make sure to enclose them in paragraph tags.</p>
</section>
<section class="prerequisites">
<h2>Requirements</h2>
<p>Add information about the skills and knowledge students need to take
@williamcspace
williamcspace / ObjectId.js
Created September 26, 2018 09:05
Mongo's ObjectId generator
var MACHINE_ID = parseInt(Math.random() * 0xFFFFFF, 10);
ObjectID.prototype.generate = function(time) {
if ('number' != typeof time) {
time = ~~(Date.now()/1000);
}
// Use pid
var pid = (typeof process === 'undefined' ? Math.floor(Math.random() * 100000) : process.pid) % 0xFFFF;
var inc = this.get_inc();
@williamcspace
williamcspace / quill-toolbar.html
Created July 11, 2018 09:25
quill toolbar default
<div id="editor-toolbar">
<span class="ql-formats">
<select class="ql-font"></select>
<select class="ql-size"></select>
</span>
<span class="ql-formats">
<button class="ql-bold"></button>
<button class="ql-italic"></button>
<button class="ql-underline"></button>
<button class="ql-strike"></button>
## 安裝語系檔
$ sudo locale-gen "en_US.UTF-8"
## 重新設定語系檔
$ sudo dpkg-reconfigure locales
## 設定檔
@williamcspace
williamcspace / startserver.bat
Created July 16, 2017 16:58
minecraft server
java -Xmx1024M -Xms1024M -jar minecraft_server.1.12.jar nogui
@williamcspace
williamcspace / VideoPlayer.md
Last active July 6, 2017 16:00
video.js react wrapper

video.js and ReactJS integration

Here's a basic ReactJS player implementation.

It just instantiates the video.js player on componentDidMount and destroys it on componentWillUnmount.

import React from 'react';
import videojs from 'video.js'
@williamcspace
williamcspace / binding.js
Created June 30, 2017 07:34
five ways for binding react methods
// https://medium.freecodecamp.org/react-binding-patterns-5-approaches-for-handling-this-92c651b5af56
// Approach 1: Use React.createClass
var HelloWorld = React.createClass({
getInitialState() {
return { message: 'Hi' };
},
logMessage() {
// this magically works because React.createClass autobinds.
console.log(this.state.message);
@williamcspace
williamcspace / array-filter.js
Created August 31, 2016 09:53
practical functional array operations
// When: You want to remove unwanted elements based on a condition.
// Example: remove duplicate elements from an array.\
const names = ['will', 'bill', 'william', 'bill', 'william', 'will'];
const uniqueNames = names.filter((elem, index, arr) => arr.indexOf(elem) === index); // [ 'will', 'bill', 'william' ]
@williamcspace
williamcspace / getTasks-v1.js
Created August 26, 2016 07:32
Recursion with pure function - Tasks Runner example
var input = ['dist'];
var config = {
'dist': ['build', 'deploy'],
'build': ['js', 'css', 'version-rev'],
'js': ['lint','uglify'],
'css': ['sass', 'css-min']
};
var tasks = [];