Skip to content

Instantly share code, notes, and snippets.

Avatar

Evan You yyx990803

View GitHub Profile
@yyx990803
yyx990803 / frameworks.md
Created Dec 3, 2012
国内互联网公司的前端框架简介
View frameworks.md

百度:Tangram

基本上就是个百度版jQuery,2.0版本使用链式API,更像了。
配套的还有UI库Magic和模版引擎BaiduTemplate(和ejs很像)

腾讯:JX

理念在介绍里面写的很详细,代码清晰,注释丰富,可读性很好,但只有文档没有实例。
比较传统的大块头框架,本质上来说还是一堆工具方法和对象的堆积,提供了很基本的模块化的开发方式,但没有模块间的依赖关系支持。

@yyx990803
yyx990803 / api.html
Last active Feb 24, 2017
连续请求ajax API回调顺序的问题
View api.html
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script>
// coolshell api
function xss_ajax(url, callback) {
var script_id = null;
var script = document.createElement('script');
View async_asap.html
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body {
font-family: 'Helvetica Neue', Arial, 'Microsoft Yahei', sans-serif;
padding: 0 30px;
color: #333;
@yyx990803
yyx990803 / workerify.js
Last active Dec 17, 2015
Turn a function's body into a worker.
View workerify.js
// Turns a function's body into a worker
var workerify = function (func) {
if (typeof func !== 'function') {
throw new Error('expects a function to workerify.')
}
var script = func.toString().match(/^function[^{]*{((.|\n)*)}$/)[1],
blob = new Blob([script], {'type': 'application/javascript'}),
url = window.URL.createObjectURL(blob)
return new Worker(url)
}
@yyx990803
yyx990803 / task.js
Created Jul 3, 2013
a grunt task for working with an appengine app
View task.js
grunt.registerTask( 'dev', 'start deving y\'all', function () {
grunt.task.run('watch')
grunt.util.spawn({
cmd: 'dev_appserver.py',
args: ['./app.yaml'],
opts: {
stdio: 'inherit'
}
@yyx990803
yyx990803 / nl.sh
Last active Jun 29, 2021
npm list only top level modules.
View nl.sh
alias ng="npm list -g --depth=0 2>/dev/null"
alias nl="npm list --depth=0 2>/dev/null"
@yyx990803
yyx990803 / props.md
Last active Mar 28, 2017
关于应不应该把属性的默认值放在prototype里
View props.md

TL,DR: 务必总是在构建函数里定义实例属性。

在小胖的PoorPhy物理库里,有很多类似这样的代码:

function WorldA () {
  // ...
}

WorldA.prototype = {
@yyx990803
yyx990803 / bind.js
Last active Jul 15, 2021
implementing Function.prototype.bind
View bind.js
Function.prototype.bind = function (context) {
if (typeof this !== 'function') {
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
var fn = this, // the function to bind
slice = Array.prototype.slice // cache slice method
args = slice.call(arguments, 1), // get the array of addtional arguments (to be curried)
noop = function () {}, // the intermediate function to serve as a prototype chain connector
// (assuming we don't have Object.create() here)
bound = function () {
@yyx990803
yyx990803 / 之乎者也.md
Last active Apr 21, 2020
之乎者也,一个文言风的类JS玩具语言
View 之乎者也.md
斐波那契者 得甲
 閱甲
    零乎
      零是也
    壹乎
      壹是也
    它者乎
      前者 甲 壹 差之 遞歸之也
      前前者 甲 貳 差之 遞歸之也
View Is_it_Programmers_Day.js
var now = new Date(),
year = now.getYear() + 1900,
first = new Date(year, 0, 0),
elapsedMs = now.getTime() - first.getTime(),
elapsedDays = ~~(elapsedMs / (1000 * 60 * 60 * 24))
if (elapsedDays === Math.pow(2, 8)) {
console.log("Yes. Happy Programmers' Day!")
} else {
console.log("No. Get back to work.")