Skip to content

Instantly share code, notes, and snippets.

@chengmu
chengmu / chrome xcode dev Notes.markdown
Created October 23, 2013 11:01
chrome Xcode记录

其实首先是搞下来源码,放进XCode里。。。

光索引就索引了五遍啊简直泣血。。 ###建立xcode项目

  1. 源码拷贝到本地

  2. 安装gclient(具体参见下文)

  3. 切换目录到home/src_tarball/tarball/chromium/,运行gclient, 这个会自动更新源码生成xcode项目文件:

     $ gclient runhooks
    
@chengmu
chengmu / quote.js
Created September 4, 2013 07:45
express.js + node.js build up restful api
//使用express.js+ node.js搭建restful api
var express = require('express');
var app = express();
app.use(express.bodyParser());
var quotes = [
{ author : 'Audrey Hepburn', text : "Nothing is impossible, the word itself says 'I'm possible'!"},
@chengmu
chengmu / sassNote.scss
Created September 3, 2013 08:30
SASS学习记录
/**
* SASS 学习记录
* date: 2013-09-03
* author: chengmu
* Install: gem install sass
* StartWatching: sass --watch style.scss:style.css
* features:
* 嵌套选择器/样式/伪类(`&`指向父元素)
* $定义变量(可用于属性名)
* 属性值运算 数值/[辅助函数](http://sass-lang.com/docs/yardoc/Sass/Script/Functions.html)
// Cross Browser Event Utility
// Nicholas Zakas, Professional JavaScript for Web Developers p.441
(function(window, document) {
'use strict';
var
EventUtil = {
addHandler: function( element, type, handler ) {
if ( element.addEventListener ) {
element.addEventListener ( type, handler, false );
@chengmu
chengmu / ao3.js
Created August 19, 2013 14:54
用于抓取ao3 小说
//Ajax
function request(type, url, opts, callback) {
  var xhr = new XMLHttpRequest();
  if (typeof opts === 'function') {
   callback = opts;
    opts = null;
   }
  xhr.open(type, url);
   var fd = new FormData();
@chengmu
chengmu / getDlUrl.js
Created August 18, 2013 11:50
用来抓取audiofic站点下载链接的snippet
//Ajax
function request(type, url, opts, callback) {
  var xhr = new XMLHttpRequest();
  if (typeof opts === 'function') {
   callback = opts;
    opts = null;
   }
  xhr.open(type, url);
   var fd = new FormData();
@chengmu
chengmu / replaceJQ.js
Created August 18, 2013 07:28
method to be jquery-free
/**
* 选取dom元素
*/
var $ = document.querySelectorAll.bind (document);
myList = Array.prototype.slice.call (myNodeList);
/**
@chengmu
chengmu / jsNinjaNots.md
Created August 16, 2013 10:23
Javascript Ninja Notes

js传参

按值(value)传递, 但传过来的参数本身是个引用,因此若修改其内部值,原对象便会修改

var a = { b: 1 }
function c(o) { o.b=2 }
function d(o) { o = {} }
c(a)   //a = {b:2} 

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
(function () {
var a = window.a = {
name : 'a'
};
var aStr = window.aStr = 'stringA';
window.a.name = 'b';
window.aStr = 'stringB';