Skip to content

Instantly share code, notes, and snippets.

View yyx990803's full-sized avatar

Evan You yyx990803

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

百度:Tangram

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

腾讯:JX

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

@yyx990803
yyx990803 / api.html
Last active May 19, 2023 23:17
连续请求ajax API回调顺序的问题
<!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');
<!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 December 17, 2015 08:09
Turn a function's body into a worker.
// 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 July 3, 2013 15:07
a grunt task for working with an appengine app
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 March 5, 2024 01:24
npm list only top level modules.
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 March 28, 2017 11:39
关于应不应该把属性的默认值放在prototype里

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

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

function WorldA () {
  // ...
}

WorldA.prototype = {
@yyx990803
yyx990803 / bind.js
Last active June 15, 2022 09:15
implementing Function.prototype.bind
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 April 21, 2020 03:58
之乎者也,一个文言风的类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.")