Skip to content

Instantly share code, notes, and snippets.

View shuding's full-sized avatar
🌿

Shu Ding shuding

🌿
View GitHub Profile
@shuding
shuding / font.css
Created February 22, 2016 07:34
A simple CSS snippet for font rendering
body {
font-family: Helvetica, Arial, 'PingFang SC', 'Lantinghei SC', 'Microsoft Yahei', sans-serif;
text-rendering: geometricPrecision;
font-kerning: auto;
-webkit-font-smoothing: antialiased;
font-variant-ligatures: common-ligatures discretionary-ligatures;
-webkit-font-feature-settings: "liga", "dlig";
font-feature-settings: "liga", "dlig";
}

Flux 的威力在于其函数式编程 -> no side effects(to MVC)。

@shuding
shuding / index.js
Created March 1, 2016 05:25
A Snippet From Redux
/*
* This is a dummy function to check if the function name has been altered by minification.
* If the function has been minified and NODE_ENV !== 'production', warn the user.
*/
function isCrushed() {}
if (process.env.NODE_ENV !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
(0, _warning2["default"])('You are currently using minified code outside of NODE_ENV === \'production\'. ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' + 'to ensure you have the correct code for your production build.');
}
@shuding
shuding / tokenizer.js
Last active August 21, 2017 12:18
tokenizer.js
function f1(name, a) {
if (name == 'sin') { return Math.sin(a); }
if (name == 'cos') { return Math.cos(a); }
return 1;
}
function f0(name) {
if (name == 'sin') { return 1; }
if (name == 'cos') { return 2; }
return 1;
}
@shuding
shuding / innsbruck-font.css
Created May 20, 2016 22:34
innsbruck-font.css
/* Open Sans */ @import url(https://fonts.googleapis.com/css?family=Quicksand:700|Open+Sans:400,400italic,700italic,700); body { font-family: 'open sans', 'pingfang sc', sans-serif; }
/* Arvo */ @import url(https://fonts.googleapis.com/css?family=Arvo:400,400italic,700,700italic); body { font-family: 'arvo', 'pingfang sc', sans-serif; }
/* Lato */ @import url(https://fonts.googleapis.com/css?family=Lato:400,400italic,700,700italic); body { font-family: 'lato', 'pingfang sc', sans-serif; }
/* Vollkorn */ @import url(https://fonts.googleapis.com/css?family=Vollkorn:400,400italic,700,700italic); p { font-family: 'vollkorn', 'stsong', 'simsun', serif; font-size: 110%; }
@shuding
shuding / it.js
Created May 29, 2016 19:02
ES6 for of iterator
Number.prototype[Symbol.iterator] = function *() { let len = this.valueOf(); for(let i = 0; i < len; ++i) yield i; };
for (let i of 16) { console.log(i); }
@shuding
shuding / javascript js tips, tricks, snippets.js
Created May 29, 2016 19:39
javascript js tips, tricks, snippets
// random numbergenerator between 0 and 1
var randomNum = ((Math.random () * 2 | 0) + 1) - 1;
// jquery inline style w/ !important
$(el).css("cssText", "overflow: visible !important;");
// random numbergenerator between 1 and 100
Math.round((Math.random() * 99) + 1)
(+new Date() + Math.floor(Math.random()*999999)).toString(36)
@shuding
shuding / delay.js
Last active June 9, 2016 11:47
One Line Implementation of `sleep(1000)`
var d=(f,t=f(),r=t.next())=>r.done||setTimeout(d,r.value,f,t);
d(function *() {
console.log('foo');
yield 1000;
console.log('bar');
yield 1000;
console.log('baz');
var pureRender = (Component) => {
Object.assign(Component.prototype, {
shouldComponentUpdate (nextProps, nextState) {
return !shallowEqual(this.props, nextProps) ||
!shallowEqual(this.state, nextState);
}
});
};
module.exports = pureRender;